aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2018-08-06 14:56:34 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-08-06 14:56:34 -0400
commit315706049c343794ad0d3e5b6f6b60b900457b11 (patch)
tree0a1596a4b5843a6262d17b4c656715854784977d
parent706d51681d636a0c4a5ef53395ec3b803e45ed4d (diff)
parentc40a56a7818cfe735fc93a69e1875f8bba834483 (diff)
Merge branch 'x86/pti-urgent' into x86/pti
Integrate the PTI Global bit fixes which conflict with the 32bit PTI support. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--Documentation/device-mapper/writecache.txt2
-rw-r--r--Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt2
-rw-r--r--Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt2
-rw-r--r--Documentation/devicetree/bindings/gpio/nintendo,hollywood-gpio.txt2
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/hideep.txt2
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/nvidia,tegra20-ictlr.txt2
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt2
-rw-r--r--Documentation/devicetree/bindings/mips/brcm/soc.txt2
-rw-r--r--Documentation/devicetree/bindings/net/fsl-fman.txt2
-rw-r--r--Documentation/devicetree/bindings/power/power_domain.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/tps65090.txt2
-rw-r--r--Documentation/devicetree/bindings/reset/st,sti-softreset.txt2
-rw-r--r--Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/qcom,apq8016-sbc.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/qcom,apq8096.txt2
-rw-r--r--Documentation/devicetree/bindings/usb/rockchip,dwc3.txt3
-rw-r--r--Documentation/devicetree/bindings/w1/w1-gpio.txt2
-rw-r--r--Documentation/networking/bonding.txt2
-rw-r--r--Documentation/networking/dpaa2/overview.rst1
-rw-r--r--Documentation/networking/e100.rst27
-rw-r--r--Documentation/networking/e1000.rst187
-rw-r--r--MAINTAINERS13
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/kernel/osf_sys.c5
-rw-r--r--arch/arc/Kconfig5
-rw-r--r--arch/arc/Makefile15
-rw-r--r--arch/arc/configs/axs101_defconfig1
-rw-r--r--arch/arc/configs/axs103_defconfig1
-rw-r--r--arch/arc/configs/axs103_smp_defconfig1
-rw-r--r--arch/arc/configs/haps_hs_defconfig1
-rw-r--r--arch/arc/configs/haps_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/hsdk_defconfig1
-rw-r--r--arch/arc/configs/nsim_700_defconfig1
-rw-r--r--arch/arc/configs/nsim_hs_defconfig1
-rw-r--r--arch/arc/configs/nsim_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_hs_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/tb10x_defconfig1
-rw-r--r--arch/arc/include/asm/cache.h4
-rw-r--r--arch/arc/include/asm/delay.h3
-rw-r--r--arch/arc/include/asm/entry-compact.h6
-rw-r--r--arch/arc/include/asm/entry.h3
-rw-r--r--arch/arc/include/asm/mach_desc.h2
-rw-r--r--arch/arc/include/asm/page.h2
-rw-r--r--arch/arc/include/asm/pgtable.h2
-rw-r--r--arch/arc/kernel/irq.c2
-rw-r--r--arch/arc/kernel/process.c47
-rw-r--r--arch/arc/mm/cache.c17
-rw-r--r--arch/arc/mm/dma.c49
-rw-r--r--arch/arc/plat-eznps/include/plat/ctop.h10
-rw-r--r--arch/arc/plat-eznps/mtm.c6
-rw-r--r--arch/arc/plat-hsdk/Kconfig3
-rw-r--r--arch/arc/plat-hsdk/platform.c62
-rw-r--r--arch/arm/boot/dts/am3517.dtsi5
-rw-r--r--arch/arm/boot/dts/armada-38x.dtsi2
-rw-r--r--arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi2
-rw-r--r--arch/arm/boot/dts/omap4-droid4-xt894.dts9
-rw-r--r--arch/arm/kernel/entry-common.S4
-rw-r--r--arch/arm/kernel/process.c1
-rw-r--r--arch/arm/mach-omap2/omap-smp.c41
-rw-r--r--arch/arm/mach-pxa/irq.c4
-rw-r--r--arch/arm/mach-rpc/ecard.c5
-rw-r--r--arch/arm64/crypto/ghash-ce-glue.c8
-rw-r--r--arch/arm64/include/asm/tlb.h2
-rw-r--r--arch/arm64/kernel/cpufeature.c4
-rw-r--r--arch/arm64/mm/hugetlbpage.c7
-rw-r--r--arch/arm64/mm/init.c4
-rw-r--r--arch/ia64/include/asm/tlb.h7
-rw-r--r--arch/ia64/kernel/perfmon.c6
-rw-r--r--arch/ia64/mm/init.c16
-rw-r--r--arch/mips/ath79/common.c2
-rw-r--r--arch/mips/bcm47xx/setup.c6
-rw-r--r--arch/mips/include/asm/mipsregs.h3
-rw-r--r--arch/mips/pci/pci.c2
-rw-r--r--arch/nds32/Kconfig12
-rw-r--r--arch/nds32/Makefile2
-rw-r--r--arch/nds32/include/asm/cacheflush.h9
-rw-r--r--arch/nds32/include/asm/futex.h2
-rw-r--r--arch/nds32/kernel/setup.c3
-rw-r--r--arch/nds32/mm/cacheflush.c100
-rw-r--r--arch/powerpc/Makefile1
-rw-r--r--arch/powerpc/include/asm/mmu_context.h37
-rw-r--r--arch/powerpc/kernel/idle_book3s.S2
-rw-r--r--arch/powerpc/kernel/pci-common.c4
-rw-r--r--arch/powerpc/kvm/book3s_64_vio.c2
-rw-r--r--arch/powerpc/kvm/book3s_64_vio_hv.c6
-rw-r--r--arch/powerpc/mm/mmu_context_iommu.c37
-rw-r--r--arch/powerpc/net/bpf_jit_comp64.c29
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c3
-rw-r--r--arch/powerpc/platforms/pseries/setup.c3
-rw-r--r--arch/powerpc/xmon/xmon.c4
-rw-r--r--arch/s390/Kconfig2
-rw-r--r--arch/sparc/include/asm/Kbuild1
-rw-r--r--arch/sparc/include/asm/msi.h32
-rw-r--r--arch/sparc/kernel/time_64.c2
-rw-r--r--arch/sparc/mm/srmmu.c20
-rw-r--r--arch/x86/Kconfig2
-rw-r--r--arch/x86/boot/compressed/Makefile8
-rw-r--r--arch/x86/boot/compressed/pgtable_64.c73
-rw-r--r--arch/x86/entry/entry_64.S18
-rw-r--r--arch/x86/events/amd/ibs.c6
-rw-r--r--arch/x86/events/intel/core.c3
-rw-r--r--arch/x86/events/intel/ds.c25
-rw-r--r--arch/x86/events/intel/uncore.h2
-rw-r--r--arch/x86/events/intel/uncore_snbep.c10
-rw-r--r--arch/x86/include/asm/processor.h1
-rw-r--r--arch/x86/include/asm/qspinlock_paravirt.h2
-rw-r--r--arch/x86/include/asm/set_memory.h1
-rw-r--r--arch/x86/include/asm/uaccess_64.h7
-rw-r--r--arch/x86/kernel/apic/apic.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c3
-rw-r--r--arch/x86/kernel/kvmclock.c12
-rw-r--r--arch/x86/kvm/Kconfig2
-rw-r--r--arch/x86/kvm/mmu.c2
-rw-r--r--arch/x86/kvm/vmx.c83
-rw-r--r--arch/x86/kvm/x86.c4
-rw-r--r--arch/x86/mm/init.c37
-rw-r--r--arch/x86/mm/init_64.c8
-rw-r--r--arch/x86/mm/pageattr.c19
-rw-r--r--arch/x86/mm/pti.c36
-rw-r--r--arch/x86/net/bpf_jit_comp32.c8
-rw-r--r--arch/x86/platform/efi/efi_64.c2
-rw-r--r--arch/x86/um/mem_32.c2
-rw-r--r--block/bio.c54
-rw-r--r--block/blk-core.c5
-rw-r--r--block/blk-mq-tag.c2
-rw-r--r--block/blk-mq.c4
-rw-r--r--crypto/af_alg.c4
-rw-r--r--drivers/acpi/acpi_lpss.c26
-rw-r--r--drivers/acpi/acpica/psloop.c31
-rw-r--r--drivers/acpi/ec.c2
-rw-r--r--drivers/base/dd.c8
-rw-r--r--drivers/block/nbd.c96
-rw-r--r--drivers/char/agp/alpha-agp.c2
-rw-r--r--drivers/char/agp/amd64-agp.c4
-rw-r--r--drivers/char/mem.c1
-rw-r--r--drivers/char/random.c10
-rw-r--r--drivers/clk/clk-aspeed.c59
-rw-r--r--drivers/clk/clk.c3
-rw-r--r--drivers/clk/meson/clk-audio-divider.c2
-rw-r--r--drivers/clk/meson/gxbb.c1
-rw-r--r--drivers/clk/mvebu/armada-37xx-periph.c38
-rw-r--r--drivers/clk/qcom/gcc-msm8996.c1
-rw-r--r--drivers/clk/qcom/mmcc-msm8996.c1
-rw-r--r--drivers/cpufreq/intel_pstate.c34
-rw-r--r--drivers/cpufreq/pcc-cpufreq.c4
-rw-r--r--drivers/cpufreq/qcom-cpufreq-kryo.c1
-rw-r--r--drivers/crypto/padlock-aes.c8
-rw-r--r--drivers/gpio/gpio-uniphier.c6
-rw-r--r--drivers/gpio/gpiolib-of.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c47
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c4
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c20
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c5
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c10
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c8
-rw-r--r--drivers/gpu/drm/amd/display/dc/dc.h1
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c27
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c19
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c2
-rw-r--r--drivers/gpu/drm/amd/display/dc/inc/dc_link_ddc.h5
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c23
-rw-r--r--drivers/gpu/drm/armada/armada_crtc.c12
-rw-r--r--drivers/gpu/drm/armada/armada_hw.h1
-rw-r--r--drivers/gpu/drm/armada/armada_overlay.c30
-rw-r--r--drivers/gpu/drm/bridge/adv7511/adv7511_drv.c12
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c8
-rw-r--r--drivers/gpu/drm/drm_context.c2
-rw-r--r--drivers/gpu/drm/drm_lease.c16
-rw-r--r--drivers/gpu/drm/i915/gvt/cmd_parser.c23
-rw-r--r--drivers/gpu/drm/i915/gvt/gvt.h29
-rw-r--r--drivers/gpu/drm/i915/gvt/handlers.c24
-rw-r--r--drivers/gpu/drm/i915/gvt/mmio.h2
-rw-r--r--drivers/gpu/drm/i915/gvt/mmio_context.c4
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c32
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c13
-rw-r--r--drivers/gpu/drm/i915/intel_display.c21
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h3
-rw-r--r--drivers/gpu/drm/imx/imx-ldb.c9
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/disp.c3
-rw-r--r--drivers/gpu/drm/nouveau/dispnv50/disp.c53
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_backlight.c6
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.h36
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c18
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp100.c9
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp102.c1
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h2
-rw-r--r--drivers/gpu/drm/sun4i/Makefile5
-rw-r--r--drivers/gpu/drm/tegra/drm.c2
-rw-r--r--drivers/gpu/drm/vc4/vc4_plane.c3
-rw-r--r--drivers/gpu/host1x/dev.c3
-rw-r--r--drivers/gpu/host1x/job.c3
-rw-r--r--drivers/gpu/ipu-v3/ipu-csi.c3
-rw-r--r--drivers/i2c/busses/i2c-davinci.c8
-rw-r--r--drivers/i2c/busses/i2c-imx.c5
-rw-r--r--drivers/i2c/busses/i2c-rcar.c54
-rw-r--r--drivers/i2c/i2c-core-base.c2
-rw-r--r--drivers/i2c/i2c-mux.c4
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c59
-rw-r--r--drivers/input/mouse/elan_i2c_core.c2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h7
-rw-r--r--drivers/iommu/intel-iommu.c32
-rw-r--r--drivers/md/dm-writecache.c43
-rw-r--r--drivers/media/platform/vsp1/vsp1_drm.c4
-rw-r--r--drivers/media/rc/bpf-lirc.c1
-rw-r--r--drivers/media/rc/rc-ir-raw.c8
-rw-r--r--drivers/media/rc/rc-main.c12
-rw-r--r--drivers/misc/cxl/api.c8
-rw-r--r--drivers/mmc/host/mxcmmc.c3
-rw-r--r--drivers/net/bonding/bond_main.c14
-rw-r--r--drivers/net/bonding/bond_options.c23
-rw-r--r--drivers/net/can/m_can/m_can.c18
-rw-r--r--drivers/net/can/mscan/mpc5xxx_can.c5
-rw-r--r--drivers/net/can/peak_canfd/peak_pciefd_main.c19
-rw-r--r--drivers/net/can/usb/ems_usb.c1
-rw-r--r--drivers/net/can/xilinx_can.c392
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c25
-rw-r--r--drivers/net/ethernet/3com/Kconfig2
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_com.c1
-rw-r--r--drivers/net/ethernet/amd/Kconfig4
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-mdio.c4
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_cfg.h2
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_hw.h4
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_main.c11
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_nic.c47
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_nic.h2
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c2
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c4
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c1
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c4
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c13
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c24
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.h1
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c30
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c13
-rw-r--r--drivers/net/ethernet/broadcom/tg3.h2
-rw-r--r--drivers/net/ethernet/cadence/macb.h11
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c36
-rw-r--r--drivers/net/ethernet/cavium/Kconfig12
-rw-r--r--drivers/net/ethernet/cavium/liquidio/lio_main.c5
-rw-r--r--drivers/net/ethernet/cavium/octeon/octeon_mgmt.c14
-rw-r--r--drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c35
-rw-r--r--drivers/net/ethernet/cirrus/Kconfig1
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c80
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_main.c1
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_tx.c1
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c43
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c12
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/alloc.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c19
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c12
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/wq.c34
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c51
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c48
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/main.c4
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed.h1
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_debug.c2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_l2.c15
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_l2.h2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_main.c2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_mcp.c52
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_sriov.c2
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_vf.c4
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_vf.h7
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c2
-rw-r--r--drivers/net/ethernet/qualcomm/qca_spi.c21
-rw-r--r--drivers/net/ethernet/realtek/r8169.c4
-rw-r--r--drivers/net/ethernet/renesas/ravb_main.c93
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c94
-rw-r--r--drivers/net/ethernet/sfc/ef10.c30
-rw-r--r--drivers/net/ethernet/sfc/efx.c17
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c40
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c1
-rw-r--r--drivers/net/hyperv/netvsc.c17
-rw-r--r--drivers/net/hyperv/rndis_filter.c1
-rw-r--r--drivers/net/ieee802154/adf7242.c34
-rw-r--r--drivers/net/ieee802154/at86rf230.c15
-rw-r--r--drivers/net/ieee802154/fakelb.c2
-rw-r--r--drivers/net/ieee802154/mcr20a.c3
-rw-r--r--drivers/net/netdevsim/devlink.c1
-rw-r--r--drivers/net/phy/marvell.c54
-rw-r--r--drivers/net/phy/mdio-mux-bcm-iproc.c2
-rw-r--r--drivers/net/phy/phy.c2
-rw-r--r--drivers/net/phy/phy_device.c7
-rw-r--r--drivers/net/phy/sfp-bus.c35
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/net/usb/asix_devices.c4
-rw-r--r--drivers/net/usb/lan78xx.c7
-rw-r--r--drivers/net/usb/qmi_wwan.c3
-rw-r--r--drivers/net/usb/rtl8150.c2
-rw-r--r--drivers/net/usb/smsc75xx.c62
-rw-r--r--drivers/net/virtio_net.c41
-rw-r--r--drivers/net/vxlan.c126
-rw-r--r--drivers/net/wan/lmc/lmc_main.c2
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c16
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.h1
-rw-r--r--drivers/net/wireless/ath/wcn36xx/testmode.c2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c3
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/9000.c69
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-config.h5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/drv.c22
-rw-r--r--drivers/net/wireless/marvell/mwifiex/usb.c7
-rw-r--r--drivers/net/wireless/mediatek/mt7601u/phy.c6
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/cfg80211.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/base.c17
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/base.h2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/core.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/ps.c4
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/usb.c2
-rw-r--r--drivers/net/xen-netfront.c6
-rw-r--r--drivers/nvme/host/core.c63
-rw-r--r--drivers/nvme/host/fabrics.c10
-rw-r--r--drivers/nvme/host/fabrics.h3
-rw-r--r--drivers/nvme/host/fc.c2
-rw-r--r--drivers/nvme/host/pci.c12
-rw-r--r--drivers/nvme/host/rdma.c2
-rw-r--r--drivers/nvme/target/configfs.c9
-rw-r--r--drivers/nvme/target/core.c2
-rw-r--r--drivers/nvme/target/fc.c44
-rw-r--r--drivers/nvme/target/loop.c2
-rw-r--r--drivers/of/base.c6
-rw-r--r--drivers/of/of_private.h2
-rw-r--r--drivers/of/overlay.c11
-rw-r--r--drivers/pci/bus.c6
-rw-r--r--drivers/pci/controller/dwc/pcie-designware-host.c3
-rw-r--r--drivers/pci/controller/pci-aardvark.c2
-rw-r--r--drivers/pci/controller/pci-ftpci100.c2
-rw-r--r--drivers/pci/controller/pci-hyperv.c8
-rw-r--r--drivers/pci/controller/pci-v3-semi.c2
-rw-r--r--drivers/pci/controller/pci-versatile.c2
-rw-r--r--drivers/pci/controller/pci-xgene.c2
-rw-r--r--drivers/pci/controller/pcie-mediatek.c2
-rw-r--r--drivers/pci/controller/pcie-mobiveil.c2
-rw-r--r--drivers/pci/endpoint/pci-epf-core.c62
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c2
-rw-r--r--drivers/pci/of.c2
-rw-r--r--drivers/pci/pci.c38
-rw-r--r--drivers/pci/pci.h11
-rw-r--r--drivers/pci/pcie/err.c2
-rw-r--r--drivers/pci/probe.c4
-rw-r--r--drivers/pci/remove.c5
-rw-r--r--drivers/phy/broadcom/phy-brcm-usb-init.c4
-rw-r--r--drivers/phy/motorola/phy-mapphone-mdm6600.c4
-rw-r--r--drivers/pinctrl/bcm/pinctrl-nsp-mux.c6
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mt7622.c48
-rw-r--r--drivers/pinctrl/pinctrl-ingenic.c2
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a77970.c14
-rw-r--r--drivers/platform/x86/dell-laptop.c2
-rw-r--r--drivers/ptp/ptp_chardev.c1
-rw-r--r--drivers/scsi/cxlflash/main.h4
-rw-r--r--drivers/scsi/cxlflash/ocxl_hw.c5
-rw-r--r--drivers/scsi/hpsa.c25
-rw-r--r--drivers/scsi/hpsa.h1
-rw-r--r--drivers/scsi/libiscsi.c12
-rw-r--r--drivers/scsi/qedf/qedf_main.c12
-rw-r--r--drivers/scsi/qedi/qedi_main.c11
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h1
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c44
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c21
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c11
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c55
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c3
-rw-r--r--drivers/scsi/scsi_error.c14
-rw-r--r--drivers/scsi/sd_zbc.c5
-rw-r--r--drivers/scsi/sg.c15
-rw-r--r--drivers/soc/imx/gpc.c21
-rw-r--r--drivers/staging/android/ashmem.c2
-rw-r--r--drivers/staging/ks7010/ks_hostif.c12
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c3
-rw-r--r--drivers/staging/rtl8188eu/Kconfig1
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_recv.c161
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_security.c92
-rw-r--r--drivers/staging/speakup/speakup_soft.c6
-rw-r--r--drivers/target/iscsi/cxgbit/cxgbit_target.c16
-rw-r--r--drivers/usb/chipidea/Kconfig9
-rw-r--r--drivers/usb/chipidea/Makefile3
-rw-r--r--drivers/usb/chipidea/ci.h8
-rw-r--r--drivers/usb/chipidea/ulpi.c3
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/hub.c8
-rw-r--r--drivers/usb/dwc2/gadget.c6
-rw-r--r--drivers/usb/dwc2/hcd.c54
-rw-r--r--drivers/usb/dwc2/hcd_intr.c9
-rw-r--r--drivers/usb/dwc3/ep0.c3
-rw-r--r--drivers/usb/gadget/composite.c1
-rw-r--r--drivers/usb/gadget/function/f_fs.c2
-rw-r--r--drivers/usb/gadget/function/f_uac2.c24
-rw-r--r--drivers/usb/gadget/function/u_audio.c88
-rw-r--r--drivers/usb/gadget/udc/aspeed-vhub/ep0.c11
-rw-r--r--drivers/usb/gadget/udc/aspeed-vhub/epn.c14
-rw-r--r--drivers/usb/gadget/udc/aspeed-vhub/vhub.h33
-rw-r--r--drivers/usb/gadget/udc/r8a66597-udc.c6
-rw-r--r--drivers/usb/host/xhci.c1
-rw-r--r--drivers/usb/phy/phy-fsl-usb.c4
-rw-r--r--drivers/usb/typec/tcpm.c2
-rw-r--r--drivers/vfio/pci/vfio_pci.c4
-rw-r--r--drivers/vfio/vfio_iommu_spapr_tce.c10
-rw-r--r--drivers/virtio/virtio_balloon.c2
-rw-r--r--fs/aio.c5
-rw-r--r--fs/block_dev.c9
-rw-r--r--fs/btrfs/extent_io.c7
-rw-r--r--fs/btrfs/ioctl.c2
-rw-r--r--fs/btrfs/scrub.c17
-rw-r--r--fs/btrfs/volumes.c2
-rw-r--r--fs/cachefiles/bind.c3
-rw-r--r--fs/cachefiles/namei.c3
-rw-r--r--fs/cachefiles/rdwr.c17
-rw-r--r--fs/exec.c7
-rw-r--r--fs/ext4/balloc.c3
-rw-r--r--fs/ext4/ialloc.c8
-rw-r--r--fs/ext4/inline.c19
-rw-r--r--fs/ext4/inode.c16
-rw-r--r--fs/ext4/mmp.c7
-rw-r--r--fs/ext4/super.c15
-rw-r--r--fs/fat/inode.c20
-rw-r--r--fs/fscache/cache.c2
-rw-r--r--fs/fscache/cookie.c7
-rw-r--r--fs/fscache/object.c1
-rw-r--r--fs/fscache/operation.c6
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/internal.h1
-rw-r--r--fs/iomap.c2
-rw-r--r--fs/jfs/jfs_dinode.h7
-rw-r--r--fs/jfs/jfs_incore.h1
-rw-r--r--fs/jfs/super.c3
-rw-r--r--fs/nfs/nfs4proc.c26
-rw-r--r--fs/squashfs/block.c2
-rw-r--r--fs/squashfs/cache.c3
-rw-r--r--fs/squashfs/file.c58
-rw-r--r--fs/squashfs/file_cache.c4
-rw-r--r--fs/squashfs/file_direct.c24
-rw-r--r--fs/squashfs/fragment.c17
-rw-r--r--fs/squashfs/squashfs.h3
-rw-r--r--fs/squashfs/squashfs_fs.h6
-rw-r--r--fs/squashfs/squashfs_fs_sb.h1
-rw-r--r--fs/squashfs/super.c5
-rw-r--r--fs/userfaultfd.c4
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c5
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c6
-rw-r--r--include/linux/blk-mq.h14
-rw-r--r--include/linux/bpf-cgroup.h1
-rw-r--r--include/linux/bpfilter.h6
-rw-r--r--include/linux/delayacct.h2
-rw-r--r--include/linux/eventfd.h1
-rw-r--r--include/linux/filter.h6
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/fsl/guts.h1
-rw-r--r--include/linux/if_bridge.h4
-rw-r--r--include/linux/igmp.h2
-rw-r--r--include/linux/intel-iommu.h1
-rw-r--r--include/linux/marvell_phy.h2
-rw-r--r--include/linux/mlx5/driver.h18
-rw-r--r--include/linux/mm.h23
-rw-r--r--include/linux/pci.h3
-rw-r--r--include/linux/perf_event.h1
-rw-r--r--include/linux/ring_buffer.h1
-rw-r--r--include/linux/rtmutex.h7
-rw-r--r--include/linux/sched/task.h2
-rw-r--r--include/linux/skbuff.h10
-rw-r--r--include/linux/syscalls.h1
-rw-r--r--include/net/cfg80211.h12
-rw-r--r--include/net/ip6_fib.h5
-rw-r--r--include/net/ip6_route.h6
-rw-r--r--include/net/ipv6.h13
-rw-r--r--include/net/netfilter/nf_tables.h5
-rw-r--r--include/net/netfilter/nf_tables_core.h6
-rw-r--r--include/net/netfilter/nf_tproxy.h4
-rw-r--r--include/net/tc_act/tc_csum.h1
-rw-r--r--include/net/tc_act/tc_tunnel_key.h1
-rw-r--r--include/net/tcp.h13
-rw-r--r--include/net/xdp_sock.h4
-rw-r--r--include/uapi/linux/aio_abi.h6
-rw-r--r--include/uapi/linux/btf.h2
-rw-r--r--include/uapi/linux/ethtool.h2
-rw-r--r--include/uapi/linux/perf_event.h2
-rw-r--r--include/uapi/linux/tcp.h4
-rw-r--r--ipc/sem.c2
-rw-r--r--ipc/shm.c12
-rw-r--r--kernel/auditsc.c13
-rw-r--r--kernel/bpf/arraymap.c2
-rw-r--r--kernel/bpf/btf.c60
-rw-r--r--kernel/bpf/devmap.c7
-rw-r--r--kernel/bpf/hashtab.c16
-rw-r--r--kernel/bpf/sockmap.c43
-rw-r--r--kernel/bpf/syscall.c4
-rw-r--r--kernel/bpf/verifier.c11
-rw-r--r--kernel/events/core.c10
-rw-r--r--kernel/fork.c33
-rw-r--r--kernel/irq/manage.c9
-rw-r--r--kernel/kthread.c8
-rw-r--r--kernel/locking/rtmutex.c29
-rw-r--r--kernel/memremap.c22
-rw-r--r--kernel/sched/deadline.c19
-rw-r--r--kernel/sched/rt.c2
-rw-r--r--kernel/sched/topology.c2
-rw-r--r--kernel/softirq.c14
-rw-r--r--kernel/stop_machine.c14
-rw-r--r--kernel/time/tick-sched.c2
-rw-r--r--kernel/trace/ring_buffer.c16
-rw-r--r--kernel/trace/trace.c6
-rw-r--r--kernel/trace/trace_events_trigger.c18
-rw-r--r--kernel/trace/trace_kprobe.c15
-rw-r--r--lib/Kconfig.kasan2
-rw-r--r--lib/iov_iter.c77
-rw-r--r--lib/rhashtable.c27
-rw-r--r--mm/huge_memory.c2
-rw-r--r--mm/hugetlb.c7
-rw-r--r--mm/memblock.c3
-rw-r--r--mm/memcontrol.c17
-rw-r--r--mm/memory.c6
-rw-r--r--mm/mempolicy.c1
-rw-r--r--mm/mmap.c38
-rw-r--r--mm/nommu.c12
-rw-r--r--mm/page_alloc.c20
-rw-r--r--mm/shmem.c1
-rw-r--r--mm/zswap.c9
-rw-r--r--net/batman-adv/bat_iv_ogm.c4
-rw-r--r--net/batman-adv/bat_v.c4
-rw-r--r--net/batman-adv/debugfs.c40
-rw-r--r--net/batman-adv/debugfs.h11
-rw-r--r--net/batman-adv/hard-interface.c37
-rw-r--r--net/batman-adv/translation-table.c7
-rw-r--r--net/bpf/test_run.c17
-rw-r--r--net/caif/caif_dev.c4
-rw-r--r--net/core/dev.c17
-rw-r--r--net/core/filter.c161
-rw-r--r--net/core/gen_stats.c16
-rw-r--r--net/core/lwt_bpf.c2
-rw-r--r--net/core/page_pool.c2
-rw-r--r--net/core/rtnetlink.c9
-rw-r--r--net/core/skbuff.c11
-rw-r--r--net/core/sock.c6
-rw-r--r--net/core/xdp.c3
-rw-r--r--net/dns_resolver/dns_key.c28
-rw-r--r--net/dsa/slave.c6
-rw-r--r--net/ieee802154/6lowpan/core.c6
-rw-r--r--net/ipv4/fib_frontend.c5
-rw-r--r--net/ipv4/igmp.c62
-rw-r--r--net/ipv4/inet_fragment.c8
-rw-r--r--net/ipv4/ip_fragment.c5
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/ip_sockglue.c11
-rw-r--r--net/ipv4/netfilter/ip_tables.c1
-rw-r--r--net/ipv4/netfilter/nf_tproxy_ipv4.c18
-rw-r--r--net/ipv4/sysctl_net_ipv4.c5
-rw-r--r--net/ipv4/tcp.c16
-rw-r--r--net/ipv4/tcp_bbr.c4
-rw-r--r--net/ipv4/tcp_dctcp.c75
-rw-r--r--net/ipv4/tcp_input.c74
-rw-r--r--net/ipv4/tcp_ipv4.c23
-rw-r--r--net/ipv4/tcp_output.c36
-rw-r--r--net/ipv6/Kconfig1
-rw-r--r--net/ipv6/addrconf.c3
-rw-r--r--net/ipv6/calipso.c9
-rw-r--r--net/ipv6/datagram.c7
-rw-r--r--net/ipv6/esp6.c4
-rw-r--r--net/ipv6/exthdrs.c111
-rw-r--r--net/ipv6/icmp.c5
-rw-r--r--net/ipv6/ip6_fib.c156
-rw-r--r--net/ipv6/ip6_gre.c3
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/ip6_vti.c11
-rw-r--r--net/ipv6/ipv6_sockglue.c32
-rw-r--r--net/ipv6/mcast.c67
-rw-r--r--net/ipv6/ndisc.c2
-rw-r--r--net/ipv6/netfilter/ip6_tables.c1
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c2
-rw-r--r--net/ipv6/netfilter/nf_tproxy_ipv6.c18
-rw-r--r--net/ipv6/route.c51
-rw-r--r--net/ipv6/seg6_iptunnel.c2
-rw-r--r--net/ipv6/tcp_ipv6.c6
-rw-r--r--net/l2tp/l2tp_ppp.c13
-rw-r--r--net/mac80211/rx.c5
-rw-r--r--net/mac80211/util.c3
-rw-r--r--net/netfilter/Kconfig25
-rw-r--r--net/netfilter/Makefile7
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_conntrack_proto_dccp.c8
-rw-r--r--net/netfilter/nf_tables_api.c304
-rw-r--r--net/netfilter/nf_tables_set_core.c28
-rw-r--r--net/netfilter/nft_compat.c13
-rw-r--r--net/netfilter/nft_immediate.c3
-rw-r--r--net/netfilter/nft_lookup.c13
-rw-r--r--net/netfilter/nft_set_bitmap.c19
-rw-r--r--net/netfilter/nft_set_hash.c30
-rw-r--r--net/netfilter/nft_set_rbtree.c26
-rw-r--r--net/netfilter/xt_TPROXY.c8
-rw-r--r--net/netlink/af_netlink.c7
-rw-r--r--net/nfc/llcp_commands.c9
-rw-r--r--net/nsh/nsh.c2
-rw-r--r--net/openvswitch/meter.c10
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/qrtr/qrtr.c13
-rw-r--r--net/rds/ib_frmr.c5
-rw-r--r--net/rds/ib_mr.h3
-rw-r--r--net/rds/ib_rdma.c21
-rw-r--r--net/rds/rdma.c13
-rw-r--r--net/rds/rds.h5
-rw-r--r--net/rds/send.c12
-rw-r--r--net/rxrpc/call_accept.c4
-rw-r--r--net/sched/act_csum.c6
-rw-r--r--net/sched/act_tunnel_key.c6
-rw-r--r--net/sched/cls_api.c4
-rw-r--r--net/sched/sch_fq_codel.c25
-rw-r--r--net/sctp/transport.c2
-rw-r--r--net/smc/af_smc.c37
-rw-r--r--net/smc/smc_cdc.c3
-rw-r--r--net/smc/smc_clc.c3
-rw-r--r--net/smc/smc_close.c2
-rw-r--r--net/smc/smc_tx.c12
-rw-r--r--net/socket.c5
-rw-r--r--net/tipc/discover.c18
-rw-r--r--net/tipc/net.c17
-rw-r--r--net/tipc/node.c7
-rw-r--r--net/tls/tls_sw.c10
-rw-r--r--net/wireless/nl80211.c25
-rw-r--r--net/wireless/reg.c28
-rw-r--r--net/wireless/trace.h18
-rw-r--r--net/xdp/xsk.c34
-rw-r--r--net/xdp/xsk_queue.h11
-rw-r--r--net/xfrm/xfrm_policy.c3
-rw-r--r--net/xfrm/xfrm_user.c18
-rw-r--r--samples/bpf/.gitignore49
-rw-r--r--samples/bpf/parse_varlen.c6
-rw-r--r--samples/bpf/test_overhead_user.c19
-rw-r--r--samples/bpf/trace_event_user.c27
-rwxr-xr-xsamples/bpf/xdp2skb_meta.sh6
-rw-r--r--samples/bpf/xdpsock_user.c2
-rwxr-xr-xscripts/tags.sh1
-rw-r--r--sound/core/rawmidi.c20
-rw-r--r--sound/pci/hda/patch_conexant.c1
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--tools/arch/powerpc/include/uapi/asm/unistd.h1
-rw-r--r--tools/arch/x86/include/asm/mcsafe_test.h13
-rw-r--r--tools/arch/x86/lib/memcpy_64.S112
-rw-r--r--tools/bpf/bpftool/common.c11
-rw-r--r--tools/bpf/bpftool/map.c14
-rw-r--r--tools/include/uapi/linux/bpf.h28
-rw-r--r--tools/include/uapi/linux/btf.h2
-rw-r--r--tools/include/uapi/linux/perf_event.h2
-rw-r--r--tools/lib/bpf/btf.c39
-rw-r--r--tools/lib/bpf/btf.h10
-rw-r--r--tools/lib/bpf/libbpf.c87
-rw-r--r--tools/lib/bpf/libbpf.h4
-rw-r--r--tools/objtool/elf.c6
-rw-r--r--tools/perf/arch/x86/util/pmu.c1
-rw-r--r--tools/perf/arch/x86/util/tsc.c1
-rw-r--r--tools/perf/bench/Build1
-rw-r--r--tools/perf/bench/mem-memcpy-x86-64-asm.S1
-rw-r--r--tools/perf/bench/mem-memcpy-x86-64-lib.c24
-rw-r--r--tools/perf/perf.h1
-rw-r--r--tools/perf/util/header.h1
-rw-r--r--tools/perf/util/namespaces.h1
-rw-r--r--tools/power/x86/turbostat/turbostat.84
-rw-r--r--tools/power/x86/turbostat/turbostat.c120
-rw-r--r--tools/testing/selftests/bpf/Makefile2
-rw-r--r--tools/testing/selftests/bpf/bpf_helpers.h9
-rw-r--r--tools/testing/selftests/bpf/test_btf.c114
-rw-r--r--tools/testing/selftests/bpf/test_btf_haskv.c7
-rwxr-xr-xtools/testing/selftests/bpf/test_lwt_seg6local.sh6
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c63
-rw-r--r--tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc28
-rwxr-xr-xtools/testing/selftests/net/fib_tests.sh41
-rw-r--r--tools/testing/selftests/net/tcp_mmap.c2
-rwxr-xr-xtools/testing/selftests/net/udpgso_bench.sh3
-rw-r--r--tools/usb/ffs-test.c19
-rw-r--r--tools/virtio/asm/barrier.h4
-rw-r--r--tools/virtio/linux/kernel.h5
-rw-r--r--virt/kvm/eventfd.c17
702 files changed, 6806 insertions, 3450 deletions
diff --git a/Documentation/device-mapper/writecache.txt b/Documentation/device-mapper/writecache.txt
index 4424fa2c67d7..01532b3008ae 100644
--- a/Documentation/device-mapper/writecache.txt
+++ b/Documentation/device-mapper/writecache.txt
@@ -15,6 +15,8 @@ Constructor parameters:
15 size) 15 size)
165. the number of optional parameters (the parameters with an argument 165. the number of optional parameters (the parameters with an argument
17 count as two) 17 count as two)
18 start_sector n (default: 0)
19 offset from the start of cache device in 512-byte sectors
18 high_watermark n (default: 50) 20 high_watermark n (default: 50)
19 start writeback when the number of used blocks reach this 21 start writeback when the number of used blocks reach this
20 watermark 22 watermark
diff --git a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
index bdadc3da9556..6970f30a3770 100644
--- a/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
@@ -66,7 +66,7 @@ Required root node properties:
66 - "insignal,arndale-octa" - for Exynos5420-based Insignal Arndale 66 - "insignal,arndale-octa" - for Exynos5420-based Insignal Arndale
67 Octa board. 67 Octa board.
68 - "insignal,origen" - for Exynos4210-based Insignal Origen board. 68 - "insignal,origen" - for Exynos4210-based Insignal Origen board.
69 - "insignal,origen4412 - for Exynos4412-based Insignal Origen board. 69 - "insignal,origen4412" - for Exynos4412-based Insignal Origen board.
70 70
71 71
72Optional nodes: 72Optional nodes:
diff --git a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
index 6fddb4f4f71a..3055d5c2c04e 100644
--- a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
+++ b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
@@ -36,7 +36,7 @@ Optional nodes:
36 36
37 - port/ports: to describe a connection to an external encoder. The 37 - port/ports: to describe a connection to an external encoder. The
38 binding follows Documentation/devicetree/bindings/graph.txt and 38 binding follows Documentation/devicetree/bindings/graph.txt and
39 suppors a single port with a single endpoint. 39 supports a single port with a single endpoint.
40 40
41 - See also Documentation/devicetree/bindings/display/tilcdc/panel.txt and 41 - See also Documentation/devicetree/bindings/display/tilcdc/panel.txt and
42 Documentation/devicetree/bindings/display/tilcdc/tfp410.txt for connecting 42 Documentation/devicetree/bindings/display/tilcdc/tfp410.txt for connecting
diff --git a/Documentation/devicetree/bindings/gpio/nintendo,hollywood-gpio.txt b/Documentation/devicetree/bindings/gpio/nintendo,hollywood-gpio.txt
index 20fc72d9e61e..45a61b462287 100644
--- a/Documentation/devicetree/bindings/gpio/nintendo,hollywood-gpio.txt
+++ b/Documentation/devicetree/bindings/gpio/nintendo,hollywood-gpio.txt
@@ -1,7 +1,7 @@
1Nintendo Wii (Hollywood) GPIO controller 1Nintendo Wii (Hollywood) GPIO controller
2 2
3Required properties: 3Required properties:
4- compatible: "nintendo,hollywood-gpio 4- compatible: "nintendo,hollywood-gpio"
5- reg: Physical base address and length of the controller's registers. 5- reg: Physical base address and length of the controller's registers.
6- gpio-controller: Marks the device node as a GPIO controller. 6- gpio-controller: Marks the device node as a GPIO controller.
7- #gpio-cells: Should be <2>. The first cell is the pin number and the 7- #gpio-cells: Should be <2>. The first cell is the pin number and the
diff --git a/Documentation/devicetree/bindings/input/touchscreen/hideep.txt b/Documentation/devicetree/bindings/input/touchscreen/hideep.txt
index 121d9b7c79a2..1063c30d53f7 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/hideep.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/hideep.txt
@@ -32,7 +32,7 @@ i2c@00000000 {
32 reg = <0x6c>; 32 reg = <0x6c>;
33 interrupt-parent = <&gpx1>; 33 interrupt-parent = <&gpx1>;
34 interrupts = <2 IRQ_TYPE_LEVEL_LOW>; 34 interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
35 vdd-supply = <&ldo15_reg>"; 35 vdd-supply = <&ldo15_reg>;
36 vid-supply = <&ldo18_reg>; 36 vid-supply = <&ldo18_reg>;
37 reset-gpios = <&gpx1 5 0>; 37 reset-gpios = <&gpx1 5 0>;
38 touchscreen-size-x = <1080>; 38 touchscreen-size-x = <1080>;
diff --git a/Documentation/devicetree/bindings/interrupt-controller/nvidia,tegra20-ictlr.txt b/Documentation/devicetree/bindings/interrupt-controller/nvidia,tegra20-ictlr.txt
index 1099fe0788fa..f246ccbf8838 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/nvidia,tegra20-ictlr.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/nvidia,tegra20-ictlr.txt
@@ -15,7 +15,7 @@ Required properties:
15 include "nvidia,tegra30-ictlr". 15 include "nvidia,tegra30-ictlr".
16- reg : Specifies base physical address and size of the registers. 16- reg : Specifies base physical address and size of the registers.
17 Each controller must be described separately (Tegra20 has 4 of them, 17 Each controller must be described separately (Tegra20 has 4 of them,
18 whereas Tegra30 and later have 5" 18 whereas Tegra30 and later have 5).
19- interrupt-controller : Identifies the node as an interrupt controller. 19- interrupt-controller : Identifies the node as an interrupt controller.
20- #interrupt-cells : Specifies the number of cells needed to encode an 20- #interrupt-cells : Specifies the number of cells needed to encode an
21 interrupt source. The value must be 3. 21 interrupt source. The value must be 3.
diff --git a/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt b/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt
index 136bd612bd83..6a36bf66d932 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt
@@ -12,7 +12,7 @@ Required properties:
12 specifier, shall be 2 12 specifier, shall be 2
13- interrupts: interrupts references to primary interrupt controller 13- interrupts: interrupts references to primary interrupt controller
14 (only needed for exti controller with multiple exti under 14 (only needed for exti controller with multiple exti under
15 same parent interrupt: st,stm32-exti and st,stm32h7-exti") 15 same parent interrupt: st,stm32-exti and st,stm32h7-exti)
16 16
17Example: 17Example:
18 18
diff --git a/Documentation/devicetree/bindings/mips/brcm/soc.txt b/Documentation/devicetree/bindings/mips/brcm/soc.txt
index 356c29789cf5..3a66d3c483e1 100644
--- a/Documentation/devicetree/bindings/mips/brcm/soc.txt
+++ b/Documentation/devicetree/bindings/mips/brcm/soc.txt
@@ -152,7 +152,7 @@ Required properties:
152- compatible : should contain one of: 152- compatible : should contain one of:
153 "brcm,bcm7425-timers" 153 "brcm,bcm7425-timers"
154 "brcm,bcm7429-timers" 154 "brcm,bcm7429-timers"
155 "brcm,bcm7435-timers and 155 "brcm,bcm7435-timers" and
156 "brcm,brcmstb-timers" 156 "brcm,brcmstb-timers"
157- reg : the timers register range 157- reg : the timers register range
158- interrupts : the interrupt line for this timer block 158- interrupts : the interrupt line for this timer block
diff --git a/Documentation/devicetree/bindings/net/fsl-fman.txt b/Documentation/devicetree/bindings/net/fsl-fman.txt
index df873d1f3b7c..f8c33890bc29 100644
--- a/Documentation/devicetree/bindings/net/fsl-fman.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fman.txt
@@ -238,7 +238,7 @@ PROPERTIES
238 Must include one of the following: 238 Must include one of the following:
239 - "fsl,fman-dtsec" for dTSEC MAC 239 - "fsl,fman-dtsec" for dTSEC MAC
240 - "fsl,fman-xgec" for XGEC MAC 240 - "fsl,fman-xgec" for XGEC MAC
241 - "fsl,fman-memac for mEMAC MAC 241 - "fsl,fman-memac" for mEMAC MAC
242 242
243- cell-index 243- cell-index
244 Usage: required 244 Usage: required
diff --git a/Documentation/devicetree/bindings/power/power_domain.txt b/Documentation/devicetree/bindings/power/power_domain.txt
index 9b387f861aed..7dec508987c7 100644
--- a/Documentation/devicetree/bindings/power/power_domain.txt
+++ b/Documentation/devicetree/bindings/power/power_domain.txt
@@ -133,7 +133,7 @@ located inside a PM domain with index 0 of a power controller represented by a
133node with the label "power". 133node with the label "power".
134In the second example the consumer device are partitioned across two PM domains, 134In the second example the consumer device are partitioned across two PM domains,
135the first with index 0 and the second with index 1, of a power controller that 135the first with index 0 and the second with index 1, of a power controller that
136is represented by a node with the label "power. 136is represented by a node with the label "power".
137 137
138Optional properties: 138Optional properties:
139- required-opps: This contains phandle to an OPP node in another device's OPP 139- required-opps: This contains phandle to an OPP node in another device's OPP
diff --git a/Documentation/devicetree/bindings/regulator/tps65090.txt b/Documentation/devicetree/bindings/regulator/tps65090.txt
index ca69f5e3040c..ae326f263597 100644
--- a/Documentation/devicetree/bindings/regulator/tps65090.txt
+++ b/Documentation/devicetree/bindings/regulator/tps65090.txt
@@ -16,7 +16,7 @@ Required properties:
16Optional properties: 16Optional properties:
17- ti,enable-ext-control: This is applicable for DCDC1, DCDC2 and DCDC3. 17- ti,enable-ext-control: This is applicable for DCDC1, DCDC2 and DCDC3.
18 If DCDCs are externally controlled then this property should be there. 18 If DCDCs are externally controlled then this property should be there.
19- "dcdc-ext-control-gpios: This is applicable for DCDC1, DCDC2 and DCDC3. 19- dcdc-ext-control-gpios: This is applicable for DCDC1, DCDC2 and DCDC3.
20 If DCDCs are externally controlled and if it is from GPIO then GPIO 20 If DCDCs are externally controlled and if it is from GPIO then GPIO
21 number should be provided. If it is externally controlled and no GPIO 21 number should be provided. If it is externally controlled and no GPIO
22 entry then driver will just configure this rails as external control 22 entry then driver will just configure this rails as external control
diff --git a/Documentation/devicetree/bindings/reset/st,sti-softreset.txt b/Documentation/devicetree/bindings/reset/st,sti-softreset.txt
index a21658f18fe6..3661e6153a92 100644
--- a/Documentation/devicetree/bindings/reset/st,sti-softreset.txt
+++ b/Documentation/devicetree/bindings/reset/st,sti-softreset.txt
@@ -15,7 +15,7 @@ Please refer to reset.txt in this directory for common reset
15controller binding usage. 15controller binding usage.
16 16
17Required properties: 17Required properties:
18- compatible: Should be st,stih407-softreset"; 18- compatible: Should be "st,stih407-softreset";
19- #reset-cells: 1, see below 19- #reset-cells: 1, see below
20 20
21example: 21example:
diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
index d330c73de9a2..68b7d6207e3d 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
@@ -39,7 +39,7 @@ Required properties:
39 39
40Optional property: 40Optional property:
41- clock-frequency: Desired I2C bus clock frequency in Hz. 41- clock-frequency: Desired I2C bus clock frequency in Hz.
42 When missing default to 400000Hz. 42 When missing default to 100000Hz.
43 43
44Child nodes should conform to I2C bus binding as described in i2c.txt. 44Child nodes should conform to I2C bus binding as described in i2c.txt.
45 45
diff --git a/Documentation/devicetree/bindings/sound/qcom,apq8016-sbc.txt b/Documentation/devicetree/bindings/sound/qcom,apq8016-sbc.txt
index 6a4aadc4ce06..84b28dbe9f15 100644
--- a/Documentation/devicetree/bindings/sound/qcom,apq8016-sbc.txt
+++ b/Documentation/devicetree/bindings/sound/qcom,apq8016-sbc.txt
@@ -30,7 +30,7 @@ Required properties:
30 30
31 Board connectors: 31 Board connectors:
32 * Headset Mic 32 * Headset Mic
33 * Secondary Mic", 33 * Secondary Mic
34 * DMIC 34 * DMIC
35 * Ext Spk 35 * Ext Spk
36 36
diff --git a/Documentation/devicetree/bindings/sound/qcom,apq8096.txt b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt
index aa54e49fc8a2..c7600a93ab39 100644
--- a/Documentation/devicetree/bindings/sound/qcom,apq8096.txt
+++ b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt
@@ -35,7 +35,7 @@ This binding describes the APQ8096 sound card, which uses qdsp for audio.
35 "Digital Mic3" 35 "Digital Mic3"
36 36
37 Audio pins and MicBias on WCD9335 Codec: 37 Audio pins and MicBias on WCD9335 Codec:
38 "MIC_BIAS1 38 "MIC_BIAS1"
39 "MIC_BIAS2" 39 "MIC_BIAS2"
40 "MIC_BIAS3" 40 "MIC_BIAS3"
41 "MIC_BIAS4" 41 "MIC_BIAS4"
diff --git a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
index 252a05c5d976..c8c4b00ecb94 100644
--- a/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
@@ -16,7 +16,8 @@ A child node must exist to represent the core DWC3 IP block. The name of
16the node is not important. The content of the node is defined in dwc3.txt. 16the node is not important. The content of the node is defined in dwc3.txt.
17 17
18Phy documentation is provided in the following places: 18Phy documentation is provided in the following places:
19Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt 19Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt - USB2.0 PHY
20Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt - Type-C PHY
20 21
21Example device nodes: 22Example device nodes:
22 23
diff --git a/Documentation/devicetree/bindings/w1/w1-gpio.txt b/Documentation/devicetree/bindings/w1/w1-gpio.txt
index 6e09c35d9f1a..37091902a021 100644
--- a/Documentation/devicetree/bindings/w1/w1-gpio.txt
+++ b/Documentation/devicetree/bindings/w1/w1-gpio.txt
@@ -15,7 +15,7 @@ Optional properties:
15 15
16Examples: 16Examples:
17 17
18 onewire@0 { 18 onewire {
19 compatible = "w1-gpio"; 19 compatible = "w1-gpio";
20 gpios = <&gpio 126 0>, <&gpio 105 0>; 20 gpios = <&gpio 126 0>, <&gpio 105 0>;
21 }; 21 };
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index c13214d073a4..d3e5dd26db12 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1490,7 +1490,7 @@ To remove an ARP target:
1490 1490
1491To configure the interval between learning packet transmits: 1491To configure the interval between learning packet transmits:
1492# echo 12 > /sys/class/net/bond0/bonding/lp_interval 1492# echo 12 > /sys/class/net/bond0/bonding/lp_interval
1493 NOTE: the lp_inteval is the number of seconds between instances where 1493 NOTE: the lp_interval is the number of seconds between instances where
1494the bonding driver sends learning packets to each slaves peer switch. The 1494the bonding driver sends learning packets to each slaves peer switch. The
1495default interval is 1 second. 1495default interval is 1 second.
1496 1496
diff --git a/Documentation/networking/dpaa2/overview.rst b/Documentation/networking/dpaa2/overview.rst
index 79fede4447d6..d638b5a8aadd 100644
--- a/Documentation/networking/dpaa2/overview.rst
+++ b/Documentation/networking/dpaa2/overview.rst
@@ -1,5 +1,6 @@
1.. include:: <isonum.txt> 1.. include:: <isonum.txt>
2 2
3=========================================================
3DPAA2 (Data Path Acceleration Architecture Gen2) Overview 4DPAA2 (Data Path Acceleration Architecture Gen2) Overview
4========================================================= 5=========================================================
5 6
diff --git a/Documentation/networking/e100.rst b/Documentation/networking/e100.rst
index 9708f5fa76de..f81111eba9c5 100644
--- a/Documentation/networking/e100.rst
+++ b/Documentation/networking/e100.rst
@@ -47,41 +47,45 @@ Driver Configuration Parameters
47The default value for each parameter is generally the recommended setting, 47The default value for each parameter is generally the recommended setting,
48unless otherwise noted. 48unless otherwise noted.
49 49
50Rx Descriptors: Number of receive descriptors. A receive descriptor is a data 50Rx Descriptors:
51 Number of receive descriptors. A receive descriptor is a data
51 structure that describes a receive buffer and its attributes to the network 52 structure that describes a receive buffer and its attributes to the network
52 controller. The data in the descriptor is used by the controller to write 53 controller. The data in the descriptor is used by the controller to write
53 data from the controller to host memory. In the 3.x.x driver the valid range 54 data from the controller to host memory. In the 3.x.x driver the valid range
54 for this parameter is 64-256. The default value is 256. This parameter can be 55 for this parameter is 64-256. The default value is 256. This parameter can be
55 changed using the command:: 56 changed using the command::
56 57
57 ethtool -G eth? rx n 58 ethtool -G eth? rx n
58 59
59 Where n is the number of desired Rx descriptors. 60 Where n is the number of desired Rx descriptors.
60 61
61Tx Descriptors: Number of transmit descriptors. A transmit descriptor is a data 62Tx Descriptors:
63 Number of transmit descriptors. A transmit descriptor is a data
62 structure that describes a transmit buffer and its attributes to the network 64 structure that describes a transmit buffer and its attributes to the network
63 controller. The data in the descriptor is used by the controller to read 65 controller. The data in the descriptor is used by the controller to read
64 data from the host memory to the controller. In the 3.x.x driver the valid 66 data from the host memory to the controller. In the 3.x.x driver the valid
65 range for this parameter is 64-256. The default value is 128. This parameter 67 range for this parameter is 64-256. The default value is 128. This parameter
66 can be changed using the command:: 68 can be changed using the command::
67 69
68 ethtool -G eth? tx n 70 ethtool -G eth? tx n
69 71
70 Where n is the number of desired Tx descriptors. 72 Where n is the number of desired Tx descriptors.
71 73
72Speed/Duplex: The driver auto-negotiates the link speed and duplex settings by 74Speed/Duplex:
75 The driver auto-negotiates the link speed and duplex settings by
73 default. The ethtool utility can be used as follows to force speed/duplex.:: 76 default. The ethtool utility can be used as follows to force speed/duplex.::
74 77
75 ethtool -s eth? autoneg off speed {10|100} duplex {full|half} 78 ethtool -s eth? autoneg off speed {10|100} duplex {full|half}
76 79
77 NOTE: setting the speed/duplex to incorrect values will cause the link to 80 NOTE: setting the speed/duplex to incorrect values will cause the link to
78 fail. 81 fail.
79 82
80Event Log Message Level: The driver uses the message level flag to log events 83Event Log Message Level:
84 The driver uses the message level flag to log events
81 to syslog. The message level can be set at driver load time. It can also be 85 to syslog. The message level can be set at driver load time. It can also be
82 set using the command:: 86 set using the command::
83 87
84 ethtool -s eth? msglvl n 88 ethtool -s eth? msglvl n
85 89
86 90
87Additional Configurations 91Additional Configurations
@@ -92,7 +96,7 @@ Configuring the Driver on Different Distributions
92 96
93Configuring a network driver to load properly when the system is started 97Configuring a network driver to load properly when the system is started
94is distribution dependent. Typically, the configuration process involves 98is distribution dependent. Typically, the configuration process involves
95adding an alias line to /etc/modprobe.d/*.conf as well as editing other 99adding an alias line to `/etc/modprobe.d/*.conf` as well as editing other
96system startup scripts and/or configuration files. Many popular Linux 100system startup scripts and/or configuration files. Many popular Linux
97distributions ship with tools to make these changes for you. To learn 101distributions ship with tools to make these changes for you. To learn
98the proper way to configure a network device for your system, refer to 102the proper way to configure a network device for your system, refer to
@@ -160,7 +164,10 @@ This results in unbalanced receive traffic.
160If you have multiple interfaces in a server, either turn on ARP 164If you have multiple interfaces in a server, either turn on ARP
161filtering by 165filtering by
162 166
163(1) entering:: echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter 167(1) entering::
168
169 echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
170
164 (this only works if your kernel's version is higher than 2.4.5), or 171 (this only works if your kernel's version is higher than 2.4.5), or
165 172
166(2) installing the interfaces in separate broadcast domains (either 173(2) installing the interfaces in separate broadcast domains (either
diff --git a/Documentation/networking/e1000.rst b/Documentation/networking/e1000.rst
index 144b87eef153..f10dd4086921 100644
--- a/Documentation/networking/e1000.rst
+++ b/Documentation/networking/e1000.rst
@@ -34,7 +34,8 @@ Command Line Parameters
34The default value for each parameter is generally the recommended setting, 34The default value for each parameter is generally the recommended setting,
35unless otherwise noted. 35unless otherwise noted.
36 36
37NOTES: For more information about the AutoNeg, Duplex, and Speed 37NOTES:
38 For more information about the AutoNeg, Duplex, and Speed
38 parameters, see the "Speed and Duplex Configuration" section in 39 parameters, see the "Speed and Duplex Configuration" section in
39 this document. 40 this document.
40 41
@@ -45,22 +46,27 @@ NOTES: For more information about the AutoNeg, Duplex, and Speed
45 46
46AutoNeg 47AutoNeg
47------- 48-------
49
48(Supported only on adapters with copper connections) 50(Supported only on adapters with copper connections)
49Valid Range: 0x01-0x0F, 0x20-0x2F 51
50Default Value: 0x2F 52:Valid Range: 0x01-0x0F, 0x20-0x2F
53:Default Value: 0x2F
51 54
52This parameter is a bit-mask that specifies the speed and duplex settings 55This parameter is a bit-mask that specifies the speed and duplex settings
53advertised by the adapter. When this parameter is used, the Speed and 56advertised by the adapter. When this parameter is used, the Speed and
54Duplex parameters must not be specified. 57Duplex parameters must not be specified.
55 58
56NOTE: Refer to the Speed and Duplex section of this readme for more 59NOTE:
60 Refer to the Speed and Duplex section of this readme for more
57 information on the AutoNeg parameter. 61 information on the AutoNeg parameter.
58 62
59Duplex 63Duplex
60------ 64------
65
61(Supported only on adapters with copper connections) 66(Supported only on adapters with copper connections)
62Valid Range: 0-2 (0=auto-negotiate, 1=half, 2=full) 67
63Default Value: 0 68:Valid Range: 0-2 (0=auto-negotiate, 1=half, 2=full)
69:Default Value: 0
64 70
65This defines the direction in which data is allowed to flow. Can be 71This defines the direction in which data is allowed to flow. Can be
66either one or two-directional. If both Duplex and the link partner are 72either one or two-directional. If both Duplex and the link partner are
@@ -70,18 +76,22 @@ duplex.
70 76
71FlowControl 77FlowControl
72----------- 78-----------
73Valid Range: 0-3 (0=none, 1=Rx only, 2=Tx only, 3=Rx&Tx) 79
74Default Value: Reads flow control settings from the EEPROM 80:Valid Range: 0-3 (0=none, 1=Rx only, 2=Tx only, 3=Rx&Tx)
81:Default Value: Reads flow control settings from the EEPROM
75 82
76This parameter controls the automatic generation(Tx) and response(Rx) 83This parameter controls the automatic generation(Tx) and response(Rx)
77to Ethernet PAUSE frames. 84to Ethernet PAUSE frames.
78 85
79InterruptThrottleRate 86InterruptThrottleRate
80--------------------- 87---------------------
88
81(not supported on Intel(R) 82542, 82543 or 82544-based adapters) 89(not supported on Intel(R) 82542, 82543 or 82544-based adapters)
82Valid Range: 0,1,3,4,100-100000 (0=off, 1=dynamic, 3=dynamic conservative, 90
83 4=simplified balancing) 91:Valid Range:
84Default Value: 3 92 0,1,3,4,100-100000 (0=off, 1=dynamic, 3=dynamic conservative,
93 4=simplified balancing)
94:Default Value: 3
85 95
86The driver can limit the amount of interrupts per second that the adapter 96The driver can limit the amount of interrupts per second that the adapter
87will generate for incoming packets. It does this by writing a value to the 97will generate for incoming packets. It does this by writing a value to the
@@ -135,13 +145,15 @@ Setting InterruptThrottleRate to 0 turns off any interrupt moderation
135and may improve small packet latency, but is generally not suitable 145and may improve small packet latency, but is generally not suitable
136for bulk throughput traffic. 146for bulk throughput traffic.
137 147
138NOTE: InterruptThrottleRate takes precedence over the TxAbsIntDelay and 148NOTE:
149 InterruptThrottleRate takes precedence over the TxAbsIntDelay and
139 RxAbsIntDelay parameters. In other words, minimizing the receive 150 RxAbsIntDelay parameters. In other words, minimizing the receive
140 and/or transmit absolute delays does not force the controller to 151 and/or transmit absolute delays does not force the controller to
141 generate more interrupts than what the Interrupt Throttle Rate 152 generate more interrupts than what the Interrupt Throttle Rate
142 allows. 153 allows.
143 154
144CAUTION: If you are using the Intel(R) PRO/1000 CT Network Connection 155CAUTION:
156 If you are using the Intel(R) PRO/1000 CT Network Connection
145 (controller 82547), setting InterruptThrottleRate to a value 157 (controller 82547), setting InterruptThrottleRate to a value
146 greater than 75,000, may hang (stop transmitting) adapters 158 greater than 75,000, may hang (stop transmitting) adapters
147 under certain network conditions. If this occurs a NETDEV 159 under certain network conditions. If this occurs a NETDEV
@@ -151,7 +163,8 @@ CAUTION: If you are using the Intel(R) PRO/1000 CT Network Connection
151 hang, ensure that InterruptThrottleRate is set no greater 163 hang, ensure that InterruptThrottleRate is set no greater
152 than 75,000 and is not set to 0. 164 than 75,000 and is not set to 0.
153 165
154NOTE: When e1000 is loaded with default settings and multiple adapters 166NOTE:
167 When e1000 is loaded with default settings and multiple adapters
155 are in use simultaneously, the CPU utilization may increase non- 168 are in use simultaneously, the CPU utilization may increase non-
156 linearly. In order to limit the CPU utilization without impacting 169 linearly. In order to limit the CPU utilization without impacting
157 the overall throughput, we recommend that you load the driver as 170 the overall throughput, we recommend that you load the driver as
@@ -168,9 +181,11 @@ NOTE: When e1000 is loaded with default settings and multiple adapters
168 181
169RxDescriptors 182RxDescriptors
170------------- 183-------------
171Valid Range: 48-256 for 82542 and 82543-based adapters 184
172 48-4096 for all other supported adapters 185:Valid Range:
173Default Value: 256 186 - 48-256 for 82542 and 82543-based adapters
187 - 48-4096 for all other supported adapters
188:Default Value: 256
174 189
175This value specifies the number of receive buffer descriptors allocated 190This value specifies the number of receive buffer descriptors allocated
176by the driver. Increasing this value allows the driver to buffer more 191by the driver. Increasing this value allows the driver to buffer more
@@ -180,15 +195,17 @@ Each descriptor is 16 bytes. A receive buffer is also allocated for each
180descriptor and can be either 2048, 4096, 8192, or 16384 bytes, depending 195descriptor and can be either 2048, 4096, 8192, or 16384 bytes, depending
181on the MTU setting. The maximum MTU size is 16110. 196on the MTU setting. The maximum MTU size is 16110.
182 197
183NOTE: MTU designates the frame size. It only needs to be set for Jumbo 198NOTE:
199 MTU designates the frame size. It only needs to be set for Jumbo
184 Frames. Depending on the available system resources, the request 200 Frames. Depending on the available system resources, the request
185 for a higher number of receive descriptors may be denied. In this 201 for a higher number of receive descriptors may be denied. In this
186 case, use a lower number. 202 case, use a lower number.
187 203
188RxIntDelay 204RxIntDelay
189---------- 205----------
190Valid Range: 0-65535 (0=off) 206
191Default Value: 0 207:Valid Range: 0-65535 (0=off)
208:Default Value: 0
192 209
193This value delays the generation of receive interrupts in units of 1.024 210This value delays the generation of receive interrupts in units of 1.024
194microseconds. Receive interrupt reduction can improve CPU efficiency if 211microseconds. Receive interrupt reduction can improve CPU efficiency if
@@ -198,7 +215,8 @@ of TCP traffic. If the system is reporting dropped receives, this value
198may be set too high, causing the driver to run out of available receive 215may be set too high, causing the driver to run out of available receive
199descriptors. 216descriptors.
200 217
201CAUTION: When setting RxIntDelay to a value other than 0, adapters may 218CAUTION:
219 When setting RxIntDelay to a value other than 0, adapters may
202 hang (stop transmitting) under certain network conditions. If 220 hang (stop transmitting) under certain network conditions. If
203 this occurs a NETDEV WATCHDOG message is logged in the system 221 this occurs a NETDEV WATCHDOG message is logged in the system
204 event log. In addition, the controller is automatically reset, 222 event log. In addition, the controller is automatically reset,
@@ -207,9 +225,11 @@ CAUTION: When setting RxIntDelay to a value other than 0, adapters may
207 225
208RxAbsIntDelay 226RxAbsIntDelay
209------------- 227-------------
228
210(This parameter is supported only on 82540, 82545 and later adapters.) 229(This parameter is supported only on 82540, 82545 and later adapters.)
211Valid Range: 0-65535 (0=off) 230
212Default Value: 128 231:Valid Range: 0-65535 (0=off)
232:Default Value: 128
213 233
214This value, in units of 1.024 microseconds, limits the delay in which a 234This value, in units of 1.024 microseconds, limits the delay in which a
215receive interrupt is generated. Useful only if RxIntDelay is non-zero, 235receive interrupt is generated. Useful only if RxIntDelay is non-zero,
@@ -220,9 +240,11 @@ conditions.
220 240
221Speed 241Speed
222----- 242-----
243
223(This parameter is supported only on adapters with copper connections.) 244(This parameter is supported only on adapters with copper connections.)
224Valid Settings: 0, 10, 100, 1000 245
225Default Value: 0 (auto-negotiate at all supported speeds) 246:Valid Settings: 0, 10, 100, 1000
247:Default Value: 0 (auto-negotiate at all supported speeds)
226 248
227Speed forces the line speed to the specified value in megabits per second 249Speed forces the line speed to the specified value in megabits per second
228(Mbps). If this parameter is not specified or is set to 0 and the link 250(Mbps). If this parameter is not specified or is set to 0 and the link
@@ -231,22 +253,26 @@ speed. Duplex should also be set when Speed is set to either 10 or 100.
231 253
232TxDescriptors 254TxDescriptors
233------------- 255-------------
234Valid Range: 48-256 for 82542 and 82543-based adapters 256
235 48-4096 for all other supported adapters 257:Valid Range:
236Default Value: 256 258 - 48-256 for 82542 and 82543-based adapters
259 - 48-4096 for all other supported adapters
260:Default Value: 256
237 261
238This value is the number of transmit descriptors allocated by the driver. 262This value is the number of transmit descriptors allocated by the driver.
239Increasing this value allows the driver to queue more transmits. Each 263Increasing this value allows the driver to queue more transmits. Each
240descriptor is 16 bytes. 264descriptor is 16 bytes.
241 265
242NOTE: Depending on the available system resources, the request for a 266NOTE:
267 Depending on the available system resources, the request for a
243 higher number of transmit descriptors may be denied. In this case, 268 higher number of transmit descriptors may be denied. In this case,
244 use a lower number. 269 use a lower number.
245 270
246TxIntDelay 271TxIntDelay
247---------- 272----------
248Valid Range: 0-65535 (0=off) 273
249Default Value: 8 274:Valid Range: 0-65535 (0=off)
275:Default Value: 8
250 276
251This value delays the generation of transmit interrupts in units of 277This value delays the generation of transmit interrupts in units of
2521.024 microseconds. Transmit interrupt reduction can improve CPU 2781.024 microseconds. Transmit interrupt reduction can improve CPU
@@ -256,9 +282,11 @@ causing the driver to run out of available transmit descriptors.
256 282
257TxAbsIntDelay 283TxAbsIntDelay
258------------- 284-------------
285
259(This parameter is supported only on 82540, 82545 and later adapters.) 286(This parameter is supported only on 82540, 82545 and later adapters.)
260Valid Range: 0-65535 (0=off) 287
261Default Value: 32 288:Valid Range: 0-65535 (0=off)
289:Default Value: 32
262 290
263This value, in units of 1.024 microseconds, limits the delay in which a 291This value, in units of 1.024 microseconds, limits the delay in which a
264transmit interrupt is generated. Useful only if TxIntDelay is non-zero, 292transmit interrupt is generated. Useful only if TxIntDelay is non-zero,
@@ -269,18 +297,21 @@ network conditions.
269 297
270XsumRX 298XsumRX
271------ 299------
300
272(This parameter is NOT supported on the 82542-based adapter.) 301(This parameter is NOT supported on the 82542-based adapter.)
273Valid Range: 0-1 302
274Default Value: 1 303:Valid Range: 0-1
304:Default Value: 1
275 305
276A value of '1' indicates that the driver should enable IP checksum 306A value of '1' indicates that the driver should enable IP checksum
277offload for received packets (both UDP and TCP) to the adapter hardware. 307offload for received packets (both UDP and TCP) to the adapter hardware.
278 308
279Copybreak 309Copybreak
280--------- 310---------
281Valid Range: 0-xxxxxxx (0=off) 311
282Default Value: 256 312:Valid Range: 0-xxxxxxx (0=off)
283Usage: modprobe e1000.ko copybreak=128 313:Default Value: 256
314:Usage: modprobe e1000.ko copybreak=128
284 315
285Driver copies all packets below or equaling this size to a fresh RX 316Driver copies all packets below or equaling this size to a fresh RX
286buffer before handing it up the stack. 317buffer before handing it up the stack.
@@ -292,8 +323,9 @@ it is also available during runtime at
292 323
293SmartPowerDownEnable 324SmartPowerDownEnable
294-------------------- 325--------------------
295Valid Range: 0-1 326
296Default Value: 0 (disabled) 327:Valid Range: 0-1
328:Default Value: 0 (disabled)
297 329
298Allows PHY to turn off in lower power states. The user can turn off 330Allows PHY to turn off in lower power states. The user can turn off
299this parameter in supported chipsets. 331this parameter in supported chipsets.
@@ -309,14 +341,14 @@ fiber interface board only links at 1000 Mbps full-duplex.
309 341
310For copper-based boards, the keywords interact as follows: 342For copper-based boards, the keywords interact as follows:
311 343
312 The default operation is auto-negotiate. The board advertises all 344- The default operation is auto-negotiate. The board advertises all
313 supported speed and duplex combinations, and it links at the highest 345 supported speed and duplex combinations, and it links at the highest
314 common speed and duplex mode IF the link partner is set to auto-negotiate. 346 common speed and duplex mode IF the link partner is set to auto-negotiate.
315 347
316 If Speed = 1000, limited auto-negotiation is enabled and only 1000 Mbps 348- If Speed = 1000, limited auto-negotiation is enabled and only 1000 Mbps
317 is advertised (The 1000BaseT spec requires auto-negotiation.) 349 is advertised (The 1000BaseT spec requires auto-negotiation.)
318 350
319 If Speed = 10 or 100, then both Speed and Duplex should be set. Auto- 351- If Speed = 10 or 100, then both Speed and Duplex should be set. Auto-
320 negotiation is disabled, and the AutoNeg parameter is ignored. Partner 352 negotiation is disabled, and the AutoNeg parameter is ignored. Partner
321 SHOULD also be forced. 353 SHOULD also be forced.
322 354
@@ -328,13 +360,15 @@ process.
328The parameter may be specified as either a decimal or hexadecimal value as 360The parameter may be specified as either a decimal or hexadecimal value as
329determined by the bitmap below. 361determined by the bitmap below.
330 362
363============== ====== ====== ======= ======= ====== ====== ======= ======
331Bit position 7 6 5 4 3 2 1 0 364Bit position 7 6 5 4 3 2 1 0
332Decimal Value 128 64 32 16 8 4 2 1 365Decimal Value 128 64 32 16 8 4 2 1
333Hex value 80 40 20 10 8 4 2 1 366Hex value 80 40 20 10 8 4 2 1
334Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10 367Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10
335Duplex Full Full Half Full Half 368Duplex Full Full Half Full Half
369============== ====== ====== ======= ======= ====== ====== ======= ======
336 370
337Some examples of using AutoNeg: 371Some examples of using AutoNeg::
338 372
339 modprobe e1000 AutoNeg=0x01 (Restricts autonegotiation to 10 Half) 373 modprobe e1000 AutoNeg=0x01 (Restricts autonegotiation to 10 Half)
340 modprobe e1000 AutoNeg=1 (Same as above) 374 modprobe e1000 AutoNeg=1 (Same as above)
@@ -357,56 +391,59 @@ Additional Configurations
357 391
358Jumbo Frames 392Jumbo Frames
359------------ 393------------
360Jumbo Frames support is enabled by changing the MTU to a value larger 394
361than the default of 1500. Use the ifconfig command to increase the MTU 395 Jumbo Frames support is enabled by changing the MTU to a value larger than
362size. For example:: 396 the default of 1500. Use the ifconfig command to increase the MTU size.
397 For example::
363 398
364 ifconfig eth<x> mtu 9000 up 399 ifconfig eth<x> mtu 9000 up
365 400
366This setting is not saved across reboots. It can be made permanent if 401 This setting is not saved across reboots. It can be made permanent if
367you add:: 402 you add::
368 403
369 MTU=9000 404 MTU=9000
370 405
371to the file /etc/sysconfig/network-scripts/ifcfg-eth<x>. This example 406 to the file /etc/sysconfig/network-scripts/ifcfg-eth<x>. This example
372applies to the Red Hat distributions; other distributions may store this 407 applies to the Red Hat distributions; other distributions may store this
373setting in a different location. 408 setting in a different location.
409
410Notes:
411 Degradation in throughput performance may be observed in some Jumbo frames
412 environments. If this is observed, increasing the application's socket buffer
413 size and/or increasing the /proc/sys/net/ipv4/tcp_*mem entry values may help.
414 See the specific application manual and /usr/src/linux*/Documentation/
415 networking/ip-sysctl.txt for more details.
374 416
375Notes: Degradation in throughput performance may be observed in some 417 - The maximum MTU setting for Jumbo Frames is 16110. This value coincides
376Jumbo frames environments. If this is observed, increasing the 418 with the maximum Jumbo Frames size of 16128.
377application's socket buffer size and/or increasing the
378/proc/sys/net/ipv4/tcp_*mem entry values may help. See the specific
379application manual and /usr/src/linux*/Documentation/
380networking/ip-sysctl.txt for more details.
381 419
382- The maximum MTU setting for Jumbo Frames is 16110. This value 420 - Using Jumbo frames at 10 or 100 Mbps is not supported and may result in
383 coincides with the maximum Jumbo Frames size of 16128. 421 poor performance or loss of link.
384 422
385- Using Jumbo frames at 10 or 100 Mbps is not supported and may result 423 - Adapters based on the Intel(R) 82542 and 82573V/E controller do not
386 in poor performance or loss of link. 424 support Jumbo Frames. These correspond to the following product names::
387 425
388- Adapters based on the Intel(R) 82542 and 82573V/E controller do not 426 Intel(R) PRO/1000 Gigabit Server Adapter
389 support Jumbo Frames. These correspond to the following product names: 427 Intel(R) PRO/1000 PM Network Connection
390 Intel(R) PRO/1000 Gigabit Server Adapter Intel(R) PRO/1000 PM Network
391 Connection
392 428
393ethtool 429ethtool
394------- 430-------
395The driver utilizes the ethtool interface for driver configuration and
396diagnostics, as well as displaying statistical information. The ethtool
397version 1.6 or later is required for this functionality.
398 431
399The latest release of ethtool can be found from 432 The driver utilizes the ethtool interface for driver configuration and
400https://www.kernel.org/pub/software/network/ethtool/ 433 diagnostics, as well as displaying statistical information. The ethtool
434 version 1.6 or later is required for this functionality.
435
436 The latest release of ethtool can be found from
437 https://www.kernel.org/pub/software/network/ethtool/
401 438
402Enabling Wake on LAN* (WoL) 439Enabling Wake on LAN* (WoL)
403--------------------------- 440---------------------------
404WoL is configured through the ethtool* utility.
405 441
406WoL will be enabled on the system during the next shut down or reboot. 442 WoL is configured through the ethtool* utility.
407For this driver version, in order to enable WoL, the e1000 driver must be
408loaded when shutting down or rebooting the system.
409 443
444 WoL will be enabled on the system during the next shut down or reboot.
445 For this driver version, in order to enable WoL, the e1000 driver must be
446 loaded when shutting down or rebooting the system.
410 447
411Support 448Support
412======= 449=======
diff --git a/MAINTAINERS b/MAINTAINERS
index 192d7f73fd01..7cebd5bba8a8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2523,7 +2523,7 @@ S: Supported
2523F: drivers/scsi/esas2r 2523F: drivers/scsi/esas2r
2524 2524
2525ATUSB IEEE 802.15.4 RADIO DRIVER 2525ATUSB IEEE 802.15.4 RADIO DRIVER
2526M: Stefan Schmidt <stefan@osg.samsung.com> 2526M: Stefan Schmidt <stefan@datenfreihafen.org>
2527L: linux-wpan@vger.kernel.org 2527L: linux-wpan@vger.kernel.org
2528S: Maintained 2528S: Maintained
2529F: drivers/net/ieee802154/atusb.c 2529F: drivers/net/ieee802154/atusb.c
@@ -5444,6 +5444,7 @@ F: drivers/iommu/exynos-iommu.c
5444 5444
5445EZchip NPS platform support 5445EZchip NPS platform support
5446M: Vineet Gupta <vgupta@synopsys.com> 5446M: Vineet Gupta <vgupta@synopsys.com>
5447M: Ofer Levi <oferle@mellanox.com>
5447S: Supported 5448S: Supported
5448F: arch/arc/plat-eznps 5449F: arch/arc/plat-eznps
5449F: arch/arc/boot/dts/eznps.dts 5450F: arch/arc/boot/dts/eznps.dts
@@ -5790,7 +5791,6 @@ F: include/linux/fsl/
5790 5791
5791FREESCALE SOC FS_ENET DRIVER 5792FREESCALE SOC FS_ENET DRIVER
5792M: Pantelis Antoniou <pantelis.antoniou@gmail.com> 5793M: Pantelis Antoniou <pantelis.antoniou@gmail.com>
5793M: Vitaly Bordug <vbordug@ru.mvista.com>
5794L: linuxppc-dev@lists.ozlabs.org 5794L: linuxppc-dev@lists.ozlabs.org
5795L: netdev@vger.kernel.org 5795L: netdev@vger.kernel.org
5796S: Maintained 5796S: Maintained
@@ -6909,7 +6909,7 @@ F: drivers/clk/clk-versaclock5.c
6909 6909
6910IEEE 802.15.4 SUBSYSTEM 6910IEEE 802.15.4 SUBSYSTEM
6911M: Alexander Aring <alex.aring@gmail.com> 6911M: Alexander Aring <alex.aring@gmail.com>
6912M: Stefan Schmidt <stefan@osg.samsung.com> 6912M: Stefan Schmidt <stefan@datenfreihafen.org>
6913L: linux-wpan@vger.kernel.org 6913L: linux-wpan@vger.kernel.org
6914W: http://wpan.cakelab.org/ 6914W: http://wpan.cakelab.org/
6915T: git git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan.git 6915T: git git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan.git
@@ -7096,6 +7096,7 @@ F: include/uapi/linux/input.h
7096F: include/uapi/linux/input-event-codes.h 7096F: include/uapi/linux/input-event-codes.h
7097F: include/linux/input/ 7097F: include/linux/input/
7098F: Documentation/devicetree/bindings/input/ 7098F: Documentation/devicetree/bindings/input/
7099F: Documentation/devicetree/bindings/serio/
7099F: Documentation/input/ 7100F: Documentation/input/
7100 7101
7101INPUT MULTITOUCH (MT) PROTOCOL 7102INPUT MULTITOUCH (MT) PROTOCOL
@@ -7985,7 +7986,7 @@ F: lib/test_kmod.c
7985F: tools/testing/selftests/kmod/ 7986F: tools/testing/selftests/kmod/
7986 7987
7987KPROBES 7988KPROBES
7988M: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> 7989M: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7989M: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7990M: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
7990M: "David S. Miller" <davem@davemloft.net> 7991M: "David S. Miller" <davem@davemloft.net>
7991M: Masami Hiramatsu <mhiramat@kernel.org> 7992M: Masami Hiramatsu <mhiramat@kernel.org>
@@ -8629,7 +8630,7 @@ MARVELL MWIFIEX WIRELESS DRIVER
8629M: Amitkumar Karwar <amitkarwar@gmail.com> 8630M: Amitkumar Karwar <amitkarwar@gmail.com>
8630M: Nishant Sarmukadam <nishants@marvell.com> 8631M: Nishant Sarmukadam <nishants@marvell.com>
8631M: Ganapathi Bhat <gbhat@marvell.com> 8632M: Ganapathi Bhat <gbhat@marvell.com>
8632M: Xinming Hu <huxm@marvell.com> 8633M: Xinming Hu <huxinming820@gmail.com>
8633L: linux-wireless@vger.kernel.org 8634L: linux-wireless@vger.kernel.org
8634S: Maintained 8635S: Maintained
8635F: drivers/net/wireless/marvell/mwifiex/ 8636F: drivers/net/wireless/marvell/mwifiex/
@@ -9075,7 +9076,7 @@ S: Maintained
9075F: drivers/usb/mtu3/ 9076F: drivers/usb/mtu3/
9076 9077
9077MEGACHIPS STDPXXXX-GE-B850V3-FW LVDS/DP++ BRIDGES 9078MEGACHIPS STDPXXXX-GE-B850V3-FW LVDS/DP++ BRIDGES
9078M: Peter Senna Tschudin <peter.senna@collabora.com> 9079M: Peter Senna Tschudin <peter.senna@gmail.com>
9079M: Martin Donnelly <martin.donnelly@ge.com> 9080M: Martin Donnelly <martin.donnelly@ge.com>
9080M: Martyn Welch <martyn.welch@collabora.co.uk> 9081M: Martyn Welch <martyn.welch@collabora.co.uk>
9081S: Maintained 9082S: Maintained
diff --git a/Makefile b/Makefile
index 2d80fbbe51a8..7a3c4548162b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
2VERSION = 4 2VERSION = 4
3PATCHLEVEL = 18 3PATCHLEVEL = 18
4SUBLEVEL = 0 4SUBLEVEL = 0
5EXTRAVERSION = -rc4 5EXTRAVERSION = -rc8
6NAME = Merciless Moray 6NAME = Merciless Moray
7 7
8# *DOCUMENTATION* 8# *DOCUMENTATION*
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 6e921754c8fc..c210a25dd6da 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1180,13 +1180,10 @@ SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
1180SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options, 1180SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1181 struct rusage32 __user *, ur) 1181 struct rusage32 __user *, ur)
1182{ 1182{
1183 unsigned int status = 0;
1184 struct rusage r; 1183 struct rusage r;
1185 long err = kernel_wait4(pid, &status, options, &r); 1184 long err = kernel_wait4(pid, ustatus, options, &r);
1186 if (err <= 0) 1185 if (err <= 0)
1187 return err; 1186 return err;
1188 if (put_user(status, ustatus))
1189 return -EFAULT;
1190 if (!ur) 1187 if (!ur)
1191 return err; 1188 return err;
1192 if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime)) 1189 if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime))
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index e81bcd271be7..5151d81476a1 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -50,6 +50,9 @@ config ARC
50 select HAVE_KERNEL_LZMA 50 select HAVE_KERNEL_LZMA
51 select ARCH_HAS_PTE_SPECIAL 51 select ARCH_HAS_PTE_SPECIAL
52 52
53config ARCH_HAS_CACHE_LINE_SIZE
54 def_bool y
55
53config MIGHT_HAVE_PCI 56config MIGHT_HAVE_PCI
54 bool 57 bool
55 58
@@ -413,7 +416,7 @@ config ARC_HAS_DIV_REM
413 416
414config ARC_HAS_ACCL_REGS 417config ARC_HAS_ACCL_REGS
415 bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)" 418 bool "Reg Pair ACCL:ACCH (FPU and/or MPY > 6)"
416 default n 419 default y
417 help 420 help
418 Depending on the configuration, CPU can contain accumulator reg-pair 421 Depending on the configuration, CPU can contain accumulator reg-pair
419 (also referred to as r58:r59). These can also be used by gcc as GPR so 422 (also referred to as r58:r59). These can also be used by gcc as GPR so
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index d37f49d6a27f..6c1b20dd76ad 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -16,7 +16,7 @@ endif
16 16
17KBUILD_DEFCONFIG := nsim_700_defconfig 17KBUILD_DEFCONFIG := nsim_700_defconfig
18 18
19cflags-y += -fno-common -pipe -fno-builtin -D__linux__ 19cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
20cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7 20cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
21cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs 21cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
22 22
@@ -140,16 +140,3 @@ dtbs: scripts
140 140
141archclean: 141archclean:
142 $(Q)$(MAKE) $(clean)=$(boot) 142 $(Q)$(MAKE) $(clean)=$(boot)
143
144# Hacks to enable final link due to absence of link-time branch relexation
145# and gcc choosing optimal(shorter) branches at -O3
146#
147# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
148# However lib/decompress_inflate.o (.init.text) calls
149# zlib_inflate_workspacesize (.text) causing relocation errors.
150# Thus forcing all exten calls in this file to be long calls
151export CFLAGS_decompress_inflate.o = -mmedium-calls
152export CFLAGS_initramfs.o = -mmedium-calls
153ifdef CONFIG_SMP
154export CFLAGS_core.o = -mmedium-calls
155endif
diff --git a/arch/arc/configs/axs101_defconfig b/arch/arc/configs/axs101_defconfig
index 09f85154c5a4..a635ea972304 100644
--- a/arch/arc/configs/axs101_defconfig
+++ b/arch/arc/configs/axs101_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../arc_initramfs/"
15CONFIG_EMBEDDED=y 14CONFIG_EMBEDDED=y
16CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
17# CONFIG_VM_EVENT_COUNTERS is not set 16# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/axs103_defconfig b/arch/arc/configs/axs103_defconfig
index 09fed3ef22b6..aa507e423075 100644
--- a/arch/arc/configs/axs103_defconfig
+++ b/arch/arc/configs/axs103_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
15CONFIG_EMBEDDED=y 14CONFIG_EMBEDDED=y
16CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
17# CONFIG_VM_EVENT_COUNTERS is not set 16# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/axs103_smp_defconfig b/arch/arc/configs/axs103_smp_defconfig
index ea2f6d817d1a..eba07f468654 100644
--- a/arch/arc/configs/axs103_smp_defconfig
+++ b/arch/arc/configs/axs103_smp_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
15CONFIG_EMBEDDED=y 14CONFIG_EMBEDDED=y
16CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
17# CONFIG_VM_EVENT_COUNTERS is not set 16# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/haps_hs_defconfig b/arch/arc/configs/haps_hs_defconfig
index ab231c040efe..098b19fbaa51 100644
--- a/arch/arc/configs/haps_hs_defconfig
+++ b/arch/arc/configs/haps_hs_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
15CONFIG_EXPERT=y 14CONFIG_EXPERT=y
16CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
17# CONFIG_COMPAT_BRK is not set 16# CONFIG_COMPAT_BRK is not set
diff --git a/arch/arc/configs/haps_hs_smp_defconfig b/arch/arc/configs/haps_hs_smp_defconfig
index cf449cbf440d..0104c404d897 100644
--- a/arch/arc/configs/haps_hs_smp_defconfig
+++ b/arch/arc/configs/haps_hs_smp_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
15CONFIG_EMBEDDED=y 14CONFIG_EMBEDDED=y
16CONFIG_PERF_EVENTS=y 15CONFIG_PERF_EVENTS=y
17# CONFIG_VM_EVENT_COUNTERS is not set 16# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
index 1b54c72f4296..6491be0ddbc9 100644
--- a/arch/arc/configs/hsdk_defconfig
+++ b/arch/arc/configs/hsdk_defconfig
@@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y
9# CONFIG_UTS_NS is not set 9# CONFIG_UTS_NS is not set
10# CONFIG_PID_NS is not set 10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
13CONFIG_EMBEDDED=y 12CONFIG_EMBEDDED=y
14CONFIG_PERF_EVENTS=y 13CONFIG_PERF_EVENTS=y
15# CONFIG_VM_EVENT_COUNTERS is not set 14# CONFIG_VM_EVENT_COUNTERS is not set
diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig
index 31c2c70b34a1..99e05cf63fca 100644
--- a/arch/arc/configs/nsim_700_defconfig
+++ b/arch/arc/configs/nsim_700_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../arc_initramfs/"
15CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
16CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
17CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsim_hs_defconfig b/arch/arc/configs/nsim_hs_defconfig
index a578c721d50f..0dc4f9b737e7 100644
--- a/arch/arc/configs/nsim_hs_defconfig
+++ b/arch/arc/configs/nsim_hs_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../../arc_initramfs_hs/"
15CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
16CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
17CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsim_hs_smp_defconfig b/arch/arc/configs/nsim_hs_smp_defconfig
index 37d7395f3272..be3c30a15e54 100644
--- a/arch/arc/configs/nsim_hs_smp_defconfig
+++ b/arch/arc/configs/nsim_hs_smp_defconfig
@@ -9,7 +9,6 @@ CONFIG_NAMESPACES=y
9# CONFIG_UTS_NS is not set 9# CONFIG_UTS_NS is not set
10# CONFIG_PID_NS is not set 10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12CONFIG_INITRAMFS_SOURCE="../arc_initramfs_hs/"
13CONFIG_KALLSYMS_ALL=y 12CONFIG_KALLSYMS_ALL=y
14CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
15CONFIG_PERF_EVENTS=y 14CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig
index 1e1470e2a7f0..3a74b9b21772 100644
--- a/arch/arc/configs/nsimosci_defconfig
+++ b/arch/arc/configs/nsimosci_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../arc_initramfs/"
15CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
16CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
17CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig
index 084a6e42685b..ea2834b4dc1d 100644
--- a/arch/arc/configs/nsimosci_hs_defconfig
+++ b/arch/arc/configs/nsimosci_hs_defconfig
@@ -11,7 +11,6 @@ CONFIG_NAMESPACES=y
11# CONFIG_UTS_NS is not set 11# CONFIG_UTS_NS is not set
12# CONFIG_PID_NS is not set 12# CONFIG_PID_NS is not set
13CONFIG_BLK_DEV_INITRD=y 13CONFIG_BLK_DEV_INITRD=y
14CONFIG_INITRAMFS_SOURCE="../arc_initramfs_hs/"
15CONFIG_KALLSYMS_ALL=y 14CONFIG_KALLSYMS_ALL=y
16CONFIG_EMBEDDED=y 15CONFIG_EMBEDDED=y
17CONFIG_PERF_EVENTS=y 16CONFIG_PERF_EVENTS=y
diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig
index f36d47990415..80a5a1b4924b 100644
--- a/arch/arc/configs/nsimosci_hs_smp_defconfig
+++ b/arch/arc/configs/nsimosci_hs_smp_defconfig
@@ -9,7 +9,6 @@ CONFIG_IKCONFIG_PROC=y
9# CONFIG_UTS_NS is not set 9# CONFIG_UTS_NS is not set
10# CONFIG_PID_NS is not set 10# CONFIG_PID_NS is not set
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12CONFIG_INITRAMFS_SOURCE="../arc_initramfs_hs/"
13CONFIG_PERF_EVENTS=y 12CONFIG_PERF_EVENTS=y
14# CONFIG_COMPAT_BRK is not set 13# CONFIG_COMPAT_BRK is not set
15CONFIG_KPROBES=y 14CONFIG_KPROBES=y
diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig
index 1aca2e8fd1ba..2cc87f909747 100644
--- a/arch/arc/configs/tb10x_defconfig
+++ b/arch/arc/configs/tb10x_defconfig
@@ -56,7 +56,6 @@ CONFIG_STMMAC_ETH=y
56# CONFIG_INPUT is not set 56# CONFIG_INPUT is not set
57# CONFIG_SERIO is not set 57# CONFIG_SERIO is not set
58# CONFIG_VT is not set 58# CONFIG_VT is not set
59CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
60# CONFIG_LEGACY_PTYS is not set 59# CONFIG_LEGACY_PTYS is not set
61# CONFIG_DEVKMEM is not set 60# CONFIG_DEVKMEM is not set
62CONFIG_SERIAL_8250=y 61CONFIG_SERIAL_8250=y
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h
index 8486f328cc5d..ff7d3232764a 100644
--- a/arch/arc/include/asm/cache.h
+++ b/arch/arc/include/asm/cache.h
@@ -48,7 +48,9 @@
48}) 48})
49 49
50/* Largest line length for either L1 or L2 is 128 bytes */ 50/* Largest line length for either L1 or L2 is 128 bytes */
51#define ARCH_DMA_MINALIGN 128 51#define SMP_CACHE_BYTES 128
52#define cache_line_size() SMP_CACHE_BYTES
53#define ARCH_DMA_MINALIGN SMP_CACHE_BYTES
52 54
53extern void arc_cache_init(void); 55extern void arc_cache_init(void);
54extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len); 56extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
diff --git a/arch/arc/include/asm/delay.h b/arch/arc/include/asm/delay.h
index d5da2115d78a..03d6bb0f4e13 100644
--- a/arch/arc/include/asm/delay.h
+++ b/arch/arc/include/asm/delay.h
@@ -17,8 +17,11 @@
17#ifndef __ASM_ARC_UDELAY_H 17#ifndef __ASM_ARC_UDELAY_H
18#define __ASM_ARC_UDELAY_H 18#define __ASM_ARC_UDELAY_H
19 19
20#include <asm-generic/types.h>
20#include <asm/param.h> /* HZ */ 21#include <asm/param.h> /* HZ */
21 22
23extern unsigned long loops_per_jiffy;
24
22static inline void __delay(unsigned long loops) 25static inline void __delay(unsigned long loops)
23{ 26{
24 __asm__ __volatile__( 27 __asm__ __volatile__(
diff --git a/arch/arc/include/asm/entry-compact.h b/arch/arc/include/asm/entry-compact.h
index ec36d5b6d435..29f3988c9424 100644
--- a/arch/arc/include/asm/entry-compact.h
+++ b/arch/arc/include/asm/entry-compact.h
@@ -234,6 +234,9 @@
234 POP gp 234 POP gp
235 RESTORE_R12_TO_R0 235 RESTORE_R12_TO_R0
236 236
237#ifdef CONFIG_ARC_CURR_IN_REG
238 ld r25, [sp, 12]
239#endif
237 ld sp, [sp] /* restore original sp */ 240 ld sp, [sp] /* restore original sp */
238 /* orig_r0, ECR, user_r25 skipped automatically */ 241 /* orig_r0, ECR, user_r25 skipped automatically */
239.endm 242.endm
@@ -315,6 +318,9 @@
315 POP gp 318 POP gp
316 RESTORE_R12_TO_R0 319 RESTORE_R12_TO_R0
317 320
321#ifdef CONFIG_ARC_CURR_IN_REG
322 ld r25, [sp, 12]
323#endif
318 ld sp, [sp] /* restore original sp */ 324 ld sp, [sp] /* restore original sp */
319 /* orig_r0, ECR, user_r25 skipped automatically */ 325 /* orig_r0, ECR, user_r25 skipped automatically */
320.endm 326.endm
diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h
index 51597f344a62..302b0db8ea2b 100644
--- a/arch/arc/include/asm/entry.h
+++ b/arch/arc/include/asm/entry.h
@@ -86,9 +86,6 @@
86 POP r1 86 POP r1
87 POP r0 87 POP r0
88 88
89#ifdef CONFIG_ARC_CURR_IN_REG
90 ld r25, [sp, 12]
91#endif
92.endm 89.endm
93 90
94/*-------------------------------------------------------------- 91/*--------------------------------------------------------------
diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h
index c28e6c347b49..871f3cb16af9 100644
--- a/arch/arc/include/asm/mach_desc.h
+++ b/arch/arc/include/asm/mach_desc.h
@@ -34,9 +34,7 @@ struct machine_desc {
34 const char *name; 34 const char *name;
35 const char **dt_compat; 35 const char **dt_compat;
36 void (*init_early)(void); 36 void (*init_early)(void);
37#ifdef CONFIG_SMP
38 void (*init_per_cpu)(unsigned int); 37 void (*init_per_cpu)(unsigned int);
39#endif
40 void (*init_machine)(void); 38 void (*init_machine)(void);
41 void (*init_late)(void); 39 void (*init_late)(void);
42 40
diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 109baa06831c..09ddddf71cc5 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -105,7 +105,7 @@ typedef pte_t * pgtable_t;
105#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) 105#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
106 106
107/* Default Permissions for stack/heaps pages (Non Executable) */ 107/* Default Permissions for stack/heaps pages (Non Executable) */
108#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE) 108#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
109 109
110#define WANT_PAGE_VIRTUAL 1 110#define WANT_PAGE_VIRTUAL 1
111 111
diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 8ec5599a0957..cf4be70d5892 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -377,7 +377,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
377 377
378/* Decode a PTE containing swap "identifier "into constituents */ 378/* Decode a PTE containing swap "identifier "into constituents */
379#define __swp_type(pte_lookalike) (((pte_lookalike).val) & 0x1f) 379#define __swp_type(pte_lookalike) (((pte_lookalike).val) & 0x1f)
380#define __swp_offset(pte_lookalike) ((pte_lookalike).val << 13) 380#define __swp_offset(pte_lookalike) ((pte_lookalike).val >> 13)
381 381
382/* NOPs, to keep generic kernel happy */ 382/* NOPs, to keep generic kernel happy */
383#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 383#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
index 538b36afe89e..62b185057c04 100644
--- a/arch/arc/kernel/irq.c
+++ b/arch/arc/kernel/irq.c
@@ -31,10 +31,10 @@ void __init init_IRQ(void)
31 /* a SMP H/w block could do IPI IRQ request here */ 31 /* a SMP H/w block could do IPI IRQ request here */
32 if (plat_smp_ops.init_per_cpu) 32 if (plat_smp_ops.init_per_cpu)
33 plat_smp_ops.init_per_cpu(smp_processor_id()); 33 plat_smp_ops.init_per_cpu(smp_processor_id());
34#endif
34 35
35 if (machine_desc->init_per_cpu) 36 if (machine_desc->init_per_cpu)
36 machine_desc->init_per_cpu(smp_processor_id()); 37 machine_desc->init_per_cpu(smp_processor_id());
37#endif
38} 38}
39 39
40/* 40/*
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index 5ac3b547453f..4674541eba3f 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -47,7 +47,8 @@ SYSCALL_DEFINE0(arc_gettls)
47SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new) 47SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
48{ 48{
49 struct pt_regs *regs = current_pt_regs(); 49 struct pt_regs *regs = current_pt_regs();
50 int uval = -EFAULT; 50 u32 uval;
51 int ret;
51 52
52 /* 53 /*
53 * This is only for old cores lacking LLOCK/SCOND, which by defintion 54 * This is only for old cores lacking LLOCK/SCOND, which by defintion
@@ -60,23 +61,47 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
60 /* Z indicates to userspace if operation succeded */ 61 /* Z indicates to userspace if operation succeded */
61 regs->status32 &= ~STATUS_Z_MASK; 62 regs->status32 &= ~STATUS_Z_MASK;
62 63
63 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 64 ret = access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr));
64 return -EFAULT; 65 if (!ret)
66 goto fail;
65 67
68again:
66 preempt_disable(); 69 preempt_disable();
67 70
68 if (__get_user(uval, uaddr)) 71 ret = __get_user(uval, uaddr);
69 goto done; 72 if (ret)
73 goto fault;
70 74
71 if (uval == expected) { 75 if (uval != expected)
72 if (!__put_user(new, uaddr)) 76 goto out;
73 regs->status32 |= STATUS_Z_MASK;
74 }
75 77
76done: 78 ret = __put_user(new, uaddr);
77 preempt_enable(); 79 if (ret)
80 goto fault;
81
82 regs->status32 |= STATUS_Z_MASK;
78 83
84out:
85 preempt_enable();
79 return uval; 86 return uval;
87
88fault:
89 preempt_enable();
90
91 if (unlikely(ret != -EFAULT))
92 goto fail;
93
94 down_read(&current->mm->mmap_sem);
95 ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
96 FAULT_FLAG_WRITE, NULL);
97 up_read(&current->mm->mmap_sem);
98
99 if (likely(!ret))
100 goto again;
101
102fail:
103 force_sig(SIGSEGV, current);
104 return ret;
80} 105}
81 106
82#ifdef CONFIG_ISA_ARCV2 107#ifdef CONFIG_ISA_ARCV2
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index 9dbe645ee127..25c631942500 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -1038,7 +1038,7 @@ void flush_cache_mm(struct mm_struct *mm)
1038void flush_cache_page(struct vm_area_struct *vma, unsigned long u_vaddr, 1038void flush_cache_page(struct vm_area_struct *vma, unsigned long u_vaddr,
1039 unsigned long pfn) 1039 unsigned long pfn)
1040{ 1040{
1041 unsigned int paddr = pfn << PAGE_SHIFT; 1041 phys_addr_t paddr = pfn << PAGE_SHIFT;
1042 1042
1043 u_vaddr &= PAGE_MASK; 1043 u_vaddr &= PAGE_MASK;
1044 1044
@@ -1058,8 +1058,9 @@ void flush_anon_page(struct vm_area_struct *vma, struct page *page,
1058 unsigned long u_vaddr) 1058 unsigned long u_vaddr)
1059{ 1059{
1060 /* TBD: do we really need to clear the kernel mapping */ 1060 /* TBD: do we really need to clear the kernel mapping */
1061 __flush_dcache_page(page_address(page), u_vaddr); 1061 __flush_dcache_page((phys_addr_t)page_address(page), u_vaddr);
1062 __flush_dcache_page(page_address(page), page_address(page)); 1062 __flush_dcache_page((phys_addr_t)page_address(page),
1063 (phys_addr_t)page_address(page));
1063 1064
1064} 1065}
1065 1066
@@ -1246,6 +1247,16 @@ void __init arc_cache_init_master(void)
1246 } 1247 }
1247 } 1248 }
1248 1249
1250 /*
1251 * Check that SMP_CACHE_BYTES (and hence ARCH_DMA_MINALIGN) is larger
1252 * or equal to any cache line length.
1253 */
1254 BUILD_BUG_ON_MSG(L1_CACHE_BYTES > SMP_CACHE_BYTES,
1255 "SMP_CACHE_BYTES must be >= any cache line length");
1256 if (is_isa_arcv2() && (l2_line_sz > SMP_CACHE_BYTES))
1257 panic("L2 Cache line [%d] > kernel Config [%d]\n",
1258 l2_line_sz, SMP_CACHE_BYTES);
1259
1249 /* Note that SLC disable not formally supported till HS 3.0 */ 1260 /* Note that SLC disable not formally supported till HS 3.0 */
1250 if (is_isa_arcv2() && l2_line_sz && !slc_enable) 1261 if (is_isa_arcv2() && l2_line_sz && !slc_enable)
1251 arc_slc_disable(); 1262 arc_slc_disable();
diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
index 8c1071840979..ec47e6079f5d 100644
--- a/arch/arc/mm/dma.c
+++ b/arch/arc/mm/dma.c
@@ -129,14 +129,59 @@ int arch_dma_mmap(struct device *dev, struct vm_area_struct *vma,
129 return ret; 129 return ret;
130} 130}
131 131
132/*
133 * Cache operations depending on function and direction argument, inspired by
134 * https://lkml.org/lkml/2018/5/18/979
135 * "dma_sync_*_for_cpu and direction=TO_DEVICE (was Re: [PATCH 02/20]
136 * dma-mapping: provide a generic dma-noncoherent implementation)"
137 *
138 * | map == for_device | unmap == for_cpu
139 * |----------------------------------------------------------------
140 * TO_DEV | writeback writeback | none none
141 * FROM_DEV | invalidate invalidate | invalidate* invalidate*
142 * BIDIR | writeback+inv writeback+inv | invalidate invalidate
143 *
144 * [*] needed for CPU speculative prefetches
145 *
146 * NOTE: we don't check the validity of direction argument as it is done in
147 * upper layer functions (in include/linux/dma-mapping.h)
148 */
149
132void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr, 150void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr,
133 size_t size, enum dma_data_direction dir) 151 size_t size, enum dma_data_direction dir)
134{ 152{
135 dma_cache_wback(paddr, size); 153 switch (dir) {
154 case DMA_TO_DEVICE:
155 dma_cache_wback(paddr, size);
156 break;
157
158 case DMA_FROM_DEVICE:
159 dma_cache_inv(paddr, size);
160 break;
161
162 case DMA_BIDIRECTIONAL:
163 dma_cache_wback_inv(paddr, size);
164 break;
165
166 default:
167 break;
168 }
136} 169}
137 170
138void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, 171void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
139 size_t size, enum dma_data_direction dir) 172 size_t size, enum dma_data_direction dir)
140{ 173{
141 dma_cache_inv(paddr, size); 174 switch (dir) {
175 case DMA_TO_DEVICE:
176 break;
177
178 /* FROM_DEVICE invalidate needed if speculative CPU prefetch only */
179 case DMA_FROM_DEVICE:
180 case DMA_BIDIRECTIONAL:
181 dma_cache_inv(paddr, size);
182 break;
183
184 default:
185 break;
186 }
142} 187}
diff --git a/arch/arc/plat-eznps/include/plat/ctop.h b/arch/arc/plat-eznps/include/plat/ctop.h
index 0c7d11022d0f..4f6a1673b3a6 100644
--- a/arch/arc/plat-eznps/include/plat/ctop.h
+++ b/arch/arc/plat-eznps/include/plat/ctop.h
@@ -21,6 +21,7 @@
21#error "Incorrect ctop.h include" 21#error "Incorrect ctop.h include"
22#endif 22#endif
23 23
24#include <linux/types.h>
24#include <soc/nps/common.h> 25#include <soc/nps/common.h>
25 26
26/* core auxiliary registers */ 27/* core auxiliary registers */
@@ -143,6 +144,15 @@ struct nps_host_reg_gim_p_int_dst {
143}; 144};
144 145
145/* AUX registers definition */ 146/* AUX registers definition */
147struct nps_host_reg_aux_dpc {
148 union {
149 struct {
150 u32 ien:1, men:1, hen:1, reserved:29;
151 };
152 u32 value;
153 };
154};
155
146struct nps_host_reg_aux_udmc { 156struct nps_host_reg_aux_udmc {
147 union { 157 union {
148 struct { 158 struct {
diff --git a/arch/arc/plat-eznps/mtm.c b/arch/arc/plat-eznps/mtm.c
index 2388de3d09ef..ed0077ef666e 100644
--- a/arch/arc/plat-eznps/mtm.c
+++ b/arch/arc/plat-eznps/mtm.c
@@ -15,6 +15,8 @@
15 */ 15 */
16 16
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/init.h>
19#include <linux/kernel.h>
18#include <linux/io.h> 20#include <linux/io.h>
19#include <linux/log2.h> 21#include <linux/log2.h>
20#include <asm/arcregs.h> 22#include <asm/arcregs.h>
@@ -157,10 +159,10 @@ void mtm_enable_core(unsigned int cpu)
157/* Verify and set the value of the mtm hs counter */ 159/* Verify and set the value of the mtm hs counter */
158static int __init set_mtm_hs_ctr(char *ctr_str) 160static int __init set_mtm_hs_ctr(char *ctr_str)
159{ 161{
160 long hs_ctr; 162 int hs_ctr;
161 int ret; 163 int ret;
162 164
163 ret = kstrtol(ctr_str, 0, &hs_ctr); 165 ret = kstrtoint(ctr_str, 0, &hs_ctr);
164 166
165 if (ret || hs_ctr > MT_HS_CNT_MAX || hs_ctr < MT_HS_CNT_MIN) { 167 if (ret || hs_ctr > MT_HS_CNT_MAX || hs_ctr < MT_HS_CNT_MIN) {
166 pr_err("** Invalid @nps_mtm_hs_ctr [%d] needs to be [%d:%d] (incl)\n", 168 pr_err("** Invalid @nps_mtm_hs_ctr [%d] needs to be [%d:%d] (incl)\n",
diff --git a/arch/arc/plat-hsdk/Kconfig b/arch/arc/plat-hsdk/Kconfig
index 19ab3cf98f0f..9356753c2ed8 100644
--- a/arch/arc/plat-hsdk/Kconfig
+++ b/arch/arc/plat-hsdk/Kconfig
@@ -7,5 +7,8 @@
7 7
8menuconfig ARC_SOC_HSDK 8menuconfig ARC_SOC_HSDK
9 bool "ARC HS Development Kit SOC" 9 bool "ARC HS Development Kit SOC"
10 depends on ISA_ARCV2
11 select ARC_HAS_ACCL_REGS
10 select CLK_HSDK 12 select CLK_HSDK
11 select RESET_HSDK 13 select RESET_HSDK
14 select MIGHT_HAVE_PCI
diff --git a/arch/arc/plat-hsdk/platform.c b/arch/arc/plat-hsdk/platform.c
index 2958aedb649a..2588b842407c 100644
--- a/arch/arc/plat-hsdk/platform.c
+++ b/arch/arc/plat-hsdk/platform.c
@@ -42,6 +42,66 @@ static void __init hsdk_init_per_cpu(unsigned int cpu)
42#define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108) 42#define SDIO_UHS_REG_EXT (SDIO_BASE + 0x108)
43#define SDIO_UHS_REG_EXT_DIV_2 (2 << 30) 43#define SDIO_UHS_REG_EXT_DIV_2 (2 << 30)
44 44
45#define HSDK_GPIO_INTC (ARC_PERIPHERAL_BASE + 0x3000)
46
47static void __init hsdk_enable_gpio_intc_wire(void)
48{
49 /*
50 * Peripherals on CPU Card are wired to cpu intc via intermediate
51 * DW APB GPIO blocks (mainly for debouncing)
52 *
53 * ---------------------
54 * | snps,archs-intc |
55 * ---------------------
56 * |
57 * ----------------------
58 * | snps,archs-idu-intc |
59 * ----------------------
60 * | | | | |
61 * | [eth] [USB] [... other peripherals]
62 * |
63 * -------------------
64 * | snps,dw-apb-intc |
65 * -------------------
66 * | | | |
67 * [Bt] [HAPS] [... other peripherals]
68 *
69 * Current implementation of "irq-dw-apb-ictl" driver doesn't work well
70 * with stacked INTCs. In particular problem happens if its master INTC
71 * not yet instantiated. See discussion here -
72 * https://lkml.org/lkml/2015/3/4/755
73 *
74 * So setup the first gpio block as a passive pass thru and hide it from
75 * DT hardware topology - connect intc directly to cpu intc
76 * The GPIO "wire" needs to be init nevertheless (here)
77 *
78 * One side adv is that peripheral interrupt handling avoids one nested
79 * intc ISR hop
80 *
81 * According to HSDK User's Manual [1], "Table 2 Interrupt Mapping"
82 * we have the following GPIO input lines used as sources of interrupt:
83 * - GPIO[0] - Bluetooth interrupt of RS9113 module
84 * - GPIO[2] - HAPS interrupt (on HapsTrak 3 connector)
85 * - GPIO[3] - Audio codec (MAX9880A) interrupt
86 * - GPIO[8-23] - Available on Arduino and PMOD_x headers
87 * For now there's no use of Arduino and PMOD_x headers in Linux
88 * use-case so we only enable lines 0, 2 and 3.
89 *
90 * [1] https://github.com/foss-for-synopsys-dwc-arc-processors/ARC-Development-Systems-Forum/wiki/docs/ARC_HSDK_User_Guide.pdf
91 */
92#define GPIO_INTEN (HSDK_GPIO_INTC + 0x30)
93#define GPIO_INTMASK (HSDK_GPIO_INTC + 0x34)
94#define GPIO_INTTYPE_LEVEL (HSDK_GPIO_INTC + 0x38)
95#define GPIO_INT_POLARITY (HSDK_GPIO_INTC + 0x3c)
96#define GPIO_INT_CONNECTED_MASK 0x0d
97
98 iowrite32(0xffffffff, (void __iomem *) GPIO_INTMASK);
99 iowrite32(~GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTMASK);
100 iowrite32(0x00000000, (void __iomem *) GPIO_INTTYPE_LEVEL);
101 iowrite32(0xffffffff, (void __iomem *) GPIO_INT_POLARITY);
102 iowrite32(GPIO_INT_CONNECTED_MASK, (void __iomem *) GPIO_INTEN);
103}
104
45static void __init hsdk_init_early(void) 105static void __init hsdk_init_early(void)
46{ 106{
47 /* 107 /*
@@ -62,6 +122,8 @@ static void __init hsdk_init_early(void)
62 * minimum possible div-by-2. 122 * minimum possible div-by-2.
63 */ 123 */
64 iowrite32(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT); 124 iowrite32(SDIO_UHS_REG_EXT_DIV_2, (void __iomem *) SDIO_UHS_REG_EXT);
125
126 hsdk_enable_gpio_intc_wire();
65} 127}
66 128
67static const char *hsdk_compat[] __initconst = { 129static const char *hsdk_compat[] __initconst = {
diff --git a/arch/arm/boot/dts/am3517.dtsi b/arch/arm/boot/dts/am3517.dtsi
index 4b6062b631b1..23ea381d363f 100644
--- a/arch/arm/boot/dts/am3517.dtsi
+++ b/arch/arm/boot/dts/am3517.dtsi
@@ -91,6 +91,11 @@
91 }; 91 };
92}; 92};
93 93
94/* Table Table 5-79 of the TRM shows 480ab000 is reserved */
95&usb_otg_hs {
96 status = "disabled";
97};
98
94&iva { 99&iva {
95 status = "disabled"; 100 status = "disabled";
96}; 101};
diff --git a/arch/arm/boot/dts/armada-38x.dtsi b/arch/arm/boot/dts/armada-38x.dtsi
index 18edc9bc7927..929459c42760 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -547,7 +547,7 @@
547 547
548 thermal: thermal@e8078 { 548 thermal: thermal@e8078 {
549 compatible = "marvell,armada380-thermal"; 549 compatible = "marvell,armada380-thermal";
550 reg = <0xe4078 0x4>, <0xe4074 0x4>; 550 reg = <0xe4078 0x4>, <0xe4070 0x8>;
551 status = "okay"; 551 status = "okay";
552 }; 552 };
553 553
diff --git a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
index 19a075aee19e..f14df0baf2ab 100644
--- a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
@@ -692,7 +692,7 @@
692 dsa,member = <0 0>; 692 dsa,member = <0 0>;
693 eeprom-length = <512>; 693 eeprom-length = <512>;
694 interrupt-parent = <&gpio6>; 694 interrupt-parent = <&gpio6>;
695 interrupts = <3 IRQ_TYPE_EDGE_FALLING>; 695 interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
696 interrupt-controller; 696 interrupt-controller;
697 #interrupt-cells = <2>; 697 #interrupt-cells = <2>;
698 698
diff --git a/arch/arm/boot/dts/omap4-droid4-xt894.dts b/arch/arm/boot/dts/omap4-droid4-xt894.dts
index bdf73cbcec3a..e7c3c563ff8f 100644
--- a/arch/arm/boot/dts/omap4-droid4-xt894.dts
+++ b/arch/arm/boot/dts/omap4-droid4-xt894.dts
@@ -159,13 +159,7 @@
159 159
160 dais = <&mcbsp2_port>, <&mcbsp3_port>; 160 dais = <&mcbsp2_port>, <&mcbsp3_port>;
161 }; 161 };
162};
163
164&dss {
165 status = "okay";
166};
167 162
168&gpio6 {
169 pwm8: dmtimer-pwm-8 { 163 pwm8: dmtimer-pwm-8 {
170 pinctrl-names = "default"; 164 pinctrl-names = "default";
171 pinctrl-0 = <&vibrator_direction_pin>; 165 pinctrl-0 = <&vibrator_direction_pin>;
@@ -192,7 +186,10 @@
192 pwm-names = "enable", "direction"; 186 pwm-names = "enable", "direction";
193 direction-duty-cycle-ns = <10000000>; 187 direction-duty-cycle-ns = <10000000>;
194 }; 188 };
189};
195 190
191&dss {
192 status = "okay";
196}; 193};
197 194
198&dsi1 { 195&dsi1 {
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 106a1466518d..746565a876dc 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -48,6 +48,7 @@ saved_pc .req lr
48 * from those features make this path too inefficient. 48 * from those features make this path too inefficient.
49 */ 49 */
50ret_fast_syscall: 50ret_fast_syscall:
51__ret_fast_syscall:
51 UNWIND(.fnstart ) 52 UNWIND(.fnstart )
52 UNWIND(.cantunwind ) 53 UNWIND(.cantunwind )
53 disable_irq_notrace @ disable interrupts 54 disable_irq_notrace @ disable interrupts
@@ -78,6 +79,7 @@ fast_work_pending:
78 * call. 79 * call.
79 */ 80 */
80ret_fast_syscall: 81ret_fast_syscall:
82__ret_fast_syscall:
81 UNWIND(.fnstart ) 83 UNWIND(.fnstart )
82 UNWIND(.cantunwind ) 84 UNWIND(.cantunwind )
83 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 85 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
@@ -255,7 +257,7 @@ local_restart:
255 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls? 257 tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls?
256 bne __sys_trace 258 bne __sys_trace
257 259
258 invoke_syscall tbl, scno, r10, ret_fast_syscall 260 invoke_syscall tbl, scno, r10, __ret_fast_syscall
259 261
260 add r1, sp, #S_OFF 262 add r1, sp, #S_OFF
2612: cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE) 2632: cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 225d1c58d2de..d9c299133111 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -338,6 +338,7 @@ static struct vm_area_struct gate_vma = {
338 338
339static int __init gate_vma_init(void) 339static int __init gate_vma_init(void)
340{ 340{
341 vma_init(&gate_vma, NULL);
341 gate_vma.vm_page_prot = PAGE_READONLY_EXEC; 342 gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
342 return 0; 343 return 0;
343} 344}
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 69df3620eca5..1c73694c871a 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -109,6 +109,45 @@ void omap5_erratum_workaround_801819(void)
109static inline void omap5_erratum_workaround_801819(void) { } 109static inline void omap5_erratum_workaround_801819(void) { }
110#endif 110#endif
111 111
112#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
113/*
114 * Configure ACR and enable ACTLR[0] (Enable invalidates of BTB with
115 * ICIALLU) to activate the workaround for secondary Core.
116 * NOTE: it is assumed that the primary core's configuration is done
117 * by the boot loader (kernel will detect a misconfiguration and complain
118 * if this is not done).
119 *
120 * In General Purpose(GP) devices, ACR bit settings can only be done
121 * by ROM code in "secure world" using the smc call and there is no
122 * option to update the "firmware" on such devices. This also works for
123 * High security(HS) devices, as a backup option in case the
124 * "update" is not done in the "security firmware".
125 */
126static void omap5_secondary_harden_predictor(void)
127{
128 u32 acr, acr_mask;
129
130 asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
131
132 /*
133 * ACTLR[0] (Enable invalidates of BTB with ICIALLU)
134 */
135 acr_mask = BIT(0);
136
137 /* Do we already have it done.. if yes, skip expensive smc */
138 if ((acr & acr_mask) == acr_mask)
139 return;
140
141 acr |= acr_mask;
142 omap_smc1(OMAP5_DRA7_MON_SET_ACR_INDEX, acr);
143
144 pr_debug("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n",
145 __func__, smp_processor_id());
146}
147#else
148static inline void omap5_secondary_harden_predictor(void) { }
149#endif
150
112static void omap4_secondary_init(unsigned int cpu) 151static void omap4_secondary_init(unsigned int cpu)
113{ 152{
114 /* 153 /*
@@ -131,6 +170,8 @@ static void omap4_secondary_init(unsigned int cpu)
131 set_cntfreq(); 170 set_cntfreq();
132 /* Configure ACR to disable streaming WA for 801819 */ 171 /* Configure ACR to disable streaming WA for 801819 */
133 omap5_erratum_workaround_801819(); 172 omap5_erratum_workaround_801819();
173 /* Enable ACR to allow for ICUALLU workaround */
174 omap5_secondary_harden_predictor();
134 } 175 }
135 176
136 /* 177 /*
diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c
index 9c10248fadcc..4e8c2116808e 100644
--- a/arch/arm/mach-pxa/irq.c
+++ b/arch/arm/mach-pxa/irq.c
@@ -185,7 +185,7 @@ static int pxa_irq_suspend(void)
185{ 185{
186 int i; 186 int i;
187 187
188 for (i = 0; i < pxa_internal_irq_nr / 32; i++) { 188 for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
189 void __iomem *base = irq_base(i); 189 void __iomem *base = irq_base(i);
190 190
191 saved_icmr[i] = __raw_readl(base + ICMR); 191 saved_icmr[i] = __raw_readl(base + ICMR);
@@ -204,7 +204,7 @@ static void pxa_irq_resume(void)
204{ 204{
205 int i; 205 int i;
206 206
207 for (i = 0; i < pxa_internal_irq_nr / 32; i++) { 207 for (i = 0; i < DIV_ROUND_UP(pxa_internal_irq_nr, 32); i++) {
208 void __iomem *base = irq_base(i); 208 void __iomem *base = irq_base(i);
209 209
210 __raw_writel(saved_icmr[i], base + ICMR); 210 __raw_writel(saved_icmr[i], base + ICMR);
diff --git a/arch/arm/mach-rpc/ecard.c b/arch/arm/mach-rpc/ecard.c
index 39aef4876ed4..04b2f22c2739 100644
--- a/arch/arm/mach-rpc/ecard.c
+++ b/arch/arm/mach-rpc/ecard.c
@@ -212,7 +212,7 @@ static DEFINE_MUTEX(ecard_mutex);
212 */ 212 */
213static void ecard_init_pgtables(struct mm_struct *mm) 213static void ecard_init_pgtables(struct mm_struct *mm)
214{ 214{
215 struct vm_area_struct vma; 215 struct vm_area_struct vma = TLB_FLUSH_VMA(mm, VM_EXEC);
216 216
217 /* We want to set up the page tables for the following mapping: 217 /* We want to set up the page tables for the following mapping:
218 * Virtual Physical 218 * Virtual Physical
@@ -237,9 +237,6 @@ static void ecard_init_pgtables(struct mm_struct *mm)
237 237
238 memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (EASI_SIZE / PGDIR_SIZE)); 238 memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (EASI_SIZE / PGDIR_SIZE));
239 239
240 vma.vm_flags = VM_EXEC;
241 vma.vm_mm = mm;
242
243 flush_tlb_range(&vma, IO_START, IO_START + IO_SIZE); 240 flush_tlb_range(&vma, IO_START, IO_START + IO_SIZE);
244 flush_tlb_range(&vma, EASI_START, EASI_START + EASI_SIZE); 241 flush_tlb_range(&vma, EASI_START, EASI_START + EASI_SIZE);
245} 242}
diff --git a/arch/arm64/crypto/ghash-ce-glue.c b/arch/arm64/crypto/ghash-ce-glue.c
index 7cf0b1aa6ea8..8a10f1d7199a 100644
--- a/arch/arm64/crypto/ghash-ce-glue.c
+++ b/arch/arm64/crypto/ghash-ce-glue.c
@@ -488,9 +488,13 @@ static int gcm_decrypt(struct aead_request *req)
488 err = skcipher_walk_done(&walk, 488 err = skcipher_walk_done(&walk,
489 walk.nbytes % AES_BLOCK_SIZE); 489 walk.nbytes % AES_BLOCK_SIZE);
490 } 490 }
491 if (walk.nbytes) 491 if (walk.nbytes) {
492 pmull_gcm_encrypt_block(iv, iv, NULL, 492 kernel_neon_begin();
493 pmull_gcm_encrypt_block(iv, iv, ctx->aes_key.key_enc,
493 num_rounds(&ctx->aes_key)); 494 num_rounds(&ctx->aes_key));
495 kernel_neon_end();
496 }
497
494 } else { 498 } else {
495 __aes_arm64_encrypt(ctx->aes_key.key_enc, tag, iv, 499 __aes_arm64_encrypt(ctx->aes_key.key_enc, tag, iv,
496 num_rounds(&ctx->aes_key)); 500 num_rounds(&ctx->aes_key));
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index ffdaea7954bb..0ad1cf233470 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -37,7 +37,7 @@ static inline void __tlb_remove_table(void *_table)
37 37
38static inline void tlb_flush(struct mmu_gather *tlb) 38static inline void tlb_flush(struct mmu_gather *tlb)
39{ 39{
40 struct vm_area_struct vma = { .vm_mm = tlb->mm, }; 40 struct vm_area_struct vma = TLB_FLUSH_VMA(tlb->mm, 0);
41 41
42 /* 42 /*
43 * The ASID allocator will either invalidate the ASID or mark 43 * The ASID allocator will either invalidate the ASID or mark
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index f24892a40d2c..c6d80743f4ed 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1351,9 +1351,9 @@ static void __update_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
1351 1351
1352static void update_cpu_capabilities(u16 scope_mask) 1352static void update_cpu_capabilities(u16 scope_mask)
1353{ 1353{
1354 __update_cpu_capabilities(arm64_features, scope_mask, "detected:");
1355 __update_cpu_capabilities(arm64_errata, scope_mask, 1354 __update_cpu_capabilities(arm64_errata, scope_mask,
1356 "enabling workaround for"); 1355 "enabling workaround for");
1356 __update_cpu_capabilities(arm64_features, scope_mask, "detected:");
1357} 1357}
1358 1358
1359static int __enable_cpu_capability(void *arg) 1359static int __enable_cpu_capability(void *arg)
@@ -1408,8 +1408,8 @@ __enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
1408 1408
1409static void __init enable_cpu_capabilities(u16 scope_mask) 1409static void __init enable_cpu_capabilities(u16 scope_mask)
1410{ 1410{
1411 __enable_cpu_capabilities(arm64_features, scope_mask);
1412 __enable_cpu_capabilities(arm64_errata, scope_mask); 1411 __enable_cpu_capabilities(arm64_errata, scope_mask);
1412 __enable_cpu_capabilities(arm64_features, scope_mask);
1413} 1413}
1414 1414
1415/* 1415/*
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index ecc6818191df..192b3ba07075 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -108,7 +108,6 @@ static pte_t get_clear_flush(struct mm_struct *mm,
108 unsigned long pgsize, 108 unsigned long pgsize,
109 unsigned long ncontig) 109 unsigned long ncontig)
110{ 110{
111 struct vm_area_struct vma = { .vm_mm = mm };
112 pte_t orig_pte = huge_ptep_get(ptep); 111 pte_t orig_pte = huge_ptep_get(ptep);
113 bool valid = pte_valid(orig_pte); 112 bool valid = pte_valid(orig_pte);
114 unsigned long i, saddr = addr; 113 unsigned long i, saddr = addr;
@@ -125,8 +124,10 @@ static pte_t get_clear_flush(struct mm_struct *mm,
125 orig_pte = pte_mkdirty(orig_pte); 124 orig_pte = pte_mkdirty(orig_pte);
126 } 125 }
127 126
128 if (valid) 127 if (valid) {
128 struct vm_area_struct vma = TLB_FLUSH_VMA(mm, 0);
129 flush_tlb_range(&vma, saddr, addr); 129 flush_tlb_range(&vma, saddr, addr);
130 }
130 return orig_pte; 131 return orig_pte;
131} 132}
132 133
@@ -145,7 +146,7 @@ static void clear_flush(struct mm_struct *mm,
145 unsigned long pgsize, 146 unsigned long pgsize,
146 unsigned long ncontig) 147 unsigned long ncontig)
147{ 148{
148 struct vm_area_struct vma = { .vm_mm = mm }; 149 struct vm_area_struct vma = TLB_FLUSH_VMA(mm, 0);
149 unsigned long i, saddr = addr; 150 unsigned long i, saddr = addr;
150 151
151 for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) 152 for (i = 0; i < ncontig; i++, addr += pgsize, ptep++)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 325cfb3b858a..9abf8a1e7b25 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -611,11 +611,13 @@ void __init mem_init(void)
611 BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64); 611 BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64);
612#endif 612#endif
613 613
614#ifdef CONFIG_SPARSEMEM_VMEMMAP
614 /* 615 /*
615 * Make sure we chose the upper bound of sizeof(struct page) 616 * Make sure we chose the upper bound of sizeof(struct page)
616 * correctly. 617 * correctly when sizing the VMEMMAP array.
617 */ 618 */
618 BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT)); 619 BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT));
620#endif
619 621
620 if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { 622 if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
621 extern int sysctl_overcommit_memory; 623 extern int sysctl_overcommit_memory;
diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h
index 44f0ac0df308..516355a774bf 100644
--- a/arch/ia64/include/asm/tlb.h
+++ b/arch/ia64/include/asm/tlb.h
@@ -115,12 +115,11 @@ ia64_tlb_flush_mmu_tlbonly(struct mmu_gather *tlb, unsigned long start, unsigned
115 flush_tlb_all(); 115 flush_tlb_all();
116 } else { 116 } else {
117 /* 117 /*
118 * XXX fix me: flush_tlb_range() should take an mm pointer instead of a 118 * flush_tlb_range() takes a vma instead of a mm pointer because
119 * vma pointer. 119 * some architectures want the vm_flags for ITLB/DTLB flush.
120 */ 120 */
121 struct vm_area_struct vma; 121 struct vm_area_struct vma = TLB_FLUSH_VMA(tlb->mm, 0);
122 122
123 vma.vm_mm = tlb->mm;
124 /* flush the address range from the tlb: */ 123 /* flush the address range from the tlb: */
125 flush_tlb_range(&vma, start, end); 124 flush_tlb_range(&vma, start, end);
126 /* now flush the virt. page-table area mapping the address range: */ 125 /* now flush the virt. page-table area mapping the address range: */
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 3b38c717008a..46bff1661836 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2278,17 +2278,15 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
2278 DPRINT(("smpl_buf @%p\n", smpl_buf)); 2278 DPRINT(("smpl_buf @%p\n", smpl_buf));
2279 2279
2280 /* allocate vma */ 2280 /* allocate vma */
2281 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 2281 vma = vm_area_alloc(mm);
2282 if (!vma) { 2282 if (!vma) {
2283 DPRINT(("Cannot allocate vma\n")); 2283 DPRINT(("Cannot allocate vma\n"));
2284 goto error_kmem; 2284 goto error_kmem;
2285 } 2285 }
2286 INIT_LIST_HEAD(&vma->anon_vma_chain);
2287 2286
2288 /* 2287 /*
2289 * partially initialize the vma for the sampling buffer 2288 * partially initialize the vma for the sampling buffer
2290 */ 2289 */
2291 vma->vm_mm = mm;
2292 vma->vm_file = get_file(filp); 2290 vma->vm_file = get_file(filp);
2293 vma->vm_flags = VM_READ|VM_MAYREAD|VM_DONTEXPAND|VM_DONTDUMP; 2291 vma->vm_flags = VM_READ|VM_MAYREAD|VM_DONTEXPAND|VM_DONTDUMP;
2294 vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */ 2292 vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */
@@ -2346,7 +2344,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
2346 return 0; 2344 return 0;
2347 2345
2348error: 2346error:
2349 kmem_cache_free(vm_area_cachep, vma); 2347 vm_area_free(vma);
2350error_kmem: 2348error_kmem:
2351 pfm_rvfree(smpl_buf, size); 2349 pfm_rvfree(smpl_buf, size);
2352 2350
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 18278b448530..3b85c3ecac38 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -114,10 +114,9 @@ ia64_init_addr_space (void)
114 * the problem. When the process attempts to write to the register backing store 114 * the problem. When the process attempts to write to the register backing store
115 * for the first time, it will get a SEGFAULT in this case. 115 * for the first time, it will get a SEGFAULT in this case.
116 */ 116 */
117 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 117 vma = vm_area_alloc(current->mm);
118 if (vma) { 118 if (vma) {
119 INIT_LIST_HEAD(&vma->anon_vma_chain); 119 vma_set_anonymous(vma);
120 vma->vm_mm = current->mm;
121 vma->vm_start = current->thread.rbs_bot & PAGE_MASK; 120 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
122 vma->vm_end = vma->vm_start + PAGE_SIZE; 121 vma->vm_end = vma->vm_start + PAGE_SIZE;
123 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT; 122 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
@@ -125,7 +124,7 @@ ia64_init_addr_space (void)
125 down_write(&current->mm->mmap_sem); 124 down_write(&current->mm->mmap_sem);
126 if (insert_vm_struct(current->mm, vma)) { 125 if (insert_vm_struct(current->mm, vma)) {
127 up_write(&current->mm->mmap_sem); 126 up_write(&current->mm->mmap_sem);
128 kmem_cache_free(vm_area_cachep, vma); 127 vm_area_free(vma);
129 return; 128 return;
130 } 129 }
131 up_write(&current->mm->mmap_sem); 130 up_write(&current->mm->mmap_sem);
@@ -133,10 +132,9 @@ ia64_init_addr_space (void)
133 132
134 /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */ 133 /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
135 if (!(current->personality & MMAP_PAGE_ZERO)) { 134 if (!(current->personality & MMAP_PAGE_ZERO)) {
136 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 135 vma = vm_area_alloc(current->mm);
137 if (vma) { 136 if (vma) {
138 INIT_LIST_HEAD(&vma->anon_vma_chain); 137 vma_set_anonymous(vma);
139 vma->vm_mm = current->mm;
140 vma->vm_end = PAGE_SIZE; 138 vma->vm_end = PAGE_SIZE;
141 vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT); 139 vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
142 vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO | 140 vma->vm_flags = VM_READ | VM_MAYREAD | VM_IO |
@@ -144,7 +142,7 @@ ia64_init_addr_space (void)
144 down_write(&current->mm->mmap_sem); 142 down_write(&current->mm->mmap_sem);
145 if (insert_vm_struct(current->mm, vma)) { 143 if (insert_vm_struct(current->mm, vma)) {
146 up_write(&current->mm->mmap_sem); 144 up_write(&current->mm->mmap_sem);
147 kmem_cache_free(vm_area_cachep, vma); 145 vm_area_free(vma);
148 return; 146 return;
149 } 147 }
150 up_write(&current->mm->mmap_sem); 148 up_write(&current->mm->mmap_sem);
@@ -277,7 +275,7 @@ static struct vm_area_struct gate_vma;
277 275
278static int __init gate_vma_init(void) 276static int __init gate_vma_init(void)
279{ 277{
280 gate_vma.vm_mm = NULL; 278 vma_init(&gate_vma, NULL);
281 gate_vma.vm_start = FIXADDR_USER_START; 279 gate_vma.vm_start = FIXADDR_USER_START;
282 gate_vma.vm_end = FIXADDR_USER_END; 280 gate_vma.vm_end = FIXADDR_USER_END;
283 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC; 281 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
diff --git a/arch/mips/ath79/common.c b/arch/mips/ath79/common.c
index 10a405d593df..c782b10ddf50 100644
--- a/arch/mips/ath79/common.c
+++ b/arch/mips/ath79/common.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(ath79_ddr_ctrl_init);
58 58
59void ath79_ddr_wb_flush(u32 reg) 59void ath79_ddr_wb_flush(u32 reg)
60{ 60{
61 void __iomem *flush_reg = ath79_ddr_wb_flush_base + reg; 61 void __iomem *flush_reg = ath79_ddr_wb_flush_base + (reg * 4);
62 62
63 /* Flush the DDR write buffer. */ 63 /* Flush the DDR write buffer. */
64 __raw_writel(0x1, flush_reg); 64 __raw_writel(0x1, flush_reg);
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 8c9cbf13d32a..6054d49e608e 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -212,12 +212,6 @@ static int __init bcm47xx_cpu_fixes(void)
212 */ 212 */
213 if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706) 213 if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706)
214 cpu_wait = NULL; 214 cpu_wait = NULL;
215
216 /*
217 * BCM47XX Erratum "R10: PCIe Transactions Periodically Fail"
218 * Enable ExternalSync for sync instruction to take effect
219 */
220 set_c0_config7(MIPS_CONF7_ES);
221 break; 215 break;
222#endif 216#endif
223 } 217 }
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 0bc270806ec5..ae461d91cd1f 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -681,8 +681,6 @@
681#define MIPS_CONF7_WII (_ULCAST_(1) << 31) 681#define MIPS_CONF7_WII (_ULCAST_(1) << 31)
682 682
683#define MIPS_CONF7_RPS (_ULCAST_(1) << 2) 683#define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
684/* ExternalSync */
685#define MIPS_CONF7_ES (_ULCAST_(1) << 8)
686 684
687#define MIPS_CONF7_IAR (_ULCAST_(1) << 10) 685#define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
688#define MIPS_CONF7_AR (_ULCAST_(1) << 16) 686#define MIPS_CONF7_AR (_ULCAST_(1) << 16)
@@ -2767,7 +2765,6 @@ __BUILD_SET_C0(status)
2767__BUILD_SET_C0(cause) 2765__BUILD_SET_C0(cause)
2768__BUILD_SET_C0(config) 2766__BUILD_SET_C0(config)
2769__BUILD_SET_C0(config5) 2767__BUILD_SET_C0(config5)
2770__BUILD_SET_C0(config7)
2771__BUILD_SET_C0(intcontrol) 2768__BUILD_SET_C0(intcontrol)
2772__BUILD_SET_C0(intctl) 2769__BUILD_SET_C0(intctl)
2773__BUILD_SET_C0(srsmap) 2770__BUILD_SET_C0(srsmap)
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 9632436d74d7..c2e94cf5ecda 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -54,5 +54,5 @@ void pci_resource_to_user(const struct pci_dev *dev, int bar,
54 phys_addr_t size = resource_size(rsrc); 54 phys_addr_t size = resource_size(rsrc);
55 55
56 *start = fixup_bigphys_addr(rsrc->start, size); 56 *start = fixup_bigphys_addr(rsrc->start, size);
57 *end = rsrc->start + size; 57 *end = rsrc->start + size - 1;
58} 58}
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 6aed974276d8..34f7222c5efe 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -12,17 +12,17 @@ config NDS32
12 select CLONE_BACKWARDS 12 select CLONE_BACKWARDS
13 select COMMON_CLK 13 select COMMON_CLK
14 select DMA_NONCOHERENT_OPS 14 select DMA_NONCOHERENT_OPS
15 select GENERIC_ASHLDI3
16 select GENERIC_ASHRDI3
17 select GENERIC_LSHRDI3
18 select GENERIC_CMPDI2
19 select GENERIC_MULDI3
20 select GENERIC_UCMPDI2
21 select GENERIC_ATOMIC64 15 select GENERIC_ATOMIC64
22 select GENERIC_CPU_DEVICES 16 select GENERIC_CPU_DEVICES
23 select GENERIC_CLOCKEVENTS 17 select GENERIC_CLOCKEVENTS
24 select GENERIC_IRQ_CHIP 18 select GENERIC_IRQ_CHIP
25 select GENERIC_IRQ_SHOW 19 select GENERIC_IRQ_SHOW
20 select GENERIC_LIB_ASHLDI3
21 select GENERIC_LIB_ASHRDI3
22 select GENERIC_LIB_CMPDI2
23 select GENERIC_LIB_LSHRDI3
24 select GENERIC_LIB_MULDI3
25 select GENERIC_LIB_UCMPDI2
26 select GENERIC_STRNCPY_FROM_USER 26 select GENERIC_STRNCPY_FROM_USER
27 select GENERIC_STRNLEN_USER 27 select GENERIC_STRNLEN_USER
28 select GENERIC_TIME_VSYSCALL 28 select GENERIC_TIME_VSYSCALL
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile
index 513bb2e9baf9..031c676821ff 100644
--- a/arch/nds32/Makefile
+++ b/arch/nds32/Makefile
@@ -34,10 +34,12 @@ ifdef CONFIG_CPU_LITTLE_ENDIAN
34KBUILD_CFLAGS += $(call cc-option, -EL) 34KBUILD_CFLAGS += $(call cc-option, -EL)
35KBUILD_AFLAGS += $(call cc-option, -EL) 35KBUILD_AFLAGS += $(call cc-option, -EL)
36LDFLAGS += $(call cc-option, -EL) 36LDFLAGS += $(call cc-option, -EL)
37CHECKFLAGS += -D__NDS32_EL__
37else 38else
38KBUILD_CFLAGS += $(call cc-option, -EB) 39KBUILD_CFLAGS += $(call cc-option, -EB)
39KBUILD_AFLAGS += $(call cc-option, -EB) 40KBUILD_AFLAGS += $(call cc-option, -EB)
40LDFLAGS += $(call cc-option, -EB) 41LDFLAGS += $(call cc-option, -EB)
42CHECKFLAGS += -D__NDS32_EB__
41endif 43endif
42 44
43boot := arch/nds32/boot 45boot := arch/nds32/boot
diff --git a/arch/nds32/include/asm/cacheflush.h b/arch/nds32/include/asm/cacheflush.h
index 10b48f0d8e85..8b26198d51bb 100644
--- a/arch/nds32/include/asm/cacheflush.h
+++ b/arch/nds32/include/asm/cacheflush.h
@@ -8,6 +8,8 @@
8 8
9#define PG_dcache_dirty PG_arch_1 9#define PG_dcache_dirty PG_arch_1
10 10
11void flush_icache_range(unsigned long start, unsigned long end);
12void flush_icache_page(struct vm_area_struct *vma, struct page *page);
11#ifdef CONFIG_CPU_CACHE_ALIASING 13#ifdef CONFIG_CPU_CACHE_ALIASING
12void flush_cache_mm(struct mm_struct *mm); 14void flush_cache_mm(struct mm_struct *mm);
13void flush_cache_dup_mm(struct mm_struct *mm); 15void flush_cache_dup_mm(struct mm_struct *mm);
@@ -34,13 +36,16 @@ void flush_anon_page(struct vm_area_struct *vma,
34void flush_kernel_dcache_page(struct page *page); 36void flush_kernel_dcache_page(struct page *page);
35void flush_kernel_vmap_range(void *addr, int size); 37void flush_kernel_vmap_range(void *addr, int size);
36void invalidate_kernel_vmap_range(void *addr, int size); 38void invalidate_kernel_vmap_range(void *addr, int size);
37void flush_icache_range(unsigned long start, unsigned long end);
38void flush_icache_page(struct vm_area_struct *vma, struct page *page);
39#define flush_dcache_mmap_lock(mapping) xa_lock_irq(&(mapping)->i_pages) 39#define flush_dcache_mmap_lock(mapping) xa_lock_irq(&(mapping)->i_pages)
40#define flush_dcache_mmap_unlock(mapping) xa_unlock_irq(&(mapping)->i_pages) 40#define flush_dcache_mmap_unlock(mapping) xa_unlock_irq(&(mapping)->i_pages)
41 41
42#else 42#else
43#include <asm-generic/cacheflush.h> 43#include <asm-generic/cacheflush.h>
44#undef flush_icache_range
45#undef flush_icache_page
46#undef flush_icache_user_range
47void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
48 unsigned long addr, int len);
44#endif 49#endif
45 50
46#endif /* __NDS32_CACHEFLUSH_H__ */ 51#endif /* __NDS32_CACHEFLUSH_H__ */
diff --git a/arch/nds32/include/asm/futex.h b/arch/nds32/include/asm/futex.h
index eab5e84bd991..cb6cb91cfdf8 100644
--- a/arch/nds32/include/asm/futex.h
+++ b/arch/nds32/include/asm/futex.h
@@ -16,7 +16,7 @@
16 " .popsection\n" \ 16 " .popsection\n" \
17 " .pushsection .fixup,\"ax\"\n" \ 17 " .pushsection .fixup,\"ax\"\n" \
18 "4: move %0, " err_reg "\n" \ 18 "4: move %0, " err_reg "\n" \
19 " j 3b\n" \ 19 " b 3b\n" \
20 " .popsection" 20 " .popsection"
21 21
22#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \ 22#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c
index 2f5b2ccebe47..63a1a5ef5219 100644
--- a/arch/nds32/kernel/setup.c
+++ b/arch/nds32/kernel/setup.c
@@ -278,7 +278,8 @@ static void __init setup_memory(void)
278 278
279void __init setup_arch(char **cmdline_p) 279void __init setup_arch(char **cmdline_p)
280{ 280{
281 early_init_devtree( __dtb_start); 281 early_init_devtree(__atags_pointer ? \
282 phys_to_virt(__atags_pointer) : __dtb_start);
282 283
283 setup_cpuinfo(); 284 setup_cpuinfo();
284 285
diff --git a/arch/nds32/mm/cacheflush.c b/arch/nds32/mm/cacheflush.c
index ce8fd34497bf..254703653b6f 100644
--- a/arch/nds32/mm/cacheflush.c
+++ b/arch/nds32/mm/cacheflush.c
@@ -13,7 +13,39 @@
13 13
14extern struct cache_info L1_cache_info[2]; 14extern struct cache_info L1_cache_info[2];
15 15
16#ifndef CONFIG_CPU_CACHE_ALIASING 16void flush_icache_range(unsigned long start, unsigned long end)
17{
18 unsigned long line_size, flags;
19 line_size = L1_cache_info[DCACHE].line_size;
20 start = start & ~(line_size - 1);
21 end = (end + line_size - 1) & ~(line_size - 1);
22 local_irq_save(flags);
23 cpu_cache_wbinval_range(start, end, 1);
24 local_irq_restore(flags);
25}
26EXPORT_SYMBOL(flush_icache_range);
27
28void flush_icache_page(struct vm_area_struct *vma, struct page *page)
29{
30 unsigned long flags;
31 unsigned long kaddr;
32 local_irq_save(flags);
33 kaddr = (unsigned long)kmap_atomic(page);
34 cpu_cache_wbinval_page(kaddr, vma->vm_flags & VM_EXEC);
35 kunmap_atomic((void *)kaddr);
36 local_irq_restore(flags);
37}
38EXPORT_SYMBOL(flush_icache_page);
39
40void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
41 unsigned long addr, int len)
42{
43 unsigned long kaddr;
44 kaddr = (unsigned long)kmap_atomic(page) + (addr & ~PAGE_MASK);
45 flush_icache_range(kaddr, kaddr + len);
46 kunmap_atomic((void *)kaddr);
47}
48
17void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, 49void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
18 pte_t * pte) 50 pte_t * pte)
19{ 51{
@@ -35,19 +67,15 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
35 67
36 if ((test_and_clear_bit(PG_dcache_dirty, &page->flags)) || 68 if ((test_and_clear_bit(PG_dcache_dirty, &page->flags)) ||
37 (vma->vm_flags & VM_EXEC)) { 69 (vma->vm_flags & VM_EXEC)) {
38 70 unsigned long kaddr;
39 if (!PageHighMem(page)) { 71 local_irq_save(flags);
40 cpu_cache_wbinval_page((unsigned long) 72 kaddr = (unsigned long)kmap_atomic(page);
41 page_address(page), 73 cpu_cache_wbinval_page(kaddr, vma->vm_flags & VM_EXEC);
42 vma->vm_flags & VM_EXEC); 74 kunmap_atomic((void *)kaddr);
43 } else { 75 local_irq_restore(flags);
44 unsigned long kaddr = (unsigned long)kmap_atomic(page);
45 cpu_cache_wbinval_page(kaddr, vma->vm_flags & VM_EXEC);
46 kunmap_atomic((void *)kaddr);
47 }
48 } 76 }
49} 77}
50#else 78#ifdef CONFIG_CPU_CACHE_ALIASING
51extern pte_t va_present(struct mm_struct *mm, unsigned long addr); 79extern pte_t va_present(struct mm_struct *mm, unsigned long addr);
52 80
53static inline unsigned long aliasing(unsigned long addr, unsigned long page) 81static inline unsigned long aliasing(unsigned long addr, unsigned long page)
@@ -317,52 +345,4 @@ void invalidate_kernel_vmap_range(void *addr, int size)
317 local_irq_restore(flags); 345 local_irq_restore(flags);
318} 346}
319EXPORT_SYMBOL(invalidate_kernel_vmap_range); 347EXPORT_SYMBOL(invalidate_kernel_vmap_range);
320
321void flush_icache_range(unsigned long start, unsigned long end)
322{
323 unsigned long line_size, flags;
324 line_size = L1_cache_info[DCACHE].line_size;
325 start = start & ~(line_size - 1);
326 end = (end + line_size - 1) & ~(line_size - 1);
327 local_irq_save(flags);
328 cpu_cache_wbinval_range(start, end, 1);
329 local_irq_restore(flags);
330}
331EXPORT_SYMBOL(flush_icache_range);
332
333void flush_icache_page(struct vm_area_struct *vma, struct page *page)
334{
335 unsigned long flags;
336 local_irq_save(flags);
337 cpu_cache_wbinval_page((unsigned long)page_address(page),
338 vma->vm_flags & VM_EXEC);
339 local_irq_restore(flags);
340}
341
342void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
343 pte_t * pte)
344{
345 struct page *page;
346 unsigned long flags;
347 unsigned long pfn = pte_pfn(*pte);
348
349 if (!pfn_valid(pfn))
350 return;
351
352 if (vma->vm_mm == current->active_mm) {
353 local_irq_save(flags);
354 __nds32__mtsr_dsb(addr, NDS32_SR_TLB_VPN);
355 __nds32__tlbop_rwr(*pte);
356 __nds32__isb();
357 local_irq_restore(flags);
358 }
359
360 page = pfn_to_page(pfn);
361 if (test_and_clear_bit(PG_dcache_dirty, &page->flags) ||
362 (vma->vm_flags & VM_EXEC)) {
363 local_irq_save(flags);
364 cpu_dcache_wbinval_page((unsigned long)page_address(page));
365 local_irq_restore(flags);
366 }
367}
368#endif 348#endif
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 2ea575cb3401..fb96206de317 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -243,6 +243,7 @@ endif
243cpu-as-$(CONFIG_4xx) += -Wa,-m405 243cpu-as-$(CONFIG_4xx) += -Wa,-m405
244cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec) 244cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
245cpu-as-$(CONFIG_E200) += -Wa,-me200 245cpu-as-$(CONFIG_E200) += -Wa,-me200
246cpu-as-$(CONFIG_E500) += -Wa,-me500
246cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 247cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4
247cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc) 248cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc)
248 249
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
index 896efa559996..b2f89b621b15 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -35,9 +35,9 @@ extern struct mm_iommu_table_group_mem_t *mm_iommu_lookup_rm(
35extern struct mm_iommu_table_group_mem_t *mm_iommu_find(struct mm_struct *mm, 35extern struct mm_iommu_table_group_mem_t *mm_iommu_find(struct mm_struct *mm,
36 unsigned long ua, unsigned long entries); 36 unsigned long ua, unsigned long entries);
37extern long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem, 37extern long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem,
38 unsigned long ua, unsigned long *hpa); 38 unsigned long ua, unsigned int pageshift, unsigned long *hpa);
39extern long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem, 39extern long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem,
40 unsigned long ua, unsigned long *hpa); 40 unsigned long ua, unsigned int pageshift, unsigned long *hpa);
41extern long mm_iommu_mapped_inc(struct mm_iommu_table_group_mem_t *mem); 41extern long mm_iommu_mapped_inc(struct mm_iommu_table_group_mem_t *mem);
42extern void mm_iommu_mapped_dec(struct mm_iommu_table_group_mem_t *mem); 42extern void mm_iommu_mapped_dec(struct mm_iommu_table_group_mem_t *mem);
43#endif 43#endif
@@ -143,24 +143,33 @@ static inline void mm_context_remove_copro(struct mm_struct *mm)
143{ 143{
144 int c; 144 int c;
145 145
146 c = atomic_dec_if_positive(&mm->context.copros);
147
148 /* Detect imbalance between add and remove */
149 WARN_ON(c < 0);
150
151 /* 146 /*
152 * Need to broadcast a global flush of the full mm before 147 * When removing the last copro, we need to broadcast a global
153 * decrementing active_cpus count, as the next TLBI may be 148 * flush of the full mm, as the next TLBI may be local and the
154 * local and the nMMU and/or PSL need to be cleaned up. 149 * nMMU and/or PSL need to be cleaned up.
155 * Should be rare enough so that it's acceptable. 150 *
151 * Both the 'copros' and 'active_cpus' counts are looked at in
152 * flush_all_mm() to determine the scope (local/global) of the
153 * TLBIs, so we need to flush first before decrementing
154 * 'copros'. If this API is used by several callers for the
155 * same context, it can lead to over-flushing. It's hopefully
156 * not common enough to be a problem.
156 * 157 *
157 * Skip on hash, as we don't know how to do the proper flush 158 * Skip on hash, as we don't know how to do the proper flush
158 * for the time being. Invalidations will remain global if 159 * for the time being. Invalidations will remain global if
159 * used on hash. 160 * used on hash. Note that we can't drop 'copros' either, as
161 * it could make some invalidations local with no flush
162 * in-between.
160 */ 163 */
161 if (c == 0 && radix_enabled()) { 164 if (radix_enabled()) {
162 flush_all_mm(mm); 165 flush_all_mm(mm);
163 dec_mm_active_cpus(mm); 166
167 c = atomic_dec_if_positive(&mm->context.copros);
168 /* Detect imbalance between add and remove */
169 WARN_ON(c < 0);
170
171 if (c == 0)
172 dec_mm_active_cpus(mm);
164 } 173 }
165} 174}
166#else 175#else
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index e734f6e45abc..689306118b48 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -144,7 +144,9 @@ power9_restore_additional_sprs:
144 mtspr SPRN_MMCR1, r4 144 mtspr SPRN_MMCR1, r4
145 145
146 ld r3, STOP_MMCR2(r13) 146 ld r3, STOP_MMCR2(r13)
147 ld r4, PACA_SPRG_VDSO(r13)
147 mtspr SPRN_MMCR2, r3 148 mtspr SPRN_MMCR2, r3
149 mtspr SPRN_SPRG3, r4
148 blr 150 blr
149 151
150/* 152/*
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe9733ffffaa..471aac313b89 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -42,6 +42,8 @@
42#include <asm/ppc-pci.h> 42#include <asm/ppc-pci.h>
43#include <asm/eeh.h> 43#include <asm/eeh.h>
44 44
45#include "../../../drivers/pci/pci.h"
46
45/* hose_spinlock protects accesses to the the phb_bitmap. */ 47/* hose_spinlock protects accesses to the the phb_bitmap. */
46static DEFINE_SPINLOCK(hose_spinlock); 48static DEFINE_SPINLOCK(hose_spinlock);
47LIST_HEAD(hose_list); 49LIST_HEAD(hose_list);
@@ -1014,7 +1016,7 @@ void pcibios_setup_bus_devices(struct pci_bus *bus)
1014 /* Cardbus can call us to add new devices to a bus, so ignore 1016 /* Cardbus can call us to add new devices to a bus, so ignore
1015 * those who are already fully discovered 1017 * those who are already fully discovered
1016 */ 1018 */
1017 if (dev->is_added) 1019 if (pci_dev_is_added(dev))
1018 continue; 1020 continue;
1019 1021
1020 pcibios_setup_device(dev); 1022 pcibios_setup_device(dev);
diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index d066e37551ec..8c456fa691a5 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -449,7 +449,7 @@ long kvmppc_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
449 /* This only handles v2 IOMMU type, v1 is handled via ioctl() */ 449 /* This only handles v2 IOMMU type, v1 is handled via ioctl() */
450 return H_TOO_HARD; 450 return H_TOO_HARD;
451 451
452 if (WARN_ON_ONCE(mm_iommu_ua_to_hpa(mem, ua, &hpa))) 452 if (WARN_ON_ONCE(mm_iommu_ua_to_hpa(mem, ua, tbl->it_page_shift, &hpa)))
453 return H_HARDWARE; 453 return H_HARDWARE;
454 454
455 if (mm_iommu_mapped_inc(mem)) 455 if (mm_iommu_mapped_inc(mem))
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 925fc316a104..5b298f5a1a14 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -279,7 +279,8 @@ static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
279 if (!mem) 279 if (!mem)
280 return H_TOO_HARD; 280 return H_TOO_HARD;
281 281
282 if (WARN_ON_ONCE_RM(mm_iommu_ua_to_hpa_rm(mem, ua, &hpa))) 282 if (WARN_ON_ONCE_RM(mm_iommu_ua_to_hpa_rm(mem, ua, tbl->it_page_shift,
283 &hpa)))
283 return H_HARDWARE; 284 return H_HARDWARE;
284 285
285 pua = (void *) vmalloc_to_phys(pua); 286 pua = (void *) vmalloc_to_phys(pua);
@@ -469,7 +470,8 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
469 470
470 mem = mm_iommu_lookup_rm(vcpu->kvm->mm, ua, IOMMU_PAGE_SIZE_4K); 471 mem = mm_iommu_lookup_rm(vcpu->kvm->mm, ua, IOMMU_PAGE_SIZE_4K);
471 if (mem) 472 if (mem)
472 prereg = mm_iommu_ua_to_hpa_rm(mem, ua, &tces) == 0; 473 prereg = mm_iommu_ua_to_hpa_rm(mem, ua,
474 IOMMU_PAGE_SHIFT_4K, &tces) == 0;
473 } 475 }
474 476
475 if (!prereg) { 477 if (!prereg) {
diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
index abb43646927a..a4ca57612558 100644
--- a/arch/powerpc/mm/mmu_context_iommu.c
+++ b/arch/powerpc/mm/mmu_context_iommu.c
@@ -19,6 +19,7 @@
19#include <linux/hugetlb.h> 19#include <linux/hugetlb.h>
20#include <linux/swap.h> 20#include <linux/swap.h>
21#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
22#include <asm/pte-walk.h>
22 23
23static DEFINE_MUTEX(mem_list_mutex); 24static DEFINE_MUTEX(mem_list_mutex);
24 25
@@ -27,6 +28,7 @@ struct mm_iommu_table_group_mem_t {
27 struct rcu_head rcu; 28 struct rcu_head rcu;
28 unsigned long used; 29 unsigned long used;
29 atomic64_t mapped; 30 atomic64_t mapped;
31 unsigned int pageshift;
30 u64 ua; /* userspace address */ 32 u64 ua; /* userspace address */
31 u64 entries; /* number of entries in hpas[] */ 33 u64 entries; /* number of entries in hpas[] */
32 u64 *hpas; /* vmalloc'ed */ 34 u64 *hpas; /* vmalloc'ed */
@@ -125,6 +127,8 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
125{ 127{
126 struct mm_iommu_table_group_mem_t *mem; 128 struct mm_iommu_table_group_mem_t *mem;
127 long i, j, ret = 0, locked_entries = 0; 129 long i, j, ret = 0, locked_entries = 0;
130 unsigned int pageshift;
131 unsigned long flags;
128 struct page *page = NULL; 132 struct page *page = NULL;
129 133
130 mutex_lock(&mem_list_mutex); 134 mutex_lock(&mem_list_mutex);
@@ -159,6 +163,12 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
159 goto unlock_exit; 163 goto unlock_exit;
160 } 164 }
161 165
166 /*
167 * For a starting point for a maximum page size calculation
168 * we use @ua and @entries natural alignment to allow IOMMU pages
169 * smaller than huge pages but still bigger than PAGE_SIZE.
170 */
171 mem->pageshift = __ffs(ua | (entries << PAGE_SHIFT));
162 mem->hpas = vzalloc(array_size(entries, sizeof(mem->hpas[0]))); 172 mem->hpas = vzalloc(array_size(entries, sizeof(mem->hpas[0])));
163 if (!mem->hpas) { 173 if (!mem->hpas) {
164 kfree(mem); 174 kfree(mem);
@@ -199,6 +209,23 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
199 } 209 }
200 } 210 }
201populate: 211populate:
212 pageshift = PAGE_SHIFT;
213 if (PageCompound(page)) {
214 pte_t *pte;
215 struct page *head = compound_head(page);
216 unsigned int compshift = compound_order(head);
217
218 local_irq_save(flags); /* disables as well */
219 pte = find_linux_pte(mm->pgd, ua, NULL, &pageshift);
220 local_irq_restore(flags);
221
222 /* Double check it is still the same pinned page */
223 if (pte && pte_page(*pte) == head &&
224 pageshift == compshift)
225 pageshift = max_t(unsigned int, pageshift,
226 PAGE_SHIFT);
227 }
228 mem->pageshift = min(mem->pageshift, pageshift);
202 mem->hpas[i] = page_to_pfn(page) << PAGE_SHIFT; 229 mem->hpas[i] = page_to_pfn(page) << PAGE_SHIFT;
203 } 230 }
204 231
@@ -349,7 +376,7 @@ struct mm_iommu_table_group_mem_t *mm_iommu_find(struct mm_struct *mm,
349EXPORT_SYMBOL_GPL(mm_iommu_find); 376EXPORT_SYMBOL_GPL(mm_iommu_find);
350 377
351long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem, 378long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem,
352 unsigned long ua, unsigned long *hpa) 379 unsigned long ua, unsigned int pageshift, unsigned long *hpa)
353{ 380{
354 const long entry = (ua - mem->ua) >> PAGE_SHIFT; 381 const long entry = (ua - mem->ua) >> PAGE_SHIFT;
355 u64 *va = &mem->hpas[entry]; 382 u64 *va = &mem->hpas[entry];
@@ -357,6 +384,9 @@ long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem,
357 if (entry >= mem->entries) 384 if (entry >= mem->entries)
358 return -EFAULT; 385 return -EFAULT;
359 386
387 if (pageshift > mem->pageshift)
388 return -EFAULT;
389
360 *hpa = *va | (ua & ~PAGE_MASK); 390 *hpa = *va | (ua & ~PAGE_MASK);
361 391
362 return 0; 392 return 0;
@@ -364,7 +394,7 @@ long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem,
364EXPORT_SYMBOL_GPL(mm_iommu_ua_to_hpa); 394EXPORT_SYMBOL_GPL(mm_iommu_ua_to_hpa);
365 395
366long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem, 396long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem,
367 unsigned long ua, unsigned long *hpa) 397 unsigned long ua, unsigned int pageshift, unsigned long *hpa)
368{ 398{
369 const long entry = (ua - mem->ua) >> PAGE_SHIFT; 399 const long entry = (ua - mem->ua) >> PAGE_SHIFT;
370 void *va = &mem->hpas[entry]; 400 void *va = &mem->hpas[entry];
@@ -373,6 +403,9 @@ long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem,
373 if (entry >= mem->entries) 403 if (entry >= mem->entries)
374 return -EFAULT; 404 return -EFAULT;
375 405
406 if (pageshift > mem->pageshift)
407 return -EFAULT;
408
376 pa = (void *) vmalloc_to_phys(va); 409 pa = (void *) vmalloc_to_phys(va);
377 if (!pa) 410 if (!pa)
378 return -EFAULT; 411 return -EFAULT;
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index 380cbf9a40d9..c0a9bcd28356 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -286,6 +286,7 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
286 u64 imm64; 286 u64 imm64;
287 u8 *func; 287 u8 *func;
288 u32 true_cond; 288 u32 true_cond;
289 u32 tmp_idx;
289 290
290 /* 291 /*
291 * addrs[] maps a BPF bytecode address into a real offset from 292 * addrs[] maps a BPF bytecode address into a real offset from
@@ -637,11 +638,7 @@ emit_clear:
637 case BPF_STX | BPF_XADD | BPF_W: 638 case BPF_STX | BPF_XADD | BPF_W:
638 /* Get EA into TMP_REG_1 */ 639 /* Get EA into TMP_REG_1 */
639 PPC_ADDI(b2p[TMP_REG_1], dst_reg, off); 640 PPC_ADDI(b2p[TMP_REG_1], dst_reg, off);
640 /* error if EA is not word-aligned */ 641 tmp_idx = ctx->idx * 4;
641 PPC_ANDI(b2p[TMP_REG_2], b2p[TMP_REG_1], 0x03);
642 PPC_BCC_SHORT(COND_EQ, (ctx->idx * 4) + 12);
643 PPC_LI(b2p[BPF_REG_0], 0);
644 PPC_JMP(exit_addr);
645 /* load value from memory into TMP_REG_2 */ 642 /* load value from memory into TMP_REG_2 */
646 PPC_BPF_LWARX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1], 0); 643 PPC_BPF_LWARX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1], 0);
647 /* add value from src_reg into this */ 644 /* add value from src_reg into this */
@@ -649,32 +646,16 @@ emit_clear:
649 /* store result back */ 646 /* store result back */
650 PPC_BPF_STWCX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1]); 647 PPC_BPF_STWCX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1]);
651 /* we're done if this succeeded */ 648 /* we're done if this succeeded */
652 PPC_BCC_SHORT(COND_EQ, (ctx->idx * 4) + (7*4)); 649 PPC_BCC_SHORT(COND_NE, tmp_idx);
653 /* otherwise, let's try once more */
654 PPC_BPF_LWARX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1], 0);
655 PPC_ADD(b2p[TMP_REG_2], b2p[TMP_REG_2], src_reg);
656 PPC_BPF_STWCX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1]);
657 /* exit if the store was not successful */
658 PPC_LI(b2p[BPF_REG_0], 0);
659 PPC_BCC(COND_NE, exit_addr);
660 break; 650 break;
661 /* *(u64 *)(dst + off) += src */ 651 /* *(u64 *)(dst + off) += src */
662 case BPF_STX | BPF_XADD | BPF_DW: 652 case BPF_STX | BPF_XADD | BPF_DW:
663 PPC_ADDI(b2p[TMP_REG_1], dst_reg, off); 653 PPC_ADDI(b2p[TMP_REG_1], dst_reg, off);
664 /* error if EA is not doubleword-aligned */ 654 tmp_idx = ctx->idx * 4;
665 PPC_ANDI(b2p[TMP_REG_2], b2p[TMP_REG_1], 0x07);
666 PPC_BCC_SHORT(COND_EQ, (ctx->idx * 4) + (3*4));
667 PPC_LI(b2p[BPF_REG_0], 0);
668 PPC_JMP(exit_addr);
669 PPC_BPF_LDARX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1], 0);
670 PPC_ADD(b2p[TMP_REG_2], b2p[TMP_REG_2], src_reg);
671 PPC_BPF_STDCX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1]);
672 PPC_BCC_SHORT(COND_EQ, (ctx->idx * 4) + (7*4));
673 PPC_BPF_LDARX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1], 0); 655 PPC_BPF_LDARX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1], 0);
674 PPC_ADD(b2p[TMP_REG_2], b2p[TMP_REG_2], src_reg); 656 PPC_ADD(b2p[TMP_REG_2], b2p[TMP_REG_2], src_reg);
675 PPC_BPF_STDCX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1]); 657 PPC_BPF_STDCX(b2p[TMP_REG_2], 0, b2p[TMP_REG_1]);
676 PPC_LI(b2p[BPF_REG_0], 0); 658 PPC_BCC_SHORT(COND_NE, tmp_idx);
677 PPC_BCC(COND_NE, exit_addr);
678 break; 659 break;
679 660
680 /* 661 /*
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 5bd0eb6681bc..70b2e1e0f23c 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -46,6 +46,7 @@
46 46
47#include "powernv.h" 47#include "powernv.h"
48#include "pci.h" 48#include "pci.h"
49#include "../../../../drivers/pci/pci.h"
49 50
50#define PNV_IODA1_M64_NUM 16 /* Number of M64 BARs */ 51#define PNV_IODA1_M64_NUM 16 /* Number of M64 BARs */
51#define PNV_IODA1_M64_SEGS 8 /* Segments per M64 BAR */ 52#define PNV_IODA1_M64_SEGS 8 /* Segments per M64 BAR */
@@ -3138,7 +3139,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
3138 struct pci_dn *pdn; 3139 struct pci_dn *pdn;
3139 int mul, total_vfs; 3140 int mul, total_vfs;
3140 3141
3141 if (!pdev->is_physfn || pdev->is_added) 3142 if (!pdev->is_physfn || pci_dev_is_added(pdev))
3142 return; 3143 return;
3143 3144
3144 pdn = pci_get_pdn(pdev); 3145 pdn = pci_get_pdn(pdev);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 139f0af6c3d9..8a4868a3964b 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -71,6 +71,7 @@
71#include <asm/security_features.h> 71#include <asm/security_features.h>
72 72
73#include "pseries.h" 73#include "pseries.h"
74#include "../../../../drivers/pci/pci.h"
74 75
75int CMO_PrPSP = -1; 76int CMO_PrPSP = -1;
76int CMO_SecPSP = -1; 77int CMO_SecPSP = -1;
@@ -664,7 +665,7 @@ static void pseries_pci_fixup_iov_resources(struct pci_dev *pdev)
664 const int *indexes; 665 const int *indexes;
665 struct device_node *dn = pci_device_to_OF_node(pdev); 666 struct device_node *dn = pci_device_to_OF_node(pdev);
666 667
667 if (!pdev->is_physfn || pdev->is_added) 668 if (!pdev->is_physfn || pci_dev_is_added(pdev))
668 return; 669 return;
669 /*Firmware must support open sriov otherwise dont configure*/ 670 /*Firmware must support open sriov otherwise dont configure*/
670 indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL); 671 indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL);
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 47166ad2a669..196978733e64 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2734,7 +2734,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr,
2734{ 2734{
2735 int nr, dotted; 2735 int nr, dotted;
2736 unsigned long first_adr; 2736 unsigned long first_adr;
2737 unsigned long inst, last_inst = 0; 2737 unsigned int inst, last_inst = 0;
2738 unsigned char val[4]; 2738 unsigned char val[4];
2739 2739
2740 dotted = 0; 2740 dotted = 0;
@@ -2758,7 +2758,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr,
2758 dotted = 0; 2758 dotted = 0;
2759 last_inst = inst; 2759 last_inst = inst;
2760 if (praddr) 2760 if (praddr)
2761 printf(REG" %.8lx", adr, inst); 2761 printf(REG" %.8x", adr, inst);
2762 printf("\t"); 2762 printf("\t");
2763 dump_func(inst, adr); 2763 dump_func(inst, adr);
2764 printf("\n"); 2764 printf("\n");
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index e44bb2b2873e..8a1863d9ed53 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -140,7 +140,7 @@ config S390
140 select HAVE_FUNCTION_GRAPH_TRACER 140 select HAVE_FUNCTION_GRAPH_TRACER
141 select HAVE_FUNCTION_TRACER 141 select HAVE_FUNCTION_TRACER
142 select HAVE_FUTEX_CMPXCHG if FUTEX 142 select HAVE_FUTEX_CMPXCHG if FUTEX
143 select HAVE_GCC_PLUGINS 143 select HAVE_GCC_PLUGINS if BROKEN
144 select HAVE_KERNEL_BZIP2 144 select HAVE_KERNEL_BZIP2
145 select HAVE_KERNEL_GZIP 145 select HAVE_KERNEL_GZIP
146 select HAVE_KERNEL_LZ4 146 select HAVE_KERNEL_LZ4
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index ac67828da201..410b263ef5c8 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -13,6 +13,7 @@ generic-y += local64.h
13generic-y += mcs_spinlock.h 13generic-y += mcs_spinlock.h
14generic-y += mm-arch-hooks.h 14generic-y += mm-arch-hooks.h
15generic-y += module.h 15generic-y += module.h
16generic-y += msi.h
16generic-y += preempt.h 17generic-y += preempt.h
17generic-y += rwsem.h 18generic-y += rwsem.h
18generic-y += serial.h 19generic-y += serial.h
diff --git a/arch/sparc/include/asm/msi.h b/arch/sparc/include/asm/msi.h
deleted file mode 100644
index 3c17c1074431..000000000000
--- a/arch/sparc/include/asm/msi.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * msi.h: Defines specific to the MBus - Sbus - Interface.
4 *
5 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
7 */
8
9#ifndef _SPARC_MSI_H
10#define _SPARC_MSI_H
11
12/*
13 * Locations of MSI Registers.
14 */
15#define MSI_MBUS_ARBEN 0xe0001008 /* MBus Arbiter Enable register */
16
17/*
18 * Useful bits in the MSI Registers.
19 */
20#define MSI_ASYNC_MODE 0x80000000 /* Operate the MSI asynchronously */
21
22
23static inline void msi_set_sync(void)
24{
25 __asm__ __volatile__ ("lda [%0] %1, %%g3\n\t"
26 "andn %%g3, %2, %%g3\n\t"
27 "sta %%g3, [%0] %1\n\t" : :
28 "r" (MSI_MBUS_ARBEN),
29 "i" (ASI_M_CTL), "r" (MSI_ASYNC_MODE) : "g3");
30}
31
32#endif /* !(_SPARC_MSI_H) */
diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index 2ef8cfa9677e..f0eba72aa1ad 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -814,7 +814,7 @@ static void __init get_tick_patch(void)
814 } 814 }
815} 815}
816 816
817static void init_tick_ops(struct sparc64_tick_ops *ops) 817static void __init init_tick_ops(struct sparc64_tick_ops *ops)
818{ 818{
819 unsigned long freq, quotient, tick; 819 unsigned long freq, quotient, tick;
820 820
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 1d70c3f6d986..be9cb0065179 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -37,7 +37,6 @@
37#include <asm/mbus.h> 37#include <asm/mbus.h>
38#include <asm/page.h> 38#include <asm/page.h>
39#include <asm/asi.h> 39#include <asm/asi.h>
40#include <asm/msi.h>
41#include <asm/smp.h> 40#include <asm/smp.h>
42#include <asm/io.h> 41#include <asm/io.h>
43 42
@@ -116,6 +115,25 @@ static inline void srmmu_ctxd_set(ctxd_t *ctxp, pgd_t *pgdp)
116 set_pte((pte_t *)ctxp, pte); 115 set_pte((pte_t *)ctxp, pte);
117} 116}
118 117
118/*
119 * Locations of MSI Registers.
120 */
121#define MSI_MBUS_ARBEN 0xe0001008 /* MBus Arbiter Enable register */
122
123/*
124 * Useful bits in the MSI Registers.
125 */
126#define MSI_ASYNC_MODE 0x80000000 /* Operate the MSI asynchronously */
127
128static void msi_set_sync(void)
129{
130 __asm__ __volatile__ ("lda [%0] %1, %%g3\n\t"
131 "andn %%g3, %2, %%g3\n\t"
132 "sta %%g3, [%0] %1\n\t" : :
133 "r" (MSI_MBUS_ARBEN),
134 "i" (ASI_M_CTL), "r" (MSI_ASYNC_MODE) : "g3");
135}
136
119void pmd_set(pmd_t *pmdp, pte_t *ptep) 137void pmd_set(pmd_t *pmdp, pte_t *ptep)
120{ 138{
121 unsigned long ptp; /* Physical address, shifted right by 4 */ 139 unsigned long ptp; /* Physical address, shifted right by 4 */
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f1dbb4ee19d7..887d3a7bb646 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -63,7 +63,7 @@ config X86
63 select ARCH_HAS_PTE_SPECIAL 63 select ARCH_HAS_PTE_SPECIAL
64 select ARCH_HAS_REFCOUNT 64 select ARCH_HAS_REFCOUNT
65 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 65 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64
66 select ARCH_HAS_UACCESS_MCSAFE if X86_64 66 select ARCH_HAS_UACCESS_MCSAFE if X86_64 && X86_MCE
67 select ARCH_HAS_SET_MEMORY 67 select ARCH_HAS_SET_MEMORY
68 select ARCH_HAS_SG_CHAIN 68 select ARCH_HAS_SG_CHAIN
69 select ARCH_HAS_STRICT_KERNEL_RWX 69 select ARCH_HAS_STRICT_KERNEL_RWX
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index fa42f895fdde..169c2feda14a 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -106,9 +106,13 @@ define cmd_check_data_rel
106 done 106 done
107endef 107endef
108 108
109# We need to run two commands under "if_changed", so merge them into a
110# single invocation.
111quiet_cmd_check-and-link-vmlinux = LD $@
112 cmd_check-and-link-vmlinux = $(cmd_check_data_rel); $(cmd_ld)
113
109$(obj)/vmlinux: $(vmlinux-objs-y) FORCE 114$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
110 $(call if_changed,check_data_rel) 115 $(call if_changed,check-and-link-vmlinux)
111 $(call if_changed,ld)
112 116
113OBJCOPYFLAGS_vmlinux.bin := -R .comment -S 117OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
114$(obj)/vmlinux.bin: vmlinux FORCE 118$(obj)/vmlinux.bin: vmlinux FORCE
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c
index 8c5107545251..9e2157371491 100644
--- a/arch/x86/boot/compressed/pgtable_64.c
+++ b/arch/x86/boot/compressed/pgtable_64.c
@@ -1,3 +1,4 @@
1#include <asm/e820/types.h>
1#include <asm/processor.h> 2#include <asm/processor.h>
2#include "pgtable.h" 3#include "pgtable.h"
3#include "../string.h" 4#include "../string.h"
@@ -34,10 +35,62 @@ unsigned long *trampoline_32bit __section(.data);
34extern struct boot_params *boot_params; 35extern struct boot_params *boot_params;
35int cmdline_find_option_bool(const char *option); 36int cmdline_find_option_bool(const char *option);
36 37
38static unsigned long find_trampoline_placement(void)
39{
40 unsigned long bios_start, ebda_start;
41 unsigned long trampoline_start;
42 struct boot_e820_entry *entry;
43 int i;
44
45 /*
46 * Find a suitable spot for the trampoline.
47 * This code is based on reserve_bios_regions().
48 */
49
50 ebda_start = *(unsigned short *)0x40e << 4;
51 bios_start = *(unsigned short *)0x413 << 10;
52
53 if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
54 bios_start = BIOS_START_MAX;
55
56 if (ebda_start > BIOS_START_MIN && ebda_start < bios_start)
57 bios_start = ebda_start;
58
59 bios_start = round_down(bios_start, PAGE_SIZE);
60
61 /* Find the first usable memory region under bios_start. */
62 for (i = boot_params->e820_entries - 1; i >= 0; i--) {
63 entry = &boot_params->e820_table[i];
64
65 /* Skip all entries above bios_start. */
66 if (bios_start <= entry->addr)
67 continue;
68
69 /* Skip non-RAM entries. */
70 if (entry->type != E820_TYPE_RAM)
71 continue;
72
73 /* Adjust bios_start to the end of the entry if needed. */
74 if (bios_start > entry->addr + entry->size)
75 bios_start = entry->addr + entry->size;
76
77 /* Keep bios_start page-aligned. */
78 bios_start = round_down(bios_start, PAGE_SIZE);
79
80 /* Skip the entry if it's too small. */
81 if (bios_start - TRAMPOLINE_32BIT_SIZE < entry->addr)
82 continue;
83
84 break;
85 }
86
87 /* Place the trampoline just below the end of low memory */
88 return bios_start - TRAMPOLINE_32BIT_SIZE;
89}
90
37struct paging_config paging_prepare(void *rmode) 91struct paging_config paging_prepare(void *rmode)
38{ 92{
39 struct paging_config paging_config = {}; 93 struct paging_config paging_config = {};
40 unsigned long bios_start, ebda_start;
41 94
42 /* Initialize boot_params. Required for cmdline_find_option_bool(). */ 95 /* Initialize boot_params. Required for cmdline_find_option_bool(). */
43 boot_params = rmode; 96 boot_params = rmode;
@@ -61,23 +114,7 @@ struct paging_config paging_prepare(void *rmode)
61 paging_config.l5_required = 1; 114 paging_config.l5_required = 1;
62 } 115 }
63 116
64 /* 117 paging_config.trampoline_start = find_trampoline_placement();
65 * Find a suitable spot for the trampoline.
66 * This code is based on reserve_bios_regions().
67 */
68
69 ebda_start = *(unsigned short *)0x40e << 4;
70 bios_start = *(unsigned short *)0x413 << 10;
71
72 if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX)
73 bios_start = BIOS_START_MAX;
74
75 if (ebda_start > BIOS_START_MIN && ebda_start < bios_start)
76 bios_start = ebda_start;
77
78 /* Place the trampoline just below the end of low memory, aligned to 4k */
79 paging_config.trampoline_start = bios_start - TRAMPOLINE_32BIT_SIZE;
80 paging_config.trampoline_start = round_down(paging_config.trampoline_start, PAGE_SIZE);
81 118
82 trampoline_32bit = (unsigned long *)paging_config.trampoline_start; 119 trampoline_32bit = (unsigned long *)paging_config.trampoline_start;
83 120
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 73a522d53b53..8ae7ffda8f98 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -981,7 +981,7 @@ ENTRY(\sym)
981 981
982 call \do_sym 982 call \do_sym
983 983
984 jmp error_exit /* %ebx: no swapgs flag */ 984 jmp error_exit
985 .endif 985 .endif
986END(\sym) 986END(\sym)
987.endm 987.endm
@@ -1222,7 +1222,6 @@ END(paranoid_exit)
1222 1222
1223/* 1223/*
1224 * Save all registers in pt_regs, and switch GS if needed. 1224 * Save all registers in pt_regs, and switch GS if needed.
1225 * Return: EBX=0: came from user mode; EBX=1: otherwise
1226 */ 1225 */
1227ENTRY(error_entry) 1226ENTRY(error_entry)
1228 UNWIND_HINT_FUNC 1227 UNWIND_HINT_FUNC
@@ -1269,7 +1268,6 @@ ENTRY(error_entry)
1269 * for these here too. 1268 * for these here too.
1270 */ 1269 */
1271.Lerror_kernelspace: 1270.Lerror_kernelspace:
1272 incl %ebx
1273 leaq native_irq_return_iret(%rip), %rcx 1271 leaq native_irq_return_iret(%rip), %rcx
1274 cmpq %rcx, RIP+8(%rsp) 1272 cmpq %rcx, RIP+8(%rsp)
1275 je .Lerror_bad_iret 1273 je .Lerror_bad_iret
@@ -1303,28 +1301,20 @@ ENTRY(error_entry)
1303 1301
1304 /* 1302 /*
1305 * Pretend that the exception came from user mode: set up pt_regs 1303 * Pretend that the exception came from user mode: set up pt_regs
1306 * as if we faulted immediately after IRET and clear EBX so that 1304 * as if we faulted immediately after IRET.
1307 * error_exit knows that we will be returning to user mode.
1308 */ 1305 */
1309 mov %rsp, %rdi 1306 mov %rsp, %rdi
1310 call fixup_bad_iret 1307 call fixup_bad_iret
1311 mov %rax, %rsp 1308 mov %rax, %rsp
1312 decl %ebx
1313 jmp .Lerror_entry_from_usermode_after_swapgs 1309 jmp .Lerror_entry_from_usermode_after_swapgs
1314END(error_entry) 1310END(error_entry)
1315 1311
1316
1317/*
1318 * On entry, EBX is a "return to kernel mode" flag:
1319 * 1: already in kernel mode, don't need SWAPGS
1320 * 0: user gsbase is loaded, we need SWAPGS and standard preparation for return to usermode
1321 */
1322ENTRY(error_exit) 1312ENTRY(error_exit)
1323 UNWIND_HINT_REGS 1313 UNWIND_HINT_REGS
1324 DISABLE_INTERRUPTS(CLBR_ANY) 1314 DISABLE_INTERRUPTS(CLBR_ANY)
1325 TRACE_IRQS_OFF 1315 TRACE_IRQS_OFF
1326 testl %ebx, %ebx 1316 testb $3, CS(%rsp)
1327 jnz retint_kernel 1317 jz retint_kernel
1328 jmp retint_user 1318 jmp retint_user
1329END(error_exit) 1319END(error_exit)
1330 1320
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 4b98101209a1..d50bb4dc0650 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -579,7 +579,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
579{ 579{
580 struct cpu_perf_ibs *pcpu = this_cpu_ptr(perf_ibs->pcpu); 580 struct cpu_perf_ibs *pcpu = this_cpu_ptr(perf_ibs->pcpu);
581 struct perf_event *event = pcpu->event; 581 struct perf_event *event = pcpu->event;
582 struct hw_perf_event *hwc = &event->hw; 582 struct hw_perf_event *hwc;
583 struct perf_sample_data data; 583 struct perf_sample_data data;
584 struct perf_raw_record raw; 584 struct perf_raw_record raw;
585 struct pt_regs regs; 585 struct pt_regs regs;
@@ -602,6 +602,10 @@ fail:
602 return 0; 602 return 0;
603 } 603 }
604 604
605 if (WARN_ON_ONCE(!event))
606 goto fail;
607
608 hwc = &event->hw;
605 msr = hwc->config_base; 609 msr = hwc->config_base;
606 buf = ibs_data.regs; 610 buf = ibs_data.regs;
607 rdmsrl(msr, *buf); 611 rdmsrl(msr, *buf);
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 707b2a96e516..86f0c15dcc2d 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -2997,6 +2997,9 @@ static int intel_pmu_hw_config(struct perf_event *event)
2997 } 2997 }
2998 if (x86_pmu.pebs_aliases) 2998 if (x86_pmu.pebs_aliases)
2999 x86_pmu.pebs_aliases(event); 2999 x86_pmu.pebs_aliases(event);
3000
3001 if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
3002 event->attr.sample_type |= __PERF_SAMPLE_CALLCHAIN_EARLY;
3000 } 3003 }
3001 3004
3002 if (needs_branch_stack(event)) { 3005 if (needs_branch_stack(event)) {
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index 8cf03f101938..8dbba77e0518 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -1186,16 +1186,20 @@ static void setup_pebs_sample_data(struct perf_event *event,
1186 } 1186 }
1187 1187
1188 /* 1188 /*
1189 * We must however always use iregs for the unwinder to stay sane; the
1190 * record BP,SP,IP can point into thin air when the record is from a
1191 * previous PMI context or an (I)RET happend between the record and
1192 * PMI.
1193 */
1194 if (sample_type & PERF_SAMPLE_CALLCHAIN)
1195 data->callchain = perf_callchain(event, iregs);
1196
1197 /*
1189 * We use the interrupt regs as a base because the PEBS record does not 1198 * We use the interrupt regs as a base because the PEBS record does not
1190 * contain a full regs set, specifically it seems to lack segment 1199 * contain a full regs set, specifically it seems to lack segment
1191 * descriptors, which get used by things like user_mode(). 1200 * descriptors, which get used by things like user_mode().
1192 * 1201 *
1193 * In the simple case fix up only the IP for PERF_SAMPLE_IP. 1202 * In the simple case fix up only the IP for PERF_SAMPLE_IP.
1194 *
1195 * We must however always use BP,SP from iregs for the unwinder to stay
1196 * sane; the record BP,SP can point into thin air when the record is
1197 * from a previous PMI context or an (I)RET happend between the record
1198 * and PMI.
1199 */ 1203 */
1200 *regs = *iregs; 1204 *regs = *iregs;
1201 1205
@@ -1214,15 +1218,8 @@ static void setup_pebs_sample_data(struct perf_event *event,
1214 regs->si = pebs->si; 1218 regs->si = pebs->si;
1215 regs->di = pebs->di; 1219 regs->di = pebs->di;
1216 1220
1217 /* 1221 regs->bp = pebs->bp;
1218 * Per the above; only set BP,SP if we don't need callchains. 1222 regs->sp = pebs->sp;
1219 *
1220 * XXX: does this make sense?
1221 */
1222 if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
1223 regs->bp = pebs->bp;
1224 regs->sp = pebs->sp;
1225 }
1226 1223
1227#ifndef CONFIG_X86_32 1224#ifndef CONFIG_X86_32
1228 regs->r8 = pebs->r8; 1225 regs->r8 = pebs->r8;
diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
index c9e1e0bef3c3..e17ab885b1e9 100644
--- a/arch/x86/events/intel/uncore.h
+++ b/arch/x86/events/intel/uncore.h
@@ -28,7 +28,7 @@
28#define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff) 28#define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff)
29#define UNCORE_PCI_DEV_IDX(data) (data & 0xff) 29#define UNCORE_PCI_DEV_IDX(data) (data & 0xff)
30#define UNCORE_EXTRA_PCI_DEV 0xff 30#define UNCORE_EXTRA_PCI_DEV 0xff
31#define UNCORE_EXTRA_PCI_DEV_MAX 3 31#define UNCORE_EXTRA_PCI_DEV_MAX 4
32 32
33#define UNCORE_EVENT_CONSTRAINT(c, n) EVENT_CONSTRAINT(c, n, 0xff) 33#define UNCORE_EVENT_CONSTRAINT(c, n) EVENT_CONSTRAINT(c, n, 0xff)
34 34
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 87dc0263a2e1..51d7c117e3c7 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -1029,6 +1029,7 @@ void snbep_uncore_cpu_init(void)
1029enum { 1029enum {
1030 SNBEP_PCI_QPI_PORT0_FILTER, 1030 SNBEP_PCI_QPI_PORT0_FILTER,
1031 SNBEP_PCI_QPI_PORT1_FILTER, 1031 SNBEP_PCI_QPI_PORT1_FILTER,
1032 BDX_PCI_QPI_PORT2_FILTER,
1032 HSWEP_PCI_PCU_3, 1033 HSWEP_PCI_PCU_3,
1033}; 1034};
1034 1035
@@ -3286,15 +3287,18 @@ static const struct pci_device_id bdx_uncore_pci_ids[] = {
3286 }, 3287 },
3287 { /* QPI Port 0 filter */ 3288 { /* QPI Port 0 filter */
3288 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f86), 3289 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f86),
3289 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, 0), 3290 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
3291 SNBEP_PCI_QPI_PORT0_FILTER),
3290 }, 3292 },
3291 { /* QPI Port 1 filter */ 3293 { /* QPI Port 1 filter */
3292 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f96), 3294 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f96),
3293 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, 1), 3295 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
3296 SNBEP_PCI_QPI_PORT1_FILTER),
3294 }, 3297 },
3295 { /* QPI Port 2 filter */ 3298 { /* QPI Port 2 filter */
3296 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f46), 3299 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6f46),
3297 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, 2), 3300 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
3301 BDX_PCI_QPI_PORT2_FILTER),
3298 }, 3302 },
3299 { /* PCU.3 (for Capability registers) */ 3303 { /* PCU.3 (for Capability registers) */
3300 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fc0), 3304 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x6fc0),
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index cfd29ee8c3da..59663c08c949 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -966,6 +966,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
966 966
967extern unsigned long arch_align_stack(unsigned long sp); 967extern unsigned long arch_align_stack(unsigned long sp);
968extern void free_init_pages(char *what, unsigned long begin, unsigned long end); 968extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
969extern void free_kernel_image_pages(void *begin, void *end);
969 970
970void default_idle(void); 971void default_idle(void);
971#ifdef CONFIG_XEN 972#ifdef CONFIG_XEN
diff --git a/arch/x86/include/asm/qspinlock_paravirt.h b/arch/x86/include/asm/qspinlock_paravirt.h
index 9ef5ee03d2d7..159622ee0674 100644
--- a/arch/x86/include/asm/qspinlock_paravirt.h
+++ b/arch/x86/include/asm/qspinlock_paravirt.h
@@ -43,7 +43,7 @@ asm (".pushsection .text;"
43 "push %rdx;" 43 "push %rdx;"
44 "mov $0x1,%eax;" 44 "mov $0x1,%eax;"
45 "xor %edx,%edx;" 45 "xor %edx,%edx;"
46 "lock cmpxchg %dl,(%rdi);" 46 LOCK_PREFIX "cmpxchg %dl,(%rdi);"
47 "cmp $0x1,%al;" 47 "cmp $0x1,%al;"
48 "jne .slowpath;" 48 "jne .slowpath;"
49 "pop %rdx;" 49 "pop %rdx;"
diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h
index bd090367236c..34cffcef7375 100644
--- a/arch/x86/include/asm/set_memory.h
+++ b/arch/x86/include/asm/set_memory.h
@@ -46,6 +46,7 @@ int set_memory_np(unsigned long addr, int numpages);
46int set_memory_4k(unsigned long addr, int numpages); 46int set_memory_4k(unsigned long addr, int numpages);
47int set_memory_encrypted(unsigned long addr, int numpages); 47int set_memory_encrypted(unsigned long addr, int numpages);
48int set_memory_decrypted(unsigned long addr, int numpages); 48int set_memory_decrypted(unsigned long addr, int numpages);
49int set_memory_np_noalias(unsigned long addr, int numpages);
49 50
50int set_memory_array_uc(unsigned long *addr, int addrinarray); 51int set_memory_array_uc(unsigned long *addr, int addrinarray);
51int set_memory_array_wc(unsigned long *addr, int addrinarray); 52int set_memory_array_wc(unsigned long *addr, int addrinarray);
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 62acb613114b..a9d637bc301d 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -52,7 +52,12 @@ copy_to_user_mcsafe(void *to, const void *from, unsigned len)
52 unsigned long ret; 52 unsigned long ret;
53 53
54 __uaccess_begin(); 54 __uaccess_begin();
55 ret = memcpy_mcsafe(to, from, len); 55 /*
56 * Note, __memcpy_mcsafe() is explicitly used since it can
57 * handle exceptions / faults. memcpy_mcsafe() may fall back to
58 * memcpy() which lacks this handling.
59 */
60 ret = __memcpy_mcsafe(to, from, len);
56 __uaccess_end(); 61 __uaccess_end();
57 return ret; 62 return ret;
58} 63}
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 2aabd4cb0e3f..adbda5847b14 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -573,6 +573,9 @@ static u32 skx_deadline_rev(void)
573 case 0x04: return 0x02000014; 573 case 0x04: return 0x02000014;
574 } 574 }
575 575
576 if (boot_cpu_data.x86_stepping > 4)
577 return 0;
578
576 return ~0U; 579 return ~0U;
577} 580}
578 581
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index c102ad51025e..8c50754c09c1 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2165,9 +2165,6 @@ static ssize_t store_int_with_restart(struct device *s,
2165 if (check_interval == old_check_interval) 2165 if (check_interval == old_check_interval)
2166 return ret; 2166 return ret;
2167 2167
2168 if (check_interval < 1)
2169 check_interval = 1;
2170
2171 mutex_lock(&mce_sysfs_mutex); 2168 mutex_lock(&mce_sysfs_mutex);
2172 mce_restart(); 2169 mce_restart();
2173 mutex_unlock(&mce_sysfs_mutex); 2170 mutex_unlock(&mce_sysfs_mutex);
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index bf8d1eb7fca3..3b8e7c13c614 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -138,6 +138,7 @@ static unsigned long kvm_get_tsc_khz(void)
138 src = &hv_clock[cpu].pvti; 138 src = &hv_clock[cpu].pvti;
139 tsc_khz = pvclock_tsc_khz(src); 139 tsc_khz = pvclock_tsc_khz(src);
140 put_cpu(); 140 put_cpu();
141 setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
141 return tsc_khz; 142 return tsc_khz;
142} 143}
143 144
@@ -319,6 +320,8 @@ void __init kvmclock_init(void)
319 printk(KERN_INFO "kvm-clock: Using msrs %x and %x", 320 printk(KERN_INFO "kvm-clock: Using msrs %x and %x",
320 msr_kvm_system_time, msr_kvm_wall_clock); 321 msr_kvm_system_time, msr_kvm_wall_clock);
321 322
323 pvclock_set_pvti_cpu0_va(hv_clock);
324
322 if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT)) 325 if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE_STABLE_BIT))
323 pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT); 326 pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
324 327
@@ -366,14 +369,11 @@ int __init kvm_setup_vsyscall_timeinfo(void)
366 vcpu_time = &hv_clock[cpu].pvti; 369 vcpu_time = &hv_clock[cpu].pvti;
367 flags = pvclock_read_flags(vcpu_time); 370 flags = pvclock_read_flags(vcpu_time);
368 371
369 if (!(flags & PVCLOCK_TSC_STABLE_BIT)) {
370 put_cpu();
371 return 1;
372 }
373
374 pvclock_set_pvti_cpu0_va(hv_clock);
375 put_cpu(); 372 put_cpu();
376 373
374 if (!(flags & PVCLOCK_TSC_STABLE_BIT))
375 return 1;
376
377 kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK; 377 kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK;
378#endif 378#endif
379 return 0; 379 return 0;
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 92fd433c50b9..1bbec387d289 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -85,7 +85,7 @@ config KVM_AMD_SEV
85 def_bool y 85 def_bool y
86 bool "AMD Secure Encrypted Virtualization (SEV) support" 86 bool "AMD Secure Encrypted Virtualization (SEV) support"
87 depends on KVM_AMD && X86_64 87 depends on KVM_AMD && X86_64
88 depends on CRYPTO_DEV_CCP && CRYPTO_DEV_CCP_DD && CRYPTO_DEV_SP_PSP 88 depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m)
89 ---help--- 89 ---help---
90 Provides support for launching Encrypted VMs on AMD processors. 90 Provides support for launching Encrypted VMs on AMD processors.
91 91
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index d594690d8b95..6b8f11521c41 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -890,7 +890,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
890 if (cache->nobjs >= min) 890 if (cache->nobjs >= min)
891 return 0; 891 return 0;
892 while (cache->nobjs < ARRAY_SIZE(cache->objects)) { 892 while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
893 page = (void *)__get_free_page(GFP_KERNEL); 893 page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
894 if (!page) 894 if (!page)
895 return -ENOMEM; 895 return -ENOMEM;
896 cache->objects[cache->nobjs++] = page; 896 cache->objects[cache->nobjs++] = page;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1689f433f3a0..5d8e317c2b04 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2571,6 +2571,7 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
2571 struct vcpu_vmx *vmx = to_vmx(vcpu); 2571 struct vcpu_vmx *vmx = to_vmx(vcpu);
2572#ifdef CONFIG_X86_64 2572#ifdef CONFIG_X86_64
2573 int cpu = raw_smp_processor_id(); 2573 int cpu = raw_smp_processor_id();
2574 unsigned long fs_base, kernel_gs_base;
2574#endif 2575#endif
2575 int i; 2576 int i;
2576 2577
@@ -2586,12 +2587,20 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
2586 vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel; 2587 vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
2587 2588
2588#ifdef CONFIG_X86_64 2589#ifdef CONFIG_X86_64
2589 save_fsgs_for_kvm(); 2590 if (likely(is_64bit_mm(current->mm))) {
2590 vmx->host_state.fs_sel = current->thread.fsindex; 2591 save_fsgs_for_kvm();
2591 vmx->host_state.gs_sel = current->thread.gsindex; 2592 vmx->host_state.fs_sel = current->thread.fsindex;
2592#else 2593 vmx->host_state.gs_sel = current->thread.gsindex;
2593 savesegment(fs, vmx->host_state.fs_sel); 2594 fs_base = current->thread.fsbase;
2594 savesegment(gs, vmx->host_state.gs_sel); 2595 kernel_gs_base = current->thread.gsbase;
2596 } else {
2597#endif
2598 savesegment(fs, vmx->host_state.fs_sel);
2599 savesegment(gs, vmx->host_state.gs_sel);
2600#ifdef CONFIG_X86_64
2601 fs_base = read_msr(MSR_FS_BASE);
2602 kernel_gs_base = read_msr(MSR_KERNEL_GS_BASE);
2603 }
2595#endif 2604#endif
2596 if (!(vmx->host_state.fs_sel & 7)) { 2605 if (!(vmx->host_state.fs_sel & 7)) {
2597 vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel); 2606 vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel);
@@ -2611,10 +2620,10 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
2611 savesegment(ds, vmx->host_state.ds_sel); 2620 savesegment(ds, vmx->host_state.ds_sel);
2612 savesegment(es, vmx->host_state.es_sel); 2621 savesegment(es, vmx->host_state.es_sel);
2613 2622
2614 vmcs_writel(HOST_FS_BASE, current->thread.fsbase); 2623 vmcs_writel(HOST_FS_BASE, fs_base);
2615 vmcs_writel(HOST_GS_BASE, cpu_kernelmode_gs_base(cpu)); 2624 vmcs_writel(HOST_GS_BASE, cpu_kernelmode_gs_base(cpu));
2616 2625
2617 vmx->msr_host_kernel_gs_base = current->thread.gsbase; 2626 vmx->msr_host_kernel_gs_base = kernel_gs_base;
2618 if (is_long_mode(&vmx->vcpu)) 2627 if (is_long_mode(&vmx->vcpu))
2619 wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); 2628 wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
2620#else 2629#else
@@ -4322,11 +4331,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
4322 vmcs_conf->order = get_order(vmcs_conf->size); 4331 vmcs_conf->order = get_order(vmcs_conf->size);
4323 vmcs_conf->basic_cap = vmx_msr_high & ~0x1fff; 4332 vmcs_conf->basic_cap = vmx_msr_high & ~0x1fff;
4324 4333
4325 /* KVM supports Enlightened VMCS v1 only */ 4334 vmcs_conf->revision_id = vmx_msr_low;
4326 if (static_branch_unlikely(&enable_evmcs))
4327 vmcs_conf->revision_id = KVM_EVMCS_VERSION;
4328 else
4329 vmcs_conf->revision_id = vmx_msr_low;
4330 4335
4331 vmcs_conf->pin_based_exec_ctrl = _pin_based_exec_control; 4336 vmcs_conf->pin_based_exec_ctrl = _pin_based_exec_control;
4332 vmcs_conf->cpu_based_exec_ctrl = _cpu_based_exec_control; 4337 vmcs_conf->cpu_based_exec_ctrl = _cpu_based_exec_control;
@@ -4396,7 +4401,13 @@ static struct vmcs *alloc_vmcs_cpu(int cpu)
4396 return NULL; 4401 return NULL;
4397 vmcs = page_address(pages); 4402 vmcs = page_address(pages);
4398 memset(vmcs, 0, vmcs_config.size); 4403 memset(vmcs, 0, vmcs_config.size);
4399 vmcs->revision_id = vmcs_config.revision_id; /* vmcs revision id */ 4404
4405 /* KVM supports Enlightened VMCS v1 only */
4406 if (static_branch_unlikely(&enable_evmcs))
4407 vmcs->revision_id = KVM_EVMCS_VERSION;
4408 else
4409 vmcs->revision_id = vmcs_config.revision_id;
4410
4400 return vmcs; 4411 return vmcs;
4401} 4412}
4402 4413
@@ -4564,6 +4575,19 @@ static __init int alloc_kvm_area(void)
4564 return -ENOMEM; 4575 return -ENOMEM;
4565 } 4576 }
4566 4577
4578 /*
4579 * When eVMCS is enabled, alloc_vmcs_cpu() sets
4580 * vmcs->revision_id to KVM_EVMCS_VERSION instead of
4581 * revision_id reported by MSR_IA32_VMX_BASIC.
4582 *
4583 * However, even though not explictly documented by
4584 * TLFS, VMXArea passed as VMXON argument should
4585 * still be marked with revision_id reported by
4586 * physical CPU.
4587 */
4588 if (static_branch_unlikely(&enable_evmcs))
4589 vmcs->revision_id = vmcs_config.revision_id;
4590
4567 per_cpu(vmxarea, cpu) = vmcs; 4591 per_cpu(vmxarea, cpu) = vmcs;
4568 } 4592 }
4569 return 0; 4593 return 0;
@@ -7869,6 +7893,8 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
7869 HRTIMER_MODE_REL_PINNED); 7893 HRTIMER_MODE_REL_PINNED);
7870 vmx->nested.preemption_timer.function = vmx_preemption_timer_fn; 7894 vmx->nested.preemption_timer.function = vmx_preemption_timer_fn;
7871 7895
7896 vmx->nested.vpid02 = allocate_vpid();
7897
7872 vmx->nested.vmxon = true; 7898 vmx->nested.vmxon = true;
7873 return 0; 7899 return 0;
7874 7900
@@ -8456,21 +8482,20 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
8456/* Emulate the VMPTRST instruction */ 8482/* Emulate the VMPTRST instruction */
8457static int handle_vmptrst(struct kvm_vcpu *vcpu) 8483static int handle_vmptrst(struct kvm_vcpu *vcpu)
8458{ 8484{
8459 unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); 8485 unsigned long exit_qual = vmcs_readl(EXIT_QUALIFICATION);
8460 u32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); 8486 u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO);
8461 gva_t vmcs_gva; 8487 gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr;
8462 struct x86_exception e; 8488 struct x86_exception e;
8489 gva_t gva;
8463 8490
8464 if (!nested_vmx_check_permission(vcpu)) 8491 if (!nested_vmx_check_permission(vcpu))
8465 return 1; 8492 return 1;
8466 8493
8467 if (get_vmx_mem_address(vcpu, exit_qualification, 8494 if (get_vmx_mem_address(vcpu, exit_qual, instr_info, true, &gva))
8468 vmx_instruction_info, true, &vmcs_gva))
8469 return 1; 8495 return 1;
8470 /* *_system ok, nested_vmx_check_permission has verified cpl=0 */ 8496 /* *_system ok, nested_vmx_check_permission has verified cpl=0 */
8471 if (kvm_write_guest_virt_system(vcpu, vmcs_gva, 8497 if (kvm_write_guest_virt_system(vcpu, gva, (void *)&current_vmptr,
8472 (void *)&to_vmx(vcpu)->nested.current_vmptr, 8498 sizeof(gpa_t), &e)) {
8473 sizeof(u64), &e)) {
8474 kvm_inject_page_fault(vcpu, &e); 8499 kvm_inject_page_fault(vcpu, &e);
8475 return 1; 8500 return 1;
8476 } 8501 }
@@ -10346,11 +10371,9 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
10346 goto free_vmcs; 10371 goto free_vmcs;
10347 } 10372 }
10348 10373
10349 if (nested) { 10374 if (nested)
10350 nested_vmx_setup_ctls_msrs(&vmx->nested.msrs, 10375 nested_vmx_setup_ctls_msrs(&vmx->nested.msrs,
10351 kvm_vcpu_apicv_active(&vmx->vcpu)); 10376 kvm_vcpu_apicv_active(&vmx->vcpu));
10352 vmx->nested.vpid02 = allocate_vpid();
10353 }
10354 10377
10355 vmx->nested.posted_intr_nv = -1; 10378 vmx->nested.posted_intr_nv = -1;
10356 vmx->nested.current_vmptr = -1ull; 10379 vmx->nested.current_vmptr = -1ull;
@@ -10367,7 +10390,6 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
10367 return &vmx->vcpu; 10390 return &vmx->vcpu;
10368 10391
10369free_vmcs: 10392free_vmcs:
10370 free_vpid(vmx->nested.vpid02);
10371 free_loaded_vmcs(vmx->loaded_vmcs); 10393 free_loaded_vmcs(vmx->loaded_vmcs);
10372free_msrs: 10394free_msrs:
10373 kfree(vmx->guest_msrs); 10395 kfree(vmx->guest_msrs);
@@ -11753,7 +11775,6 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu)
11753{ 11775{
11754 struct vcpu_vmx *vmx = to_vmx(vcpu); 11776 struct vcpu_vmx *vmx = to_vmx(vcpu);
11755 struct vmcs12 *vmcs12 = get_vmcs12(vcpu); 11777 struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
11756 u32 msr_entry_idx;
11757 u32 exit_qual; 11778 u32 exit_qual;
11758 int r; 11779 int r;
11759 11780
@@ -11775,10 +11796,10 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu)
11775 nested_get_vmcs12_pages(vcpu, vmcs12); 11796 nested_get_vmcs12_pages(vcpu, vmcs12);
11776 11797
11777 r = EXIT_REASON_MSR_LOAD_FAIL; 11798 r = EXIT_REASON_MSR_LOAD_FAIL;
11778 msr_entry_idx = nested_vmx_load_msr(vcpu, 11799 exit_qual = nested_vmx_load_msr(vcpu,
11779 vmcs12->vm_entry_msr_load_addr, 11800 vmcs12->vm_entry_msr_load_addr,
11780 vmcs12->vm_entry_msr_load_count); 11801 vmcs12->vm_entry_msr_load_count);
11781 if (msr_entry_idx) 11802 if (exit_qual)
11782 goto fail; 11803 goto fail;
11783 11804
11784 /* 11805 /*
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0046aa70205a..2b812b3c5088 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1097,6 +1097,7 @@ static u32 msr_based_features[] = {
1097 1097
1098 MSR_F10H_DECFG, 1098 MSR_F10H_DECFG,
1099 MSR_IA32_UCODE_REV, 1099 MSR_IA32_UCODE_REV,
1100 MSR_IA32_ARCH_CAPABILITIES,
1100}; 1101};
1101 1102
1102static unsigned int num_msr_based_features; 1103static unsigned int num_msr_based_features;
@@ -1105,7 +1106,8 @@ static int kvm_get_msr_feature(struct kvm_msr_entry *msr)
1105{ 1106{
1106 switch (msr->index) { 1107 switch (msr->index) {
1107 case MSR_IA32_UCODE_REV: 1108 case MSR_IA32_UCODE_REV:
1108 rdmsrl(msr->index, msr->data); 1109 case MSR_IA32_ARCH_CAPABILITIES:
1110 rdmsrl_safe(msr->index, &msr->data);
1109 break; 1111 break;
1110 default: 1112 default:
1111 if (kvm_x86_ops->get_msr_feature(msr)) 1113 if (kvm_x86_ops->get_msr_feature(msr))
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index cee58a972cb2..74b157ac078d 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -773,13 +773,44 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
773 } 773 }
774} 774}
775 775
776/*
777 * begin/end can be in the direct map or the "high kernel mapping"
778 * used for the kernel image only. free_init_pages() will do the
779 * right thing for either kind of address.
780 */
781void free_kernel_image_pages(void *begin, void *end)
782{
783 unsigned long begin_ul = (unsigned long)begin;
784 unsigned long end_ul = (unsigned long)end;
785 unsigned long len_pages = (end_ul - begin_ul) >> PAGE_SHIFT;
786
787
788 free_init_pages("unused kernel image", begin_ul, end_ul);
789
790 /*
791 * PTI maps some of the kernel into userspace. For performance,
792 * this includes some kernel areas that do not contain secrets.
793 * Those areas might be adjacent to the parts of the kernel image
794 * being freed, which may contain secrets. Remove the "high kernel
795 * image mapping" for these freed areas, ensuring they are not even
796 * potentially vulnerable to Meltdown regardless of the specific
797 * optimizations PTI is currently using.
798 *
799 * The "noalias" prevents unmapping the direct map alias which is
800 * needed to access the freed pages.
801 *
802 * This is only valid for 64bit kernels. 32bit has only one mapping
803 * which can't be treated in this way for obvious reasons.
804 */
805 if (IS_ENABLED(CONFIG_X86_64) && cpu_feature_enabled(X86_FEATURE_PTI))
806 set_memory_np_noalias(begin_ul, len_pages);
807}
808
776void __ref free_initmem(void) 809void __ref free_initmem(void)
777{ 810{
778 e820__reallocate_tables(); 811 e820__reallocate_tables();
779 812
780 free_init_pages("unused kernel", 813 free_kernel_image_pages(&__init_begin, &__init_end);
781 (unsigned long)(&__init_begin),
782 (unsigned long)(&__init_end));
783} 814}
784 815
785#ifdef CONFIG_BLK_DEV_INITRD 816#ifdef CONFIG_BLK_DEV_INITRD
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 9b19f9a8948e..dd519f372169 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1283,12 +1283,8 @@ void mark_rodata_ro(void)
1283 set_memory_ro(start, (end-start) >> PAGE_SHIFT); 1283 set_memory_ro(start, (end-start) >> PAGE_SHIFT);
1284#endif 1284#endif
1285 1285
1286 free_init_pages("unused kernel", 1286 free_kernel_image_pages((void *)text_end, (void *)rodata_start);
1287 (unsigned long) __va(__pa_symbol(text_end)), 1287 free_kernel_image_pages((void *)rodata_end, (void *)_sdata);
1288 (unsigned long) __va(__pa_symbol(rodata_start)));
1289 free_init_pages("unused kernel",
1290 (unsigned long) __va(__pa_symbol(rodata_end)),
1291 (unsigned long) __va(__pa_symbol(_sdata)));
1292 1288
1293 debug_checkwx(); 1289 debug_checkwx();
1294} 1290}
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 3bded76e8d5c..0a74996a1149 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -53,6 +53,7 @@ static DEFINE_SPINLOCK(cpa_lock);
53#define CPA_FLUSHTLB 1 53#define CPA_FLUSHTLB 1
54#define CPA_ARRAY 2 54#define CPA_ARRAY 2
55#define CPA_PAGES_ARRAY 4 55#define CPA_PAGES_ARRAY 4
56#define CPA_NO_CHECK_ALIAS 8 /* Do not search for aliases */
56 57
57#ifdef CONFIG_PROC_FS 58#ifdef CONFIG_PROC_FS
58static unsigned long direct_pages_count[PG_LEVEL_NUM]; 59static unsigned long direct_pages_count[PG_LEVEL_NUM];
@@ -1486,6 +1487,9 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
1486 1487
1487 /* No alias checking for _NX bit modifications */ 1488 /* No alias checking for _NX bit modifications */
1488 checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX; 1489 checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX;
1490 /* Has caller explicitly disabled alias checking? */
1491 if (in_flag & CPA_NO_CHECK_ALIAS)
1492 checkalias = 0;
1489 1493
1490 ret = __change_page_attr_set_clr(&cpa, checkalias); 1494 ret = __change_page_attr_set_clr(&cpa, checkalias);
1491 1495
@@ -1772,6 +1776,15 @@ int set_memory_np(unsigned long addr, int numpages)
1772 return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0); 1776 return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_PRESENT), 0);
1773} 1777}
1774 1778
1779int set_memory_np_noalias(unsigned long addr, int numpages)
1780{
1781 int cpa_flags = CPA_NO_CHECK_ALIAS;
1782
1783 return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
1784 __pgprot(_PAGE_PRESENT), 0,
1785 cpa_flags, NULL);
1786}
1787
1775int set_memory_4k(unsigned long addr, int numpages) 1788int set_memory_4k(unsigned long addr, int numpages)
1776{ 1789{
1777 return change_page_attr_set_clr(&addr, numpages, __pgprot(0), 1790 return change_page_attr_set_clr(&addr, numpages, __pgprot(0),
@@ -1784,6 +1797,12 @@ int set_memory_nonglobal(unsigned long addr, int numpages)
1784 __pgprot(_PAGE_GLOBAL), 0); 1797 __pgprot(_PAGE_GLOBAL), 0);
1785} 1798}
1786 1799
1800int set_memory_global(unsigned long addr, int numpages)
1801{
1802 return change_page_attr_set(&addr, numpages,
1803 __pgprot(_PAGE_GLOBAL), 0);
1804}
1805
1787static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc) 1806static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc)
1788{ 1807{
1789 struct cpa_data cpa; 1808 struct cpa_data cpa;
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index bcf35dac1920..ef8db6ffc836 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -470,6 +470,13 @@ static inline bool pti_kernel_image_global_ok(void)
470} 470}
471 471
472/* 472/*
473 * This is the only user for these and it is not arch-generic
474 * like the other set_memory.h functions. Just extern them.
475 */
476extern int set_memory_nonglobal(unsigned long addr, int numpages);
477extern int set_memory_global(unsigned long addr, int numpages);
478
479/*
473 * For some configurations, map all of kernel text into the user page 480 * For some configurations, map all of kernel text into the user page
474 * tables. This reduces TLB misses, especially on non-PCID systems. 481 * tables. This reduces TLB misses, especially on non-PCID systems.
475 */ 482 */
@@ -481,7 +488,8 @@ static void pti_clone_kernel_text(void)
481 * clone the areas past rodata, they might contain secrets. 488 * clone the areas past rodata, they might contain secrets.
482 */ 489 */
483 unsigned long start = PFN_ALIGN(_text); 490 unsigned long start = PFN_ALIGN(_text);
484 unsigned long end = (unsigned long)__end_rodata_aligned; 491 unsigned long end_clone = (unsigned long)__end_rodata_aligned;
492 unsigned long end_global = PFN_ALIGN((unsigned long)__stop___ex_table);
485 493
486 if (!pti_kernel_image_global_ok()) 494 if (!pti_kernel_image_global_ok())
487 return; 495 return;
@@ -493,15 +501,19 @@ static void pti_clone_kernel_text(void)
493 * pti_set_kernel_image_nonglobal() did to clear the 501 * pti_set_kernel_image_nonglobal() did to clear the
494 * global bit. 502 * global bit.
495 */ 503 */
496 pti_clone_pmds(start, end, 0); 504 pti_clone_pmds(start, end_clone, _PAGE_RW);
505
506 /*
507 * pti_clone_pmds() will set the global bit in any PMDs
508 * that it clones, but we also need to get any PTEs in
509 * the last level for areas that are not huge-page-aligned.
510 */
511
512 /* Set the global bit for normal non-__init kernel text: */
513 set_memory_global(start, (end_global - start) >> PAGE_SHIFT);
497} 514}
498 515
499/* 516void pti_set_kernel_image_nonglobal(void)
500 * This is the only user for it and it is not arch-generic like
501 * the other set_memory.h functions. Just extern it.
502 */
503extern int set_memory_nonglobal(unsigned long addr, int numpages);
504static void pti_set_kernel_image_nonglobal(void)
505{ 517{
506 /* 518 /*
507 * The identity map is created with PMDs, regardless of the 519 * The identity map is created with PMDs, regardless of the
@@ -512,9 +524,11 @@ static void pti_set_kernel_image_nonglobal(void)
512 unsigned long start = PFN_ALIGN(_text); 524 unsigned long start = PFN_ALIGN(_text);
513 unsigned long end = ALIGN((unsigned long)_end, PMD_PAGE_SIZE); 525 unsigned long end = ALIGN((unsigned long)_end, PMD_PAGE_SIZE);
514 526
515 if (pti_kernel_image_global_ok()) 527 /*
516 return; 528 * This clears _PAGE_GLOBAL from the entire kernel image.
517 529 * pti_clone_kernel_text() map put _PAGE_GLOBAL back for
530 * areas that are mapped to userspace.
531 */
518 set_memory_nonglobal(start, (end - start) >> PAGE_SHIFT); 532 set_memory_nonglobal(start, (end - start) >> PAGE_SHIFT);
519} 533}
520 534
diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c
index 55799873ebe5..8f6cc71e0848 100644
--- a/arch/x86/net/bpf_jit_comp32.c
+++ b/arch/x86/net/bpf_jit_comp32.c
@@ -1441,8 +1441,8 @@ static void emit_prologue(u8 **pprog, u32 stack_depth)
1441 1441
1442 /* sub esp,STACK_SIZE */ 1442 /* sub esp,STACK_SIZE */
1443 EMIT2_off32(0x81, 0xEC, STACK_SIZE); 1443 EMIT2_off32(0x81, 0xEC, STACK_SIZE);
1444 /* sub ebp,SCRATCH_SIZE+4+12*/ 1444 /* sub ebp,SCRATCH_SIZE+12*/
1445 EMIT3(0x83, add_1reg(0xE8, IA32_EBP), SCRATCH_SIZE + 16); 1445 EMIT3(0x83, add_1reg(0xE8, IA32_EBP), SCRATCH_SIZE + 12);
1446 /* xor ebx,ebx */ 1446 /* xor ebx,ebx */
1447 EMIT2(0x31, add_2reg(0xC0, IA32_EBX, IA32_EBX)); 1447 EMIT2(0x31, add_2reg(0xC0, IA32_EBX, IA32_EBX));
1448 1448
@@ -1475,8 +1475,8 @@ static void emit_epilogue(u8 **pprog, u32 stack_depth)
1475 /* mov edx,dword ptr [ebp+off]*/ 1475 /* mov edx,dword ptr [ebp+off]*/
1476 EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EDX), STACK_VAR(r0[1])); 1476 EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EDX), STACK_VAR(r0[1]));
1477 1477
1478 /* add ebp,SCRATCH_SIZE+4+12*/ 1478 /* add ebp,SCRATCH_SIZE+12*/
1479 EMIT3(0x83, add_1reg(0xC0, IA32_EBP), SCRATCH_SIZE + 16); 1479 EMIT3(0x83, add_1reg(0xC0, IA32_EBP), SCRATCH_SIZE + 12);
1480 1480
1481 /* mov ebx,dword ptr [ebp-12]*/ 1481 /* mov ebx,dword ptr [ebp-12]*/
1482 EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EBX), -12); 1482 EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EBX), -12);
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 77873ce700ae..5f2eb3231607 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -417,7 +417,7 @@ static void __init __map_region(efi_memory_desc_t *md, u64 va)
417 if (!(md->attribute & EFI_MEMORY_WB)) 417 if (!(md->attribute & EFI_MEMORY_WB))
418 flags |= _PAGE_PCD; 418 flags |= _PAGE_PCD;
419 419
420 if (sev_active()) 420 if (sev_active() && md->type != EFI_MEMORY_MAPPED_IO)
421 flags |= _PAGE_ENC; 421 flags |= _PAGE_ENC;
422 422
423 pfn = md->phys_addr >> PAGE_SHIFT; 423 pfn = md->phys_addr >> PAGE_SHIFT;
diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
index 744afdc18cf3..56c44d865f7b 100644
--- a/arch/x86/um/mem_32.c
+++ b/arch/x86/um/mem_32.c
@@ -16,7 +16,7 @@ static int __init gate_vma_init(void)
16 if (!FIXADDR_USER_START) 16 if (!FIXADDR_USER_START)
17 return 0; 17 return 0;
18 18
19 gate_vma.vm_mm = NULL; 19 vma_init(&gate_vma, NULL);
20 gate_vma.vm_start = FIXADDR_USER_START; 20 gate_vma.vm_start = FIXADDR_USER_START;
21 gate_vma.vm_end = FIXADDR_USER_END; 21 gate_vma.vm_end = FIXADDR_USER_END;
22 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC; 22 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
diff --git a/block/bio.c b/block/bio.c
index 67eff5eddc49..047c5dca6d90 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -903,25 +903,27 @@ int bio_add_page(struct bio *bio, struct page *page,
903EXPORT_SYMBOL(bio_add_page); 903EXPORT_SYMBOL(bio_add_page);
904 904
905/** 905/**
906 * bio_iov_iter_get_pages - pin user or kernel pages and add them to a bio 906 * __bio_iov_iter_get_pages - pin user or kernel pages and add them to a bio
907 * @bio: bio to add pages to 907 * @bio: bio to add pages to
908 * @iter: iov iterator describing the region to be mapped 908 * @iter: iov iterator describing the region to be mapped
909 * 909 *
910 * Pins as many pages from *iter and appends them to @bio's bvec array. The 910 * Pins pages from *iter and appends them to @bio's bvec array. The
911 * pages will have to be released using put_page() when done. 911 * pages will have to be released using put_page() when done.
912 * For multi-segment *iter, this function only adds pages from the
913 * the next non-empty segment of the iov iterator.
912 */ 914 */
913int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) 915static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
914{ 916{
915 unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt; 917 unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt, idx;
916 struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; 918 struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt;
917 struct page **pages = (struct page **)bv; 919 struct page **pages = (struct page **)bv;
918 size_t offset, diff; 920 size_t offset;
919 ssize_t size; 921 ssize_t size;
920 922
921 size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); 923 size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset);
922 if (unlikely(size <= 0)) 924 if (unlikely(size <= 0))
923 return size ? size : -EFAULT; 925 return size ? size : -EFAULT;
924 nr_pages = (size + offset + PAGE_SIZE - 1) / PAGE_SIZE; 926 idx = nr_pages = (size + offset + PAGE_SIZE - 1) / PAGE_SIZE;
925 927
926 /* 928 /*
927 * Deep magic below: We need to walk the pinned pages backwards 929 * Deep magic below: We need to walk the pinned pages backwards
@@ -934,21 +936,46 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
934 bio->bi_iter.bi_size += size; 936 bio->bi_iter.bi_size += size;
935 bio->bi_vcnt += nr_pages; 937 bio->bi_vcnt += nr_pages;
936 938
937 diff = (nr_pages * PAGE_SIZE - offset) - size; 939 while (idx--) {
938 while (nr_pages--) { 940 bv[idx].bv_page = pages[idx];
939 bv[nr_pages].bv_page = pages[nr_pages]; 941 bv[idx].bv_len = PAGE_SIZE;
940 bv[nr_pages].bv_len = PAGE_SIZE; 942 bv[idx].bv_offset = 0;
941 bv[nr_pages].bv_offset = 0;
942 } 943 }
943 944
944 bv[0].bv_offset += offset; 945 bv[0].bv_offset += offset;
945 bv[0].bv_len -= offset; 946 bv[0].bv_len -= offset;
946 if (diff) 947 bv[nr_pages - 1].bv_len -= nr_pages * PAGE_SIZE - offset - size;
947 bv[bio->bi_vcnt - 1].bv_len -= diff;
948 948
949 iov_iter_advance(iter, size); 949 iov_iter_advance(iter, size);
950 return 0; 950 return 0;
951} 951}
952
953/**
954 * bio_iov_iter_get_pages - pin user or kernel pages and add them to a bio
955 * @bio: bio to add pages to
956 * @iter: iov iterator describing the region to be mapped
957 *
958 * Pins pages from *iter and appends them to @bio's bvec array. The
959 * pages will have to be released using put_page() when done.
960 * The function tries, but does not guarantee, to pin as many pages as
961 * fit into the bio, or are requested in *iter, whatever is smaller.
962 * If MM encounters an error pinning the requested pages, it stops.
963 * Error is returned only if 0 pages could be pinned.
964 */
965int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
966{
967 unsigned short orig_vcnt = bio->bi_vcnt;
968
969 do {
970 int ret = __bio_iov_iter_get_pages(bio, iter);
971
972 if (unlikely(ret))
973 return bio->bi_vcnt > orig_vcnt ? 0 : ret;
974
975 } while (iov_iter_count(iter) && !bio_full(bio));
976
977 return 0;
978}
952EXPORT_SYMBOL_GPL(bio_iov_iter_get_pages); 979EXPORT_SYMBOL_GPL(bio_iov_iter_get_pages);
953 980
954static void submit_bio_wait_endio(struct bio *bio) 981static void submit_bio_wait_endio(struct bio *bio)
@@ -1866,6 +1893,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
1866 bio_integrity_trim(split); 1893 bio_integrity_trim(split);
1867 1894
1868 bio_advance(bio, split->bi_iter.bi_size); 1895 bio_advance(bio, split->bi_iter.bi_size);
1896 bio->bi_iter.bi_done = 0;
1869 1897
1870 if (bio_flagged(bio, BIO_TRACE_COMPLETION)) 1898 if (bio_flagged(bio, BIO_TRACE_COMPLETION))
1871 bio_set_flag(split, BIO_TRACE_COMPLETION); 1899 bio_set_flag(split, BIO_TRACE_COMPLETION);
diff --git a/block/blk-core.c b/block/blk-core.c
index f84a9b7b6f5a..ee33590f54eb 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2155,11 +2155,12 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
2155 if (part->policy && op_is_write(bio_op(bio))) { 2155 if (part->policy && op_is_write(bio_op(bio))) {
2156 char b[BDEVNAME_SIZE]; 2156 char b[BDEVNAME_SIZE];
2157 2157
2158 printk(KERN_ERR 2158 WARN_ONCE(1,
2159 "generic_make_request: Trying to write " 2159 "generic_make_request: Trying to write "
2160 "to read-only block-device %s (partno %d)\n", 2160 "to read-only block-device %s (partno %d)\n",
2161 bio_devname(bio, b), part->partno); 2161 bio_devname(bio, b), part->partno);
2162 return true; 2162 /* Older lvm-tools actually trigger this */
2163 return false;
2163 } 2164 }
2164 2165
2165 return false; 2166 return false;
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 09b2ee6694fb..3de0836163c2 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -271,7 +271,7 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)
271 * test and set the bit before assining ->rqs[]. 271 * test and set the bit before assining ->rqs[].
272 */ 272 */
273 rq = tags->rqs[bitnr]; 273 rq = tags->rqs[bitnr];
274 if (rq && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) 274 if (rq && blk_mq_request_started(rq))
275 iter_data->fn(rq, iter_data->data, reserved); 275 iter_data->fn(rq, iter_data->data, reserved);
276 276
277 return true; 277 return true;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 95919268564b..654b0dc7e001 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -558,10 +558,8 @@ static void __blk_mq_complete_request(struct request *rq)
558 bool shared = false; 558 bool shared = false;
559 int cpu; 559 int cpu;
560 560
561 if (cmpxchg(&rq->state, MQ_RQ_IN_FLIGHT, MQ_RQ_COMPLETE) != 561 if (!blk_mq_mark_complete(rq))
562 MQ_RQ_IN_FLIGHT)
563 return; 562 return;
564
565 if (rq->internal_tag != -1) 563 if (rq->internal_tag != -1)
566 blk_mq_sched_completed_request(rq); 564 blk_mq_sched_completed_request(rq);
567 565
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 314c52c967e5..c166f424871c 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1155,8 +1155,10 @@ int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,
1155 1155
1156 /* make one iovec available as scatterlist */ 1156 /* make one iovec available as scatterlist */
1157 err = af_alg_make_sg(&rsgl->sgl, &msg->msg_iter, seglen); 1157 err = af_alg_make_sg(&rsgl->sgl, &msg->msg_iter, seglen);
1158 if (err < 0) 1158 if (err < 0) {
1159 rsgl->sg_num_bytes = 0;
1159 return err; 1160 return err;
1161 }
1160 1162
1161 /* chain the new scatterlist with previous one */ 1163 /* chain the new scatterlist with previous one */
1162 if (areq->last_rsgl) 1164 if (areq->last_rsgl)
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index f8fecfec5df9..9706613eecf9 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -879,6 +879,7 @@ static void acpi_lpss_dismiss(struct device *dev)
879#define LPSS_GPIODEF0_DMA_LLP BIT(13) 879#define LPSS_GPIODEF0_DMA_LLP BIT(13)
880 880
881static DEFINE_MUTEX(lpss_iosf_mutex); 881static DEFINE_MUTEX(lpss_iosf_mutex);
882static bool lpss_iosf_d3_entered;
882 883
883static void lpss_iosf_enter_d3_state(void) 884static void lpss_iosf_enter_d3_state(void)
884{ 885{
@@ -921,6 +922,9 @@ static void lpss_iosf_enter_d3_state(void)
921 922
922 iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE, 923 iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE,
923 LPSS_IOSF_GPIODEF0, value1, mask1); 924 LPSS_IOSF_GPIODEF0, value1, mask1);
925
926 lpss_iosf_d3_entered = true;
927
924exit: 928exit:
925 mutex_unlock(&lpss_iosf_mutex); 929 mutex_unlock(&lpss_iosf_mutex);
926} 930}
@@ -935,6 +939,11 @@ static void lpss_iosf_exit_d3_state(void)
935 939
936 mutex_lock(&lpss_iosf_mutex); 940 mutex_lock(&lpss_iosf_mutex);
937 941
942 if (!lpss_iosf_d3_entered)
943 goto exit;
944
945 lpss_iosf_d3_entered = false;
946
938 iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE, 947 iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE,
939 LPSS_IOSF_GPIODEF0, value1, mask1); 948 LPSS_IOSF_GPIODEF0, value1, mask1);
940 949
@@ -944,13 +953,13 @@ static void lpss_iosf_exit_d3_state(void)
944 iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO1, MBI_CFG_WRITE, 953 iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO1, MBI_CFG_WRITE,
945 LPSS_IOSF_PMCSR, value2, mask2); 954 LPSS_IOSF_PMCSR, value2, mask2);
946 955
956exit:
947 mutex_unlock(&lpss_iosf_mutex); 957 mutex_unlock(&lpss_iosf_mutex);
948} 958}
949 959
950static int acpi_lpss_suspend(struct device *dev, bool runtime) 960static int acpi_lpss_suspend(struct device *dev, bool wakeup)
951{ 961{
952 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); 962 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
953 bool wakeup = runtime || device_may_wakeup(dev);
954 int ret; 963 int ret;
955 964
956 if (pdata->dev_desc->flags & LPSS_SAVE_CTX) 965 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
@@ -963,14 +972,14 @@ static int acpi_lpss_suspend(struct device *dev, bool runtime)
963 * wrong status for devices being about to be powered off. See 972 * wrong status for devices being about to be powered off. See
964 * lpss_iosf_enter_d3_state() for further information. 973 * lpss_iosf_enter_d3_state() for further information.
965 */ 974 */
966 if ((runtime || !pm_suspend_via_firmware()) && 975 if (acpi_target_system_state() == ACPI_STATE_S0 &&
967 lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available()) 976 lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
968 lpss_iosf_enter_d3_state(); 977 lpss_iosf_enter_d3_state();
969 978
970 return ret; 979 return ret;
971} 980}
972 981
973static int acpi_lpss_resume(struct device *dev, bool runtime) 982static int acpi_lpss_resume(struct device *dev)
974{ 983{
975 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); 984 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
976 int ret; 985 int ret;
@@ -979,8 +988,7 @@ static int acpi_lpss_resume(struct device *dev, bool runtime)
979 * This call is kept first to be in symmetry with 988 * This call is kept first to be in symmetry with
980 * acpi_lpss_runtime_suspend() one. 989 * acpi_lpss_runtime_suspend() one.
981 */ 990 */
982 if ((runtime || !pm_resume_via_firmware()) && 991 if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
983 lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
984 lpss_iosf_exit_d3_state(); 992 lpss_iosf_exit_d3_state();
985 993
986 ret = acpi_dev_resume(dev); 994 ret = acpi_dev_resume(dev);
@@ -1004,12 +1012,12 @@ static int acpi_lpss_suspend_late(struct device *dev)
1004 return 0; 1012 return 0;
1005 1013
1006 ret = pm_generic_suspend_late(dev); 1014 ret = pm_generic_suspend_late(dev);
1007 return ret ? ret : acpi_lpss_suspend(dev, false); 1015 return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev));
1008} 1016}
1009 1017
1010static int acpi_lpss_resume_early(struct device *dev) 1018static int acpi_lpss_resume_early(struct device *dev)
1011{ 1019{
1012 int ret = acpi_lpss_resume(dev, false); 1020 int ret = acpi_lpss_resume(dev);
1013 1021
1014 return ret ? ret : pm_generic_resume_early(dev); 1022 return ret ? ret : pm_generic_resume_early(dev);
1015} 1023}
@@ -1024,7 +1032,7 @@ static int acpi_lpss_runtime_suspend(struct device *dev)
1024 1032
1025static int acpi_lpss_runtime_resume(struct device *dev) 1033static int acpi_lpss_runtime_resume(struct device *dev)
1026{ 1034{
1027 int ret = acpi_lpss_resume(dev, true); 1035 int ret = acpi_lpss_resume(dev);
1028 1036
1029 return ret ? ret : pm_generic_runtime_resume(dev); 1037 return ret ? ret : pm_generic_runtime_resume(dev);
1030} 1038}
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index bc5f05906bd1..44f35ab3347d 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -497,6 +497,18 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
497 status = 497 status =
498 acpi_ps_create_op(walk_state, aml_op_start, &op); 498 acpi_ps_create_op(walk_state, aml_op_start, &op);
499 if (ACPI_FAILURE(status)) { 499 if (ACPI_FAILURE(status)) {
500 /*
501 * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by
502 * executing it as a control method. However, if we encounter
503 * an error while loading the table, we need to keep trying to
504 * load the table rather than aborting the table load. Set the
505 * status to AE_OK to proceed with the table load.
506 */
507 if ((walk_state->
508 parse_flags & ACPI_PARSE_MODULE_LEVEL)
509 && status == AE_ALREADY_EXISTS) {
510 status = AE_OK;
511 }
500 if (status == AE_CTRL_PARSE_CONTINUE) { 512 if (status == AE_CTRL_PARSE_CONTINUE) {
501 continue; 513 continue;
502 } 514 }
@@ -694,6 +706,25 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
694 acpi_ps_next_parse_state(walk_state, op, status); 706 acpi_ps_next_parse_state(walk_state, op, status);
695 if (status == AE_CTRL_PENDING) { 707 if (status == AE_CTRL_PENDING) {
696 status = AE_OK; 708 status = AE_OK;
709 } else
710 if ((walk_state->
711 parse_flags & ACPI_PARSE_MODULE_LEVEL)
712 && status != AE_CTRL_TRANSFER
713 && ACPI_FAILURE(status)) {
714 /*
715 * ACPI_PARSE_MODULE_LEVEL flag means that we are currently
716 * loading a table by executing it as a control method.
717 * However, if we encounter an error while loading the table,
718 * we need to keep trying to load the table rather than
719 * aborting the table load (setting the status to AE_OK
720 * continues the table load). If we get a failure at this
721 * point, it means that the dispatcher got an error while
722 * processing Op (most likely an AML operand error) or a
723 * control method was called from module level and the
724 * dispatcher returned AE_CTRL_TRANSFER. In the latter case,
725 * leave the status alone, there's nothing wrong with it.
726 */
727 status = AE_OK;
697 } 728 }
698 } 729 }
699 730
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 442a9e24f439..917f77f4cb55 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -2042,7 +2042,7 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = {
2042 .ident = "Thinkpad X1 Carbon 6th", 2042 .ident = "Thinkpad X1 Carbon 6th",
2043 .matches = { 2043 .matches = {
2044 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 2044 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2045 DMI_MATCH(DMI_PRODUCT_NAME, "20KGS3JF01"), 2045 DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"),
2046 }, 2046 },
2047 }, 2047 },
2048 { }, 2048 { },
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 1435d7281c66..6ebcd65d64b6 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -434,14 +434,6 @@ re_probe:
434 goto probe_failed; 434 goto probe_failed;
435 } 435 }
436 436
437 /*
438 * Ensure devices are listed in devices_kset in correct order
439 * It's important to move Dev to the end of devices_kset before
440 * calling .probe, because it could be recursive and parent Dev
441 * should always go first
442 */
443 devices_kset_move_last(dev);
444
445 if (dev->bus->probe) { 437 if (dev->bus->probe) {
446 ret = dev->bus->probe(dev); 438 ret = dev->bus->probe(dev);
447 if (ret) 439 if (ret)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 74a05561b620..3fb95c8d9fd8 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -112,12 +112,16 @@ struct nbd_device {
112 struct task_struct *task_setup; 112 struct task_struct *task_setup;
113}; 113};
114 114
115#define NBD_CMD_REQUEUED 1
116
115struct nbd_cmd { 117struct nbd_cmd {
116 struct nbd_device *nbd; 118 struct nbd_device *nbd;
119 struct mutex lock;
117 int index; 120 int index;
118 int cookie; 121 int cookie;
119 struct completion send_complete;
120 blk_status_t status; 122 blk_status_t status;
123 unsigned long flags;
124 u32 cmd_cookie;
121}; 125};
122 126
123#if IS_ENABLED(CONFIG_DEBUG_FS) 127#if IS_ENABLED(CONFIG_DEBUG_FS)
@@ -146,6 +150,35 @@ static inline struct device *nbd_to_dev(struct nbd_device *nbd)
146 return disk_to_dev(nbd->disk); 150 return disk_to_dev(nbd->disk);
147} 151}
148 152
153static void nbd_requeue_cmd(struct nbd_cmd *cmd)
154{
155 struct request *req = blk_mq_rq_from_pdu(cmd);
156
157 if (!test_and_set_bit(NBD_CMD_REQUEUED, &cmd->flags))
158 blk_mq_requeue_request(req, true);
159}
160
161#define NBD_COOKIE_BITS 32
162
163static u64 nbd_cmd_handle(struct nbd_cmd *cmd)
164{
165 struct request *req = blk_mq_rq_from_pdu(cmd);
166 u32 tag = blk_mq_unique_tag(req);
167 u64 cookie = cmd->cmd_cookie;
168
169 return (cookie << NBD_COOKIE_BITS) | tag;
170}
171
172static u32 nbd_handle_to_tag(u64 handle)
173{
174 return (u32)handle;
175}
176
177static u32 nbd_handle_to_cookie(u64 handle)
178{
179 return (u32)(handle >> NBD_COOKIE_BITS);
180}
181
149static const char *nbdcmd_to_ascii(int cmd) 182static const char *nbdcmd_to_ascii(int cmd)
150{ 183{
151 switch (cmd) { 184 switch (cmd) {
@@ -319,6 +352,9 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
319 } 352 }
320 config = nbd->config; 353 config = nbd->config;
321 354
355 if (!mutex_trylock(&cmd->lock))
356 return BLK_EH_RESET_TIMER;
357
322 if (config->num_connections > 1) { 358 if (config->num_connections > 1) {
323 dev_err_ratelimited(nbd_to_dev(nbd), 359 dev_err_ratelimited(nbd_to_dev(nbd),
324 "Connection timed out, retrying (%d/%d alive)\n", 360 "Connection timed out, retrying (%d/%d alive)\n",
@@ -343,7 +379,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
343 nbd_mark_nsock_dead(nbd, nsock, 1); 379 nbd_mark_nsock_dead(nbd, nsock, 1);
344 mutex_unlock(&nsock->tx_lock); 380 mutex_unlock(&nsock->tx_lock);
345 } 381 }
346 blk_mq_requeue_request(req, true); 382 mutex_unlock(&cmd->lock);
383 nbd_requeue_cmd(cmd);
347 nbd_config_put(nbd); 384 nbd_config_put(nbd);
348 return BLK_EH_DONE; 385 return BLK_EH_DONE;
349 } 386 }
@@ -353,6 +390,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
353 } 390 }
354 set_bit(NBD_TIMEDOUT, &config->runtime_flags); 391 set_bit(NBD_TIMEDOUT, &config->runtime_flags);
355 cmd->status = BLK_STS_IOERR; 392 cmd->status = BLK_STS_IOERR;
393 mutex_unlock(&cmd->lock);
356 sock_shutdown(nbd); 394 sock_shutdown(nbd);
357 nbd_config_put(nbd); 395 nbd_config_put(nbd);
358done: 396done:
@@ -430,9 +468,9 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
430 struct iov_iter from; 468 struct iov_iter from;
431 unsigned long size = blk_rq_bytes(req); 469 unsigned long size = blk_rq_bytes(req);
432 struct bio *bio; 470 struct bio *bio;
471 u64 handle;
433 u32 type; 472 u32 type;
434 u32 nbd_cmd_flags = 0; 473 u32 nbd_cmd_flags = 0;
435 u32 tag = blk_mq_unique_tag(req);
436 int sent = nsock->sent, skip = 0; 474 int sent = nsock->sent, skip = 0;
437 475
438 iov_iter_kvec(&from, WRITE | ITER_KVEC, &iov, 1, sizeof(request)); 476 iov_iter_kvec(&from, WRITE | ITER_KVEC, &iov, 1, sizeof(request));
@@ -474,6 +512,8 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
474 goto send_pages; 512 goto send_pages;
475 } 513 }
476 iov_iter_advance(&from, sent); 514 iov_iter_advance(&from, sent);
515 } else {
516 cmd->cmd_cookie++;
477 } 517 }
478 cmd->index = index; 518 cmd->index = index;
479 cmd->cookie = nsock->cookie; 519 cmd->cookie = nsock->cookie;
@@ -482,7 +522,8 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
482 request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9); 522 request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
483 request.len = htonl(size); 523 request.len = htonl(size);
484 } 524 }
485 memcpy(request.handle, &tag, sizeof(tag)); 525 handle = nbd_cmd_handle(cmd);
526 memcpy(request.handle, &handle, sizeof(handle));
486 527
487 dev_dbg(nbd_to_dev(nbd), "request %p: sending control (%s@%llu,%uB)\n", 528 dev_dbg(nbd_to_dev(nbd), "request %p: sending control (%s@%llu,%uB)\n",
488 req, nbdcmd_to_ascii(type), 529 req, nbdcmd_to_ascii(type),
@@ -500,6 +541,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
500 nsock->pending = req; 541 nsock->pending = req;
501 nsock->sent = sent; 542 nsock->sent = sent;
502 } 543 }
544 set_bit(NBD_CMD_REQUEUED, &cmd->flags);
503 return BLK_STS_RESOURCE; 545 return BLK_STS_RESOURCE;
504 } 546 }
505 dev_err_ratelimited(disk_to_dev(nbd->disk), 547 dev_err_ratelimited(disk_to_dev(nbd->disk),
@@ -541,6 +583,7 @@ send_pages:
541 */ 583 */
542 nsock->pending = req; 584 nsock->pending = req;
543 nsock->sent = sent; 585 nsock->sent = sent;
586 set_bit(NBD_CMD_REQUEUED, &cmd->flags);
544 return BLK_STS_RESOURCE; 587 return BLK_STS_RESOURCE;
545 } 588 }
546 dev_err(disk_to_dev(nbd->disk), 589 dev_err(disk_to_dev(nbd->disk),
@@ -573,10 +616,12 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
573 struct nbd_reply reply; 616 struct nbd_reply reply;
574 struct nbd_cmd *cmd; 617 struct nbd_cmd *cmd;
575 struct request *req = NULL; 618 struct request *req = NULL;
619 u64 handle;
576 u16 hwq; 620 u16 hwq;
577 u32 tag; 621 u32 tag;
578 struct kvec iov = {.iov_base = &reply, .iov_len = sizeof(reply)}; 622 struct kvec iov = {.iov_base = &reply, .iov_len = sizeof(reply)};
579 struct iov_iter to; 623 struct iov_iter to;
624 int ret = 0;
580 625
581 reply.magic = 0; 626 reply.magic = 0;
582 iov_iter_kvec(&to, READ | ITER_KVEC, &iov, 1, sizeof(reply)); 627 iov_iter_kvec(&to, READ | ITER_KVEC, &iov, 1, sizeof(reply));
@@ -594,8 +639,8 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
594 return ERR_PTR(-EPROTO); 639 return ERR_PTR(-EPROTO);
595 } 640 }
596 641
597 memcpy(&tag, reply.handle, sizeof(u32)); 642 memcpy(&handle, reply.handle, sizeof(handle));
598 643 tag = nbd_handle_to_tag(handle);
599 hwq = blk_mq_unique_tag_to_hwq(tag); 644 hwq = blk_mq_unique_tag_to_hwq(tag);
600 if (hwq < nbd->tag_set.nr_hw_queues) 645 if (hwq < nbd->tag_set.nr_hw_queues)
601 req = blk_mq_tag_to_rq(nbd->tag_set.tags[hwq], 646 req = blk_mq_tag_to_rq(nbd->tag_set.tags[hwq],
@@ -606,11 +651,25 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
606 return ERR_PTR(-ENOENT); 651 return ERR_PTR(-ENOENT);
607 } 652 }
608 cmd = blk_mq_rq_to_pdu(req); 653 cmd = blk_mq_rq_to_pdu(req);
654
655 mutex_lock(&cmd->lock);
656 if (cmd->cmd_cookie != nbd_handle_to_cookie(handle)) {
657 dev_err(disk_to_dev(nbd->disk), "Double reply on req %p, cmd_cookie %u, handle cookie %u\n",
658 req, cmd->cmd_cookie, nbd_handle_to_cookie(handle));
659 ret = -ENOENT;
660 goto out;
661 }
662 if (test_bit(NBD_CMD_REQUEUED, &cmd->flags)) {
663 dev_err(disk_to_dev(nbd->disk), "Raced with timeout on req %p\n",
664 req);
665 ret = -ENOENT;
666 goto out;
667 }
609 if (ntohl(reply.error)) { 668 if (ntohl(reply.error)) {
610 dev_err(disk_to_dev(nbd->disk), "Other side returned error (%d)\n", 669 dev_err(disk_to_dev(nbd->disk), "Other side returned error (%d)\n",
611 ntohl(reply.error)); 670 ntohl(reply.error));
612 cmd->status = BLK_STS_IOERR; 671 cmd->status = BLK_STS_IOERR;
613 return cmd; 672 goto out;
614 } 673 }
615 674
616 dev_dbg(nbd_to_dev(nbd), "request %p: got reply\n", req); 675 dev_dbg(nbd_to_dev(nbd), "request %p: got reply\n", req);
@@ -635,18 +694,18 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
635 if (nbd_disconnected(config) || 694 if (nbd_disconnected(config) ||
636 config->num_connections <= 1) { 695 config->num_connections <= 1) {
637 cmd->status = BLK_STS_IOERR; 696 cmd->status = BLK_STS_IOERR;
638 return cmd; 697 goto out;
639 } 698 }
640 return ERR_PTR(-EIO); 699 ret = -EIO;
700 goto out;
641 } 701 }
642 dev_dbg(nbd_to_dev(nbd), "request %p: got %d bytes data\n", 702 dev_dbg(nbd_to_dev(nbd), "request %p: got %d bytes data\n",
643 req, bvec.bv_len); 703 req, bvec.bv_len);
644 } 704 }
645 } else {
646 /* See the comment in nbd_queue_rq. */
647 wait_for_completion(&cmd->send_complete);
648 } 705 }
649 return cmd; 706out:
707 mutex_unlock(&cmd->lock);
708 return ret ? ERR_PTR(ret) : cmd;
650} 709}
651 710
652static void recv_work(struct work_struct *work) 711static void recv_work(struct work_struct *work)
@@ -805,7 +864,7 @@ again:
805 */ 864 */
806 blk_mq_start_request(req); 865 blk_mq_start_request(req);
807 if (unlikely(nsock->pending && nsock->pending != req)) { 866 if (unlikely(nsock->pending && nsock->pending != req)) {
808 blk_mq_requeue_request(req, true); 867 nbd_requeue_cmd(cmd);
809 ret = 0; 868 ret = 0;
810 goto out; 869 goto out;
811 } 870 }
@@ -818,7 +877,7 @@ again:
818 dev_err_ratelimited(disk_to_dev(nbd->disk), 877 dev_err_ratelimited(disk_to_dev(nbd->disk),
819 "Request send failed, requeueing\n"); 878 "Request send failed, requeueing\n");
820 nbd_mark_nsock_dead(nbd, nsock, 1); 879 nbd_mark_nsock_dead(nbd, nsock, 1);
821 blk_mq_requeue_request(req, true); 880 nbd_requeue_cmd(cmd);
822 ret = 0; 881 ret = 0;
823 } 882 }
824out: 883out:
@@ -842,7 +901,8 @@ static blk_status_t nbd_queue_rq(struct blk_mq_hw_ctx *hctx,
842 * that the server is misbehaving (or there was an error) before we're 901 * that the server is misbehaving (or there was an error) before we're
843 * done sending everything over the wire. 902 * done sending everything over the wire.
844 */ 903 */
845 init_completion(&cmd->send_complete); 904 mutex_lock(&cmd->lock);
905 clear_bit(NBD_CMD_REQUEUED, &cmd->flags);
846 906
847 /* We can be called directly from the user space process, which means we 907 /* We can be called directly from the user space process, which means we
848 * could possibly have signals pending so our sendmsg will fail. In 908 * could possibly have signals pending so our sendmsg will fail. In
@@ -854,7 +914,7 @@ static blk_status_t nbd_queue_rq(struct blk_mq_hw_ctx *hctx,
854 ret = BLK_STS_IOERR; 914 ret = BLK_STS_IOERR;
855 else if (!ret) 915 else if (!ret)
856 ret = BLK_STS_OK; 916 ret = BLK_STS_OK;
857 complete(&cmd->send_complete); 917 mutex_unlock(&cmd->lock);
858 918
859 return ret; 919 return ret;
860} 920}
@@ -1460,6 +1520,8 @@ static int nbd_init_request(struct blk_mq_tag_set *set, struct request *rq,
1460{ 1520{
1461 struct nbd_cmd *cmd = blk_mq_rq_to_pdu(rq); 1521 struct nbd_cmd *cmd = blk_mq_rq_to_pdu(rq);
1462 cmd->nbd = set->driver_data; 1522 cmd->nbd = set->driver_data;
1523 cmd->flags = 0;
1524 mutex_init(&cmd->lock);
1463 return 0; 1525 return 0;
1464} 1526}
1465 1527
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index 53fe633df1e8..c9bf2c219841 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -11,7 +11,7 @@
11 11
12#include "agp.h" 12#include "agp.h"
13 13
14static int alpha_core_agp_vm_fault(struct vm_fault *vmf) 14static vm_fault_t alpha_core_agp_vm_fault(struct vm_fault *vmf)
15{ 15{
16 alpha_agp_info *agp = agp_bridge->dev_private_data; 16 alpha_agp_info *agp = agp_bridge->dev_private_data;
17 dma_addr_t dma_addr; 17 dma_addr_t dma_addr;
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index e50c29c97ca7..c69e39fdd02b 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -156,7 +156,7 @@ static u64 amd64_configure(struct pci_dev *hammer, u64 gatt_table)
156 156
157 /* Address to map to */ 157 /* Address to map to */
158 pci_read_config_dword(hammer, AMD64_GARTAPERTUREBASE, &tmp); 158 pci_read_config_dword(hammer, AMD64_GARTAPERTUREBASE, &tmp);
159 aperturebase = tmp << 25; 159 aperturebase = (u64)tmp << 25;
160 aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK); 160 aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK);
161 161
162 enable_gart_translation(hammer, gatt_table); 162 enable_gart_translation(hammer, gatt_table);
@@ -277,7 +277,7 @@ static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap)
277 pci_read_config_dword(nb, AMD64_GARTAPERTURECTL, &nb_order); 277 pci_read_config_dword(nb, AMD64_GARTAPERTURECTL, &nb_order);
278 nb_order = (nb_order >> 1) & 7; 278 nb_order = (nb_order >> 1) & 7;
279 pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base); 279 pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base);
280 nb_aper = nb_base << 25; 280 nb_aper = (u64)nb_base << 25;
281 281
282 /* Northbridge seems to contain crap. Try the AGP bridge. */ 282 /* Northbridge seems to contain crap. Try the AGP bridge. */
283 283
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index ffeb60d3434c..df66a9dd0aae 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -708,6 +708,7 @@ static int mmap_zero(struct file *file, struct vm_area_struct *vma)
708#endif 708#endif
709 if (vma->vm_flags & VM_SHARED) 709 if (vma->vm_flags & VM_SHARED)
710 return shmem_zero_setup(vma); 710 return shmem_zero_setup(vma);
711 vma_set_anonymous(vma);
711 return 0; 712 return 0;
712} 713}
713 714
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cd888d4ee605..bd449ad52442 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1895,14 +1895,22 @@ static int
1895write_pool(struct entropy_store *r, const char __user *buffer, size_t count) 1895write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1896{ 1896{
1897 size_t bytes; 1897 size_t bytes;
1898 __u32 buf[16]; 1898 __u32 t, buf[16];
1899 const char __user *p = buffer; 1899 const char __user *p = buffer;
1900 1900
1901 while (count > 0) { 1901 while (count > 0) {
1902 int b, i = 0;
1903
1902 bytes = min(count, sizeof(buf)); 1904 bytes = min(count, sizeof(buf));
1903 if (copy_from_user(&buf, p, bytes)) 1905 if (copy_from_user(&buf, p, bytes))
1904 return -EFAULT; 1906 return -EFAULT;
1905 1907
1908 for (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) {
1909 if (!arch_get_random_int(&t))
1910 break;
1911 buf[i] ^= t;
1912 }
1913
1906 count -= bytes; 1914 count -= bytes;
1907 p += bytes; 1915 p += bytes;
1908 1916
diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c
index 38b366b00c57..7b70a074095d 100644
--- a/drivers/clk/clk-aspeed.c
+++ b/drivers/clk/clk-aspeed.c
@@ -24,7 +24,7 @@
24#define ASPEED_MPLL_PARAM 0x20 24#define ASPEED_MPLL_PARAM 0x20
25#define ASPEED_HPLL_PARAM 0x24 25#define ASPEED_HPLL_PARAM 0x24
26#define AST2500_HPLL_BYPASS_EN BIT(20) 26#define AST2500_HPLL_BYPASS_EN BIT(20)
27#define AST2400_HPLL_STRAPPED BIT(18) 27#define AST2400_HPLL_PROGRAMMED BIT(18)
28#define AST2400_HPLL_BYPASS_EN BIT(17) 28#define AST2400_HPLL_BYPASS_EN BIT(17)
29#define ASPEED_MISC_CTRL 0x2c 29#define ASPEED_MISC_CTRL 0x2c
30#define UART_DIV13_EN BIT(12) 30#define UART_DIV13_EN BIT(12)
@@ -91,8 +91,8 @@ static const struct aspeed_gate_data aspeed_gates[] = {
91 [ASPEED_CLK_GATE_GCLK] = { 1, 7, "gclk-gate", NULL, 0 }, /* 2D engine */ 91 [ASPEED_CLK_GATE_GCLK] = { 1, 7, "gclk-gate", NULL, 0 }, /* 2D engine */
92 [ASPEED_CLK_GATE_MCLK] = { 2, -1, "mclk-gate", "mpll", CLK_IS_CRITICAL }, /* SDRAM */ 92 [ASPEED_CLK_GATE_MCLK] = { 2, -1, "mclk-gate", "mpll", CLK_IS_CRITICAL }, /* SDRAM */
93 [ASPEED_CLK_GATE_VCLK] = { 3, 6, "vclk-gate", NULL, 0 }, /* Video Capture */ 93 [ASPEED_CLK_GATE_VCLK] = { 3, 6, "vclk-gate", NULL, 0 }, /* Video Capture */
94 [ASPEED_CLK_GATE_BCLK] = { 4, 8, "bclk-gate", "bclk", 0 }, /* PCIe/PCI */ 94 [ASPEED_CLK_GATE_BCLK] = { 4, 8, "bclk-gate", "bclk", CLK_IS_CRITICAL }, /* PCIe/PCI */
95 [ASPEED_CLK_GATE_DCLK] = { 5, -1, "dclk-gate", NULL, 0 }, /* DAC */ 95 [ASPEED_CLK_GATE_DCLK] = { 5, -1, "dclk-gate", NULL, CLK_IS_CRITICAL }, /* DAC */
96 [ASPEED_CLK_GATE_REFCLK] = { 6, -1, "refclk-gate", "clkin", CLK_IS_CRITICAL }, 96 [ASPEED_CLK_GATE_REFCLK] = { 6, -1, "refclk-gate", "clkin", CLK_IS_CRITICAL },
97 [ASPEED_CLK_GATE_USBPORT2CLK] = { 7, 3, "usb-port2-gate", NULL, 0 }, /* USB2.0 Host port 2 */ 97 [ASPEED_CLK_GATE_USBPORT2CLK] = { 7, 3, "usb-port2-gate", NULL, 0 }, /* USB2.0 Host port 2 */
98 [ASPEED_CLK_GATE_LCLK] = { 8, 5, "lclk-gate", NULL, 0 }, /* LPC */ 98 [ASPEED_CLK_GATE_LCLK] = { 8, 5, "lclk-gate", NULL, 0 }, /* LPC */
@@ -212,9 +212,22 @@ static int aspeed_clk_is_enabled(struct clk_hw *hw)
212{ 212{
213 struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw); 213 struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
214 u32 clk = BIT(gate->clock_idx); 214 u32 clk = BIT(gate->clock_idx);
215 u32 rst = BIT(gate->reset_idx);
215 u32 enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk; 216 u32 enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk;
216 u32 reg; 217 u32 reg;
217 218
219 /*
220 * If the IP is in reset, treat the clock as not enabled,
221 * this happens with some clocks such as the USB one when
222 * coming from cold reset. Without this, aspeed_clk_enable()
223 * will fail to lift the reset.
224 */
225 if (gate->reset_idx >= 0) {
226 regmap_read(gate->map, ASPEED_RESET_CTRL, &reg);
227 if (reg & rst)
228 return 0;
229 }
230
218 regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, &reg); 231 regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, &reg);
219 232
220 return ((reg & clk) == enval) ? 1 : 0; 233 return ((reg & clk) == enval) ? 1 : 0;
@@ -565,29 +578,45 @@ builtin_platform_driver(aspeed_clk_driver);
565static void __init aspeed_ast2400_cc(struct regmap *map) 578static void __init aspeed_ast2400_cc(struct regmap *map)
566{ 579{
567 struct clk_hw *hw; 580 struct clk_hw *hw;
568 u32 val, freq, div; 581 u32 val, div, clkin, hpll;
582 const u16 hpll_rates[][4] = {
583 {384, 360, 336, 408},
584 {400, 375, 350, 425},
585 };
586 int rate;
569 587
570 /* 588 /*
571 * CLKIN is the crystal oscillator, 24, 48 or 25MHz selected by 589 * CLKIN is the crystal oscillator, 24, 48 or 25MHz selected by
572 * strapping 590 * strapping
573 */ 591 */
574 regmap_read(map, ASPEED_STRAP, &val); 592 regmap_read(map, ASPEED_STRAP, &val);
575 if (val & CLKIN_25MHZ_EN) 593 rate = (val >> 8) & 3;
576 freq = 25000000; 594 if (val & CLKIN_25MHZ_EN) {
577 else if (val & AST2400_CLK_SOURCE_SEL) 595 clkin = 25000000;
578 freq = 48000000; 596 hpll = hpll_rates[1][rate];
579 else 597 } else if (val & AST2400_CLK_SOURCE_SEL) {
580 freq = 24000000; 598 clkin = 48000000;
581 hw = clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, freq); 599 hpll = hpll_rates[0][rate];
582 pr_debug("clkin @%u MHz\n", freq / 1000000); 600 } else {
601 clkin = 24000000;
602 hpll = hpll_rates[0][rate];
603 }
604 hw = clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, clkin);
605 pr_debug("clkin @%u MHz\n", clkin / 1000000);
583 606
584 /* 607 /*
585 * High-speed PLL clock derived from the crystal. This the CPU clock, 608 * High-speed PLL clock derived from the crystal. This the CPU clock,
586 * and we assume that it is enabled 609 * and we assume that it is enabled. It can be configured through the
610 * HPLL_PARAM register, or set to a specified frequency by strapping.
587 */ 611 */
588 regmap_read(map, ASPEED_HPLL_PARAM, &val); 612 regmap_read(map, ASPEED_HPLL_PARAM, &val);
589 WARN(val & AST2400_HPLL_STRAPPED, "hpll is strapped not configured"); 613 if (val & AST2400_HPLL_PROGRAMMED)
590 aspeed_clk_data->hws[ASPEED_CLK_HPLL] = aspeed_ast2400_calc_pll("hpll", val); 614 hw = aspeed_ast2400_calc_pll("hpll", val);
615 else
616 hw = clk_hw_register_fixed_rate(NULL, "hpll", "clkin", 0,
617 hpll * 1000000);
618
619 aspeed_clk_data->hws[ASPEED_CLK_HPLL] = hw;
591 620
592 /* 621 /*
593 * Strap bits 11:10 define the CPU/AHB clock frequency ratio (aka HCLK) 622 * Strap bits 11:10 define the CPU/AHB clock frequency ratio (aka HCLK)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 9760b526ca31..e2ed078abd90 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -24,7 +24,6 @@
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/clkdev.h> 26#include <linux/clkdev.h>
27#include <linux/stringify.h>
28 27
29#include "clk.h" 28#include "clk.h"
30 29
@@ -2559,7 +2558,7 @@ static const struct {
2559 unsigned long flag; 2558 unsigned long flag;
2560 const char *name; 2559 const char *name;
2561} clk_flags[] = { 2560} clk_flags[] = {
2562#define ENTRY(f) { f, __stringify(f) } 2561#define ENTRY(f) { f, #f }
2563 ENTRY(CLK_SET_RATE_GATE), 2562 ENTRY(CLK_SET_RATE_GATE),
2564 ENTRY(CLK_SET_PARENT_GATE), 2563 ENTRY(CLK_SET_PARENT_GATE),
2565 ENTRY(CLK_SET_RATE_PARENT), 2564 ENTRY(CLK_SET_RATE_PARENT),
diff --git a/drivers/clk/meson/clk-audio-divider.c b/drivers/clk/meson/clk-audio-divider.c
index 58f546e04807..e4cf96ba704e 100644
--- a/drivers/clk/meson/clk-audio-divider.c
+++ b/drivers/clk/meson/clk-audio-divider.c
@@ -51,7 +51,7 @@ static unsigned long audio_divider_recalc_rate(struct clk_hw *hw,
51 struct meson_clk_audio_div_data *adiv = meson_clk_audio_div_data(clk); 51 struct meson_clk_audio_div_data *adiv = meson_clk_audio_div_data(clk);
52 unsigned long divider; 52 unsigned long divider;
53 53
54 divider = meson_parm_read(clk->map, &adiv->div); 54 divider = meson_parm_read(clk->map, &adiv->div) + 1;
55 55
56 return DIV_ROUND_UP_ULL((u64)parent_rate, divider); 56 return DIV_ROUND_UP_ULL((u64)parent_rate, divider);
57} 57}
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 240658404367..177fffb9ebef 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -498,6 +498,7 @@ static struct clk_regmap gxbb_fclk_div2 = {
498 .ops = &clk_regmap_gate_ops, 498 .ops = &clk_regmap_gate_ops,
499 .parent_names = (const char *[]){ "fclk_div2_div" }, 499 .parent_names = (const char *[]){ "fclk_div2_div" },
500 .num_parents = 1, 500 .num_parents = 1,
501 .flags = CLK_IS_CRITICAL,
501 }, 502 },
502}; 503};
503 504
diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c
index 6860bd5a37c5..44e4e27eddad 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -35,6 +35,7 @@
35#define CLK_SEL 0x10 35#define CLK_SEL 0x10
36#define CLK_DIS 0x14 36#define CLK_DIS 0x14
37 37
38#define ARMADA_37XX_DVFS_LOAD_1 1
38#define LOAD_LEVEL_NR 4 39#define LOAD_LEVEL_NR 4
39 40
40#define ARMADA_37XX_NB_L0L1 0x18 41#define ARMADA_37XX_NB_L0L1 0x18
@@ -507,6 +508,40 @@ static long clk_pm_cpu_round_rate(struct clk_hw *hw, unsigned long rate,
507 return -EINVAL; 508 return -EINVAL;
508} 509}
509 510
511/*
512 * Switching the CPU from the L2 or L3 frequencies (300 and 200 Mhz
513 * respectively) to L0 frequency (1.2 Ghz) requires a significant
514 * amount of time to let VDD stabilize to the appropriate
515 * voltage. This amount of time is large enough that it cannot be
516 * covered by the hardware countdown register. Due to this, the CPU
517 * might start operating at L0 before the voltage is stabilized,
518 * leading to CPU stalls.
519 *
520 * To work around this problem, we prevent switching directly from the
521 * L2/L3 frequencies to the L0 frequency, and instead switch to the L1
522 * frequency in-between. The sequence therefore becomes:
523 * 1. First switch from L2/L3(200/300MHz) to L1(600MHZ)
524 * 2. Sleep 20ms for stabling VDD voltage
525 * 3. Then switch from L1(600MHZ) to L0(1200Mhz).
526 */
527static void clk_pm_cpu_set_rate_wa(unsigned long rate, struct regmap *base)
528{
529 unsigned int cur_level;
530
531 if (rate != 1200 * 1000 * 1000)
532 return;
533
534 regmap_read(base, ARMADA_37XX_NB_CPU_LOAD, &cur_level);
535 cur_level &= ARMADA_37XX_NB_CPU_LOAD_MASK;
536 if (cur_level <= ARMADA_37XX_DVFS_LOAD_1)
537 return;
538
539 regmap_update_bits(base, ARMADA_37XX_NB_CPU_LOAD,
540 ARMADA_37XX_NB_CPU_LOAD_MASK,
541 ARMADA_37XX_DVFS_LOAD_1);
542 msleep(20);
543}
544
510static int clk_pm_cpu_set_rate(struct clk_hw *hw, unsigned long rate, 545static int clk_pm_cpu_set_rate(struct clk_hw *hw, unsigned long rate,
511 unsigned long parent_rate) 546 unsigned long parent_rate)
512{ 547{
@@ -537,6 +572,9 @@ static int clk_pm_cpu_set_rate(struct clk_hw *hw, unsigned long rate,
537 */ 572 */
538 reg = ARMADA_37XX_NB_CPU_LOAD; 573 reg = ARMADA_37XX_NB_CPU_LOAD;
539 mask = ARMADA_37XX_NB_CPU_LOAD_MASK; 574 mask = ARMADA_37XX_NB_CPU_LOAD_MASK;
575
576 clk_pm_cpu_set_rate_wa(rate, base);
577
540 regmap_update_bits(base, reg, mask, load_level); 578 regmap_update_bits(base, reg, mask, load_level);
541 579
542 return rate; 580 return rate;
diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
index 9f35b3fe1d97..ff8d66fd94e6 100644
--- a/drivers/clk/qcom/gcc-msm8996.c
+++ b/drivers/clk/qcom/gcc-msm8996.c
@@ -2781,6 +2781,7 @@ static struct clk_branch gcc_ufs_rx_cfg_clk = {
2781 2781
2782static struct clk_branch gcc_ufs_tx_symbol_0_clk = { 2782static struct clk_branch gcc_ufs_tx_symbol_0_clk = {
2783 .halt_reg = 0x75018, 2783 .halt_reg = 0x75018,
2784 .halt_check = BRANCH_HALT_SKIP,
2784 .clkr = { 2785 .clkr = {
2785 .enable_reg = 0x75018, 2786 .enable_reg = 0x75018,
2786 .enable_mask = BIT(0), 2787 .enable_mask = BIT(0),
diff --git a/drivers/clk/qcom/mmcc-msm8996.c b/drivers/clk/qcom/mmcc-msm8996.c
index 1a25ee4f3658..4b20d1b67a1b 100644
--- a/drivers/clk/qcom/mmcc-msm8996.c
+++ b/drivers/clk/qcom/mmcc-msm8996.c
@@ -2910,6 +2910,7 @@ static struct gdsc mmagic_bimc_gdsc = {
2910 .name = "mmagic_bimc", 2910 .name = "mmagic_bimc",
2911 }, 2911 },
2912 .pwrsts = PWRSTS_OFF_ON, 2912 .pwrsts = PWRSTS_OFF_ON,
2913 .flags = ALWAYS_ON,
2913}; 2914};
2914 2915
2915static struct gdsc mmagic_video_gdsc = { 2916static struct gdsc mmagic_video_gdsc = {
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index ece120da3353..d4ed0022b0dd 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -311,12 +311,20 @@ static DEFINE_MUTEX(intel_pstate_limits_lock);
311 311
312#ifdef CONFIG_ACPI 312#ifdef CONFIG_ACPI
313 313
314static bool intel_pstate_get_ppc_enable_status(void) 314static bool intel_pstate_acpi_pm_profile_server(void)
315{ 315{
316 if (acpi_gbl_FADT.preferred_profile == PM_ENTERPRISE_SERVER || 316 if (acpi_gbl_FADT.preferred_profile == PM_ENTERPRISE_SERVER ||
317 acpi_gbl_FADT.preferred_profile == PM_PERFORMANCE_SERVER) 317 acpi_gbl_FADT.preferred_profile == PM_PERFORMANCE_SERVER)
318 return true; 318 return true;
319 319
320 return false;
321}
322
323static bool intel_pstate_get_ppc_enable_status(void)
324{
325 if (intel_pstate_acpi_pm_profile_server())
326 return true;
327
320 return acpi_ppc; 328 return acpi_ppc;
321} 329}
322 330
@@ -459,6 +467,11 @@ static inline void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *pol
459static inline void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy) 467static inline void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy)
460{ 468{
461} 469}
470
471static inline bool intel_pstate_acpi_pm_profile_server(void)
472{
473 return false;
474}
462#endif 475#endif
463 476
464static inline void update_turbo_state(void) 477static inline void update_turbo_state(void)
@@ -1841,7 +1854,7 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
1841 intel_pstate_hwp_enable(cpu); 1854 intel_pstate_hwp_enable(cpu);
1842 1855
1843 id = x86_match_cpu(intel_pstate_hwp_boost_ids); 1856 id = x86_match_cpu(intel_pstate_hwp_boost_ids);
1844 if (id) 1857 if (id && intel_pstate_acpi_pm_profile_server())
1845 hwp_boost = true; 1858 hwp_boost = true;
1846 } 1859 }
1847 1860
@@ -2394,6 +2407,18 @@ static bool __init intel_pstate_no_acpi_pss(void)
2394 return true; 2407 return true;
2395} 2408}
2396 2409
2410static bool __init intel_pstate_no_acpi_pcch(void)
2411{
2412 acpi_status status;
2413 acpi_handle handle;
2414
2415 status = acpi_get_handle(NULL, "\\_SB", &handle);
2416 if (ACPI_FAILURE(status))
2417 return true;
2418
2419 return !acpi_has_method(handle, "PCCH");
2420}
2421
2397static bool __init intel_pstate_has_acpi_ppc(void) 2422static bool __init intel_pstate_has_acpi_ppc(void)
2398{ 2423{
2399 int i; 2424 int i;
@@ -2453,7 +2478,10 @@ static bool __init intel_pstate_platform_pwr_mgmt_exists(void)
2453 2478
2454 switch (plat_info[idx].data) { 2479 switch (plat_info[idx].data) {
2455 case PSS: 2480 case PSS:
2456 return intel_pstate_no_acpi_pss(); 2481 if (!intel_pstate_no_acpi_pss())
2482 return false;
2483
2484 return intel_pstate_no_acpi_pcch();
2457 case PPC: 2485 case PPC:
2458 return intel_pstate_has_acpi_ppc() && !force_load; 2486 return intel_pstate_has_acpi_ppc() && !force_load;
2459 } 2487 }
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
index 3f0ce2ae35ee..0c56c9759672 100644
--- a/drivers/cpufreq/pcc-cpufreq.c
+++ b/drivers/cpufreq/pcc-cpufreq.c
@@ -580,6 +580,10 @@ static int __init pcc_cpufreq_init(void)
580{ 580{
581 int ret; 581 int ret;
582 582
583 /* Skip initialization if another cpufreq driver is there. */
584 if (cpufreq_get_current_driver())
585 return 0;
586
583 if (acpi_disabled) 587 if (acpi_disabled)
584 return 0; 588 return 0;
585 589
diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
index 29389accf3e9..efc9a7ae4857 100644
--- a/drivers/cpufreq/qcom-cpufreq-kryo.c
+++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
@@ -183,6 +183,7 @@ static struct platform_driver qcom_cpufreq_kryo_driver = {
183static const struct of_device_id qcom_cpufreq_kryo_match_list[] __initconst = { 183static const struct of_device_id qcom_cpufreq_kryo_match_list[] __initconst = {
184 { .compatible = "qcom,apq8096", }, 184 { .compatible = "qcom,apq8096", },
185 { .compatible = "qcom,msm8996", }, 185 { .compatible = "qcom,msm8996", },
186 {}
186}; 187};
187 188
188/* 189/*
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 1c6cbda56afe..09d823d36d3a 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -266,6 +266,8 @@ static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key,
266 return; 266 return;
267 } 267 }
268 268
269 count -= initial;
270
269 if (initial) 271 if (initial)
270 asm volatile (".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */ 272 asm volatile (".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */
271 : "+S"(input), "+D"(output) 273 : "+S"(input), "+D"(output)
@@ -273,7 +275,7 @@ static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key,
273 275
274 asm volatile (".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */ 276 asm volatile (".byte 0xf3,0x0f,0xa7,0xc8" /* rep xcryptecb */
275 : "+S"(input), "+D"(output) 277 : "+S"(input), "+D"(output)
276 : "d"(control_word), "b"(key), "c"(count - initial)); 278 : "d"(control_word), "b"(key), "c"(count));
277} 279}
278 280
279static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key, 281static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
@@ -284,6 +286,8 @@ static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
284 if (count < cbc_fetch_blocks) 286 if (count < cbc_fetch_blocks)
285 return cbc_crypt(input, output, key, iv, control_word, count); 287 return cbc_crypt(input, output, key, iv, control_word, count);
286 288
289 count -= initial;
290
287 if (initial) 291 if (initial)
288 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0" /* rep xcryptcbc */ 292 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0" /* rep xcryptcbc */
289 : "+S" (input), "+D" (output), "+a" (iv) 293 : "+S" (input), "+D" (output), "+a" (iv)
@@ -291,7 +295,7 @@ static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
291 295
292 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0" /* rep xcryptcbc */ 296 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0" /* rep xcryptcbc */
293 : "+S" (input), "+D" (output), "+a" (iv) 297 : "+S" (input), "+D" (output), "+a" (iv)
294 : "d" (control_word), "b" (key), "c" (count-initial)); 298 : "d" (control_word), "b" (key), "c" (count));
295 return iv; 299 return iv;
296} 300}
297 301
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index d3cf9502e7e7..58faeb1cef63 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -181,7 +181,11 @@ static int uniphier_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
181 fwspec.fwnode = of_node_to_fwnode(chip->parent->of_node); 181 fwspec.fwnode = of_node_to_fwnode(chip->parent->of_node);
182 fwspec.param_count = 2; 182 fwspec.param_count = 2;
183 fwspec.param[0] = offset - UNIPHIER_GPIO_IRQ_OFFSET; 183 fwspec.param[0] = offset - UNIPHIER_GPIO_IRQ_OFFSET;
184 fwspec.param[1] = IRQ_TYPE_NONE; 184 /*
185 * IRQ_TYPE_NONE is rejected by the parent irq domain. Set LEVEL_HIGH
186 * temporarily. Anyway, ->irq_set_type() will override it later.
187 */
188 fwspec.param[1] = IRQ_TYPE_LEVEL_HIGH;
185 189
186 return irq_create_fwspec_mapping(&fwspec); 190 return irq_create_fwspec_mapping(&fwspec);
187} 191}
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 28d968088131..53a14ee8ad6d 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -64,7 +64,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
64 * Note that active low is the default. 64 * Note that active low is the default.
65 */ 65 */
66 if (IS_ENABLED(CONFIG_REGULATOR) && 66 if (IS_ENABLED(CONFIG_REGULATOR) &&
67 (of_device_is_compatible(np, "reg-fixed-voltage") || 67 (of_device_is_compatible(np, "regulator-fixed") ||
68 of_device_is_compatible(np, "reg-fixed-voltage") ||
68 of_device_is_compatible(np, "regulator-gpio"))) { 69 of_device_is_compatible(np, "regulator-gpio"))) {
69 /* 70 /*
70 * The regulator GPIO handles are specified such that the 71 * The regulator GPIO handles are specified such that the
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
index f4c474a95875..71efcf38f11b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
@@ -57,6 +57,10 @@
57#define ACP_I2S_COMP2_CAP_REG_OFFSET 0xa8 57#define ACP_I2S_COMP2_CAP_REG_OFFSET 0xa8
58#define ACP_I2S_COMP1_PLAY_REG_OFFSET 0x6c 58#define ACP_I2S_COMP1_PLAY_REG_OFFSET 0x6c
59#define ACP_I2S_COMP2_PLAY_REG_OFFSET 0x68 59#define ACP_I2S_COMP2_PLAY_REG_OFFSET 0x68
60#define ACP_BT_PLAY_REGS_START 0x14970
61#define ACP_BT_PLAY_REGS_END 0x14a24
62#define ACP_BT_COMP1_REG_OFFSET 0xac
63#define ACP_BT_COMP2_REG_OFFSET 0xa8
60 64
61#define mmACP_PGFSM_RETAIN_REG 0x51c9 65#define mmACP_PGFSM_RETAIN_REG 0x51c9
62#define mmACP_PGFSM_CONFIG_REG 0x51ca 66#define mmACP_PGFSM_CONFIG_REG 0x51ca
@@ -77,7 +81,7 @@
77#define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE 0x000000FF 81#define ACP_SOFT_RESET_DONE_TIME_OUT_VALUE 0x000000FF
78 82
79#define ACP_TIMEOUT_LOOP 0x000000FF 83#define ACP_TIMEOUT_LOOP 0x000000FF
80#define ACP_DEVS 3 84#define ACP_DEVS 4
81#define ACP_SRC_ID 162 85#define ACP_SRC_ID 162
82 86
83enum { 87enum {
@@ -316,14 +320,13 @@ static int acp_hw_init(void *handle)
316 if (adev->acp.acp_cell == NULL) 320 if (adev->acp.acp_cell == NULL)
317 return -ENOMEM; 321 return -ENOMEM;
318 322
319 adev->acp.acp_res = kcalloc(4, sizeof(struct resource), GFP_KERNEL); 323 adev->acp.acp_res = kcalloc(5, sizeof(struct resource), GFP_KERNEL);
320
321 if (adev->acp.acp_res == NULL) { 324 if (adev->acp.acp_res == NULL) {
322 kfree(adev->acp.acp_cell); 325 kfree(adev->acp.acp_cell);
323 return -ENOMEM; 326 return -ENOMEM;
324 } 327 }
325 328
326 i2s_pdata = kcalloc(2, sizeof(struct i2s_platform_data), GFP_KERNEL); 329 i2s_pdata = kcalloc(3, sizeof(struct i2s_platform_data), GFP_KERNEL);
327 if (i2s_pdata == NULL) { 330 if (i2s_pdata == NULL) {
328 kfree(adev->acp.acp_res); 331 kfree(adev->acp.acp_res);
329 kfree(adev->acp.acp_cell); 332 kfree(adev->acp.acp_cell);
@@ -358,6 +361,20 @@ static int acp_hw_init(void *handle)
358 i2s_pdata[1].i2s_reg_comp1 = ACP_I2S_COMP1_CAP_REG_OFFSET; 361 i2s_pdata[1].i2s_reg_comp1 = ACP_I2S_COMP1_CAP_REG_OFFSET;
359 i2s_pdata[1].i2s_reg_comp2 = ACP_I2S_COMP2_CAP_REG_OFFSET; 362 i2s_pdata[1].i2s_reg_comp2 = ACP_I2S_COMP2_CAP_REG_OFFSET;
360 363
364 i2s_pdata[2].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET;
365 switch (adev->asic_type) {
366 case CHIP_STONEY:
367 i2s_pdata[2].quirks |= DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
368 break;
369 default:
370 break;
371 }
372
373 i2s_pdata[2].cap = DWC_I2S_PLAY | DWC_I2S_RECORD;
374 i2s_pdata[2].snd_rates = SNDRV_PCM_RATE_8000_96000;
375 i2s_pdata[2].i2s_reg_comp1 = ACP_BT_COMP1_REG_OFFSET;
376 i2s_pdata[2].i2s_reg_comp2 = ACP_BT_COMP2_REG_OFFSET;
377
361 adev->acp.acp_res[0].name = "acp2x_dma"; 378 adev->acp.acp_res[0].name = "acp2x_dma";
362 adev->acp.acp_res[0].flags = IORESOURCE_MEM; 379 adev->acp.acp_res[0].flags = IORESOURCE_MEM;
363 adev->acp.acp_res[0].start = acp_base; 380 adev->acp.acp_res[0].start = acp_base;
@@ -373,13 +390,18 @@ static int acp_hw_init(void *handle)
373 adev->acp.acp_res[2].start = acp_base + ACP_I2S_CAP_REGS_START; 390 adev->acp.acp_res[2].start = acp_base + ACP_I2S_CAP_REGS_START;
374 adev->acp.acp_res[2].end = acp_base + ACP_I2S_CAP_REGS_END; 391 adev->acp.acp_res[2].end = acp_base + ACP_I2S_CAP_REGS_END;
375 392
376 adev->acp.acp_res[3].name = "acp2x_dma_irq"; 393 adev->acp.acp_res[3].name = "acp2x_dw_bt_i2s_play_cap";
377 adev->acp.acp_res[3].flags = IORESOURCE_IRQ; 394 adev->acp.acp_res[3].flags = IORESOURCE_MEM;
378 adev->acp.acp_res[3].start = amdgpu_irq_create_mapping(adev, 162); 395 adev->acp.acp_res[3].start = acp_base + ACP_BT_PLAY_REGS_START;
379 adev->acp.acp_res[3].end = adev->acp.acp_res[3].start; 396 adev->acp.acp_res[3].end = acp_base + ACP_BT_PLAY_REGS_END;
397
398 adev->acp.acp_res[4].name = "acp2x_dma_irq";
399 adev->acp.acp_res[4].flags = IORESOURCE_IRQ;
400 adev->acp.acp_res[4].start = amdgpu_irq_create_mapping(adev, 162);
401 adev->acp.acp_res[4].end = adev->acp.acp_res[4].start;
380 402
381 adev->acp.acp_cell[0].name = "acp_audio_dma"; 403 adev->acp.acp_cell[0].name = "acp_audio_dma";
382 adev->acp.acp_cell[0].num_resources = 4; 404 adev->acp.acp_cell[0].num_resources = 5;
383 adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0]; 405 adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
384 adev->acp.acp_cell[0].platform_data = &adev->asic_type; 406 adev->acp.acp_cell[0].platform_data = &adev->asic_type;
385 adev->acp.acp_cell[0].pdata_size = sizeof(adev->asic_type); 407 adev->acp.acp_cell[0].pdata_size = sizeof(adev->asic_type);
@@ -396,6 +418,12 @@ static int acp_hw_init(void *handle)
396 adev->acp.acp_cell[2].platform_data = &i2s_pdata[1]; 418 adev->acp.acp_cell[2].platform_data = &i2s_pdata[1];
397 adev->acp.acp_cell[2].pdata_size = sizeof(struct i2s_platform_data); 419 adev->acp.acp_cell[2].pdata_size = sizeof(struct i2s_platform_data);
398 420
421 adev->acp.acp_cell[3].name = "designware-i2s";
422 adev->acp.acp_cell[3].num_resources = 1;
423 adev->acp.acp_cell[3].resources = &adev->acp.acp_res[3];
424 adev->acp.acp_cell[3].platform_data = &i2s_pdata[2];
425 adev->acp.acp_cell[3].pdata_size = sizeof(struct i2s_platform_data);
426
399 r = mfd_add_hotplug_devices(adev->acp.parent, adev->acp.acp_cell, 427 r = mfd_add_hotplug_devices(adev->acp.parent, adev->acp.acp_cell,
400 ACP_DEVS); 428 ACP_DEVS);
401 if (r) 429 if (r)
@@ -451,7 +479,6 @@ static int acp_hw_init(void *handle)
451 val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET); 479 val = cgs_read_register(adev->acp.cgs_device, mmACP_SOFT_RESET);
452 val &= ~ACP_SOFT_RESET__SoftResetAud_MASK; 480 val &= ~ACP_SOFT_RESET__SoftResetAud_MASK;
453 cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val); 481 cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val);
454
455 return 0; 482 return 0;
456} 483}
457 484
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
index 9ab89371d9e8..ca8bf1c9a98e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -575,6 +575,7 @@ static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = {
575 { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX }, 575 { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX },
576 { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX }, 576 { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX },
577 { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX }, 577 { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX },
578 { 0x1002, 0x6900, 0x1025, 0x125A, AMDGPU_PX_QUIRK_FORCE_ATPX },
578 { 0, 0, 0, 0, 0 }, 579 { 0, 0, 0, 0, 0 },
579}; 580};
580 581
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 82312a7bc6ad..9c85a90be293 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -927,6 +927,10 @@ static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev,
927 r = amdgpu_bo_vm_update_pte(p); 927 r = amdgpu_bo_vm_update_pte(p);
928 if (r) 928 if (r)
929 return r; 929 return r;
930
931 r = reservation_object_reserve_shared(vm->root.base.bo->tbo.resv);
932 if (r)
933 return r;
930 } 934 }
931 935
932 return amdgpu_cs_sync_rings(p); 936 return amdgpu_cs_sync_rings(p);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 6e5284e6c028..2c5f093e79e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2747,6 +2747,9 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
2747 if (r) 2747 if (r)
2748 return r; 2748 return r;
2749 2749
2750 /* Make sure IB tests flushed */
2751 flush_delayed_work(&adev->late_init_work);
2752
2750 /* blat the mode back in */ 2753 /* blat the mode back in */
2751 if (fbcon) { 2754 if (fbcon) {
2752 if (!amdgpu_device_has_dc_support(adev)) { 2755 if (!amdgpu_device_has_dc_support(adev)) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index edf16b2b957a..fdcb498f6d19 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -107,6 +107,9 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,
107 return; 107 return;
108 list_add_tail(&base->bo_list, &bo->va); 108 list_add_tail(&base->bo_list, &bo->va);
109 109
110 if (bo->tbo.type == ttm_bo_type_kernel)
111 list_move(&base->vm_status, &vm->relocated);
112
110 if (bo->tbo.resv != vm->root.base.bo->tbo.resv) 113 if (bo->tbo.resv != vm->root.base.bo->tbo.resv)
111 return; 114 return;
112 115
@@ -468,7 +471,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev,
468 pt->parent = amdgpu_bo_ref(parent->base.bo); 471 pt->parent = amdgpu_bo_ref(parent->base.bo);
469 472
470 amdgpu_vm_bo_base_init(&entry->base, vm, pt); 473 amdgpu_vm_bo_base_init(&entry->base, vm, pt);
471 list_move(&entry->base.vm_status, &vm->relocated);
472 } 474 }
473 475
474 if (level < AMDGPU_VM_PTB) { 476 if (level < AMDGPU_VM_PTB) {
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 4304d9e408b8..ace9ad578ca0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -83,22 +83,21 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
83 enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ? 83 enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ?
84 I2C_MOT_TRUE : I2C_MOT_FALSE; 84 I2C_MOT_TRUE : I2C_MOT_FALSE;
85 enum ddc_result res; 85 enum ddc_result res;
86 uint32_t read_bytes = msg->size; 86 ssize_t read_bytes;
87 87
88 if (WARN_ON(msg->size > 16)) 88 if (WARN_ON(msg->size > 16))
89 return -E2BIG; 89 return -E2BIG;
90 90
91 switch (msg->request & ~DP_AUX_I2C_MOT) { 91 switch (msg->request & ~DP_AUX_I2C_MOT) {
92 case DP_AUX_NATIVE_READ: 92 case DP_AUX_NATIVE_READ:
93 res = dal_ddc_service_read_dpcd_data( 93 read_bytes = dal_ddc_service_read_dpcd_data(
94 TO_DM_AUX(aux)->ddc_service, 94 TO_DM_AUX(aux)->ddc_service,
95 false, 95 false,
96 I2C_MOT_UNDEF, 96 I2C_MOT_UNDEF,
97 msg->address, 97 msg->address,
98 msg->buffer, 98 msg->buffer,
99 msg->size, 99 msg->size);
100 &read_bytes); 100 return read_bytes;
101 break;
102 case DP_AUX_NATIVE_WRITE: 101 case DP_AUX_NATIVE_WRITE:
103 res = dal_ddc_service_write_dpcd_data( 102 res = dal_ddc_service_write_dpcd_data(
104 TO_DM_AUX(aux)->ddc_service, 103 TO_DM_AUX(aux)->ddc_service,
@@ -109,15 +108,14 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
109 msg->size); 108 msg->size);
110 break; 109 break;
111 case DP_AUX_I2C_READ: 110 case DP_AUX_I2C_READ:
112 res = dal_ddc_service_read_dpcd_data( 111 read_bytes = dal_ddc_service_read_dpcd_data(
113 TO_DM_AUX(aux)->ddc_service, 112 TO_DM_AUX(aux)->ddc_service,
114 true, 113 true,
115 mot, 114 mot,
116 msg->address, 115 msg->address,
117 msg->buffer, 116 msg->buffer,
118 msg->size, 117 msg->size);
119 &read_bytes); 118 return read_bytes;
120 break;
121 case DP_AUX_I2C_WRITE: 119 case DP_AUX_I2C_WRITE:
122 res = dal_ddc_service_write_dpcd_data( 120 res = dal_ddc_service_write_dpcd_data(
123 TO_DM_AUX(aux)->ddc_service, 121 TO_DM_AUX(aux)->ddc_service,
@@ -139,9 +137,7 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
139 r == DDC_RESULT_SUCESSFULL); 137 r == DDC_RESULT_SUCESSFULL);
140#endif 138#endif
141 139
142 if (res != DDC_RESULT_SUCESSFULL) 140 return msg->size;
143 return -EIO;
144 return read_bytes;
145} 141}
146 142
147static enum drm_connector_status 143static enum drm_connector_status
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
index 5a3346124a01..5a2e952c5bea 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
@@ -255,8 +255,9 @@ static void pp_to_dc_clock_levels_with_latency(
255 DC_DECODE_PP_CLOCK_TYPE(dc_clk_type)); 255 DC_DECODE_PP_CLOCK_TYPE(dc_clk_type));
256 256
257 for (i = 0; i < clk_level_info->num_levels; i++) { 257 for (i = 0; i < clk_level_info->num_levels; i++) {
258 DRM_DEBUG("DM_PPLIB:\t %d\n", pp_clks->data[i].clocks_in_khz); 258 DRM_DEBUG("DM_PPLIB:\t %d in 10kHz\n", pp_clks->data[i].clocks_in_khz);
259 clk_level_info->data[i].clocks_in_khz = pp_clks->data[i].clocks_in_khz; 259 /* translate 10kHz to kHz */
260 clk_level_info->data[i].clocks_in_khz = pp_clks->data[i].clocks_in_khz * 10;
260 clk_level_info->data[i].latency_in_us = pp_clks->data[i].latency_in_us; 261 clk_level_info->data[i].latency_in_us = pp_clks->data[i].latency_in_us;
261 } 262 }
262} 263}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index ae48d603ebd6..49c2face1e7a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -629,14 +629,13 @@ bool dal_ddc_service_query_ddc_data(
629 return ret; 629 return ret;
630} 630}
631 631
632enum ddc_result dal_ddc_service_read_dpcd_data( 632ssize_t dal_ddc_service_read_dpcd_data(
633 struct ddc_service *ddc, 633 struct ddc_service *ddc,
634 bool i2c, 634 bool i2c,
635 enum i2c_mot_mode mot, 635 enum i2c_mot_mode mot,
636 uint32_t address, 636 uint32_t address,
637 uint8_t *data, 637 uint8_t *data,
638 uint32_t len, 638 uint32_t len)
639 uint32_t *read)
640{ 639{
641 struct aux_payload read_payload = { 640 struct aux_payload read_payload = {
642 .i2c_over_aux = i2c, 641 .i2c_over_aux = i2c,
@@ -653,8 +652,6 @@ enum ddc_result dal_ddc_service_read_dpcd_data(
653 .mot = mot 652 .mot = mot
654 }; 653 };
655 654
656 *read = 0;
657
658 if (len > DEFAULT_AUX_MAX_DATA_SIZE) { 655 if (len > DEFAULT_AUX_MAX_DATA_SIZE) {
659 BREAK_TO_DEBUGGER(); 656 BREAK_TO_DEBUGGER();
660 return DDC_RESULT_FAILED_INVALID_OPERATION; 657 return DDC_RESULT_FAILED_INVALID_OPERATION;
@@ -664,8 +661,7 @@ enum ddc_result dal_ddc_service_read_dpcd_data(
664 ddc->ctx->i2caux, 661 ddc->ctx->i2caux,
665 ddc->ddc_pin, 662 ddc->ddc_pin,
666 &command)) { 663 &command)) {
667 *read = command.payloads->length; 664 return (ssize_t)command.payloads->length;
668 return DDC_RESULT_SUCESSFULL;
669 } 665 }
670 666
671 return DDC_RESULT_FAILED_OPERATION; 667 return DDC_RESULT_FAILED_OPERATION;
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 7857cb42b3e6..bdd121485cbc 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -1767,12 +1767,10 @@ static void dp_test_send_link_training(struct dc_link *link)
1767 dp_retrain_link_dp_test(link, &link_settings, false); 1767 dp_retrain_link_dp_test(link, &link_settings, false);
1768} 1768}
1769 1769
1770/* TODO hbr2 compliance eye output is unstable 1770/* TODO Raven hbr2 compliance eye output is unstable
1771 * (toggling on and off) with debugger break 1771 * (toggling on and off) with debugger break
1772 * This caueses intermittent PHY automation failure 1772 * This caueses intermittent PHY automation failure
1773 * Need to look into the root cause */ 1773 * Need to look into the root cause */
1774static uint8_t force_tps4_for_cp2520 = 1;
1775
1776static void dp_test_send_phy_test_pattern(struct dc_link *link) 1774static void dp_test_send_phy_test_pattern(struct dc_link *link)
1777{ 1775{
1778 union phy_test_pattern dpcd_test_pattern; 1776 union phy_test_pattern dpcd_test_pattern;
@@ -1832,13 +1830,13 @@ static void dp_test_send_phy_test_pattern(struct dc_link *link)
1832 break; 1830 break;
1833 case PHY_TEST_PATTERN_CP2520_1: 1831 case PHY_TEST_PATTERN_CP2520_1:
1834 /* CP2520 pattern is unstable, temporarily use TPS4 instead */ 1832 /* CP2520 pattern is unstable, temporarily use TPS4 instead */
1835 test_pattern = (force_tps4_for_cp2520 == 1) ? 1833 test_pattern = (link->dc->caps.force_dp_tps4_for_cp2520 == 1) ?
1836 DP_TEST_PATTERN_TRAINING_PATTERN4 : 1834 DP_TEST_PATTERN_TRAINING_PATTERN4 :
1837 DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE; 1835 DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE;
1838 break; 1836 break;
1839 case PHY_TEST_PATTERN_CP2520_2: 1837 case PHY_TEST_PATTERN_CP2520_2:
1840 /* CP2520 pattern is unstable, temporarily use TPS4 instead */ 1838 /* CP2520 pattern is unstable, temporarily use TPS4 instead */
1841 test_pattern = (force_tps4_for_cp2520 == 1) ? 1839 test_pattern = (link->dc->caps.force_dp_tps4_for_cp2520 == 1) ?
1842 DP_TEST_PATTERN_TRAINING_PATTERN4 : 1840 DP_TEST_PATTERN_TRAINING_PATTERN4 :
1843 DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE; 1841 DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE;
1844 break; 1842 break;
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 9cfde0ccf4e9..53c71296f3dd 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -76,6 +76,7 @@ struct dc_caps {
76 bool is_apu; 76 bool is_apu;
77 bool dual_link_dvi; 77 bool dual_link_dvi;
78 bool post_blend_color_processing; 78 bool post_blend_color_processing;
79 bool force_dp_tps4_for_cp2520;
79}; 80};
80 81
81struct dc_dcc_surface_param { 82struct dc_dcc_surface_param {
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
index b235a75355b8..bae752332a9f 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
@@ -741,6 +741,29 @@ static struct mem_input_funcs dce_mi_funcs = {
741 .mem_input_is_flip_pending = dce_mi_is_flip_pending 741 .mem_input_is_flip_pending = dce_mi_is_flip_pending
742}; 742};
743 743
744static struct mem_input_funcs dce112_mi_funcs = {
745 .mem_input_program_display_marks = dce112_mi_program_display_marks,
746 .allocate_mem_input = dce_mi_allocate_dmif,
747 .free_mem_input = dce_mi_free_dmif,
748 .mem_input_program_surface_flip_and_addr =
749 dce_mi_program_surface_flip_and_addr,
750 .mem_input_program_pte_vm = dce_mi_program_pte_vm,
751 .mem_input_program_surface_config =
752 dce_mi_program_surface_config,
753 .mem_input_is_flip_pending = dce_mi_is_flip_pending
754};
755
756static struct mem_input_funcs dce120_mi_funcs = {
757 .mem_input_program_display_marks = dce120_mi_program_display_marks,
758 .allocate_mem_input = dce_mi_allocate_dmif,
759 .free_mem_input = dce_mi_free_dmif,
760 .mem_input_program_surface_flip_and_addr =
761 dce_mi_program_surface_flip_and_addr,
762 .mem_input_program_pte_vm = dce_mi_program_pte_vm,
763 .mem_input_program_surface_config =
764 dce_mi_program_surface_config,
765 .mem_input_is_flip_pending = dce_mi_is_flip_pending
766};
744 767
745void dce_mem_input_construct( 768void dce_mem_input_construct(
746 struct dce_mem_input *dce_mi, 769 struct dce_mem_input *dce_mi,
@@ -769,7 +792,7 @@ void dce112_mem_input_construct(
769 const struct dce_mem_input_mask *mi_mask) 792 const struct dce_mem_input_mask *mi_mask)
770{ 793{
771 dce_mem_input_construct(dce_mi, ctx, inst, regs, mi_shift, mi_mask); 794 dce_mem_input_construct(dce_mi, ctx, inst, regs, mi_shift, mi_mask);
772 dce_mi->base.funcs->mem_input_program_display_marks = dce112_mi_program_display_marks; 795 dce_mi->base.funcs = &dce112_mi_funcs;
773} 796}
774 797
775void dce120_mem_input_construct( 798void dce120_mem_input_construct(
@@ -781,5 +804,5 @@ void dce120_mem_input_construct(
781 const struct dce_mem_input_mask *mi_mask) 804 const struct dce_mem_input_mask *mi_mask)
782{ 805{
783 dce_mem_input_construct(dce_mi, ctx, inst, regs, mi_shift, mi_mask); 806 dce_mem_input_construct(dce_mi, ctx, inst, regs, mi_shift, mi_mask);
784 dce_mi->base.funcs->mem_input_program_display_marks = dce120_mi_program_display_marks; 807 dce_mi->base.funcs = &dce120_mi_funcs;
785} 808}
diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
index 38ec0d609297..344dd2e69e7c 100644
--- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c
@@ -678,9 +678,22 @@ bool dce100_validate_bandwidth(
678 struct dc *dc, 678 struct dc *dc,
679 struct dc_state *context) 679 struct dc_state *context)
680{ 680{
681 /* TODO implement when needed but for now hardcode max value*/ 681 int i;
682 context->bw.dce.dispclk_khz = 681000; 682 bool at_least_one_pipe = false;
683 context->bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER; 683
684 for (i = 0; i < dc->res_pool->pipe_count; i++) {
685 if (context->res_ctx.pipe_ctx[i].stream)
686 at_least_one_pipe = true;
687 }
688
689 if (at_least_one_pipe) {
690 /* TODO implement when needed but for now hardcode max value*/
691 context->bw.dce.dispclk_khz = 681000;
692 context->bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER;
693 } else {
694 context->bw.dce.dispclk_khz = 0;
695 context->bw.dce.yclk_khz = 0;
696 }
684 697
685 return true; 698 return true;
686} 699}
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
index df5cb2d1d164..34dac84066a0 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
@@ -1027,6 +1027,8 @@ static bool construct(
1027 dc->caps.max_slave_planes = 1; 1027 dc->caps.max_slave_planes = 1;
1028 dc->caps.is_apu = true; 1028 dc->caps.is_apu = true;
1029 dc->caps.post_blend_color_processing = false; 1029 dc->caps.post_blend_color_processing = false;
1030 /* Raven DP PHY HBR2 eye diagram pattern is not stable. Use TP4 */
1031 dc->caps.force_dp_tps4_for_cp2520 = true;
1030 1032
1031 if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV) 1033 if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
1032 dc->debug = debug_defaults_drv; 1034 dc->debug = debug_defaults_drv;
diff --git a/drivers/gpu/drm/amd/display/dc/inc/dc_link_ddc.h b/drivers/gpu/drm/amd/display/dc/inc/dc_link_ddc.h
index 30b3a08b91be..090b7a8dd67b 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/dc_link_ddc.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/dc_link_ddc.h
@@ -102,14 +102,13 @@ bool dal_ddc_service_query_ddc_data(
102 uint8_t *read_buf, 102 uint8_t *read_buf,
103 uint32_t read_size); 103 uint32_t read_size);
104 104
105enum ddc_result dal_ddc_service_read_dpcd_data( 105ssize_t dal_ddc_service_read_dpcd_data(
106 struct ddc_service *ddc, 106 struct ddc_service *ddc,
107 bool i2c, 107 bool i2c,
108 enum i2c_mot_mode mot, 108 enum i2c_mot_mode mot,
109 uint32_t address, 109 uint32_t address,
110 uint8_t *data, 110 uint8_t *data,
111 uint32_t len, 111 uint32_t len);
112 uint32_t *read);
113 112
114enum ddc_result dal_ddc_service_write_dpcd_data( 113enum ddc_result dal_ddc_service_write_dpcd_data(
115 struct ddc_service *ddc, 114 struct ddc_service *ddc,
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c
index d644a9bb9078..9f407c48d4f0 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c
@@ -381,6 +381,7 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
381 uint32_t fw_to_load; 381 uint32_t fw_to_load;
382 int result = 0; 382 int result = 0;
383 struct SMU_DRAMData_TOC *toc; 383 struct SMU_DRAMData_TOC *toc;
384 uint32_t num_entries = 0;
384 385
385 if (!hwmgr->reload_fw) { 386 if (!hwmgr->reload_fw) {
386 pr_info("skip reloading...\n"); 387 pr_info("skip reloading...\n");
@@ -422,41 +423,41 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
422 } 423 }
423 424
424 toc = (struct SMU_DRAMData_TOC *)smu_data->header; 425 toc = (struct SMU_DRAMData_TOC *)smu_data->header;
425 toc->num_entries = 0;
426 toc->structure_version = 1; 426 toc->structure_version = 1;
427 427
428 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 428 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
429 UCODE_ID_RLC_G, &toc->entry[toc->num_entries++]), 429 UCODE_ID_RLC_G, &toc->entry[num_entries++]),
430 "Failed to Get Firmware Entry.", return -EINVAL); 430 "Failed to Get Firmware Entry.", return -EINVAL);
431 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 431 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
432 UCODE_ID_CP_CE, &toc->entry[toc->num_entries++]), 432 UCODE_ID_CP_CE, &toc->entry[num_entries++]),
433 "Failed to Get Firmware Entry.", return -EINVAL); 433 "Failed to Get Firmware Entry.", return -EINVAL);
434 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 434 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
435 UCODE_ID_CP_PFP, &toc->entry[toc->num_entries++]), 435 UCODE_ID_CP_PFP, &toc->entry[num_entries++]),
436 "Failed to Get Firmware Entry.", return -EINVAL); 436 "Failed to Get Firmware Entry.", return -EINVAL);
437 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 437 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
438 UCODE_ID_CP_ME, &toc->entry[toc->num_entries++]), 438 UCODE_ID_CP_ME, &toc->entry[num_entries++]),
439 "Failed to Get Firmware Entry.", return -EINVAL); 439 "Failed to Get Firmware Entry.", return -EINVAL);
440 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 440 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
441 UCODE_ID_CP_MEC, &toc->entry[toc->num_entries++]), 441 UCODE_ID_CP_MEC, &toc->entry[num_entries++]),
442 "Failed to Get Firmware Entry.", return -EINVAL); 442 "Failed to Get Firmware Entry.", return -EINVAL);
443 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 443 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
444 UCODE_ID_CP_MEC_JT1, &toc->entry[toc->num_entries++]), 444 UCODE_ID_CP_MEC_JT1, &toc->entry[num_entries++]),
445 "Failed to Get Firmware Entry.", return -EINVAL); 445 "Failed to Get Firmware Entry.", return -EINVAL);
446 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 446 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
447 UCODE_ID_CP_MEC_JT2, &toc->entry[toc->num_entries++]), 447 UCODE_ID_CP_MEC_JT2, &toc->entry[num_entries++]),
448 "Failed to Get Firmware Entry.", return -EINVAL); 448 "Failed to Get Firmware Entry.", return -EINVAL);
449 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 449 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
450 UCODE_ID_SDMA0, &toc->entry[toc->num_entries++]), 450 UCODE_ID_SDMA0, &toc->entry[num_entries++]),
451 "Failed to Get Firmware Entry.", return -EINVAL); 451 "Failed to Get Firmware Entry.", return -EINVAL);
452 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 452 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
453 UCODE_ID_SDMA1, &toc->entry[toc->num_entries++]), 453 UCODE_ID_SDMA1, &toc->entry[num_entries++]),
454 "Failed to Get Firmware Entry.", return -EINVAL); 454 "Failed to Get Firmware Entry.", return -EINVAL);
455 if (!hwmgr->not_vf) 455 if (!hwmgr->not_vf)
456 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, 456 PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr,
457 UCODE_ID_MEC_STORAGE, &toc->entry[toc->num_entries++]), 457 UCODE_ID_MEC_STORAGE, &toc->entry[num_entries++]),
458 "Failed to Get Firmware Entry.", return -EINVAL); 458 "Failed to Get Firmware Entry.", return -EINVAL);
459 459
460 toc->num_entries = num_entries;
460 smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, upper_32_bits(smu_data->header_buffer.mc_addr)); 461 smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, upper_32_bits(smu_data->header_buffer.mc_addr));
461 smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, lower_32_bits(smu_data->header_buffer.mc_addr)); 462 smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, lower_32_bits(smu_data->header_buffer.mc_addr));
462 463
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 03eeee11dd5b..42a40daff132 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -519,8 +519,9 @@ static irqreturn_t armada_drm_irq(int irq, void *arg)
519 u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR); 519 u32 v, stat = readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
520 520
521 /* 521 /*
522 * This is rediculous - rather than writing bits to clear, we 522 * Reading the ISR appears to clear bits provided CLEAN_SPU_IRQ_ISR
523 * have to set the actual status register value. This is racy. 523 * is set. Writing has some other effect to acknowledge the IRQ -
524 * without this, we only get a single IRQ.
524 */ 525 */
525 writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR); 526 writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
526 527
@@ -1116,16 +1117,22 @@ armada_drm_crtc_set_property(struct drm_crtc *crtc,
1116static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc) 1117static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
1117{ 1118{
1118 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); 1119 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
1120 unsigned long flags;
1119 1121
1122 spin_lock_irqsave(&dcrtc->irq_lock, flags);
1120 armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA); 1123 armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
1124 spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
1121 return 0; 1125 return 0;
1122} 1126}
1123 1127
1124static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc) 1128static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
1125{ 1129{
1126 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); 1130 struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
1131 unsigned long flags;
1127 1132
1133 spin_lock_irqsave(&dcrtc->irq_lock, flags);
1128 armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA); 1134 armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
1135 spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
1129} 1136}
1130 1137
1131static const struct drm_crtc_funcs armada_crtc_funcs = { 1138static const struct drm_crtc_funcs armada_crtc_funcs = {
@@ -1415,6 +1422,7 @@ static int armada_drm_crtc_create(struct drm_device *drm, struct device *dev,
1415 CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1); 1422 CFG_PDWN64x66, dcrtc->base + LCD_SPU_SRAM_PARA1);
1416 writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1); 1423 writel_relaxed(0x2032ff81, dcrtc->base + LCD_SPU_DMA_CTRL1);
1417 writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA); 1424 writel_relaxed(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
1425 readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR);
1418 writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR); 1426 writel_relaxed(0, dcrtc->base + LCD_SPU_IRQ_ISR);
1419 1427
1420 ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc", 1428 ret = devm_request_irq(dev, irq, armada_drm_irq, 0, "armada_drm_crtc",
diff --git a/drivers/gpu/drm/armada/armada_hw.h b/drivers/gpu/drm/armada/armada_hw.h
index 27319a8335e2..345dc4d0851e 100644
--- a/drivers/gpu/drm/armada/armada_hw.h
+++ b/drivers/gpu/drm/armada/armada_hw.h
@@ -160,6 +160,7 @@ enum {
160 CFG_ALPHAM_GRA = 0x1 << 16, 160 CFG_ALPHAM_GRA = 0x1 << 16,
161 CFG_ALPHAM_CFG = 0x2 << 16, 161 CFG_ALPHAM_CFG = 0x2 << 16,
162 CFG_ALPHA_MASK = 0xff << 8, 162 CFG_ALPHA_MASK = 0xff << 8,
163#define CFG_ALPHA(x) ((x) << 8)
163 CFG_PIXCMD_MASK = 0xff, 164 CFG_PIXCMD_MASK = 0xff,
164}; 165};
165 166
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index c391955009d6..afa7ded3ae31 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -28,6 +28,7 @@ struct armada_ovl_plane_properties {
28 uint16_t contrast; 28 uint16_t contrast;
29 uint16_t saturation; 29 uint16_t saturation;
30 uint32_t colorkey_mode; 30 uint32_t colorkey_mode;
31 uint32_t colorkey_enable;
31}; 32};
32 33
33struct armada_ovl_plane { 34struct armada_ovl_plane {
@@ -54,11 +55,13 @@ armada_ovl_update_attr(struct armada_ovl_plane_properties *prop,
54 writel_relaxed(0x00002000, dcrtc->base + LCD_SPU_CBSH_HUE); 55 writel_relaxed(0x00002000, dcrtc->base + LCD_SPU_CBSH_HUE);
55 56
56 spin_lock_irq(&dcrtc->irq_lock); 57 spin_lock_irq(&dcrtc->irq_lock);
57 armada_updatel(prop->colorkey_mode | CFG_ALPHAM_GRA, 58 armada_updatel(prop->colorkey_mode,
58 CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK, 59 CFG_CKMODE_MASK | CFG_ALPHAM_MASK | CFG_ALPHA_MASK,
59 dcrtc->base + LCD_SPU_DMA_CTRL1); 60 dcrtc->base + LCD_SPU_DMA_CTRL1);
60 61 if (dcrtc->variant->has_spu_adv_reg)
61 armada_updatel(ADV_GRACOLORKEY, 0, dcrtc->base + LCD_SPU_ADV_REG); 62 armada_updatel(prop->colorkey_enable,
63 ADV_GRACOLORKEY | ADV_VIDCOLORKEY,
64 dcrtc->base + LCD_SPU_ADV_REG);
62 spin_unlock_irq(&dcrtc->irq_lock); 65 spin_unlock_irq(&dcrtc->irq_lock);
63} 66}
64 67
@@ -321,8 +324,17 @@ static int armada_ovl_plane_set_property(struct drm_plane *plane,
321 dplane->prop.colorkey_vb |= K2B(val); 324 dplane->prop.colorkey_vb |= K2B(val);
322 update_attr = true; 325 update_attr = true;
323 } else if (property == priv->colorkey_mode_prop) { 326 } else if (property == priv->colorkey_mode_prop) {
324 dplane->prop.colorkey_mode &= ~CFG_CKMODE_MASK; 327 if (val == CKMODE_DISABLE) {
325 dplane->prop.colorkey_mode |= CFG_CKMODE(val); 328 dplane->prop.colorkey_mode =
329 CFG_CKMODE(CKMODE_DISABLE) |
330 CFG_ALPHAM_CFG | CFG_ALPHA(255);
331 dplane->prop.colorkey_enable = 0;
332 } else {
333 dplane->prop.colorkey_mode =
334 CFG_CKMODE(val) |
335 CFG_ALPHAM_GRA | CFG_ALPHA(0);
336 dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
337 }
326 update_attr = true; 338 update_attr = true;
327 } else if (property == priv->brightness_prop) { 339 } else if (property == priv->brightness_prop) {
328 dplane->prop.brightness = val - 256; 340 dplane->prop.brightness = val - 256;
@@ -453,7 +465,9 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
453 dplane->prop.colorkey_yr = 0xfefefe00; 465 dplane->prop.colorkey_yr = 0xfefefe00;
454 dplane->prop.colorkey_ug = 0x01010100; 466 dplane->prop.colorkey_ug = 0x01010100;
455 dplane->prop.colorkey_vb = 0x01010100; 467 dplane->prop.colorkey_vb = 0x01010100;
456 dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB); 468 dplane->prop.colorkey_mode = CFG_CKMODE(CKMODE_RGB) |
469 CFG_ALPHAM_GRA | CFG_ALPHA(0);
470 dplane->prop.colorkey_enable = ADV_GRACOLORKEY;
457 dplane->prop.brightness = 0; 471 dplane->prop.brightness = 0;
458 dplane->prop.contrast = 0x4000; 472 dplane->prop.contrast = 0x4000;
459 dplane->prop.saturation = 0x4000; 473 dplane->prop.saturation = 0x4000;
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 73021b388e12..dd3ff2f2cdce 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -429,6 +429,18 @@ static void adv7511_hpd_work(struct work_struct *work)
429 else 429 else
430 status = connector_status_disconnected; 430 status = connector_status_disconnected;
431 431
432 /*
433 * The bridge resets its registers on unplug. So when we get a plug
434 * event and we're already supposed to be powered, cycle the bridge to
435 * restore its state.
436 */
437 if (status == connector_status_connected &&
438 adv7511->connector.status == connector_status_disconnected &&
439 adv7511->powered) {
440 regcache_mark_dirty(adv7511->regmap);
441 adv7511_power_on(adv7511);
442 }
443
432 if (adv7511->connector.status != status) { 444 if (adv7511->connector.status != status) {
433 adv7511->connector.status = status; 445 adv7511->connector.status = status;
434 if (status == connector_status_disconnected) 446 if (status == connector_status_disconnected)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 130da5195f3b..81e32199d3ef 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1510,8 +1510,9 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
1510{ 1510{
1511 struct drm_crtc *crtc; 1511 struct drm_crtc *crtc;
1512 struct drm_crtc_state *crtc_state; 1512 struct drm_crtc_state *crtc_state;
1513 struct drm_plane *plane; 1513 struct drm_plane *plane = NULL;
1514 struct drm_plane_state *old_plane_state, *new_plane_state; 1514 struct drm_plane_state *old_plane_state = NULL;
1515 struct drm_plane_state *new_plane_state = NULL;
1515 const struct drm_plane_helper_funcs *funcs; 1516 const struct drm_plane_helper_funcs *funcs;
1516 int i, n_planes = 0; 1517 int i, n_planes = 0;
1517 1518
@@ -1527,7 +1528,8 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
1527 if (n_planes != 1) 1528 if (n_planes != 1)
1528 return -EINVAL; 1529 return -EINVAL;
1529 1530
1530 if (!new_plane_state->crtc) 1531 if (!new_plane_state->crtc ||
1532 old_plane_state->crtc != new_plane_state->crtc)
1531 return -EINVAL; 1533 return -EINVAL;
1532 1534
1533 funcs = plane->helper_private; 1535 funcs = plane->helper_private;
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 3c4000facb36..f973d287696a 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -372,7 +372,7 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
372 ctx->handle = drm_legacy_ctxbitmap_next(dev); 372 ctx->handle = drm_legacy_ctxbitmap_next(dev);
373 } 373 }
374 DRM_DEBUG("%d\n", ctx->handle); 374 DRM_DEBUG("%d\n", ctx->handle);
375 if (ctx->handle == -1) { 375 if (ctx->handle < 0) {
376 DRM_DEBUG("Not enough free contexts.\n"); 376 DRM_DEBUG("Not enough free contexts.\n");
377 /* Should this return -EBUSY instead? */ 377 /* Should this return -EBUSY instead? */
378 return -ENOMEM; 378 return -ENOMEM;
diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
index 50c73c0a20b9..d638c0fb3418 100644
--- a/drivers/gpu/drm/drm_lease.c
+++ b/drivers/gpu/drm/drm_lease.c
@@ -553,24 +553,13 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
553 553
554 /* Clone the lessor file to create a new file for us */ 554 /* Clone the lessor file to create a new file for us */
555 DRM_DEBUG_LEASE("Allocating lease file\n"); 555 DRM_DEBUG_LEASE("Allocating lease file\n");
556 path_get(&lessor_file->f_path); 556 lessee_file = filp_clone_open(lessor_file);
557 lessee_file = alloc_file(&lessor_file->f_path,
558 lessor_file->f_mode,
559 fops_get(lessor_file->f_inode->i_fop));
560
561 if (IS_ERR(lessee_file)) { 557 if (IS_ERR(lessee_file)) {
562 ret = PTR_ERR(lessee_file); 558 ret = PTR_ERR(lessee_file);
563 goto out_lessee; 559 goto out_lessee;
564 } 560 }
565 561
566 /* Initialize the new file for DRM */
567 DRM_DEBUG_LEASE("Initializing the file with %p\n", lessee_file->f_op->open);
568 ret = lessee_file->f_op->open(lessee_file->f_inode, lessee_file);
569 if (ret)
570 goto out_lessee_file;
571
572 lessee_priv = lessee_file->private_data; 562 lessee_priv = lessee_file->private_data;
573
574 /* Change the file to a master one */ 563 /* Change the file to a master one */
575 drm_master_put(&lessee_priv->master); 564 drm_master_put(&lessee_priv->master);
576 lessee_priv->master = lessee; 565 lessee_priv->master = lessee;
@@ -588,9 +577,6 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
588 DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n"); 577 DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
589 return 0; 578 return 0;
590 579
591out_lessee_file:
592 fput(lessee_file);
593
594out_lessee: 580out_lessee:
595 drm_master_put(&lessee); 581 drm_master_put(&lessee);
596 582
diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index b51c05d03f14..7f562410f9cf 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -862,6 +862,7 @@ static int cmd_reg_handler(struct parser_exec_state *s,
862{ 862{
863 struct intel_vgpu *vgpu = s->vgpu; 863 struct intel_vgpu *vgpu = s->vgpu;
864 struct intel_gvt *gvt = vgpu->gvt; 864 struct intel_gvt *gvt = vgpu->gvt;
865 u32 ctx_sr_ctl;
865 866
866 if (offset + 4 > gvt->device_info.mmio_size) { 867 if (offset + 4 > gvt->device_info.mmio_size) {
867 gvt_vgpu_err("%s access to (%x) outside of MMIO range\n", 868 gvt_vgpu_err("%s access to (%x) outside of MMIO range\n",
@@ -894,6 +895,28 @@ static int cmd_reg_handler(struct parser_exec_state *s,
894 patch_value(s, cmd_ptr(s, index), VGT_PVINFO_PAGE); 895 patch_value(s, cmd_ptr(s, index), VGT_PVINFO_PAGE);
895 } 896 }
896 897
898 /* TODO
899 * Right now only scan LRI command on KBL and in inhibit context.
900 * It's good enough to support initializing mmio by lri command in
901 * vgpu inhibit context on KBL.
902 */
903 if (IS_KABYLAKE(s->vgpu->gvt->dev_priv) &&
904 intel_gvt_mmio_is_in_ctx(gvt, offset) &&
905 !strncmp(cmd, "lri", 3)) {
906 intel_gvt_hypervisor_read_gpa(s->vgpu,
907 s->workload->ring_context_gpa + 12, &ctx_sr_ctl, 4);
908 /* check inhibit context */
909 if (ctx_sr_ctl & 1) {
910 u32 data = cmd_val(s, index + 1);
911
912 if (intel_gvt_mmio_has_mode_mask(s->vgpu->gvt, offset))
913 intel_vgpu_mask_mmio_write(vgpu,
914 offset, &data, 4);
915 else
916 vgpu_vreg(vgpu, offset) = data;
917 }
918 }
919
897 /* TODO: Update the global mask if this MMIO is a masked-MMIO */ 920 /* TODO: Update the global mask if this MMIO is a masked-MMIO */
898 intel_gvt_mmio_set_cmd_accessed(gvt, offset); 921 intel_gvt_mmio_set_cmd_accessed(gvt, offset);
899 return 0; 922 return 0;
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index 05d15a095310..858967daf04b 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -268,6 +268,8 @@ struct intel_gvt_mmio {
268#define F_CMD_ACCESSED (1 << 5) 268#define F_CMD_ACCESSED (1 << 5)
269/* This reg could be accessed by unaligned address */ 269/* This reg could be accessed by unaligned address */
270#define F_UNALIGN (1 << 6) 270#define F_UNALIGN (1 << 6)
271/* This reg is saved/restored in context */
272#define F_IN_CTX (1 << 7)
271 273
272 struct gvt_mmio_block *mmio_block; 274 struct gvt_mmio_block *mmio_block;
273 unsigned int num_mmio_block; 275 unsigned int num_mmio_block;
@@ -639,6 +641,33 @@ static inline bool intel_gvt_mmio_has_mode_mask(
639 return gvt->mmio.mmio_attribute[offset >> 2] & F_MODE_MASK; 641 return gvt->mmio.mmio_attribute[offset >> 2] & F_MODE_MASK;
640} 642}
641 643
644/**
645 * intel_gvt_mmio_is_in_ctx - check if a MMIO has in-ctx mask
646 * @gvt: a GVT device
647 * @offset: register offset
648 *
649 * Returns:
650 * True if a MMIO has a in-context mask, false if it isn't.
651 *
652 */
653static inline bool intel_gvt_mmio_is_in_ctx(
654 struct intel_gvt *gvt, unsigned int offset)
655{
656 return gvt->mmio.mmio_attribute[offset >> 2] & F_IN_CTX;
657}
658
659/**
660 * intel_gvt_mmio_set_in_ctx - mask a MMIO in logical context
661 * @gvt: a GVT device
662 * @offset: register offset
663 *
664 */
665static inline void intel_gvt_mmio_set_in_ctx(
666 struct intel_gvt *gvt, unsigned int offset)
667{
668 gvt->mmio.mmio_attribute[offset >> 2] |= F_IN_CTX;
669}
670
642int intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu); 671int intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu);
643void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu); 672void intel_gvt_debugfs_remove_vgpu(struct intel_vgpu *vgpu);
644int intel_gvt_debugfs_init(struct intel_gvt *gvt); 673int intel_gvt_debugfs_init(struct intel_gvt *gvt);
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index bcbc47a88a70..8f1caacdc78a 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -3046,6 +3046,30 @@ int intel_vgpu_default_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
3046} 3046}
3047 3047
3048/** 3048/**
3049 * intel_vgpu_mask_mmio_write - write mask register
3050 * @vgpu: a vGPU
3051 * @offset: access offset
3052 * @p_data: write data buffer
3053 * @bytes: access data length
3054 *
3055 * Returns:
3056 * Zero on success, negative error code if failed.
3057 */
3058int intel_vgpu_mask_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
3059 void *p_data, unsigned int bytes)
3060{
3061 u32 mask, old_vreg;
3062
3063 old_vreg = vgpu_vreg(vgpu, offset);
3064 write_vreg(vgpu, offset, p_data, bytes);
3065 mask = vgpu_vreg(vgpu, offset) >> 16;
3066 vgpu_vreg(vgpu, offset) = (old_vreg & ~mask) |
3067 (vgpu_vreg(vgpu, offset) & mask);
3068
3069 return 0;
3070}
3071
3072/**
3049 * intel_gvt_in_force_nonpriv_whitelist - if a mmio is in whitelist to be 3073 * intel_gvt_in_force_nonpriv_whitelist - if a mmio is in whitelist to be
3050 * force-nopriv register 3074 * force-nopriv register
3051 * 3075 *
diff --git a/drivers/gpu/drm/i915/gvt/mmio.h b/drivers/gpu/drm/i915/gvt/mmio.h
index 71b620875943..dac8c6401e26 100644
--- a/drivers/gpu/drm/i915/gvt/mmio.h
+++ b/drivers/gpu/drm/i915/gvt/mmio.h
@@ -98,4 +98,6 @@ bool intel_gvt_in_force_nonpriv_whitelist(struct intel_gvt *gvt,
98int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset, 98int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset,
99 void *pdata, unsigned int bytes, bool is_read); 99 void *pdata, unsigned int bytes, bool is_read);
100 100
101int intel_vgpu_mask_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
102 void *p_data, unsigned int bytes);
101#endif 103#endif
diff --git a/drivers/gpu/drm/i915/gvt/mmio_context.c b/drivers/gpu/drm/i915/gvt/mmio_context.c
index 0f949554d118..5ca9caf7552a 100644
--- a/drivers/gpu/drm/i915/gvt/mmio_context.c
+++ b/drivers/gpu/drm/i915/gvt/mmio_context.c
@@ -581,7 +581,9 @@ void intel_gvt_init_engine_mmio_context(struct intel_gvt *gvt)
581 581
582 for (mmio = gvt->engine_mmio_list.mmio; 582 for (mmio = gvt->engine_mmio_list.mmio;
583 i915_mmio_reg_valid(mmio->reg); mmio++) { 583 i915_mmio_reg_valid(mmio->reg); mmio++) {
584 if (mmio->in_context) 584 if (mmio->in_context) {
585 gvt->engine_mmio_list.ctx_mmio_count[mmio->ring_id]++; 585 gvt->engine_mmio_list.ctx_mmio_count[mmio->ring_id]++;
586 intel_gvt_mmio_set_in_ctx(gvt, mmio->reg.reg);
587 }
586 } 588 }
587} 589}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 52f3b91d14fd..71e1aa54f774 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -652,6 +652,7 @@ enum intel_sbi_destination {
652#define QUIRK_BACKLIGHT_PRESENT (1<<3) 652#define QUIRK_BACKLIGHT_PRESENT (1<<3)
653#define QUIRK_PIN_SWIZZLED_PAGES (1<<5) 653#define QUIRK_PIN_SWIZZLED_PAGES (1<<5)
654#define QUIRK_INCREASE_T12_DELAY (1<<6) 654#define QUIRK_INCREASE_T12_DELAY (1<<6)
655#define QUIRK_INCREASE_DDI_DISABLED_TIME (1<<7)
655 656
656struct intel_fbdev; 657struct intel_fbdev;
657struct intel_fbc_work; 658struct intel_fbc_work;
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 4a02747ac658..c16cb025755e 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1998,10 +1998,38 @@ static void valleyview_pipestat_irq_handler(struct drm_i915_private *dev_priv,
1998 1998
1999static u32 i9xx_hpd_irq_ack(struct drm_i915_private *dev_priv) 1999static u32 i9xx_hpd_irq_ack(struct drm_i915_private *dev_priv)
2000{ 2000{
2001 u32 hotplug_status = I915_READ(PORT_HOTPLUG_STAT); 2001 u32 hotplug_status = 0, hotplug_status_mask;
2002 int i;
2003
2004 if (IS_G4X(dev_priv) ||
2005 IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
2006 hotplug_status_mask = HOTPLUG_INT_STATUS_G4X |
2007 DP_AUX_CHANNEL_MASK_INT_STATUS_G4X;
2008 else
2009 hotplug_status_mask = HOTPLUG_INT_STATUS_I915;
2002 2010
2003 if (hotplug_status) 2011 /*
2012 * We absolutely have to clear all the pending interrupt
2013 * bits in PORT_HOTPLUG_STAT. Otherwise the ISR port
2014 * interrupt bit won't have an edge, and the i965/g4x
2015 * edge triggered IIR will not notice that an interrupt
2016 * is still pending. We can't use PORT_HOTPLUG_EN to
2017 * guarantee the edge as the act of toggling the enable
2018 * bits can itself generate a new hotplug interrupt :(
2019 */
2020 for (i = 0; i < 10; i++) {
2021 u32 tmp = I915_READ(PORT_HOTPLUG_STAT) & hotplug_status_mask;
2022
2023 if (tmp == 0)
2024 return hotplug_status;
2025
2026 hotplug_status |= tmp;
2004 I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status); 2027 I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
2028 }
2029
2030 WARN_ONCE(1,
2031 "PORT_HOTPLUG_STAT did not clear (0x%08x)\n",
2032 I915_READ(PORT_HOTPLUG_STAT));
2005 2033
2006 return hotplug_status; 2034 return hotplug_status;
2007} 2035}
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index f4a8598a2d39..fed26d6e4e27 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1782,15 +1782,24 @@ void intel_ddi_enable_transcoder_func(const struct intel_crtc_state *crtc_state)
1782 I915_WRITE(TRANS_DDI_FUNC_CTL(cpu_transcoder), temp); 1782 I915_WRITE(TRANS_DDI_FUNC_CTL(cpu_transcoder), temp);
1783} 1783}
1784 1784
1785void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv, 1785void intel_ddi_disable_transcoder_func(const struct intel_crtc_state *crtc_state)
1786 enum transcoder cpu_transcoder)
1787{ 1786{
1787 struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
1788 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1789 enum transcoder cpu_transcoder = crtc_state->cpu_transcoder;
1788 i915_reg_t reg = TRANS_DDI_FUNC_CTL(cpu_transcoder); 1790 i915_reg_t reg = TRANS_DDI_FUNC_CTL(cpu_transcoder);
1789 uint32_t val = I915_READ(reg); 1791 uint32_t val = I915_READ(reg);
1790 1792
1791 val &= ~(TRANS_DDI_FUNC_ENABLE | TRANS_DDI_PORT_MASK | TRANS_DDI_DP_VC_PAYLOAD_ALLOC); 1793 val &= ~(TRANS_DDI_FUNC_ENABLE | TRANS_DDI_PORT_MASK | TRANS_DDI_DP_VC_PAYLOAD_ALLOC);
1792 val |= TRANS_DDI_PORT_NONE; 1794 val |= TRANS_DDI_PORT_NONE;
1793 I915_WRITE(reg, val); 1795 I915_WRITE(reg, val);
1796
1797 if (dev_priv->quirks & QUIRK_INCREASE_DDI_DISABLED_TIME &&
1798 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
1799 DRM_DEBUG_KMS("Quirk Increase DDI disabled time\n");
1800 /* Quirk time at 100ms for reliable operation */
1801 msleep(100);
1802 }
1794} 1803}
1795 1804
1796int intel_ddi_toggle_hdcp_signalling(struct intel_encoder *intel_encoder, 1805int intel_ddi_toggle_hdcp_signalling(struct intel_encoder *intel_encoder,
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2cc6faa1daa8..dec0d60921bf 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5809,7 +5809,7 @@ static void haswell_crtc_disable(struct intel_crtc_state *old_crtc_state,
5809 intel_ddi_set_vc_payload_alloc(intel_crtc->config, false); 5809 intel_ddi_set_vc_payload_alloc(intel_crtc->config, false);
5810 5810
5811 if (!transcoder_is_dsi(cpu_transcoder)) 5811 if (!transcoder_is_dsi(cpu_transcoder))
5812 intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder); 5812 intel_ddi_disable_transcoder_func(old_crtc_state);
5813 5813
5814 if (INTEL_GEN(dev_priv) >= 9) 5814 if (INTEL_GEN(dev_priv) >= 9)
5815 skylake_scaler_disable(intel_crtc); 5815 skylake_scaler_disable(intel_crtc);
@@ -14646,6 +14646,18 @@ static void quirk_increase_t12_delay(struct drm_device *dev)
14646 DRM_INFO("Applying T12 delay quirk\n"); 14646 DRM_INFO("Applying T12 delay quirk\n");
14647} 14647}
14648 14648
14649/*
14650 * GeminiLake NUC HDMI outputs require additional off time
14651 * this allows the onboard retimer to correctly sync to signal
14652 */
14653static void quirk_increase_ddi_disabled_time(struct drm_device *dev)
14654{
14655 struct drm_i915_private *dev_priv = to_i915(dev);
14656
14657 dev_priv->quirks |= QUIRK_INCREASE_DDI_DISABLED_TIME;
14658 DRM_INFO("Applying Increase DDI Disabled quirk\n");
14659}
14660
14649struct intel_quirk { 14661struct intel_quirk {
14650 int device; 14662 int device;
14651 int subsystem_vendor; 14663 int subsystem_vendor;
@@ -14732,6 +14744,13 @@ static struct intel_quirk intel_quirks[] = {
14732 14744
14733 /* Toshiba Satellite P50-C-18C */ 14745 /* Toshiba Satellite P50-C-18C */
14734 { 0x191B, 0x1179, 0xF840, quirk_increase_t12_delay }, 14746 { 0x191B, 0x1179, 0xF840, quirk_increase_t12_delay },
14747
14748 /* GeminiLake NUC */
14749 { 0x3185, 0x8086, 0x2072, quirk_increase_ddi_disabled_time },
14750 { 0x3184, 0x8086, 0x2072, quirk_increase_ddi_disabled_time },
14751 /* ASRock ITX*/
14752 { 0x3185, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
14753 { 0x3184, 0x1849, 0x2212, quirk_increase_ddi_disabled_time },
14735}; 14754};
14736 14755
14737static void intel_init_quirks(struct drm_device *dev) 14756static void intel_init_quirks(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 0361130500a6..b8eefbffc77d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1388,8 +1388,7 @@ void hsw_fdi_link_train(struct intel_crtc *crtc,
1388void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port); 1388void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port);
1389bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe); 1389bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
1390void intel_ddi_enable_transcoder_func(const struct intel_crtc_state *crtc_state); 1390void intel_ddi_enable_transcoder_func(const struct intel_crtc_state *crtc_state);
1391void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv, 1391void intel_ddi_disable_transcoder_func(const struct intel_crtc_state *crtc_state);
1392 enum transcoder cpu_transcoder);
1393void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state); 1392void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state);
1394void intel_ddi_disable_pipe_clock(const struct intel_crtc_state *crtc_state); 1393void intel_ddi_disable_pipe_clock(const struct intel_crtc_state *crtc_state);
1395struct intel_encoder * 1394struct intel_encoder *
diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 56dd7a9a8e25..dd5312b02a8d 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -612,6 +612,9 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
612 return PTR_ERR(imx_ldb->regmap); 612 return PTR_ERR(imx_ldb->regmap);
613 } 613 }
614 614
615 /* disable LDB by resetting the control register to POR default */
616 regmap_write(imx_ldb->regmap, IOMUXC_GPR2, 0);
617
615 imx_ldb->dev = dev; 618 imx_ldb->dev = dev;
616 619
617 if (of_id) 620 if (of_id)
@@ -652,14 +655,14 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
652 if (ret || i < 0 || i > 1) 655 if (ret || i < 0 || i > 1)
653 return -EINVAL; 656 return -EINVAL;
654 657
658 if (!of_device_is_available(child))
659 continue;
660
655 if (dual && i > 0) { 661 if (dual && i > 0) {
656 dev_warn(dev, "dual-channel mode, ignoring second output\n"); 662 dev_warn(dev, "dual-channel mode, ignoring second output\n");
657 continue; 663 continue;
658 } 664 }
659 665
660 if (!of_device_is_available(child))
661 continue;
662
663 channel = &imx_ldb->channel[i]; 666 channel = &imx_ldb->channel[i];
664 channel->ldb = imx_ldb; 667 channel->ldb = imx_ldb;
665 channel->chno = i; 668 channel->chno = i;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index 501d2d290e9c..70dce544984e 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -55,6 +55,9 @@ nv04_display_create(struct drm_device *dev)
55 nouveau_display(dev)->init = nv04_display_init; 55 nouveau_display(dev)->init = nv04_display_init;
56 nouveau_display(dev)->fini = nv04_display_fini; 56 nouveau_display(dev)->fini = nv04_display_fini;
57 57
58 /* Pre-nv50 doesn't support atomic, so don't expose the ioctls */
59 dev->driver->driver_features &= ~DRIVER_ATOMIC;
60
58 nouveau_hw_save_vga_fonts(dev, 1); 61 nouveau_hw_save_vga_fonts(dev, 1);
59 62
60 nv04_crtc_create(dev, 0); 63 nv04_crtc_create(dev, 0);
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index b83465ae7c1b..9bae4db84cfb 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -1585,8 +1585,9 @@ nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe)
1585 *****************************************************************************/ 1585 *****************************************************************************/
1586 1586
1587static void 1587static void
1588nv50_disp_atomic_commit_core(struct nouveau_drm *drm, u32 *interlock) 1588nv50_disp_atomic_commit_core(struct drm_atomic_state *state, u32 *interlock)
1589{ 1589{
1590 struct nouveau_drm *drm = nouveau_drm(state->dev);
1590 struct nv50_disp *disp = nv50_disp(drm->dev); 1591 struct nv50_disp *disp = nv50_disp(drm->dev);
1591 struct nv50_core *core = disp->core; 1592 struct nv50_core *core = disp->core;
1592 struct nv50_mstm *mstm; 1593 struct nv50_mstm *mstm;
@@ -1618,6 +1619,22 @@ nv50_disp_atomic_commit_core(struct nouveau_drm *drm, u32 *interlock)
1618} 1619}
1619 1620
1620static void 1621static void
1622nv50_disp_atomic_commit_wndw(struct drm_atomic_state *state, u32 *interlock)
1623{
1624 struct drm_plane_state *new_plane_state;
1625 struct drm_plane *plane;
1626 int i;
1627
1628 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1629 struct nv50_wndw *wndw = nv50_wndw(plane);
1630 if (interlock[wndw->interlock.type] & wndw->interlock.data) {
1631 if (wndw->func->update)
1632 wndw->func->update(wndw, interlock);
1633 }
1634 }
1635}
1636
1637static void
1621nv50_disp_atomic_commit_tail(struct drm_atomic_state *state) 1638nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
1622{ 1639{
1623 struct drm_device *dev = state->dev; 1640 struct drm_device *dev = state->dev;
@@ -1684,7 +1701,8 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
1684 help->disable(encoder); 1701 help->disable(encoder);
1685 interlock[NV50_DISP_INTERLOCK_CORE] |= 1; 1702 interlock[NV50_DISP_INTERLOCK_CORE] |= 1;
1686 if (outp->flush_disable) { 1703 if (outp->flush_disable) {
1687 nv50_disp_atomic_commit_core(drm, interlock); 1704 nv50_disp_atomic_commit_wndw(state, interlock);
1705 nv50_disp_atomic_commit_core(state, interlock);
1688 memset(interlock, 0x00, sizeof(interlock)); 1706 memset(interlock, 0x00, sizeof(interlock));
1689 } 1707 }
1690 } 1708 }
@@ -1693,15 +1711,8 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
1693 /* Flush disable. */ 1711 /* Flush disable. */
1694 if (interlock[NV50_DISP_INTERLOCK_CORE]) { 1712 if (interlock[NV50_DISP_INTERLOCK_CORE]) {
1695 if (atom->flush_disable) { 1713 if (atom->flush_disable) {
1696 for_each_new_plane_in_state(state, plane, new_plane_state, i) { 1714 nv50_disp_atomic_commit_wndw(state, interlock);
1697 struct nv50_wndw *wndw = nv50_wndw(plane); 1715 nv50_disp_atomic_commit_core(state, interlock);
1698 if (interlock[wndw->interlock.type] & wndw->interlock.data) {
1699 if (wndw->func->update)
1700 wndw->func->update(wndw, interlock);
1701 }
1702 }
1703
1704 nv50_disp_atomic_commit_core(drm, interlock);
1705 memset(interlock, 0x00, sizeof(interlock)); 1716 memset(interlock, 0x00, sizeof(interlock));
1706 } 1717 }
1707 } 1718 }
@@ -1762,18 +1773,14 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
1762 } 1773 }
1763 1774
1764 /* Flush update. */ 1775 /* Flush update. */
1765 for_each_new_plane_in_state(state, plane, new_plane_state, i) { 1776 nv50_disp_atomic_commit_wndw(state, interlock);
1766 struct nv50_wndw *wndw = nv50_wndw(plane);
1767 if (interlock[wndw->interlock.type] & wndw->interlock.data) {
1768 if (wndw->func->update)
1769 wndw->func->update(wndw, interlock);
1770 }
1771 }
1772 1777
1773 if (interlock[NV50_DISP_INTERLOCK_CORE]) { 1778 if (interlock[NV50_DISP_INTERLOCK_CORE]) {
1774 if (interlock[NV50_DISP_INTERLOCK_BASE] || 1779 if (interlock[NV50_DISP_INTERLOCK_BASE] ||
1780 interlock[NV50_DISP_INTERLOCK_OVLY] ||
1781 interlock[NV50_DISP_INTERLOCK_WNDW] ||
1775 !atom->state.legacy_cursor_update) 1782 !atom->state.legacy_cursor_update)
1776 nv50_disp_atomic_commit_core(drm, interlock); 1783 nv50_disp_atomic_commit_core(state, interlock);
1777 else 1784 else
1778 disp->core->func->update(disp->core, interlock, false); 1785 disp->core->func->update(disp->core, interlock, false);
1779 } 1786 }
@@ -1871,7 +1878,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,
1871 nv50_disp_atomic_commit_tail(state); 1878 nv50_disp_atomic_commit_tail(state);
1872 1879
1873 drm_for_each_crtc(crtc, dev) { 1880 drm_for_each_crtc(crtc, dev) {
1874 if (crtc->state->enable) { 1881 if (crtc->state->active) {
1875 if (!drm->have_disp_power_ref) { 1882 if (!drm->have_disp_power_ref) {
1876 drm->have_disp_power_ref = true; 1883 drm->have_disp_power_ref = true;
1877 return 0; 1884 return 0;
@@ -2119,10 +2126,6 @@ nv50_display_destroy(struct drm_device *dev)
2119 kfree(disp); 2126 kfree(disp);
2120} 2127}
2121 2128
2122MODULE_PARM_DESC(atomic, "Expose atomic ioctl (default: disabled)");
2123static int nouveau_atomic = 0;
2124module_param_named(atomic, nouveau_atomic, int, 0400);
2125
2126int 2129int
2127nv50_display_create(struct drm_device *dev) 2130nv50_display_create(struct drm_device *dev)
2128{ 2131{
@@ -2147,8 +2150,6 @@ nv50_display_create(struct drm_device *dev)
2147 disp->disp = &nouveau_display(dev)->disp; 2150 disp->disp = &nouveau_display(dev)->disp;
2148 dev->mode_config.funcs = &nv50_disp_func; 2151 dev->mode_config.funcs = &nv50_disp_func;
2149 dev->driver->driver_features |= DRIVER_PREFER_XBGR_30BPP; 2152 dev->driver->driver_features |= DRIVER_PREFER_XBGR_30BPP;
2150 if (nouveau_atomic)
2151 dev->driver->driver_features |= DRIVER_ATOMIC;
2152 2153
2153 /* small shared memory area we use for notifiers and semaphores */ 2154 /* small shared memory area we use for notifiers and semaphores */
2154 ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM, 2155 ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM,
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index debbbf0fd4bd..408b955e5c39 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -267,6 +267,7 @@ nouveau_backlight_init(struct drm_device *dev)
267 struct nouveau_drm *drm = nouveau_drm(dev); 267 struct nouveau_drm *drm = nouveau_drm(dev);
268 struct nvif_device *device = &drm->client.device; 268 struct nvif_device *device = &drm->client.device;
269 struct drm_connector *connector; 269 struct drm_connector *connector;
270 struct drm_connector_list_iter conn_iter;
270 271
271 INIT_LIST_HEAD(&drm->bl_connectors); 272 INIT_LIST_HEAD(&drm->bl_connectors);
272 273
@@ -275,7 +276,8 @@ nouveau_backlight_init(struct drm_device *dev)
275 return 0; 276 return 0;
276 } 277 }
277 278
278 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 279 drm_connector_list_iter_begin(dev, &conn_iter);
280 drm_for_each_connector_iter(connector, &conn_iter) {
279 if (connector->connector_type != DRM_MODE_CONNECTOR_LVDS && 281 if (connector->connector_type != DRM_MODE_CONNECTOR_LVDS &&
280 connector->connector_type != DRM_MODE_CONNECTOR_eDP) 282 connector->connector_type != DRM_MODE_CONNECTOR_eDP)
281 continue; 283 continue;
@@ -292,7 +294,7 @@ nouveau_backlight_init(struct drm_device *dev)
292 break; 294 break;
293 } 295 }
294 } 296 }
295 297 drm_connector_list_iter_end(&conn_iter);
296 298
297 return 0; 299 return 0;
298} 300}
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 7b557c354307..af68eae4c626 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1208,14 +1208,19 @@ nouveau_connector_create(struct drm_device *dev, int index)
1208 struct nouveau_display *disp = nouveau_display(dev); 1208 struct nouveau_display *disp = nouveau_display(dev);
1209 struct nouveau_connector *nv_connector = NULL; 1209 struct nouveau_connector *nv_connector = NULL;
1210 struct drm_connector *connector; 1210 struct drm_connector *connector;
1211 struct drm_connector_list_iter conn_iter;
1211 int type, ret = 0; 1212 int type, ret = 0;
1212 bool dummy; 1213 bool dummy;
1213 1214
1214 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1215 drm_connector_list_iter_begin(dev, &conn_iter);
1216 nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
1215 nv_connector = nouveau_connector(connector); 1217 nv_connector = nouveau_connector(connector);
1216 if (nv_connector->index == index) 1218 if (nv_connector->index == index) {
1219 drm_connector_list_iter_end(&conn_iter);
1217 return connector; 1220 return connector;
1221 }
1218 } 1222 }
1223 drm_connector_list_iter_end(&conn_iter);
1219 1224
1220 nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL); 1225 nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL);
1221 if (!nv_connector) 1226 if (!nv_connector)
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.h b/drivers/gpu/drm/nouveau/nouveau_connector.h
index a4d1a059bd3d..dc7454e7f19a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.h
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.h
@@ -33,6 +33,7 @@
33#include <drm/drm_encoder.h> 33#include <drm/drm_encoder.h>
34#include <drm/drm_dp_helper.h> 34#include <drm/drm_dp_helper.h>
35#include "nouveau_crtc.h" 35#include "nouveau_crtc.h"
36#include "nouveau_encoder.h"
36 37
37struct nvkm_i2c_port; 38struct nvkm_i2c_port;
38 39
@@ -60,19 +61,46 @@ static inline struct nouveau_connector *nouveau_connector(
60 return container_of(con, struct nouveau_connector, base); 61 return container_of(con, struct nouveau_connector, base);
61} 62}
62 63
64static inline bool
65nouveau_connector_is_mst(struct drm_connector *connector)
66{
67 const struct nouveau_encoder *nv_encoder;
68 const struct drm_encoder *encoder;
69
70 if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
71 return false;
72
73 nv_encoder = find_encoder(connector, DCB_OUTPUT_ANY);
74 if (!nv_encoder)
75 return false;
76
77 encoder = &nv_encoder->base.base;
78 return encoder->encoder_type == DRM_MODE_ENCODER_DPMST;
79}
80
81#define nouveau_for_each_non_mst_connector_iter(connector, iter) \
82 drm_for_each_connector_iter(connector, iter) \
83 for_each_if(!nouveau_connector_is_mst(connector))
84
63static inline struct nouveau_connector * 85static inline struct nouveau_connector *
64nouveau_crtc_connector_get(struct nouveau_crtc *nv_crtc) 86nouveau_crtc_connector_get(struct nouveau_crtc *nv_crtc)
65{ 87{
66 struct drm_device *dev = nv_crtc->base.dev; 88 struct drm_device *dev = nv_crtc->base.dev;
67 struct drm_connector *connector; 89 struct drm_connector *connector;
90 struct drm_connector_list_iter conn_iter;
91 struct nouveau_connector *nv_connector = NULL;
68 struct drm_crtc *crtc = to_drm_crtc(nv_crtc); 92 struct drm_crtc *crtc = to_drm_crtc(nv_crtc);
69 93
70 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 94 drm_connector_list_iter_begin(dev, &conn_iter);
71 if (connector->encoder && connector->encoder->crtc == crtc) 95 nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
72 return nouveau_connector(connector); 96 if (connector->encoder && connector->encoder->crtc == crtc) {
97 nv_connector = nouveau_connector(connector);
98 break;
99 }
73 } 100 }
101 drm_connector_list_iter_end(&conn_iter);
74 102
75 return NULL; 103 return nv_connector;
76} 104}
77 105
78struct drm_connector * 106struct drm_connector *
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 774b429142bc..ec7861457b84 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -404,6 +404,7 @@ nouveau_display_init(struct drm_device *dev)
404 struct nouveau_display *disp = nouveau_display(dev); 404 struct nouveau_display *disp = nouveau_display(dev);
405 struct nouveau_drm *drm = nouveau_drm(dev); 405 struct nouveau_drm *drm = nouveau_drm(dev);
406 struct drm_connector *connector; 406 struct drm_connector *connector;
407 struct drm_connector_list_iter conn_iter;
407 int ret; 408 int ret;
408 409
409 ret = disp->init(dev); 410 ret = disp->init(dev);
@@ -411,10 +412,12 @@ nouveau_display_init(struct drm_device *dev)
411 return ret; 412 return ret;
412 413
413 /* enable hotplug interrupts */ 414 /* enable hotplug interrupts */
414 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 415 drm_connector_list_iter_begin(dev, &conn_iter);
416 nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
415 struct nouveau_connector *conn = nouveau_connector(connector); 417 struct nouveau_connector *conn = nouveau_connector(connector);
416 nvif_notify_get(&conn->hpd); 418 nvif_notify_get(&conn->hpd);
417 } 419 }
420 drm_connector_list_iter_end(&conn_iter);
418 421
419 /* enable flip completion events */ 422 /* enable flip completion events */
420 nvif_notify_get(&drm->flip); 423 nvif_notify_get(&drm->flip);
@@ -427,6 +430,7 @@ nouveau_display_fini(struct drm_device *dev, bool suspend)
427 struct nouveau_display *disp = nouveau_display(dev); 430 struct nouveau_display *disp = nouveau_display(dev);
428 struct nouveau_drm *drm = nouveau_drm(dev); 431 struct nouveau_drm *drm = nouveau_drm(dev);
429 struct drm_connector *connector; 432 struct drm_connector *connector;
433 struct drm_connector_list_iter conn_iter;
430 434
431 if (!suspend) { 435 if (!suspend) {
432 if (drm_drv_uses_atomic_modeset(dev)) 436 if (drm_drv_uses_atomic_modeset(dev))
@@ -439,10 +443,12 @@ nouveau_display_fini(struct drm_device *dev, bool suspend)
439 nvif_notify_put(&drm->flip); 443 nvif_notify_put(&drm->flip);
440 444
441 /* disable hotplug interrupts */ 445 /* disable hotplug interrupts */
442 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 446 drm_connector_list_iter_begin(dev, &conn_iter);
447 nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
443 struct nouveau_connector *conn = nouveau_connector(connector); 448 struct nouveau_connector *conn = nouveau_connector(connector);
444 nvif_notify_put(&conn->hpd); 449 nvif_notify_put(&conn->hpd);
445 } 450 }
451 drm_connector_list_iter_end(&conn_iter);
446 452
447 drm_kms_helper_poll_disable(dev); 453 drm_kms_helper_poll_disable(dev);
448 disp->fini(dev); 454 disp->fini(dev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 775443c9af94..f5d3158f0378 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -81,6 +81,10 @@ MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
81int nouveau_modeset = -1; 81int nouveau_modeset = -1;
82module_param_named(modeset, nouveau_modeset, int, 0400); 82module_param_named(modeset, nouveau_modeset, int, 0400);
83 83
84MODULE_PARM_DESC(atomic, "Expose atomic ioctl (default: disabled)");
85static int nouveau_atomic = 0;
86module_param_named(atomic, nouveau_atomic, int, 0400);
87
84MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1)"); 88MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1)");
85static int nouveau_runtime_pm = -1; 89static int nouveau_runtime_pm = -1;
86module_param_named(runpm, nouveau_runtime_pm, int, 0400); 90module_param_named(runpm, nouveau_runtime_pm, int, 0400);
@@ -509,6 +513,9 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
509 513
510 pci_set_master(pdev); 514 pci_set_master(pdev);
511 515
516 if (nouveau_atomic)
517 driver_pci.driver_features |= DRIVER_ATOMIC;
518
512 ret = drm_get_pci_dev(pdev, pent, &driver_pci); 519 ret = drm_get_pci_dev(pdev, pent, &driver_pci);
513 if (ret) { 520 if (ret) {
514 nvkm_device_del(&device); 521 nvkm_device_del(&device);
@@ -874,22 +881,11 @@ nouveau_pmops_runtime_resume(struct device *dev)
874static int 881static int
875nouveau_pmops_runtime_idle(struct device *dev) 882nouveau_pmops_runtime_idle(struct device *dev)
876{ 883{
877 struct pci_dev *pdev = to_pci_dev(dev);
878 struct drm_device *drm_dev = pci_get_drvdata(pdev);
879 struct nouveau_drm *drm = nouveau_drm(drm_dev);
880 struct drm_crtc *crtc;
881
882 if (!nouveau_pmops_runtime()) { 884 if (!nouveau_pmops_runtime()) {
883 pm_runtime_forbid(dev); 885 pm_runtime_forbid(dev);
884 return -EBUSY; 886 return -EBUSY;
885 } 887 }
886 888
887 list_for_each_entry(crtc, &drm->dev->mode_config.crtc_list, head) {
888 if (crtc->enabled) {
889 DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
890 return -EBUSY;
891 }
892 }
893 pm_runtime_mark_last_busy(dev); 889 pm_runtime_mark_last_busy(dev);
894 pm_runtime_autosuspend(dev); 890 pm_runtime_autosuspend(dev);
895 /* we don't want the main rpm_idle to call suspend - we want to autosuspend */ 891 /* we don't want the main rpm_idle to call suspend - we want to autosuspend */
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 300daee74209..e6ccafcb9c41 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -616,7 +616,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
616 struct nouveau_bo *nvbo; 616 struct nouveau_bo *nvbo;
617 uint32_t data; 617 uint32_t data;
618 618
619 if (unlikely(r->bo_index > req->nr_buffers)) { 619 if (unlikely(r->bo_index >= req->nr_buffers)) {
620 NV_PRINTK(err, cli, "reloc bo index invalid\n"); 620 NV_PRINTK(err, cli, "reloc bo index invalid\n");
621 ret = -EINVAL; 621 ret = -EINVAL;
622 break; 622 break;
@@ -626,7 +626,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
626 if (b->presumed.valid) 626 if (b->presumed.valid)
627 continue; 627 continue;
628 628
629 if (unlikely(r->reloc_bo_index > req->nr_buffers)) { 629 if (unlikely(r->reloc_bo_index >= req->nr_buffers)) {
630 NV_PRINTK(err, cli, "reloc container bo index invalid\n"); 630 NV_PRINTK(err, cli, "reloc container bo index invalid\n");
631 ret = -EINVAL; 631 ret = -EINVAL;
632 break; 632 break;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
index 73b5d46104bd..434d2fc5bb1c 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/base.c
@@ -140,6 +140,9 @@ nvkm_fb_init(struct nvkm_subdev *subdev)
140 if (fb->func->init) 140 if (fb->func->init)
141 fb->func->init(fb); 141 fb->func->init(fb);
142 142
143 if (fb->func->init_remapper)
144 fb->func->init_remapper(fb);
145
143 if (fb->func->init_page) { 146 if (fb->func->init_page) {
144 ret = fb->func->init_page(fb); 147 ret = fb->func->init_page(fb);
145 if (WARN_ON(ret)) 148 if (WARN_ON(ret))
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp100.c
index dffe1f5e1071..8205ce436b3e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp100.c
@@ -37,6 +37,14 @@ gp100_fb_init_unkn(struct nvkm_fb *base)
37} 37}
38 38
39void 39void
40gp100_fb_init_remapper(struct nvkm_fb *fb)
41{
42 struct nvkm_device *device = fb->subdev.device;
43 /* Disable address remapper. */
44 nvkm_mask(device, 0x100c14, 0x00040000, 0x00000000);
45}
46
47void
40gp100_fb_init(struct nvkm_fb *base) 48gp100_fb_init(struct nvkm_fb *base)
41{ 49{
42 struct gf100_fb *fb = gf100_fb(base); 50 struct gf100_fb *fb = gf100_fb(base);
@@ -56,6 +64,7 @@ gp100_fb = {
56 .dtor = gf100_fb_dtor, 64 .dtor = gf100_fb_dtor,
57 .oneinit = gf100_fb_oneinit, 65 .oneinit = gf100_fb_oneinit,
58 .init = gp100_fb_init, 66 .init = gp100_fb_init,
67 .init_remapper = gp100_fb_init_remapper,
59 .init_page = gm200_fb_init_page, 68 .init_page = gm200_fb_init_page,
60 .init_unkn = gp100_fb_init_unkn, 69 .init_unkn = gp100_fb_init_unkn,
61 .ram_new = gp100_ram_new, 70 .ram_new = gp100_ram_new,
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp102.c
index b84b9861ef26..b4d74e815674 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gp102.c
@@ -31,6 +31,7 @@ gp102_fb = {
31 .dtor = gf100_fb_dtor, 31 .dtor = gf100_fb_dtor,
32 .oneinit = gf100_fb_oneinit, 32 .oneinit = gf100_fb_oneinit,
33 .init = gp100_fb_init, 33 .init = gp100_fb_init,
34 .init_remapper = gp100_fb_init_remapper,
34 .init_page = gm200_fb_init_page, 35 .init_page = gm200_fb_init_page,
35 .ram_new = gp100_ram_new, 36 .ram_new = gp100_ram_new,
36}; 37};
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
index 2857f31466bf..1e4ad61c19e1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h
@@ -11,6 +11,7 @@ struct nvkm_fb_func {
11 u32 (*tags)(struct nvkm_fb *); 11 u32 (*tags)(struct nvkm_fb *);
12 int (*oneinit)(struct nvkm_fb *); 12 int (*oneinit)(struct nvkm_fb *);
13 void (*init)(struct nvkm_fb *); 13 void (*init)(struct nvkm_fb *);
14 void (*init_remapper)(struct nvkm_fb *);
14 int (*init_page)(struct nvkm_fb *); 15 int (*init_page)(struct nvkm_fb *);
15 void (*init_unkn)(struct nvkm_fb *); 16 void (*init_unkn)(struct nvkm_fb *);
16 void (*intr)(struct nvkm_fb *); 17 void (*intr)(struct nvkm_fb *);
@@ -69,5 +70,6 @@ int gf100_fb_init_page(struct nvkm_fb *);
69 70
70int gm200_fb_init_page(struct nvkm_fb *); 71int gm200_fb_init_page(struct nvkm_fb *);
71 72
73void gp100_fb_init_remapper(struct nvkm_fb *);
72void gp100_fb_init_unkn(struct nvkm_fb *); 74void gp100_fb_init_unkn(struct nvkm_fb *);
73#endif 75#endif
diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
index 2589f4acd5ae..9c81301d0eed 100644
--- a/drivers/gpu/drm/sun4i/Makefile
+++ b/drivers/gpu/drm/sun4i/Makefile
@@ -32,7 +32,10 @@ obj-$(CONFIG_DRM_SUN4I) += sun4i-tcon.o
32obj-$(CONFIG_DRM_SUN4I) += sun4i_tv.o 32obj-$(CONFIG_DRM_SUN4I) += sun4i_tv.o
33obj-$(CONFIG_DRM_SUN4I) += sun6i_drc.o 33obj-$(CONFIG_DRM_SUN4I) += sun6i_drc.o
34 34
35obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o sun4i-frontend.o 35obj-$(CONFIG_DRM_SUN4I_BACKEND) += sun4i-backend.o
36ifdef CONFIG_DRM_SUN4I_BACKEND
37obj-$(CONFIG_DRM_SUN4I) += sun4i-frontend.o
38endif
36obj-$(CONFIG_DRM_SUN4I_HDMI) += sun4i-drm-hdmi.o 39obj-$(CONFIG_DRM_SUN4I_HDMI) += sun4i-drm-hdmi.o
37obj-$(CONFIG_DRM_SUN6I_DSI) += sun6i-dsi.o 40obj-$(CONFIG_DRM_SUN6I_DSI) += sun6i-dsi.o
38obj-$(CONFIG_DRM_SUN8I_DW_HDMI) += sun8i-drm-hdmi.o 41obj-$(CONFIG_DRM_SUN8I_DW_HDMI) += sun8i-drm-hdmi.o
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 776c1513e582..a2bd5876c633 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -398,7 +398,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
398 * unaligned offset is malformed and cause commands stream 398 * unaligned offset is malformed and cause commands stream
399 * corruption on the buffer address relocation. 399 * corruption on the buffer address relocation.
400 */ 400 */
401 if (offset & 3 || offset >= obj->gem.size) { 401 if (offset & 3 || offset > obj->gem.size) {
402 err = -EINVAL; 402 err = -EINVAL;
403 goto fail; 403 goto fail;
404 } 404 }
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 1d34619eb3fe..a951ec75d01f 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -320,6 +320,9 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
320 vc4_state->x_scaling[0] = VC4_SCALING_TPZ; 320 vc4_state->x_scaling[0] = VC4_SCALING_TPZ;
321 if (vc4_state->y_scaling[0] == VC4_SCALING_NONE) 321 if (vc4_state->y_scaling[0] == VC4_SCALING_NONE)
322 vc4_state->y_scaling[0] = VC4_SCALING_TPZ; 322 vc4_state->y_scaling[0] = VC4_SCALING_TPZ;
323 } else {
324 vc4_state->x_scaling[1] = VC4_SCALING_NONE;
325 vc4_state->y_scaling[1] = VC4_SCALING_NONE;
323 } 326 }
324 327
325 vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE && 328 vc4_state->is_unity = (vc4_state->x_scaling[0] == VC4_SCALING_NONE &&
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
index f1d5f76e9c33..d88073e7d22d 100644
--- a/drivers/gpu/host1x/dev.c
+++ b/drivers/gpu/host1x/dev.c
@@ -218,6 +218,9 @@ static int host1x_probe(struct platform_device *pdev)
218 return err; 218 return err;
219 } 219 }
220 220
221 if (IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL))
222 goto skip_iommu;
223
221 host->group = iommu_group_get(&pdev->dev); 224 host->group = iommu_group_get(&pdev->dev);
222 if (host->group) { 225 if (host->group) {
223 struct iommu_domain_geometry *geometry; 226 struct iommu_domain_geometry *geometry;
diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
index e2f4a4d93d20..527a1cddb14f 100644
--- a/drivers/gpu/host1x/job.c
+++ b/drivers/gpu/host1x/job.c
@@ -569,7 +569,8 @@ void host1x_job_unpin(struct host1x_job *job)
569 for (i = 0; i < job->num_unpins; i++) { 569 for (i = 0; i < job->num_unpins; i++) {
570 struct host1x_job_unpin_data *unpin = &job->unpins[i]; 570 struct host1x_job_unpin_data *unpin = &job->unpins[i];
571 571
572 if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) { 572 if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) &&
573 unpin->size && host->domain) {
573 iommu_unmap(host->domain, job->addr_phys[i], 574 iommu_unmap(host->domain, job->addr_phys[i],
574 unpin->size); 575 unpin->size);
575 free_iova(&host->iova, 576 free_iova(&host->iova,
diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index caa05b0702e1..5450a2db1219 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -339,7 +339,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
339 break; 339 break;
340 case V4L2_MBUS_BT656: 340 case V4L2_MBUS_BT656:
341 csicfg->ext_vsync = 0; 341 csicfg->ext_vsync = 0;
342 if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field)) 342 if (V4L2_FIELD_HAS_BOTH(mbus_fmt->field) ||
343 mbus_fmt->field == V4L2_FIELD_ALTERNATE)
343 csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED; 344 csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_INTERLACED;
344 else 345 else
345 csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE; 346 csicfg->clk_mode = IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE;
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 75d6ab177055..7379043711df 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -237,12 +237,16 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
237 /* 237 /*
238 * It's not always possible to have 1 to 2 ratio when d=7, so fall back 238 * It's not always possible to have 1 to 2 ratio when d=7, so fall back
239 * to minimal possible clkh in this case. 239 * to minimal possible clkh in this case.
240 *
241 * Note:
242 * CLKH is not allowed to be 0, in this case I2C clock is not generated
243 * at all
240 */ 244 */
241 if (clk >= clkl + d) { 245 if (clk > clkl + d) {
242 clkh = clk - clkl - d; 246 clkh = clk - clkl - d;
243 clkl -= d; 247 clkl -= d;
244 } else { 248 } else {
245 clkh = 0; 249 clkh = 1;
246 clkl = clk - (d << 1); 250 clkl = clk - (d << 1);
247 } 251 }
248 252
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 0207e194f84b..498c5e891649 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -368,6 +368,7 @@ static int i2c_imx_dma_xfer(struct imx_i2c_struct *i2c_imx,
368 goto err_desc; 368 goto err_desc;
369 } 369 }
370 370
371 reinit_completion(&dma->cmd_complete);
371 txdesc->callback = i2c_imx_dma_callback; 372 txdesc->callback = i2c_imx_dma_callback;
372 txdesc->callback_param = i2c_imx; 373 txdesc->callback_param = i2c_imx;
373 if (dma_submit_error(dmaengine_submit(txdesc))) { 374 if (dma_submit_error(dmaengine_submit(txdesc))) {
@@ -622,7 +623,6 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx,
622 * The first byte must be transmitted by the CPU. 623 * The first byte must be transmitted by the CPU.
623 */ 624 */
624 imx_i2c_write_reg(i2c_8bit_addr_from_msg(msgs), i2c_imx, IMX_I2C_I2DR); 625 imx_i2c_write_reg(i2c_8bit_addr_from_msg(msgs), i2c_imx, IMX_I2C_I2DR);
625 reinit_completion(&i2c_imx->dma->cmd_complete);
626 time_left = wait_for_completion_timeout( 626 time_left = wait_for_completion_timeout(
627 &i2c_imx->dma->cmd_complete, 627 &i2c_imx->dma->cmd_complete,
628 msecs_to_jiffies(DMA_TIMEOUT)); 628 msecs_to_jiffies(DMA_TIMEOUT));
@@ -681,7 +681,6 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
681 if (result) 681 if (result)
682 return result; 682 return result;
683 683
684 reinit_completion(&i2c_imx->dma->cmd_complete);
685 time_left = wait_for_completion_timeout( 684 time_left = wait_for_completion_timeout(
686 &i2c_imx->dma->cmd_complete, 685 &i2c_imx->dma->cmd_complete,
687 msecs_to_jiffies(DMA_TIMEOUT)); 686 msecs_to_jiffies(DMA_TIMEOUT));
@@ -1010,7 +1009,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
1010 i2c_imx->pinctrl_pins_gpio = pinctrl_lookup_state(i2c_imx->pinctrl, 1009 i2c_imx->pinctrl_pins_gpio = pinctrl_lookup_state(i2c_imx->pinctrl,
1011 "gpio"); 1010 "gpio");
1012 rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN); 1011 rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
1013 rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl", GPIOD_OUT_HIGH); 1012 rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN);
1014 1013
1015 if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER || 1014 if (PTR_ERR(rinfo->sda_gpiod) == -EPROBE_DEFER ||
1016 PTR_ERR(rinfo->scl_gpiod) == -EPROBE_DEFER) { 1015 PTR_ERR(rinfo->scl_gpiod) == -EPROBE_DEFER) {
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 5e310efd9446..3c1c817f6968 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -32,6 +32,7 @@
32#include <linux/of_device.h> 32#include <linux/of_device.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/pm_runtime.h> 34#include <linux/pm_runtime.h>
35#include <linux/reset.h>
35#include <linux/slab.h> 36#include <linux/slab.h>
36 37
37/* register offsets */ 38/* register offsets */
@@ -111,8 +112,9 @@
111#define ID_ARBLOST (1 << 3) 112#define ID_ARBLOST (1 << 3)
112#define ID_NACK (1 << 4) 113#define ID_NACK (1 << 4)
113/* persistent flags */ 114/* persistent flags */
115#define ID_P_NO_RXDMA (1 << 30) /* HW forbids RXDMA sometimes */
114#define ID_P_PM_BLOCKED (1 << 31) 116#define ID_P_PM_BLOCKED (1 << 31)
115#define ID_P_MASK ID_P_PM_BLOCKED 117#define ID_P_MASK (ID_P_PM_BLOCKED | ID_P_NO_RXDMA)
116 118
117enum rcar_i2c_type { 119enum rcar_i2c_type {
118 I2C_RCAR_GEN1, 120 I2C_RCAR_GEN1,
@@ -141,6 +143,8 @@ struct rcar_i2c_priv {
141 struct dma_chan *dma_rx; 143 struct dma_chan *dma_rx;
142 struct scatterlist sg; 144 struct scatterlist sg;
143 enum dma_data_direction dma_direction; 145 enum dma_data_direction dma_direction;
146
147 struct reset_control *rstc;
144}; 148};
145 149
146#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent) 150#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
@@ -370,6 +374,11 @@ static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv)
370 dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg), 374 dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg),
371 sg_dma_len(&priv->sg), priv->dma_direction); 375 sg_dma_len(&priv->sg), priv->dma_direction);
372 376
377 /* Gen3 can only do one RXDMA per transfer and we just completed it */
378 if (priv->devtype == I2C_RCAR_GEN3 &&
379 priv->dma_direction == DMA_FROM_DEVICE)
380 priv->flags |= ID_P_NO_RXDMA;
381
373 priv->dma_direction = DMA_NONE; 382 priv->dma_direction = DMA_NONE;
374} 383}
375 384
@@ -407,8 +416,9 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv)
407 unsigned char *buf; 416 unsigned char *buf;
408 int len; 417 int len;
409 418
410 /* Do not use DMA if it's not available or for messages < 8 bytes */ 419 /* Do various checks to see if DMA is feasible at all */
411 if (IS_ERR(chan) || msg->len < 8 || !(msg->flags & I2C_M_DMA_SAFE)) 420 if (IS_ERR(chan) || msg->len < 8 || !(msg->flags & I2C_M_DMA_SAFE) ||
421 (read && priv->flags & ID_P_NO_RXDMA))
412 return; 422 return;
413 423
414 if (read) { 424 if (read) {
@@ -739,6 +749,25 @@ static void rcar_i2c_release_dma(struct rcar_i2c_priv *priv)
739 } 749 }
740} 750}
741 751
752/* I2C is a special case, we need to poll the status of a reset */
753static int rcar_i2c_do_reset(struct rcar_i2c_priv *priv)
754{
755 int i, ret;
756
757 ret = reset_control_reset(priv->rstc);
758 if (ret)
759 return ret;
760
761 for (i = 0; i < LOOP_TIMEOUT; i++) {
762 ret = reset_control_status(priv->rstc);
763 if (ret == 0)
764 return 0;
765 udelay(1);
766 }
767
768 return -ETIMEDOUT;
769}
770
742static int rcar_i2c_master_xfer(struct i2c_adapter *adap, 771static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
743 struct i2c_msg *msgs, 772 struct i2c_msg *msgs,
744 int num) 773 int num)
@@ -750,6 +779,16 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
750 779
751 pm_runtime_get_sync(dev); 780 pm_runtime_get_sync(dev);
752 781
782 /* Gen3 needs a reset before allowing RXDMA once */
783 if (priv->devtype == I2C_RCAR_GEN3) {
784 priv->flags |= ID_P_NO_RXDMA;
785 if (!IS_ERR(priv->rstc)) {
786 ret = rcar_i2c_do_reset(priv);
787 if (ret == 0)
788 priv->flags &= ~ID_P_NO_RXDMA;
789 }
790 }
791
753 rcar_i2c_init(priv); 792 rcar_i2c_init(priv);
754 793
755 ret = rcar_i2c_bus_barrier(priv); 794 ret = rcar_i2c_bus_barrier(priv);
@@ -920,6 +959,15 @@ static int rcar_i2c_probe(struct platform_device *pdev)
920 if (ret < 0) 959 if (ret < 0)
921 goto out_pm_put; 960 goto out_pm_put;
922 961
962 if (priv->devtype == I2C_RCAR_GEN3) {
963 priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
964 if (!IS_ERR(priv->rstc)) {
965 ret = reset_control_status(priv->rstc);
966 if (ret < 0)
967 priv->rstc = ERR_PTR(-ENOTSUPP);
968 }
969 }
970
923 /* Stay always active when multi-master to keep arbitration working */ 971 /* Stay always active when multi-master to keep arbitration working */
924 if (of_property_read_bool(dev->of_node, "multi-master")) 972 if (of_property_read_bool(dev->of_node, "multi-master"))
925 priv->flags |= ID_P_PM_BLOCKED; 973 priv->flags |= ID_P_PM_BLOCKED;
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 301285c54603..15c95aaa484c 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -624,7 +624,7 @@ static int i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
624static void i2c_adapter_lock_bus(struct i2c_adapter *adapter, 624static void i2c_adapter_lock_bus(struct i2c_adapter *adapter,
625 unsigned int flags) 625 unsigned int flags)
626{ 626{
627 rt_mutex_lock(&adapter->bus_lock); 627 rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
628} 628}
629 629
630/** 630/**
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 300ab4b672e4..29646aa6132e 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -144,7 +144,7 @@ static void i2c_mux_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
144 struct i2c_mux_priv *priv = adapter->algo_data; 144 struct i2c_mux_priv *priv = adapter->algo_data;
145 struct i2c_adapter *parent = priv->muxc->parent; 145 struct i2c_adapter *parent = priv->muxc->parent;
146 146
147 rt_mutex_lock(&parent->mux_lock); 147 rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter));
148 if (!(flags & I2C_LOCK_ROOT_ADAPTER)) 148 if (!(flags & I2C_LOCK_ROOT_ADAPTER))
149 return; 149 return;
150 i2c_lock_bus(parent, flags); 150 i2c_lock_bus(parent, flags);
@@ -181,7 +181,7 @@ static void i2c_parent_lock_bus(struct i2c_adapter *adapter,
181 struct i2c_mux_priv *priv = adapter->algo_data; 181 struct i2c_mux_priv *priv = adapter->algo_data;
182 struct i2c_adapter *parent = priv->muxc->parent; 182 struct i2c_adapter *parent = priv->muxc->parent;
183 183
184 rt_mutex_lock(&parent->mux_lock); 184 rt_mutex_lock_nested(&parent->mux_lock, i2c_adapter_depth(adapter));
185 i2c_lock_bus(parent, flags); 185 i2c_lock_bus(parent, flags);
186} 186}
187 187
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index cc06e8404e9b..583d3a10b940 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1984,15 +1984,64 @@ static int modify_qp(struct ib_uverbs_file *file,
1984 goto release_qp; 1984 goto release_qp;
1985 } 1985 }
1986 1986
1987 if ((cmd->base.attr_mask & IB_QP_AV) && 1987 if ((cmd->base.attr_mask & IB_QP_AV)) {
1988 !rdma_is_port_valid(qp->device, cmd->base.dest.port_num)) { 1988 if (!rdma_is_port_valid(qp->device, cmd->base.dest.port_num)) {
1989 ret = -EINVAL; 1989 ret = -EINVAL;
1990 goto release_qp; 1990 goto release_qp;
1991 }
1992
1993 if (cmd->base.attr_mask & IB_QP_STATE &&
1994 cmd->base.qp_state == IB_QPS_RTR) {
1995 /* We are in INIT->RTR TRANSITION (if we are not,
1996 * this transition will be rejected in subsequent checks).
1997 * In the INIT->RTR transition, we cannot have IB_QP_PORT set,
1998 * but the IB_QP_STATE flag is required.
1999 *
2000 * Since kernel 3.14 (commit dbf727de7440), the uverbs driver,
2001 * when IB_QP_AV is set, has required inclusion of a valid
2002 * port number in the primary AV. (AVs are created and handled
2003 * differently for infiniband and ethernet (RoCE) ports).
2004 *
2005 * Check the port number included in the primary AV against
2006 * the port number in the qp struct, which was set (and saved)
2007 * in the RST->INIT transition.
2008 */
2009 if (cmd->base.dest.port_num != qp->real_qp->port) {
2010 ret = -EINVAL;
2011 goto release_qp;
2012 }
2013 } else {
2014 /* We are in SQD->SQD. (If we are not, this transition will
2015 * be rejected later in the verbs layer checks).
2016 * Check for both IB_QP_PORT and IB_QP_AV, these can be set
2017 * together in the SQD->SQD transition.
2018 *
2019 * If only IP_QP_AV was set, add in IB_QP_PORT as well (the
2020 * verbs layer driver does not track primary port changes
2021 * resulting from path migration. Thus, in SQD, if the primary
2022 * AV is modified, the primary port should also be modified).
2023 *
2024 * Note that in this transition, the IB_QP_STATE flag
2025 * is not allowed.
2026 */
2027 if (((cmd->base.attr_mask & (IB_QP_AV | IB_QP_PORT))
2028 == (IB_QP_AV | IB_QP_PORT)) &&
2029 cmd->base.port_num != cmd->base.dest.port_num) {
2030 ret = -EINVAL;
2031 goto release_qp;
2032 }
2033 if ((cmd->base.attr_mask & (IB_QP_AV | IB_QP_PORT))
2034 == IB_QP_AV) {
2035 cmd->base.attr_mask |= IB_QP_PORT;
2036 cmd->base.port_num = cmd->base.dest.port_num;
2037 }
2038 }
1991 } 2039 }
1992 2040
1993 if ((cmd->base.attr_mask & IB_QP_ALT_PATH) && 2041 if ((cmd->base.attr_mask & IB_QP_ALT_PATH) &&
1994 (!rdma_is_port_valid(qp->device, cmd->base.alt_port_num) || 2042 (!rdma_is_port_valid(qp->device, cmd->base.alt_port_num) ||
1995 !rdma_is_port_valid(qp->device, cmd->base.alt_dest.port_num))) { 2043 !rdma_is_port_valid(qp->device, cmd->base.alt_dest.port_num) ||
2044 cmd->base.alt_port_num != cmd->base.alt_dest.port_num)) {
1996 ret = -EINVAL; 2045 ret = -EINVAL;
1997 goto release_qp; 2046 goto release_qp;
1998 } 2047 }
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 1f9cd7d8b7ad..f5ae24865355 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1346,6 +1346,8 @@ static const struct acpi_device_id elan_acpi_id[] = {
1346 { "ELAN0611", 0 }, 1346 { "ELAN0611", 0 },
1347 { "ELAN0612", 0 }, 1347 { "ELAN0612", 0 },
1348 { "ELAN0618", 0 }, 1348 { "ELAN0618", 0 },
1349 { "ELAN061D", 0 },
1350 { "ELAN0622", 0 },
1349 { "ELAN1000", 0 }, 1351 { "ELAN1000", 0 },
1350 { } 1352 { }
1351}; 1353};
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index b353d494ad40..136f6e7bf797 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -527,6 +527,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
527 DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"), 527 DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"),
528 }, 528 },
529 }, 529 },
530 {
531 /* Lenovo LaVie Z */
532 .matches = {
533 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
534 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"),
535 },
536 },
530 { } 537 { }
531}; 538};
532 539
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index b344a883f116..115ff26e9ced 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -484,14 +484,37 @@ static int dmar_forcedac;
484static int intel_iommu_strict; 484static int intel_iommu_strict;
485static int intel_iommu_superpage = 1; 485static int intel_iommu_superpage = 1;
486static int intel_iommu_ecs = 1; 486static int intel_iommu_ecs = 1;
487static int intel_iommu_pasid28;
487static int iommu_identity_mapping; 488static int iommu_identity_mapping;
488 489
489#define IDENTMAP_ALL 1 490#define IDENTMAP_ALL 1
490#define IDENTMAP_GFX 2 491#define IDENTMAP_GFX 2
491#define IDENTMAP_AZALIA 4 492#define IDENTMAP_AZALIA 4
492 493
493#define ecs_enabled(iommu) (intel_iommu_ecs && ecap_ecs(iommu->ecap)) 494/* Broadwell and Skylake have broken ECS support — normal so-called "second
494#define pasid_enabled(iommu) (ecs_enabled(iommu) && ecap_pasid(iommu->ecap)) 495 * level" translation of DMA requests-without-PASID doesn't actually happen
496 * unless you also set the NESTE bit in an extended context-entry. Which of
497 * course means that SVM doesn't work because it's trying to do nested
498 * translation of the physical addresses it finds in the process page tables,
499 * through the IOVA->phys mapping found in the "second level" page tables.
500 *
501 * The VT-d specification was retroactively changed to change the definition
502 * of the capability bits and pretend that Broadwell/Skylake never happened...
503 * but unfortunately the wrong bit was changed. It's ECS which is broken, but
504 * for some reason it was the PASID capability bit which was redefined (from
505 * bit 28 on BDW/SKL to bit 40 in future).
506 *
507 * So our test for ECS needs to eschew those implementations which set the old
508 * PASID capabiity bit 28, since those are the ones on which ECS is broken.
509 * Unless we are working around the 'pasid28' limitations, that is, by putting
510 * the device into passthrough mode for normal DMA and thus masking the bug.
511 */
512#define ecs_enabled(iommu) (intel_iommu_ecs && ecap_ecs(iommu->ecap) && \
513 (intel_iommu_pasid28 || !ecap_broken_pasid(iommu->ecap)))
514/* PASID support is thus enabled if ECS is enabled and *either* of the old
515 * or new capability bits are set. */
516#define pasid_enabled(iommu) (ecs_enabled(iommu) && \
517 (ecap_pasid(iommu->ecap) || ecap_broken_pasid(iommu->ecap)))
495 518
496int intel_iommu_gfx_mapped; 519int intel_iommu_gfx_mapped;
497EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped); 520EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped);
@@ -554,6 +577,11 @@ static int __init intel_iommu_setup(char *str)
554 printk(KERN_INFO 577 printk(KERN_INFO
555 "Intel-IOMMU: disable extended context table support\n"); 578 "Intel-IOMMU: disable extended context table support\n");
556 intel_iommu_ecs = 0; 579 intel_iommu_ecs = 0;
580 } else if (!strncmp(str, "pasid28", 7)) {
581 printk(KERN_INFO
582 "Intel-IOMMU: enable pre-production PASID support\n");
583 intel_iommu_pasid28 = 1;
584 iommu_identity_mapping |= IDENTMAP_GFX;
557 } else if (!strncmp(str, "tboot_noforce", 13)) { 585 } else if (!strncmp(str, "tboot_noforce", 13)) {
558 printk(KERN_INFO 586 printk(KERN_INFO
559 "Intel-IOMMU: not forcing on after tboot. This could expose security risk for tboot\n"); 587 "Intel-IOMMU: not forcing on after tboot. This could expose security risk for tboot\n");
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index 07ea6a48aac6..87107c995cb5 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -136,6 +136,7 @@ struct dm_writecache {
136 struct dm_target *ti; 136 struct dm_target *ti;
137 struct dm_dev *dev; 137 struct dm_dev *dev;
138 struct dm_dev *ssd_dev; 138 struct dm_dev *ssd_dev;
139 sector_t start_sector;
139 void *memory_map; 140 void *memory_map;
140 uint64_t memory_map_size; 141 uint64_t memory_map_size;
141 size_t metadata_sectors; 142 size_t metadata_sectors;
@@ -293,6 +294,10 @@ static int persistent_memory_claim(struct dm_writecache *wc)
293 } 294 }
294 295
295 dax_read_unlock(id); 296 dax_read_unlock(id);
297
298 wc->memory_map += (size_t)wc->start_sector << SECTOR_SHIFT;
299 wc->memory_map_size -= (size_t)wc->start_sector << SECTOR_SHIFT;
300
296 return 0; 301 return 0;
297err3: 302err3:
298 kvfree(pages); 303 kvfree(pages);
@@ -311,7 +316,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
311static void persistent_memory_release(struct dm_writecache *wc) 316static void persistent_memory_release(struct dm_writecache *wc)
312{ 317{
313 if (wc->memory_vmapped) 318 if (wc->memory_vmapped)
314 vunmap(wc->memory_map); 319 vunmap(wc->memory_map - ((size_t)wc->start_sector << SECTOR_SHIFT));
315} 320}
316 321
317static struct page *persistent_memory_page(void *addr) 322static struct page *persistent_memory_page(void *addr)
@@ -359,7 +364,7 @@ static void *memory_data(struct dm_writecache *wc, struct wc_entry *e)
359 364
360static sector_t cache_sector(struct dm_writecache *wc, struct wc_entry *e) 365static sector_t cache_sector(struct dm_writecache *wc, struct wc_entry *e)
361{ 366{
362 return wc->metadata_sectors + 367 return wc->start_sector + wc->metadata_sectors +
363 ((sector_t)e->index << (wc->block_size_bits - SECTOR_SHIFT)); 368 ((sector_t)e->index << (wc->block_size_bits - SECTOR_SHIFT));
364} 369}
365 370
@@ -471,6 +476,7 @@ static void ssd_commit_flushed(struct dm_writecache *wc)
471 if (unlikely(region.sector + region.count > wc->metadata_sectors)) 476 if (unlikely(region.sector + region.count > wc->metadata_sectors))
472 region.count = wc->metadata_sectors - region.sector; 477 region.count = wc->metadata_sectors - region.sector;
473 478
479 region.sector += wc->start_sector;
474 atomic_inc(&endio.count); 480 atomic_inc(&endio.count);
475 req.bi_op = REQ_OP_WRITE; 481 req.bi_op = REQ_OP_WRITE;
476 req.bi_op_flags = REQ_SYNC; 482 req.bi_op_flags = REQ_SYNC;
@@ -1946,14 +1952,6 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
1946 } 1952 }
1947 wc->memory_map_size = i_size_read(wc->ssd_dev->bdev->bd_inode); 1953 wc->memory_map_size = i_size_read(wc->ssd_dev->bdev->bd_inode);
1948 1954
1949 if (WC_MODE_PMEM(wc)) {
1950 r = persistent_memory_claim(wc);
1951 if (r) {
1952 ti->error = "Unable to map persistent memory for cache";
1953 goto bad;
1954 }
1955 }
1956
1957 /* 1955 /*
1958 * Parse the cache block size 1956 * Parse the cache block size
1959 */ 1957 */
@@ -1982,7 +1980,16 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
1982 1980
1983 while (opt_params) { 1981 while (opt_params) {
1984 string = dm_shift_arg(&as), opt_params--; 1982 string = dm_shift_arg(&as), opt_params--;
1985 if (!strcasecmp(string, "high_watermark") && opt_params >= 1) { 1983 if (!strcasecmp(string, "start_sector") && opt_params >= 1) {
1984 unsigned long long start_sector;
1985 string = dm_shift_arg(&as), opt_params--;
1986 if (sscanf(string, "%llu%c", &start_sector, &dummy) != 1)
1987 goto invalid_optional;
1988 wc->start_sector = start_sector;
1989 if (wc->start_sector != start_sector ||
1990 wc->start_sector >= wc->memory_map_size >> SECTOR_SHIFT)
1991 goto invalid_optional;
1992 } else if (!strcasecmp(string, "high_watermark") && opt_params >= 1) {
1986 string = dm_shift_arg(&as), opt_params--; 1993 string = dm_shift_arg(&as), opt_params--;
1987 if (sscanf(string, "%d%c", &high_wm_percent, &dummy) != 1) 1994 if (sscanf(string, "%d%c", &high_wm_percent, &dummy) != 1)
1988 goto invalid_optional; 1995 goto invalid_optional;
@@ -2039,12 +2046,20 @@ invalid_optional:
2039 goto bad; 2046 goto bad;
2040 } 2047 }
2041 2048
2042 if (!WC_MODE_PMEM(wc)) { 2049 if (WC_MODE_PMEM(wc)) {
2050 r = persistent_memory_claim(wc);
2051 if (r) {
2052 ti->error = "Unable to map persistent memory for cache";
2053 goto bad;
2054 }
2055 } else {
2043 struct dm_io_region region; 2056 struct dm_io_region region;
2044 struct dm_io_request req; 2057 struct dm_io_request req;
2045 size_t n_blocks, n_metadata_blocks; 2058 size_t n_blocks, n_metadata_blocks;
2046 uint64_t n_bitmap_bits; 2059 uint64_t n_bitmap_bits;
2047 2060
2061 wc->memory_map_size -= (uint64_t)wc->start_sector << SECTOR_SHIFT;
2062
2048 bio_list_init(&wc->flush_list); 2063 bio_list_init(&wc->flush_list);
2049 wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush"); 2064 wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
2050 if (IS_ERR(wc->flush_thread)) { 2065 if (IS_ERR(wc->flush_thread)) {
@@ -2097,7 +2112,7 @@ invalid_optional:
2097 } 2112 }
2098 2113
2099 region.bdev = wc->ssd_dev->bdev; 2114 region.bdev = wc->ssd_dev->bdev;
2100 region.sector = 0; 2115 region.sector = wc->start_sector;
2101 region.count = wc->metadata_sectors; 2116 region.count = wc->metadata_sectors;
2102 req.bi_op = REQ_OP_READ; 2117 req.bi_op = REQ_OP_READ;
2103 req.bi_op_flags = REQ_SYNC; 2118 req.bi_op_flags = REQ_SYNC;
@@ -2265,7 +2280,7 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
2265 2280
2266static struct target_type writecache_target = { 2281static struct target_type writecache_target = {
2267 .name = "writecache", 2282 .name = "writecache",
2268 .version = {1, 0, 0}, 2283 .version = {1, 1, 0},
2269 .module = THIS_MODULE, 2284 .module = THIS_MODULE,
2270 .ctr = writecache_ctr, 2285 .ctr = writecache_ctr,
2271 .dtr = writecache_dtr, 2286 .dtr = writecache_dtr,
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index edb35a5c57ea..a99fc0ced7a7 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -728,9 +728,6 @@ EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
728 */ 728 */
729void vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index) 729void vsp1_du_atomic_begin(struct device *dev, unsigned int pipe_index)
730{ 730{
731 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
732
733 mutex_lock(&vsp1->drm->lock);
734} 731}
735EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin); 732EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
736 733
@@ -846,6 +843,7 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned int pipe_index,
846 843
847 drm_pipe->crc = cfg->crc; 844 drm_pipe->crc = cfg->crc;
848 845
846 mutex_lock(&vsp1->drm->lock);
849 vsp1_du_pipeline_setup_inputs(vsp1, pipe); 847 vsp1_du_pipeline_setup_inputs(vsp1, pipe);
850 vsp1_du_pipeline_configure(pipe); 848 vsp1_du_pipeline_configure(pipe);
851 mutex_unlock(&vsp1->drm->lock); 849 mutex_unlock(&vsp1->drm->lock);
diff --git a/drivers/media/rc/bpf-lirc.c b/drivers/media/rc/bpf-lirc.c
index fcfab6635f9c..81b150e5dfdb 100644
--- a/drivers/media/rc/bpf-lirc.c
+++ b/drivers/media/rc/bpf-lirc.c
@@ -174,6 +174,7 @@ static int lirc_bpf_detach(struct rc_dev *rcdev, struct bpf_prog *prog)
174 174
175 rcu_assign_pointer(raw->progs, new_array); 175 rcu_assign_pointer(raw->progs, new_array);
176 bpf_prog_array_free(old_array); 176 bpf_prog_array_free(old_array);
177 bpf_prog_put(prog);
177unlock: 178unlock:
178 mutex_unlock(&ir_raw_handler_lock); 179 mutex_unlock(&ir_raw_handler_lock);
179 return ret; 180 return ret;
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index 2e0066b1a31c..e7948908e78c 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -30,13 +30,13 @@ static int ir_raw_event_thread(void *data)
30 while (kfifo_out(&raw->kfifo, &ev, 1)) { 30 while (kfifo_out(&raw->kfifo, &ev, 1)) {
31 if (is_timing_event(ev)) { 31 if (is_timing_event(ev)) {
32 if (ev.duration == 0) 32 if (ev.duration == 0)
33 dev_err(&dev->dev, "nonsensical timing event of duration 0"); 33 dev_warn_once(&dev->dev, "nonsensical timing event of duration 0");
34 if (is_timing_event(raw->prev_ev) && 34 if (is_timing_event(raw->prev_ev) &&
35 !is_transition(&ev, &raw->prev_ev)) 35 !is_transition(&ev, &raw->prev_ev))
36 dev_err(&dev->dev, "two consecutive events of type %s", 36 dev_warn_once(&dev->dev, "two consecutive events of type %s",
37 TO_STR(ev.pulse)); 37 TO_STR(ev.pulse));
38 if (raw->prev_ev.reset && ev.pulse == 0) 38 if (raw->prev_ev.reset && ev.pulse == 0)
39 dev_err(&dev->dev, "timing event after reset should be pulse"); 39 dev_warn_once(&dev->dev, "timing event after reset should be pulse");
40 } 40 }
41 list_for_each_entry(handler, &ir_raw_handler_list, list) 41 list_for_each_entry(handler, &ir_raw_handler_list, list)
42 if (dev->enabled_protocols & 42 if (dev->enabled_protocols &
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 2e222d9ee01f..ca68e1d2b2f9 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -679,6 +679,14 @@ static void ir_timer_repeat(struct timer_list *t)
679 spin_unlock_irqrestore(&dev->keylock, flags); 679 spin_unlock_irqrestore(&dev->keylock, flags);
680} 680}
681 681
682static unsigned int repeat_period(int protocol)
683{
684 if (protocol >= ARRAY_SIZE(protocols))
685 return 100;
686
687 return protocols[protocol].repeat_period;
688}
689
682/** 690/**
683 * rc_repeat() - signals that a key is still pressed 691 * rc_repeat() - signals that a key is still pressed
684 * @dev: the struct rc_dev descriptor of the device 692 * @dev: the struct rc_dev descriptor of the device
@@ -691,7 +699,7 @@ void rc_repeat(struct rc_dev *dev)
691{ 699{
692 unsigned long flags; 700 unsigned long flags;
693 unsigned int timeout = nsecs_to_jiffies(dev->timeout) + 701 unsigned int timeout = nsecs_to_jiffies(dev->timeout) +
694 msecs_to_jiffies(protocols[dev->last_protocol].repeat_period); 702 msecs_to_jiffies(repeat_period(dev->last_protocol));
695 struct lirc_scancode sc = { 703 struct lirc_scancode sc = {
696 .scancode = dev->last_scancode, .rc_proto = dev->last_protocol, 704 .scancode = dev->last_scancode, .rc_proto = dev->last_protocol,
697 .keycode = dev->keypressed ? dev->last_keycode : KEY_RESERVED, 705 .keycode = dev->keypressed ? dev->last_keycode : KEY_RESERVED,
@@ -803,7 +811,7 @@ void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode,
803 811
804 if (dev->keypressed) { 812 if (dev->keypressed) {
805 dev->keyup_jiffies = jiffies + nsecs_to_jiffies(dev->timeout) + 813 dev->keyup_jiffies = jiffies + nsecs_to_jiffies(dev->timeout) +
806 msecs_to_jiffies(protocols[protocol].repeat_period); 814 msecs_to_jiffies(repeat_period(protocol));
807 mod_timer(&dev->timer_keyup, dev->keyup_jiffies); 815 mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
808 } 816 }
809 spin_unlock_irqrestore(&dev->keylock, flags); 817 spin_unlock_irqrestore(&dev->keylock, flags);
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index 753b1a698fc4..6b16946f9b05 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -103,15 +103,15 @@ static struct file *cxl_getfile(const char *name,
103 d_instantiate(path.dentry, inode); 103 d_instantiate(path.dentry, inode);
104 104
105 file = alloc_file(&path, OPEN_FMODE(flags), fops); 105 file = alloc_file(&path, OPEN_FMODE(flags), fops);
106 if (IS_ERR(file)) 106 if (IS_ERR(file)) {
107 goto err_dput; 107 path_put(&path);
108 goto err_fs;
109 }
108 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); 110 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
109 file->private_data = priv; 111 file->private_data = priv;
110 112
111 return file; 113 return file;
112 114
113err_dput:
114 path_put(&path);
115err_inode: 115err_inode:
116 iput(inode); 116 iput(inode);
117err_fs: 117err_fs:
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index 75f781c11e89..de4e6e5bf304 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -293,9 +293,10 @@ static void mxcmci_swap_buffers(struct mmc_data *data)
293 int i; 293 int i;
294 294
295 for_each_sg(data->sg, sg, data->sg_len, i) { 295 for_each_sg(data->sg, sg, data->sg_len, i) {
296 void *buf = kmap_atomic(sg_page(sg) + sg->offset; 296 void *buf = kmap_atomic(sg_page(sg) + sg->offset);
297 buffer_swap32(buf, sg->length); 297 buffer_swap32(buf, sg->length);
298 kunmap_atomic(buf); 298 kunmap_atomic(buf);
299 }
299} 300}
300#else 301#else
301static inline void mxcmci_swap_buffers(struct mmc_data *data) {} 302static inline void mxcmci_swap_buffers(struct mmc_data *data) {}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 63e3844c5bec..217b790d22ed 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1717,6 +1717,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
1717 goto err_upper_unlink; 1717 goto err_upper_unlink;
1718 } 1718 }
1719 1719
1720 bond->nest_level = dev_get_nest_level(bond_dev) + 1;
1721
1720 /* If the mode uses primary, then the following is handled by 1722 /* If the mode uses primary, then the following is handled by
1721 * bond_change_active_slave(). 1723 * bond_change_active_slave().
1722 */ 1724 */
@@ -1764,7 +1766,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
1764 if (bond_mode_can_use_xmit_hash(bond)) 1766 if (bond_mode_can_use_xmit_hash(bond))
1765 bond_update_slave_arr(bond, NULL); 1767 bond_update_slave_arr(bond, NULL);
1766 1768
1767 bond->nest_level = dev_get_nest_level(bond_dev);
1768 1769
1769 netdev_info(bond_dev, "Enslaving %s as %s interface with %s link\n", 1770 netdev_info(bond_dev, "Enslaving %s as %s interface with %s link\n",
1770 slave_dev->name, 1771 slave_dev->name,
@@ -3415,6 +3416,13 @@ static void bond_fold_stats(struct rtnl_link_stats64 *_res,
3415 } 3416 }
3416} 3417}
3417 3418
3419static int bond_get_nest_level(struct net_device *bond_dev)
3420{
3421 struct bonding *bond = netdev_priv(bond_dev);
3422
3423 return bond->nest_level;
3424}
3425
3418static void bond_get_stats(struct net_device *bond_dev, 3426static void bond_get_stats(struct net_device *bond_dev,
3419 struct rtnl_link_stats64 *stats) 3427 struct rtnl_link_stats64 *stats)
3420{ 3428{
@@ -3423,7 +3431,7 @@ static void bond_get_stats(struct net_device *bond_dev,
3423 struct list_head *iter; 3431 struct list_head *iter;
3424 struct slave *slave; 3432 struct slave *slave;
3425 3433
3426 spin_lock(&bond->stats_lock); 3434 spin_lock_nested(&bond->stats_lock, bond_get_nest_level(bond_dev));
3427 memcpy(stats, &bond->bond_stats, sizeof(*stats)); 3435 memcpy(stats, &bond->bond_stats, sizeof(*stats));
3428 3436
3429 rcu_read_lock(); 3437 rcu_read_lock();
@@ -4227,6 +4235,7 @@ static const struct net_device_ops bond_netdev_ops = {
4227 .ndo_neigh_setup = bond_neigh_setup, 4235 .ndo_neigh_setup = bond_neigh_setup,
4228 .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid, 4236 .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid,
4229 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, 4237 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid,
4238 .ndo_get_lock_subclass = bond_get_nest_level,
4230#ifdef CONFIG_NET_POLL_CONTROLLER 4239#ifdef CONFIG_NET_POLL_CONTROLLER
4231 .ndo_netpoll_setup = bond_netpoll_setup, 4240 .ndo_netpoll_setup = bond_netpoll_setup,
4232 .ndo_netpoll_cleanup = bond_netpoll_cleanup, 4241 .ndo_netpoll_cleanup = bond_netpoll_cleanup,
@@ -4725,6 +4734,7 @@ static int bond_init(struct net_device *bond_dev)
4725 if (!bond->wq) 4734 if (!bond->wq)
4726 return -ENOMEM; 4735 return -ENOMEM;
4727 4736
4737 bond->nest_level = SINGLE_DEPTH_NESTING;
4728 netdev_lockdep_set_classes(bond_dev); 4738 netdev_lockdep_set_classes(bond_dev);
4729 4739
4730 list_add_tail(&bond->bond_list, &bn->dev_list); 4740 list_add_tail(&bond->bond_list, &bn->dev_list);
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 98663c50ded0..4d5d01cb8141 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -743,15 +743,20 @@ const struct bond_option *bond_opt_get(unsigned int option)
743static int bond_option_mode_set(struct bonding *bond, 743static int bond_option_mode_set(struct bonding *bond,
744 const struct bond_opt_value *newval) 744 const struct bond_opt_value *newval)
745{ 745{
746 if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) { 746 if (!bond_mode_uses_arp(newval->value)) {
747 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n", 747 if (bond->params.arp_interval) {
748 newval->string); 748 netdev_dbg(bond->dev, "%s mode is incompatible with arp monitoring, start mii monitoring\n",
749 /* disable arp monitoring */ 749 newval->string);
750 bond->params.arp_interval = 0; 750 /* disable arp monitoring */
751 /* set miimon to default value */ 751 bond->params.arp_interval = 0;
752 bond->params.miimon = BOND_DEFAULT_MIIMON; 752 }
753 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n", 753
754 bond->params.miimon); 754 if (!bond->params.miimon) {
755 /* set miimon to default value */
756 bond->params.miimon = BOND_DEFAULT_MIIMON;
757 netdev_dbg(bond->dev, "Setting MII monitoring interval to %d\n",
758 bond->params.miimon);
759 }
755 } 760 }
756 761
757 if (newval->value == BOND_MODE_ALB) 762 if (newval->value == BOND_MODE_ALB)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index b397a33f3d32..9b449400376b 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -634,10 +634,12 @@ static int m_can_clk_start(struct m_can_priv *priv)
634 int err; 634 int err;
635 635
636 err = pm_runtime_get_sync(priv->device); 636 err = pm_runtime_get_sync(priv->device);
637 if (err) 637 if (err < 0) {
638 pm_runtime_put_noidle(priv->device); 638 pm_runtime_put_noidle(priv->device);
639 return err;
640 }
639 641
640 return err; 642 return 0;
641} 643}
642 644
643static void m_can_clk_stop(struct m_can_priv *priv) 645static void m_can_clk_stop(struct m_can_priv *priv)
@@ -1109,7 +1111,8 @@ static void m_can_chip_config(struct net_device *dev)
1109 1111
1110 } else { 1112 } else {
1111 /* Version 3.1.x or 3.2.x */ 1113 /* Version 3.1.x or 3.2.x */
1112 cccr &= ~(CCCR_TEST | CCCR_MON | CCCR_BRSE | CCCR_FDOE); 1114 cccr &= ~(CCCR_TEST | CCCR_MON | CCCR_BRSE | CCCR_FDOE |
1115 CCCR_NISO);
1113 1116
1114 /* Only 3.2.x has NISO Bit implemented */ 1117 /* Only 3.2.x has NISO Bit implemented */
1115 if (priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) 1118 if (priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO)
@@ -1642,8 +1645,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
1642 priv->can.clock.freq = clk_get_rate(cclk); 1645 priv->can.clock.freq = clk_get_rate(cclk);
1643 priv->mram_base = mram_addr; 1646 priv->mram_base = mram_addr;
1644 1647
1645 m_can_of_parse_mram(priv, mram_config_vals);
1646
1647 platform_set_drvdata(pdev, dev); 1648 platform_set_drvdata(pdev, dev);
1648 SET_NETDEV_DEV(dev, &pdev->dev); 1649 SET_NETDEV_DEV(dev, &pdev->dev);
1649 1650
@@ -1666,6 +1667,8 @@ static int m_can_plat_probe(struct platform_device *pdev)
1666 goto clk_disable; 1667 goto clk_disable;
1667 } 1668 }
1668 1669
1670 m_can_of_parse_mram(priv, mram_config_vals);
1671
1669 devm_can_led_init(dev); 1672 devm_can_led_init(dev);
1670 1673
1671 of_can_transceiver(dev); 1674 of_can_transceiver(dev);
@@ -1687,8 +1690,6 @@ failed_ret:
1687 return ret; 1690 return ret;
1688} 1691}
1689 1692
1690/* TODO: runtime PM with power down or sleep mode */
1691
1692static __maybe_unused int m_can_suspend(struct device *dev) 1693static __maybe_unused int m_can_suspend(struct device *dev)
1693{ 1694{
1694 struct net_device *ndev = dev_get_drvdata(dev); 1695 struct net_device *ndev = dev_get_drvdata(dev);
@@ -1715,8 +1716,6 @@ static __maybe_unused int m_can_resume(struct device *dev)
1715 1716
1716 pinctrl_pm_select_default_state(dev); 1717 pinctrl_pm_select_default_state(dev);
1717 1718
1718 m_can_init_ram(priv);
1719
1720 priv->can.state = CAN_STATE_ERROR_ACTIVE; 1719 priv->can.state = CAN_STATE_ERROR_ACTIVE;
1721 1720
1722 if (netif_running(ndev)) { 1721 if (netif_running(ndev)) {
@@ -1726,6 +1725,7 @@ static __maybe_unused int m_can_resume(struct device *dev)
1726 if (ret) 1725 if (ret)
1727 return ret; 1726 return ret;
1728 1727
1728 m_can_init_ram(priv);
1729 m_can_start(ndev); 1729 m_can_start(ndev);
1730 netif_device_attach(ndev); 1730 netif_device_attach(ndev);
1731 netif_start_queue(ndev); 1731 netif_start_queue(ndev);
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index c7427bdd3a4b..2949a381a94d 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -86,6 +86,11 @@ static u32 mpc52xx_can_get_clock(struct platform_device *ofdev,
86 return 0; 86 return 0;
87 } 87 }
88 cdm = of_iomap(np_cdm, 0); 88 cdm = of_iomap(np_cdm, 0);
89 if (!cdm) {
90 of_node_put(np_cdm);
91 dev_err(&ofdev->dev, "can't map clock node!\n");
92 return 0;
93 }
89 94
90 if (in_8(&cdm->ipb_clk_sel) & 0x1) 95 if (in_8(&cdm->ipb_clk_sel) & 0x1)
91 freq *= 2; 96 freq *= 2;
diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
index b9e28578bc7b..455a3797a200 100644
--- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
+++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
@@ -58,6 +58,10 @@ MODULE_LICENSE("GPL v2");
58#define PCIEFD_REG_SYS_VER1 0x0040 /* version reg #1 */ 58#define PCIEFD_REG_SYS_VER1 0x0040 /* version reg #1 */
59#define PCIEFD_REG_SYS_VER2 0x0044 /* version reg #2 */ 59#define PCIEFD_REG_SYS_VER2 0x0044 /* version reg #2 */
60 60
61#define PCIEFD_FW_VERSION(x, y, z) (((u32)(x) << 24) | \
62 ((u32)(y) << 16) | \
63 ((u32)(z) << 8))
64
61/* System Control Registers Bits */ 65/* System Control Registers Bits */
62#define PCIEFD_SYS_CTL_TS_RST 0x00000001 /* timestamp clock */ 66#define PCIEFD_SYS_CTL_TS_RST 0x00000001 /* timestamp clock */
63#define PCIEFD_SYS_CTL_CLK_EN 0x00000002 /* system clock */ 67#define PCIEFD_SYS_CTL_CLK_EN 0x00000002 /* system clock */
@@ -782,6 +786,21 @@ static int peak_pciefd_probe(struct pci_dev *pdev,
782 "%ux CAN-FD PCAN-PCIe FPGA v%u.%u.%u:\n", can_count, 786 "%ux CAN-FD PCAN-PCIe FPGA v%u.%u.%u:\n", can_count,
783 hw_ver_major, hw_ver_minor, hw_ver_sub); 787 hw_ver_major, hw_ver_minor, hw_ver_sub);
784 788
789#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
790 /* FW < v3.3.0 DMA logic doesn't handle correctly the mix of 32-bit and
791 * 64-bit logical addresses: this workaround forces usage of 32-bit
792 * DMA addresses only when such a fw is detected.
793 */
794 if (PCIEFD_FW_VERSION(hw_ver_major, hw_ver_minor, hw_ver_sub) <
795 PCIEFD_FW_VERSION(3, 3, 0)) {
796 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
797 if (err)
798 dev_warn(&pdev->dev,
799 "warning: can't set DMA mask %llxh (err %d)\n",
800 DMA_BIT_MASK(32), err);
801 }
802#endif
803
785 /* stop system clock */ 804 /* stop system clock */
786 pciefd_sys_writereg(pciefd, PCIEFD_SYS_CTL_CLK_EN, 805 pciefd_sys_writereg(pciefd, PCIEFD_SYS_CTL_CLK_EN,
787 PCIEFD_REG_SYS_CTL_CLR); 806 PCIEFD_REG_SYS_CTL_CLR);
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 12ff0020ecd6..b7dfd4109d24 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -1072,6 +1072,7 @@ static void ems_usb_disconnect(struct usb_interface *intf)
1072 usb_free_urb(dev->intr_urb); 1072 usb_free_urb(dev->intr_urb);
1073 1073
1074 kfree(dev->intr_in_buffer); 1074 kfree(dev->intr_in_buffer);
1075 kfree(dev->tx_msg_buffer);
1075 } 1076 }
1076} 1077}
1077 1078
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 89aec07c225f..5a24039733ef 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -2,6 +2,7 @@
2 * 2 *
3 * Copyright (C) 2012 - 2014 Xilinx, Inc. 3 * Copyright (C) 2012 - 2014 Xilinx, Inc.
4 * Copyright (C) 2009 PetaLogix. All rights reserved. 4 * Copyright (C) 2009 PetaLogix. All rights reserved.
5 * Copyright (C) 2017 Sandvik Mining and Construction Oy
5 * 6 *
6 * Description: 7 * Description:
7 * This driver is developed for Axi CAN IP and for Zynq CANPS Controller. 8 * This driver is developed for Axi CAN IP and for Zynq CANPS Controller.
@@ -25,8 +26,10 @@
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/netdevice.h> 27#include <linux/netdevice.h>
27#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/of_device.h>
28#include <linux/platform_device.h> 30#include <linux/platform_device.h>
29#include <linux/skbuff.h> 31#include <linux/skbuff.h>
32#include <linux/spinlock.h>
30#include <linux/string.h> 33#include <linux/string.h>
31#include <linux/types.h> 34#include <linux/types.h>
32#include <linux/can/dev.h> 35#include <linux/can/dev.h>
@@ -101,7 +104,7 @@ enum xcan_reg {
101#define XCAN_INTR_ALL (XCAN_IXR_TXOK_MASK | XCAN_IXR_BSOFF_MASK |\ 104#define XCAN_INTR_ALL (XCAN_IXR_TXOK_MASK | XCAN_IXR_BSOFF_MASK |\
102 XCAN_IXR_WKUP_MASK | XCAN_IXR_SLP_MASK | \ 105 XCAN_IXR_WKUP_MASK | XCAN_IXR_SLP_MASK | \
103 XCAN_IXR_RXNEMP_MASK | XCAN_IXR_ERROR_MASK | \ 106 XCAN_IXR_RXNEMP_MASK | XCAN_IXR_ERROR_MASK | \
104 XCAN_IXR_ARBLST_MASK | XCAN_IXR_RXOK_MASK) 107 XCAN_IXR_RXOFLW_MASK | XCAN_IXR_ARBLST_MASK)
105 108
106/* CAN register bit shift - XCAN_<REG>_<BIT>_SHIFT */ 109/* CAN register bit shift - XCAN_<REG>_<BIT>_SHIFT */
107#define XCAN_BTR_SJW_SHIFT 7 /* Synchronous jump width */ 110#define XCAN_BTR_SJW_SHIFT 7 /* Synchronous jump width */
@@ -118,6 +121,7 @@ enum xcan_reg {
118/** 121/**
119 * struct xcan_priv - This definition define CAN driver instance 122 * struct xcan_priv - This definition define CAN driver instance
120 * @can: CAN private data structure. 123 * @can: CAN private data structure.
124 * @tx_lock: Lock for synchronizing TX interrupt handling
121 * @tx_head: Tx CAN packets ready to send on the queue 125 * @tx_head: Tx CAN packets ready to send on the queue
122 * @tx_tail: Tx CAN packets successfully sended on the queue 126 * @tx_tail: Tx CAN packets successfully sended on the queue
123 * @tx_max: Maximum number packets the driver can send 127 * @tx_max: Maximum number packets the driver can send
@@ -132,6 +136,7 @@ enum xcan_reg {
132 */ 136 */
133struct xcan_priv { 137struct xcan_priv {
134 struct can_priv can; 138 struct can_priv can;
139 spinlock_t tx_lock;
135 unsigned int tx_head; 140 unsigned int tx_head;
136 unsigned int tx_tail; 141 unsigned int tx_tail;
137 unsigned int tx_max; 142 unsigned int tx_max;
@@ -159,6 +164,11 @@ static const struct can_bittiming_const xcan_bittiming_const = {
159 .brp_inc = 1, 164 .brp_inc = 1,
160}; 165};
161 166
167#define XCAN_CAP_WATERMARK 0x0001
168struct xcan_devtype_data {
169 unsigned int caps;
170};
171
162/** 172/**
163 * xcan_write_reg_le - Write a value to the device register little endian 173 * xcan_write_reg_le - Write a value to the device register little endian
164 * @priv: Driver private data structure 174 * @priv: Driver private data structure
@@ -238,6 +248,10 @@ static int set_reset_mode(struct net_device *ndev)
238 usleep_range(500, 10000); 248 usleep_range(500, 10000);
239 } 249 }
240 250
251 /* reset clears FIFOs */
252 priv->tx_head = 0;
253 priv->tx_tail = 0;
254
241 return 0; 255 return 0;
242} 256}
243 257
@@ -392,6 +406,7 @@ static int xcan_start_xmit(struct sk_buff *skb, struct net_device *ndev)
392 struct net_device_stats *stats = &ndev->stats; 406 struct net_device_stats *stats = &ndev->stats;
393 struct can_frame *cf = (struct can_frame *)skb->data; 407 struct can_frame *cf = (struct can_frame *)skb->data;
394 u32 id, dlc, data[2] = {0, 0}; 408 u32 id, dlc, data[2] = {0, 0};
409 unsigned long flags;
395 410
396 if (can_dropped_invalid_skb(ndev, skb)) 411 if (can_dropped_invalid_skb(ndev, skb))
397 return NETDEV_TX_OK; 412 return NETDEV_TX_OK;
@@ -439,6 +454,9 @@ static int xcan_start_xmit(struct sk_buff *skb, struct net_device *ndev)
439 data[1] = be32_to_cpup((__be32 *)(cf->data + 4)); 454 data[1] = be32_to_cpup((__be32 *)(cf->data + 4));
440 455
441 can_put_echo_skb(skb, ndev, priv->tx_head % priv->tx_max); 456 can_put_echo_skb(skb, ndev, priv->tx_head % priv->tx_max);
457
458 spin_lock_irqsave(&priv->tx_lock, flags);
459
442 priv->tx_head++; 460 priv->tx_head++;
443 461
444 /* Write the Frame to Xilinx CAN TX FIFO */ 462 /* Write the Frame to Xilinx CAN TX FIFO */
@@ -454,10 +472,16 @@ static int xcan_start_xmit(struct sk_buff *skb, struct net_device *ndev)
454 stats->tx_bytes += cf->can_dlc; 472 stats->tx_bytes += cf->can_dlc;
455 } 473 }
456 474
475 /* Clear TX-FIFO-empty interrupt for xcan_tx_interrupt() */
476 if (priv->tx_max > 1)
477 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_TXFEMP_MASK);
478
457 /* Check if the TX buffer is full */ 479 /* Check if the TX buffer is full */
458 if ((priv->tx_head - priv->tx_tail) == priv->tx_max) 480 if ((priv->tx_head - priv->tx_tail) == priv->tx_max)
459 netif_stop_queue(ndev); 481 netif_stop_queue(ndev);
460 482
483 spin_unlock_irqrestore(&priv->tx_lock, flags);
484
461 return NETDEV_TX_OK; 485 return NETDEV_TX_OK;
462} 486}
463 487
@@ -530,6 +554,123 @@ static int xcan_rx(struct net_device *ndev)
530} 554}
531 555
532/** 556/**
557 * xcan_current_error_state - Get current error state from HW
558 * @ndev: Pointer to net_device structure
559 *
560 * Checks the current CAN error state from the HW. Note that this
561 * only checks for ERROR_PASSIVE and ERROR_WARNING.
562 *
563 * Return:
564 * ERROR_PASSIVE or ERROR_WARNING if either is active, ERROR_ACTIVE
565 * otherwise.
566 */
567static enum can_state xcan_current_error_state(struct net_device *ndev)
568{
569 struct xcan_priv *priv = netdev_priv(ndev);
570 u32 status = priv->read_reg(priv, XCAN_SR_OFFSET);
571
572 if ((status & XCAN_SR_ESTAT_MASK) == XCAN_SR_ESTAT_MASK)
573 return CAN_STATE_ERROR_PASSIVE;
574 else if (status & XCAN_SR_ERRWRN_MASK)
575 return CAN_STATE_ERROR_WARNING;
576 else
577 return CAN_STATE_ERROR_ACTIVE;
578}
579
580/**
581 * xcan_set_error_state - Set new CAN error state
582 * @ndev: Pointer to net_device structure
583 * @new_state: The new CAN state to be set
584 * @cf: Error frame to be populated or NULL
585 *
586 * Set new CAN error state for the device, updating statistics and
587 * populating the error frame if given.
588 */
589static void xcan_set_error_state(struct net_device *ndev,
590 enum can_state new_state,
591 struct can_frame *cf)
592{
593 struct xcan_priv *priv = netdev_priv(ndev);
594 u32 ecr = priv->read_reg(priv, XCAN_ECR_OFFSET);
595 u32 txerr = ecr & XCAN_ECR_TEC_MASK;
596 u32 rxerr = (ecr & XCAN_ECR_REC_MASK) >> XCAN_ESR_REC_SHIFT;
597
598 priv->can.state = new_state;
599
600 if (cf) {
601 cf->can_id |= CAN_ERR_CRTL;
602 cf->data[6] = txerr;
603 cf->data[7] = rxerr;
604 }
605
606 switch (new_state) {
607 case CAN_STATE_ERROR_PASSIVE:
608 priv->can.can_stats.error_passive++;
609 if (cf)
610 cf->data[1] = (rxerr > 127) ?
611 CAN_ERR_CRTL_RX_PASSIVE :
612 CAN_ERR_CRTL_TX_PASSIVE;
613 break;
614 case CAN_STATE_ERROR_WARNING:
615 priv->can.can_stats.error_warning++;
616 if (cf)
617 cf->data[1] |= (txerr > rxerr) ?
618 CAN_ERR_CRTL_TX_WARNING :
619 CAN_ERR_CRTL_RX_WARNING;
620 break;
621 case CAN_STATE_ERROR_ACTIVE:
622 if (cf)
623 cf->data[1] |= CAN_ERR_CRTL_ACTIVE;
624 break;
625 default:
626 /* non-ERROR states are handled elsewhere */
627 WARN_ON(1);
628 break;
629 }
630}
631
632/**
633 * xcan_update_error_state_after_rxtx - Update CAN error state after RX/TX
634 * @ndev: Pointer to net_device structure
635 *
636 * If the device is in a ERROR-WARNING or ERROR-PASSIVE state, check if
637 * the performed RX/TX has caused it to drop to a lesser state and set
638 * the interface state accordingly.
639 */
640static void xcan_update_error_state_after_rxtx(struct net_device *ndev)
641{
642 struct xcan_priv *priv = netdev_priv(ndev);
643 enum can_state old_state = priv->can.state;
644 enum can_state new_state;
645
646 /* changing error state due to successful frame RX/TX can only
647 * occur from these states
648 */
649 if (old_state != CAN_STATE_ERROR_WARNING &&
650 old_state != CAN_STATE_ERROR_PASSIVE)
651 return;
652
653 new_state = xcan_current_error_state(ndev);
654
655 if (new_state != old_state) {
656 struct sk_buff *skb;
657 struct can_frame *cf;
658
659 skb = alloc_can_err_skb(ndev, &cf);
660
661 xcan_set_error_state(ndev, new_state, skb ? cf : NULL);
662
663 if (skb) {
664 struct net_device_stats *stats = &ndev->stats;
665
666 stats->rx_packets++;
667 stats->rx_bytes += cf->can_dlc;
668 netif_rx(skb);
669 }
670 }
671}
672
673/**
533 * xcan_err_interrupt - error frame Isr 674 * xcan_err_interrupt - error frame Isr
534 * @ndev: net_device pointer 675 * @ndev: net_device pointer
535 * @isr: interrupt status register value 676 * @isr: interrupt status register value
@@ -544,16 +685,12 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr)
544 struct net_device_stats *stats = &ndev->stats; 685 struct net_device_stats *stats = &ndev->stats;
545 struct can_frame *cf; 686 struct can_frame *cf;
546 struct sk_buff *skb; 687 struct sk_buff *skb;
547 u32 err_status, status, txerr = 0, rxerr = 0; 688 u32 err_status;
548 689
549 skb = alloc_can_err_skb(ndev, &cf); 690 skb = alloc_can_err_skb(ndev, &cf);
550 691
551 err_status = priv->read_reg(priv, XCAN_ESR_OFFSET); 692 err_status = priv->read_reg(priv, XCAN_ESR_OFFSET);
552 priv->write_reg(priv, XCAN_ESR_OFFSET, err_status); 693 priv->write_reg(priv, XCAN_ESR_OFFSET, err_status);
553 txerr = priv->read_reg(priv, XCAN_ECR_OFFSET) & XCAN_ECR_TEC_MASK;
554 rxerr = ((priv->read_reg(priv, XCAN_ECR_OFFSET) &
555 XCAN_ECR_REC_MASK) >> XCAN_ESR_REC_SHIFT);
556 status = priv->read_reg(priv, XCAN_SR_OFFSET);
557 694
558 if (isr & XCAN_IXR_BSOFF_MASK) { 695 if (isr & XCAN_IXR_BSOFF_MASK) {
559 priv->can.state = CAN_STATE_BUS_OFF; 696 priv->can.state = CAN_STATE_BUS_OFF;
@@ -563,28 +700,10 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr)
563 can_bus_off(ndev); 700 can_bus_off(ndev);
564 if (skb) 701 if (skb)
565 cf->can_id |= CAN_ERR_BUSOFF; 702 cf->can_id |= CAN_ERR_BUSOFF;
566 } else if ((status & XCAN_SR_ESTAT_MASK) == XCAN_SR_ESTAT_MASK) { 703 } else {
567 priv->can.state = CAN_STATE_ERROR_PASSIVE; 704 enum can_state new_state = xcan_current_error_state(ndev);
568 priv->can.can_stats.error_passive++; 705
569 if (skb) { 706 xcan_set_error_state(ndev, new_state, skb ? cf : NULL);
570 cf->can_id |= CAN_ERR_CRTL;
571 cf->data[1] = (rxerr > 127) ?
572 CAN_ERR_CRTL_RX_PASSIVE :
573 CAN_ERR_CRTL_TX_PASSIVE;
574 cf->data[6] = txerr;
575 cf->data[7] = rxerr;
576 }
577 } else if (status & XCAN_SR_ERRWRN_MASK) {
578 priv->can.state = CAN_STATE_ERROR_WARNING;
579 priv->can.can_stats.error_warning++;
580 if (skb) {
581 cf->can_id |= CAN_ERR_CRTL;
582 cf->data[1] |= (txerr > rxerr) ?
583 CAN_ERR_CRTL_TX_WARNING :
584 CAN_ERR_CRTL_RX_WARNING;
585 cf->data[6] = txerr;
586 cf->data[7] = rxerr;
587 }
588 } 707 }
589 708
590 /* Check for Arbitration lost interrupt */ 709 /* Check for Arbitration lost interrupt */
@@ -600,7 +719,6 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr)
600 if (isr & XCAN_IXR_RXOFLW_MASK) { 719 if (isr & XCAN_IXR_RXOFLW_MASK) {
601 stats->rx_over_errors++; 720 stats->rx_over_errors++;
602 stats->rx_errors++; 721 stats->rx_errors++;
603 priv->write_reg(priv, XCAN_SRR_OFFSET, XCAN_SRR_RESET_MASK);
604 if (skb) { 722 if (skb) {
605 cf->can_id |= CAN_ERR_CRTL; 723 cf->can_id |= CAN_ERR_CRTL;
606 cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW; 724 cf->data[1] |= CAN_ERR_CRTL_RX_OVERFLOW;
@@ -709,26 +827,20 @@ static int xcan_rx_poll(struct napi_struct *napi, int quota)
709 827
710 isr = priv->read_reg(priv, XCAN_ISR_OFFSET); 828 isr = priv->read_reg(priv, XCAN_ISR_OFFSET);
711 while ((isr & XCAN_IXR_RXNEMP_MASK) && (work_done < quota)) { 829 while ((isr & XCAN_IXR_RXNEMP_MASK) && (work_done < quota)) {
712 if (isr & XCAN_IXR_RXOK_MASK) { 830 work_done += xcan_rx(ndev);
713 priv->write_reg(priv, XCAN_ICR_OFFSET,
714 XCAN_IXR_RXOK_MASK);
715 work_done += xcan_rx(ndev);
716 } else {
717 priv->write_reg(priv, XCAN_ICR_OFFSET,
718 XCAN_IXR_RXNEMP_MASK);
719 break;
720 }
721 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_RXNEMP_MASK); 831 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_RXNEMP_MASK);
722 isr = priv->read_reg(priv, XCAN_ISR_OFFSET); 832 isr = priv->read_reg(priv, XCAN_ISR_OFFSET);
723 } 833 }
724 834
725 if (work_done) 835 if (work_done) {
726 can_led_event(ndev, CAN_LED_EVENT_RX); 836 can_led_event(ndev, CAN_LED_EVENT_RX);
837 xcan_update_error_state_after_rxtx(ndev);
838 }
727 839
728 if (work_done < quota) { 840 if (work_done < quota) {
729 napi_complete_done(napi, work_done); 841 napi_complete_done(napi, work_done);
730 ier = priv->read_reg(priv, XCAN_IER_OFFSET); 842 ier = priv->read_reg(priv, XCAN_IER_OFFSET);
731 ier |= (XCAN_IXR_RXOK_MASK | XCAN_IXR_RXNEMP_MASK); 843 ier |= XCAN_IXR_RXNEMP_MASK;
732 priv->write_reg(priv, XCAN_IER_OFFSET, ier); 844 priv->write_reg(priv, XCAN_IER_OFFSET, ier);
733 } 845 }
734 return work_done; 846 return work_done;
@@ -743,18 +855,71 @@ static void xcan_tx_interrupt(struct net_device *ndev, u32 isr)
743{ 855{
744 struct xcan_priv *priv = netdev_priv(ndev); 856 struct xcan_priv *priv = netdev_priv(ndev);
745 struct net_device_stats *stats = &ndev->stats; 857 struct net_device_stats *stats = &ndev->stats;
858 unsigned int frames_in_fifo;
859 int frames_sent = 1; /* TXOK => at least 1 frame was sent */
860 unsigned long flags;
861 int retries = 0;
862
863 /* Synchronize with xmit as we need to know the exact number
864 * of frames in the FIFO to stay in sync due to the TXFEMP
865 * handling.
866 * This also prevents a race between netif_wake_queue() and
867 * netif_stop_queue().
868 */
869 spin_lock_irqsave(&priv->tx_lock, flags);
870
871 frames_in_fifo = priv->tx_head - priv->tx_tail;
872
873 if (WARN_ON_ONCE(frames_in_fifo == 0)) {
874 /* clear TXOK anyway to avoid getting back here */
875 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_TXOK_MASK);
876 spin_unlock_irqrestore(&priv->tx_lock, flags);
877 return;
878 }
879
880 /* Check if 2 frames were sent (TXOK only means that at least 1
881 * frame was sent).
882 */
883 if (frames_in_fifo > 1) {
884 WARN_ON(frames_in_fifo > priv->tx_max);
885
886 /* Synchronize TXOK and isr so that after the loop:
887 * (1) isr variable is up-to-date at least up to TXOK clear
888 * time. This avoids us clearing a TXOK of a second frame
889 * but not noticing that the FIFO is now empty and thus
890 * marking only a single frame as sent.
891 * (2) No TXOK is left. Having one could mean leaving a
892 * stray TXOK as we might process the associated frame
893 * via TXFEMP handling as we read TXFEMP *after* TXOK
894 * clear to satisfy (1).
895 */
896 while ((isr & XCAN_IXR_TXOK_MASK) && !WARN_ON(++retries == 100)) {
897 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_TXOK_MASK);
898 isr = priv->read_reg(priv, XCAN_ISR_OFFSET);
899 }
746 900
747 while ((priv->tx_head - priv->tx_tail > 0) && 901 if (isr & XCAN_IXR_TXFEMP_MASK) {
748 (isr & XCAN_IXR_TXOK_MASK)) { 902 /* nothing in FIFO anymore */
903 frames_sent = frames_in_fifo;
904 }
905 } else {
906 /* single frame in fifo, just clear TXOK */
749 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_TXOK_MASK); 907 priv->write_reg(priv, XCAN_ICR_OFFSET, XCAN_IXR_TXOK_MASK);
908 }
909
910 while (frames_sent--) {
750 can_get_echo_skb(ndev, priv->tx_tail % 911 can_get_echo_skb(ndev, priv->tx_tail %
751 priv->tx_max); 912 priv->tx_max);
752 priv->tx_tail++; 913 priv->tx_tail++;
753 stats->tx_packets++; 914 stats->tx_packets++;
754 isr = priv->read_reg(priv, XCAN_ISR_OFFSET);
755 } 915 }
756 can_led_event(ndev, CAN_LED_EVENT_TX); 916
757 netif_wake_queue(ndev); 917 netif_wake_queue(ndev);
918
919 spin_unlock_irqrestore(&priv->tx_lock, flags);
920
921 can_led_event(ndev, CAN_LED_EVENT_TX);
922 xcan_update_error_state_after_rxtx(ndev);
758} 923}
759 924
760/** 925/**
@@ -773,6 +938,7 @@ static irqreturn_t xcan_interrupt(int irq, void *dev_id)
773 struct net_device *ndev = (struct net_device *)dev_id; 938 struct net_device *ndev = (struct net_device *)dev_id;
774 struct xcan_priv *priv = netdev_priv(ndev); 939 struct xcan_priv *priv = netdev_priv(ndev);
775 u32 isr, ier; 940 u32 isr, ier;
941 u32 isr_errors;
776 942
777 /* Get the interrupt status from Xilinx CAN */ 943 /* Get the interrupt status from Xilinx CAN */
778 isr = priv->read_reg(priv, XCAN_ISR_OFFSET); 944 isr = priv->read_reg(priv, XCAN_ISR_OFFSET);
@@ -791,18 +957,17 @@ static irqreturn_t xcan_interrupt(int irq, void *dev_id)
791 xcan_tx_interrupt(ndev, isr); 957 xcan_tx_interrupt(ndev, isr);
792 958
793 /* Check for the type of error interrupt and Processing it */ 959 /* Check for the type of error interrupt and Processing it */
794 if (isr & (XCAN_IXR_ERROR_MASK | XCAN_IXR_RXOFLW_MASK | 960 isr_errors = isr & (XCAN_IXR_ERROR_MASK | XCAN_IXR_RXOFLW_MASK |
795 XCAN_IXR_BSOFF_MASK | XCAN_IXR_ARBLST_MASK)) { 961 XCAN_IXR_BSOFF_MASK | XCAN_IXR_ARBLST_MASK);
796 priv->write_reg(priv, XCAN_ICR_OFFSET, (XCAN_IXR_ERROR_MASK | 962 if (isr_errors) {
797 XCAN_IXR_RXOFLW_MASK | XCAN_IXR_BSOFF_MASK | 963 priv->write_reg(priv, XCAN_ICR_OFFSET, isr_errors);
798 XCAN_IXR_ARBLST_MASK));
799 xcan_err_interrupt(ndev, isr); 964 xcan_err_interrupt(ndev, isr);
800 } 965 }
801 966
802 /* Check for the type of receive interrupt and Processing it */ 967 /* Check for the type of receive interrupt and Processing it */
803 if (isr & (XCAN_IXR_RXNEMP_MASK | XCAN_IXR_RXOK_MASK)) { 968 if (isr & XCAN_IXR_RXNEMP_MASK) {
804 ier = priv->read_reg(priv, XCAN_IER_OFFSET); 969 ier = priv->read_reg(priv, XCAN_IER_OFFSET);
805 ier &= ~(XCAN_IXR_RXNEMP_MASK | XCAN_IXR_RXOK_MASK); 970 ier &= ~XCAN_IXR_RXNEMP_MASK;
806 priv->write_reg(priv, XCAN_IER_OFFSET, ier); 971 priv->write_reg(priv, XCAN_IER_OFFSET, ier);
807 napi_schedule(&priv->napi); 972 napi_schedule(&priv->napi);
808 } 973 }
@@ -819,13 +984,9 @@ static irqreturn_t xcan_interrupt(int irq, void *dev_id)
819static void xcan_chip_stop(struct net_device *ndev) 984static void xcan_chip_stop(struct net_device *ndev)
820{ 985{
821 struct xcan_priv *priv = netdev_priv(ndev); 986 struct xcan_priv *priv = netdev_priv(ndev);
822 u32 ier;
823 987
824 /* Disable interrupts and leave the can in configuration mode */ 988 /* Disable interrupts and leave the can in configuration mode */
825 ier = priv->read_reg(priv, XCAN_IER_OFFSET); 989 set_reset_mode(ndev);
826 ier &= ~XCAN_INTR_ALL;
827 priv->write_reg(priv, XCAN_IER_OFFSET, ier);
828 priv->write_reg(priv, XCAN_SRR_OFFSET, XCAN_SRR_RESET_MASK);
829 priv->can.state = CAN_STATE_STOPPED; 990 priv->can.state = CAN_STATE_STOPPED;
830} 991}
831 992
@@ -958,10 +1119,15 @@ static const struct net_device_ops xcan_netdev_ops = {
958 */ 1119 */
959static int __maybe_unused xcan_suspend(struct device *dev) 1120static int __maybe_unused xcan_suspend(struct device *dev)
960{ 1121{
961 if (!device_may_wakeup(dev)) 1122 struct net_device *ndev = dev_get_drvdata(dev);
962 return pm_runtime_force_suspend(dev);
963 1123
964 return 0; 1124 if (netif_running(ndev)) {
1125 netif_stop_queue(ndev);
1126 netif_device_detach(ndev);
1127 xcan_chip_stop(ndev);
1128 }
1129
1130 return pm_runtime_force_suspend(dev);
965} 1131}
966 1132
967/** 1133/**
@@ -973,11 +1139,27 @@ static int __maybe_unused xcan_suspend(struct device *dev)
973 */ 1139 */
974static int __maybe_unused xcan_resume(struct device *dev) 1140static int __maybe_unused xcan_resume(struct device *dev)
975{ 1141{
976 if (!device_may_wakeup(dev)) 1142 struct net_device *ndev = dev_get_drvdata(dev);
977 return pm_runtime_force_resume(dev); 1143 int ret;
978 1144
979 return 0; 1145 ret = pm_runtime_force_resume(dev);
1146 if (ret) {
1147 dev_err(dev, "pm_runtime_force_resume failed on resume\n");
1148 return ret;
1149 }
1150
1151 if (netif_running(ndev)) {
1152 ret = xcan_chip_start(ndev);
1153 if (ret) {
1154 dev_err(dev, "xcan_chip_start failed on resume\n");
1155 return ret;
1156 }
1157
1158 netif_device_attach(ndev);
1159 netif_start_queue(ndev);
1160 }
980 1161
1162 return 0;
981} 1163}
982 1164
983/** 1165/**
@@ -992,14 +1174,6 @@ static int __maybe_unused xcan_runtime_suspend(struct device *dev)
992 struct net_device *ndev = dev_get_drvdata(dev); 1174 struct net_device *ndev = dev_get_drvdata(dev);
993 struct xcan_priv *priv = netdev_priv(ndev); 1175 struct xcan_priv *priv = netdev_priv(ndev);
994 1176
995 if (netif_running(ndev)) {
996 netif_stop_queue(ndev);
997 netif_device_detach(ndev);
998 }
999
1000 priv->write_reg(priv, XCAN_MSR_OFFSET, XCAN_MSR_SLEEP_MASK);
1001 priv->can.state = CAN_STATE_SLEEPING;
1002
1003 clk_disable_unprepare(priv->bus_clk); 1177 clk_disable_unprepare(priv->bus_clk);
1004 clk_disable_unprepare(priv->can_clk); 1178 clk_disable_unprepare(priv->can_clk);
1005 1179
@@ -1018,7 +1192,6 @@ static int __maybe_unused xcan_runtime_resume(struct device *dev)
1018 struct net_device *ndev = dev_get_drvdata(dev); 1192 struct net_device *ndev = dev_get_drvdata(dev);
1019 struct xcan_priv *priv = netdev_priv(ndev); 1193 struct xcan_priv *priv = netdev_priv(ndev);
1020 int ret; 1194 int ret;
1021 u32 isr, status;
1022 1195
1023 ret = clk_prepare_enable(priv->bus_clk); 1196 ret = clk_prepare_enable(priv->bus_clk);
1024 if (ret) { 1197 if (ret) {
@@ -1032,27 +1205,6 @@ static int __maybe_unused xcan_runtime_resume(struct device *dev)
1032 return ret; 1205 return ret;
1033 } 1206 }
1034 1207
1035 priv->write_reg(priv, XCAN_SRR_OFFSET, XCAN_SRR_RESET_MASK);
1036 isr = priv->read_reg(priv, XCAN_ISR_OFFSET);
1037 status = priv->read_reg(priv, XCAN_SR_OFFSET);
1038
1039 if (netif_running(ndev)) {
1040 if (isr & XCAN_IXR_BSOFF_MASK) {
1041 priv->can.state = CAN_STATE_BUS_OFF;
1042 priv->write_reg(priv, XCAN_SRR_OFFSET,
1043 XCAN_SRR_RESET_MASK);
1044 } else if ((status & XCAN_SR_ESTAT_MASK) ==
1045 XCAN_SR_ESTAT_MASK) {
1046 priv->can.state = CAN_STATE_ERROR_PASSIVE;
1047 } else if (status & XCAN_SR_ERRWRN_MASK) {
1048 priv->can.state = CAN_STATE_ERROR_WARNING;
1049 } else {
1050 priv->can.state = CAN_STATE_ERROR_ACTIVE;
1051 }
1052 netif_device_attach(ndev);
1053 netif_start_queue(ndev);
1054 }
1055
1056 return 0; 1208 return 0;
1057} 1209}
1058 1210
@@ -1061,6 +1213,18 @@ static const struct dev_pm_ops xcan_dev_pm_ops = {
1061 SET_RUNTIME_PM_OPS(xcan_runtime_suspend, xcan_runtime_resume, NULL) 1213 SET_RUNTIME_PM_OPS(xcan_runtime_suspend, xcan_runtime_resume, NULL)
1062}; 1214};
1063 1215
1216static const struct xcan_devtype_data xcan_zynq_data = {
1217 .caps = XCAN_CAP_WATERMARK,
1218};
1219
1220/* Match table for OF platform binding */
1221static const struct of_device_id xcan_of_match[] = {
1222 { .compatible = "xlnx,zynq-can-1.0", .data = &xcan_zynq_data },
1223 { .compatible = "xlnx,axi-can-1.00.a", },
1224 { /* end of list */ },
1225};
1226MODULE_DEVICE_TABLE(of, xcan_of_match);
1227
1064/** 1228/**
1065 * xcan_probe - Platform registration call 1229 * xcan_probe - Platform registration call
1066 * @pdev: Handle to the platform device structure 1230 * @pdev: Handle to the platform device structure
@@ -1075,8 +1239,10 @@ static int xcan_probe(struct platform_device *pdev)
1075 struct resource *res; /* IO mem resources */ 1239 struct resource *res; /* IO mem resources */
1076 struct net_device *ndev; 1240 struct net_device *ndev;
1077 struct xcan_priv *priv; 1241 struct xcan_priv *priv;
1242 const struct of_device_id *of_id;
1243 int caps = 0;
1078 void __iomem *addr; 1244 void __iomem *addr;
1079 int ret, rx_max, tx_max; 1245 int ret, rx_max, tx_max, tx_fifo_depth;
1080 1246
1081 /* Get the virtual base address for the device */ 1247 /* Get the virtual base address for the device */
1082 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1248 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1086,7 +1252,8 @@ static int xcan_probe(struct platform_device *pdev)
1086 goto err; 1252 goto err;
1087 } 1253 }
1088 1254
1089 ret = of_property_read_u32(pdev->dev.of_node, "tx-fifo-depth", &tx_max); 1255 ret = of_property_read_u32(pdev->dev.of_node, "tx-fifo-depth",
1256 &tx_fifo_depth);
1090 if (ret < 0) 1257 if (ret < 0)
1091 goto err; 1258 goto err;
1092 1259
@@ -1094,6 +1261,30 @@ static int xcan_probe(struct platform_device *pdev)
1094 if (ret < 0) 1261 if (ret < 0)
1095 goto err; 1262 goto err;
1096 1263
1264 of_id = of_match_device(xcan_of_match, &pdev->dev);
1265 if (of_id) {
1266 const struct xcan_devtype_data *devtype_data = of_id->data;
1267
1268 if (devtype_data)
1269 caps = devtype_data->caps;
1270 }
1271
1272 /* There is no way to directly figure out how many frames have been
1273 * sent when the TXOK interrupt is processed. If watermark programming
1274 * is supported, we can have 2 frames in the FIFO and use TXFEMP
1275 * to determine if 1 or 2 frames have been sent.
1276 * Theoretically we should be able to use TXFWMEMP to determine up
1277 * to 3 frames, but it seems that after putting a second frame in the
1278 * FIFO, with watermark at 2 frames, it can happen that TXFWMEMP (less
1279 * than 2 frames in FIFO) is set anyway with no TXOK (a frame was
1280 * sent), which is not a sensible state - possibly TXFWMEMP is not
1281 * completely synchronized with the rest of the bits?
1282 */
1283 if (caps & XCAN_CAP_WATERMARK)
1284 tx_max = min(tx_fifo_depth, 2);
1285 else
1286 tx_max = 1;
1287
1097 /* Create a CAN device instance */ 1288 /* Create a CAN device instance */
1098 ndev = alloc_candev(sizeof(struct xcan_priv), tx_max); 1289 ndev = alloc_candev(sizeof(struct xcan_priv), tx_max);
1099 if (!ndev) 1290 if (!ndev)
@@ -1108,6 +1299,7 @@ static int xcan_probe(struct platform_device *pdev)
1108 CAN_CTRLMODE_BERR_REPORTING; 1299 CAN_CTRLMODE_BERR_REPORTING;
1109 priv->reg_base = addr; 1300 priv->reg_base = addr;
1110 priv->tx_max = tx_max; 1301 priv->tx_max = tx_max;
1302 spin_lock_init(&priv->tx_lock);
1111 1303
1112 /* Get IRQ for the device */ 1304 /* Get IRQ for the device */
1113 ndev->irq = platform_get_irq(pdev, 0); 1305 ndev->irq = platform_get_irq(pdev, 0);
@@ -1172,9 +1364,9 @@ static int xcan_probe(struct platform_device *pdev)
1172 1364
1173 pm_runtime_put(&pdev->dev); 1365 pm_runtime_put(&pdev->dev);
1174 1366
1175 netdev_dbg(ndev, "reg_base=0x%p irq=%d clock=%d, tx fifo depth:%d\n", 1367 netdev_dbg(ndev, "reg_base=0x%p irq=%d clock=%d, tx fifo depth: actual %d, using %d\n",
1176 priv->reg_base, ndev->irq, priv->can.clock.freq, 1368 priv->reg_base, ndev->irq, priv->can.clock.freq,
1177 priv->tx_max); 1369 tx_fifo_depth, priv->tx_max);
1178 1370
1179 return 0; 1371 return 0;
1180 1372
@@ -1208,14 +1400,6 @@ static int xcan_remove(struct platform_device *pdev)
1208 return 0; 1400 return 0;
1209} 1401}
1210 1402
1211/* Match table for OF platform binding */
1212static const struct of_device_id xcan_of_match[] = {
1213 { .compatible = "xlnx,zynq-can-1.0", },
1214 { .compatible = "xlnx,axi-can-1.00.a", },
1215 { /* end of list */ },
1216};
1217MODULE_DEVICE_TABLE(of, xcan_of_match);
1218
1219static struct platform_driver xcan_driver = { 1403static struct platform_driver xcan_driver = {
1220 .probe = xcan_probe, 1404 .probe = xcan_probe,
1221 .remove = xcan_remove, 1405 .remove = xcan_remove,
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 437cd6eb4faa..bb28c701381a 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -343,6 +343,7 @@ static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
343 .xlate = irq_domain_xlate_twocell, 343 .xlate = irq_domain_xlate_twocell,
344}; 344};
345 345
346/* To be called with reg_lock held */
346static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip) 347static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
347{ 348{
348 int irq, virq; 349 int irq, virq;
@@ -362,9 +363,15 @@ static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
362 363
363static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) 364static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
364{ 365{
365 mv88e6xxx_g1_irq_free_common(chip); 366 /*
366 367 * free_irq must be called without reg_lock taken because the irq
368 * handler takes this lock, too.
369 */
367 free_irq(chip->irq, chip); 370 free_irq(chip->irq, chip);
371
372 mutex_lock(&chip->reg_lock);
373 mv88e6xxx_g1_irq_free_common(chip);
374 mutex_unlock(&chip->reg_lock);
368} 375}
369 376
370static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) 377static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
@@ -469,10 +476,12 @@ static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
469 476
470static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip) 477static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
471{ 478{
472 mv88e6xxx_g1_irq_free_common(chip);
473
474 kthread_cancel_delayed_work_sync(&chip->irq_poll_work); 479 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
475 kthread_destroy_worker(chip->kworker); 480 kthread_destroy_worker(chip->kworker);
481
482 mutex_lock(&chip->reg_lock);
483 mv88e6xxx_g1_irq_free_common(chip);
484 mutex_unlock(&chip->reg_lock);
476} 485}
477 486
478int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask) 487int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
@@ -2608,7 +2617,6 @@ static const struct mv88e6xxx_ops mv88e6085_ops = {
2608 .rmu_disable = mv88e6085_g1_rmu_disable, 2617 .rmu_disable = mv88e6085_g1_rmu_disable,
2609 .vtu_getnext = mv88e6352_g1_vtu_getnext, 2618 .vtu_getnext = mv88e6352_g1_vtu_getnext,
2610 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 2619 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
2611 .serdes_power = mv88e6341_serdes_power,
2612}; 2620};
2613 2621
2614static const struct mv88e6xxx_ops mv88e6095_ops = { 2622static const struct mv88e6xxx_ops mv88e6095_ops = {
@@ -2774,6 +2782,7 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {
2774 .reset = mv88e6352_g1_reset, 2782 .reset = mv88e6352_g1_reset,
2775 .vtu_getnext = mv88e6352_g1_vtu_getnext, 2783 .vtu_getnext = mv88e6352_g1_vtu_getnext,
2776 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 2784 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
2785 .serdes_power = mv88e6341_serdes_power,
2777 .gpio_ops = &mv88e6352_gpio_ops, 2786 .gpio_ops = &mv88e6352_gpio_ops,
2778}; 2787};
2779 2788
@@ -2951,7 +2960,6 @@ static const struct mv88e6xxx_ops mv88e6175_ops = {
2951 .reset = mv88e6352_g1_reset, 2960 .reset = mv88e6352_g1_reset,
2952 .vtu_getnext = mv88e6352_g1_vtu_getnext, 2961 .vtu_getnext = mv88e6352_g1_vtu_getnext,
2953 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 2962 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
2954 .serdes_power = mv88e6341_serdes_power,
2955}; 2963};
2956 2964
2957static const struct mv88e6xxx_ops mv88e6176_ops = { 2965static const struct mv88e6xxx_ops mv88e6176_ops = {
@@ -3327,6 +3335,7 @@ static const struct mv88e6xxx_ops mv88e6341_ops = {
3327 .reset = mv88e6352_g1_reset, 3335 .reset = mv88e6352_g1_reset,
3328 .vtu_getnext = mv88e6352_g1_vtu_getnext, 3336 .vtu_getnext = mv88e6352_g1_vtu_getnext,
3329 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, 3337 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
3338 .serdes_power = mv88e6341_serdes_power,
3330 .gpio_ops = &mv88e6352_gpio_ops, 3339 .gpio_ops = &mv88e6352_gpio_ops,
3331 .avb_ops = &mv88e6390_avb_ops, 3340 .avb_ops = &mv88e6390_avb_ops,
3332}; 3341};
@@ -4506,12 +4515,10 @@ out_g2_irq:
4506 if (chip->info->g2_irqs > 0) 4515 if (chip->info->g2_irqs > 0)
4507 mv88e6xxx_g2_irq_free(chip); 4516 mv88e6xxx_g2_irq_free(chip);
4508out_g1_irq: 4517out_g1_irq:
4509 mutex_lock(&chip->reg_lock);
4510 if (chip->irq > 0) 4518 if (chip->irq > 0)
4511 mv88e6xxx_g1_irq_free(chip); 4519 mv88e6xxx_g1_irq_free(chip);
4512 else 4520 else
4513 mv88e6xxx_irq_poll_free(chip); 4521 mv88e6xxx_irq_poll_free(chip);
4514 mutex_unlock(&chip->reg_lock);
4515out: 4522out:
4516 if (pdata) 4523 if (pdata)
4517 dev_put(pdata->netdev); 4524 dev_put(pdata->netdev);
@@ -4539,12 +4546,10 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4539 if (chip->info->g2_irqs > 0) 4546 if (chip->info->g2_irqs > 0)
4540 mv88e6xxx_g2_irq_free(chip); 4547 mv88e6xxx_g2_irq_free(chip);
4541 4548
4542 mutex_lock(&chip->reg_lock);
4543 if (chip->irq > 0) 4549 if (chip->irq > 0)
4544 mv88e6xxx_g1_irq_free(chip); 4550 mv88e6xxx_g1_irq_free(chip);
4545 else 4551 else
4546 mv88e6xxx_irq_poll_free(chip); 4552 mv88e6xxx_irq_poll_free(chip);
4547 mutex_unlock(&chip->reg_lock);
4548} 4553}
4549 4554
4550static const struct of_device_id mv88e6xxx_of_match[] = { 4555static const struct of_device_id mv88e6xxx_of_match[] = {
diff --git a/drivers/net/ethernet/3com/Kconfig b/drivers/net/ethernet/3com/Kconfig
index 5b7658bcf020..5c3ef9fc8207 100644
--- a/drivers/net/ethernet/3com/Kconfig
+++ b/drivers/net/ethernet/3com/Kconfig
@@ -32,7 +32,7 @@ config EL3
32 32
33config 3C515 33config 3C515
34 tristate "3c515 ISA \"Fast EtherLink\"" 34 tristate "3c515 ISA \"Fast EtherLink\""
35 depends on ISA && ISA_DMA_API 35 depends on ISA && ISA_DMA_API && !PPC32
36 ---help--- 36 ---help---
37 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet 37 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet
38 network card, say Y here. 38 network card, say Y here.
diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 1b9d3130af4d..17f12c18d225 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -333,6 +333,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
333 333
334 memset(&io_sq->desc_addr, 0x0, sizeof(io_sq->desc_addr)); 334 memset(&io_sq->desc_addr, 0x0, sizeof(io_sq->desc_addr));
335 335
336 io_sq->dma_addr_bits = ena_dev->dma_addr_bits;
336 io_sq->desc_entry_size = 337 io_sq->desc_entry_size =
337 (io_sq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ? 338 (io_sq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
338 sizeof(struct ena_eth_io_tx_desc) : 339 sizeof(struct ena_eth_io_tx_desc) :
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index f273af136fc7..9e5cf5583c87 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -44,7 +44,7 @@ config AMD8111_ETH
44 44
45config LANCE 45config LANCE
46 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support" 46 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support"
47 depends on ISA && ISA_DMA_API && !ARM 47 depends on ISA && ISA_DMA_API && !ARM && !PPC32
48 ---help--- 48 ---help---
49 If you have a network (Ethernet) card of this type, say Y here. 49 If you have a network (Ethernet) card of this type, say Y here.
50 Some LinkSys cards are of this type. 50 Some LinkSys cards are of this type.
@@ -138,7 +138,7 @@ config PCMCIA_NMCLAN
138 138
139config NI65 139config NI65
140 tristate "NI6510 support" 140 tristate "NI6510 support"
141 depends on ISA && ISA_DMA_API && !ARM 141 depends on ISA && ISA_DMA_API && !ARM && !PPC32
142 ---help--- 142 ---help---
143 If you have a network (Ethernet) card of this type, say Y here. 143 If you have a network (Ethernet) card of this type, say Y here.
144 144
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
index 4b5d625de8f0..8a3a60bb2688 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
@@ -1111,14 +1111,14 @@ static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
1111 1111
1112 if (pdata->tx_pause != pdata->phy.tx_pause) { 1112 if (pdata->tx_pause != pdata->phy.tx_pause) {
1113 new_state = 1; 1113 new_state = 1;
1114 pdata->hw_if.config_tx_flow_control(pdata);
1115 pdata->tx_pause = pdata->phy.tx_pause; 1114 pdata->tx_pause = pdata->phy.tx_pause;
1115 pdata->hw_if.config_tx_flow_control(pdata);
1116 } 1116 }
1117 1117
1118 if (pdata->rx_pause != pdata->phy.rx_pause) { 1118 if (pdata->rx_pause != pdata->phy.rx_pause) {
1119 new_state = 1; 1119 new_state = 1;
1120 pdata->hw_if.config_rx_flow_control(pdata);
1121 pdata->rx_pause = pdata->phy.rx_pause; 1120 pdata->rx_pause = pdata->phy.rx_pause;
1121 pdata->hw_if.config_rx_flow_control(pdata);
1122 } 1122 }
1123 1123
1124 /* Speed support */ 1124 /* Speed support */
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
index fc7383106946..91eb8910b1c9 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h
@@ -63,8 +63,6 @@
63 63
64#define AQ_CFG_NAPI_WEIGHT 64U 64#define AQ_CFG_NAPI_WEIGHT 64U
65 65
66#define AQ_CFG_MULTICAST_ADDRESS_MAX 32U
67
68/*#define AQ_CFG_MAC_ADDR_PERMANENT {0x30, 0x0E, 0xE3, 0x12, 0x34, 0x56}*/ 66/*#define AQ_CFG_MAC_ADDR_PERMANENT {0x30, 0x0E, 0xE3, 0x12, 0x34, 0x56}*/
69 67
70#define AQ_NIC_FC_OFF 0U 68#define AQ_NIC_FC_OFF 0U
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index a2d416b24ffc..2c6ebd91a9f2 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -98,6 +98,8 @@ struct aq_stats_s {
98#define AQ_HW_MEDIA_TYPE_TP 1U 98#define AQ_HW_MEDIA_TYPE_TP 1U
99#define AQ_HW_MEDIA_TYPE_FIBRE 2U 99#define AQ_HW_MEDIA_TYPE_FIBRE 2U
100 100
101#define AQ_HW_MULTICAST_ADDRESS_MAX 32U
102
101struct aq_hw_s { 103struct aq_hw_s {
102 atomic_t flags; 104 atomic_t flags;
103 u8 rbl_enabled:1; 105 u8 rbl_enabled:1;
@@ -177,7 +179,7 @@ struct aq_hw_ops {
177 unsigned int packet_filter); 179 unsigned int packet_filter);
178 180
179 int (*hw_multicast_list_set)(struct aq_hw_s *self, 181 int (*hw_multicast_list_set)(struct aq_hw_s *self,
180 u8 ar_mac[AQ_CFG_MULTICAST_ADDRESS_MAX] 182 u8 ar_mac[AQ_HW_MULTICAST_ADDRESS_MAX]
181 [ETH_ALEN], 183 [ETH_ALEN],
182 u32 count); 184 u32 count);
183 185
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
index ba5fe8c4125d..e3ae29e523f0 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
@@ -135,17 +135,10 @@ err_exit:
135static void aq_ndev_set_multicast_settings(struct net_device *ndev) 135static void aq_ndev_set_multicast_settings(struct net_device *ndev)
136{ 136{
137 struct aq_nic_s *aq_nic = netdev_priv(ndev); 137 struct aq_nic_s *aq_nic = netdev_priv(ndev);
138 int err = 0;
139 138
140 err = aq_nic_set_packet_filter(aq_nic, ndev->flags); 139 aq_nic_set_packet_filter(aq_nic, ndev->flags);
141 if (err < 0)
142 return;
143 140
144 if (netdev_mc_count(ndev)) { 141 aq_nic_set_multicast_list(aq_nic, ndev);
145 err = aq_nic_set_multicast_list(aq_nic, ndev);
146 if (err < 0)
147 return;
148 }
149} 142}
150 143
151static const struct net_device_ops aq_ndev_ops = { 144static const struct net_device_ops aq_ndev_ops = {
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 1a1a6380c128..7a22d0257e04 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -563,34 +563,41 @@ err_exit:
563 563
564int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev) 564int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev)
565{ 565{
566 unsigned int packet_filter = self->packet_filter;
566 struct netdev_hw_addr *ha = NULL; 567 struct netdev_hw_addr *ha = NULL;
567 unsigned int i = 0U; 568 unsigned int i = 0U;
568 569
569 self->mc_list.count = 0U; 570 self->mc_list.count = 0;
570 571 if (netdev_uc_count(ndev) > AQ_HW_MULTICAST_ADDRESS_MAX) {
571 netdev_for_each_mc_addr(ha, ndev) { 572 packet_filter |= IFF_PROMISC;
572 ether_addr_copy(self->mc_list.ar[i++], ha->addr); 573 } else {
573 ++self->mc_list.count; 574 netdev_for_each_uc_addr(ha, ndev) {
575 ether_addr_copy(self->mc_list.ar[i++], ha->addr);
574 576
575 if (i >= AQ_CFG_MULTICAST_ADDRESS_MAX) 577 if (i >= AQ_HW_MULTICAST_ADDRESS_MAX)
576 break; 578 break;
579 }
577 } 580 }
578 581
579 if (i >= AQ_CFG_MULTICAST_ADDRESS_MAX) { 582 if (i + netdev_mc_count(ndev) > AQ_HW_MULTICAST_ADDRESS_MAX) {
580 /* Number of filters is too big: atlantic does not support this. 583 packet_filter |= IFF_ALLMULTI;
581 * Force all multi filter to support this.
582 * With this we disable all UC filters and setup "all pass"
583 * multicast mask
584 */
585 self->packet_filter |= IFF_ALLMULTI;
586 self->aq_nic_cfg.mc_list_count = 0;
587 return self->aq_hw_ops->hw_packet_filter_set(self->aq_hw,
588 self->packet_filter);
589 } else { 584 } else {
590 return self->aq_hw_ops->hw_multicast_list_set(self->aq_hw, 585 netdev_for_each_mc_addr(ha, ndev) {
591 self->mc_list.ar, 586 ether_addr_copy(self->mc_list.ar[i++], ha->addr);
592 self->mc_list.count); 587
588 if (i >= AQ_HW_MULTICAST_ADDRESS_MAX)
589 break;
590 }
591 }
592
593 if (i > 0 && i < AQ_HW_MULTICAST_ADDRESS_MAX) {
594 packet_filter |= IFF_MULTICAST;
595 self->mc_list.count = i;
596 self->aq_hw_ops->hw_multicast_list_set(self->aq_hw,
597 self->mc_list.ar,
598 self->mc_list.count);
593 } 599 }
600 return aq_nic_set_packet_filter(self, packet_filter);
594} 601}
595 602
596int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu) 603int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu)
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
index faa533a0ec47..fecfc401f95d 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
@@ -75,7 +75,7 @@ struct aq_nic_s {
75 struct aq_hw_link_status_s link_status; 75 struct aq_hw_link_status_s link_status;
76 struct { 76 struct {
77 u32 count; 77 u32 count;
78 u8 ar[AQ_CFG_MULTICAST_ADDRESS_MAX][ETH_ALEN]; 78 u8 ar[AQ_HW_MULTICAST_ADDRESS_MAX][ETH_ALEN];
79 } mc_list; 79 } mc_list;
80 80
81 struct pci_dev *pdev; 81 struct pci_dev *pdev;
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
index 67e2f9fb9402..8cc6abadc03b 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
@@ -765,7 +765,7 @@ static int hw_atl_a0_hw_packet_filter_set(struct aq_hw_s *self,
765 765
766static int hw_atl_a0_hw_multicast_list_set(struct aq_hw_s *self, 766static int hw_atl_a0_hw_multicast_list_set(struct aq_hw_s *self,
767 u8 ar_mac 767 u8 ar_mac
768 [AQ_CFG_MULTICAST_ADDRESS_MAX] 768 [AQ_HW_MULTICAST_ADDRESS_MAX]
769 [ETH_ALEN], 769 [ETH_ALEN],
770 u32 count) 770 u32 count)
771{ 771{
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
index 819f6bcf9b4e..956860a69797 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
@@ -784,7 +784,7 @@ static int hw_atl_b0_hw_packet_filter_set(struct aq_hw_s *self,
784 784
785static int hw_atl_b0_hw_multicast_list_set(struct aq_hw_s *self, 785static int hw_atl_b0_hw_multicast_list_set(struct aq_hw_s *self,
786 u8 ar_mac 786 u8 ar_mac
787 [AQ_CFG_MULTICAST_ADDRESS_MAX] 787 [AQ_HW_MULTICAST_ADDRESS_MAX]
788 [ETH_ALEN], 788 [ETH_ALEN],
789 u32 count) 789 u32 count)
790{ 790{
@@ -812,7 +812,7 @@ static int hw_atl_b0_hw_multicast_list_set(struct aq_hw_s *self,
812 812
813 hw_atl_rpfl2_uc_flr_en_set(self, 813 hw_atl_rpfl2_uc_flr_en_set(self,
814 (self->aq_nic_cfg->is_mc_list_enabled), 814 (self->aq_nic_cfg->is_mc_list_enabled),
815 HW_ATL_B0_MAC_MIN + i); 815 HW_ATL_B0_MAC_MIN + i);
816 } 816 }
817 817
818 err = aq_hw_err_from_flags(self); 818 err = aq_hw_err_from_flags(self);
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index 94270f654b3b..7087b88550db 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -1686,6 +1686,7 @@ static struct sk_buff *atl1c_alloc_skb(struct atl1c_adapter *adapter)
1686 skb = build_skb(page_address(page) + adapter->rx_page_offset, 1686 skb = build_skb(page_address(page) + adapter->rx_page_offset,
1687 adapter->rx_frag_size); 1687 adapter->rx_frag_size);
1688 if (likely(skb)) { 1688 if (likely(skb)) {
1689 skb_reserve(skb, NET_SKB_PAD);
1689 adapter->rx_page_offset += adapter->rx_frag_size; 1690 adapter->rx_page_offset += adapter->rx_frag_size;
1690 if (adapter->rx_page_offset >= PAGE_SIZE) 1691 if (adapter->rx_page_offset >= PAGE_SIZE)
1691 adapter->rx_page = NULL; 1692 adapter->rx_page = NULL;
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index d5fca2e5a9bc..a1f60f89e059 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1946,8 +1946,8 @@ static int bcm_sysport_open(struct net_device *dev)
1946 if (!priv->is_lite) 1946 if (!priv->is_lite)
1947 priv->crc_fwd = !!(umac_readl(priv, UMAC_CMD) & CMD_CRC_FWD); 1947 priv->crc_fwd = !!(umac_readl(priv, UMAC_CMD) & CMD_CRC_FWD);
1948 else 1948 else
1949 priv->crc_fwd = !!(gib_readl(priv, GIB_CONTROL) & 1949 priv->crc_fwd = !((gib_readl(priv, GIB_CONTROL) &
1950 GIB_FCS_STRIP); 1950 GIB_FCS_STRIP) >> GIB_FCS_STRIP_SHIFT);
1951 1951
1952 phydev = of_phy_connect(dev, priv->phy_dn, bcm_sysport_adj_link, 1952 phydev = of_phy_connect(dev, priv->phy_dn, bcm_sysport_adj_link,
1953 0, priv->phy_interface); 1953 0, priv->phy_interface);
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
index d6e5d0cbf3a3..cf440b91fd04 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -278,7 +278,8 @@ struct bcm_rsb {
278#define GIB_GTX_CLK_EXT_CLK (0 << GIB_GTX_CLK_SEL_SHIFT) 278#define GIB_GTX_CLK_EXT_CLK (0 << GIB_GTX_CLK_SEL_SHIFT)
279#define GIB_GTX_CLK_125MHZ (1 << GIB_GTX_CLK_SEL_SHIFT) 279#define GIB_GTX_CLK_125MHZ (1 << GIB_GTX_CLK_SEL_SHIFT)
280#define GIB_GTX_CLK_250MHZ (2 << GIB_GTX_CLK_SEL_SHIFT) 280#define GIB_GTX_CLK_250MHZ (2 << GIB_GTX_CLK_SEL_SHIFT)
281#define GIB_FCS_STRIP (1 << 6) 281#define GIB_FCS_STRIP_SHIFT 6
282#define GIB_FCS_STRIP (1 << GIB_FCS_STRIP_SHIFT)
282#define GIB_LCL_LOOP_EN (1 << 7) 283#define GIB_LCL_LOOP_EN (1 << 7)
283#define GIB_LCL_LOOP_TXEN (1 << 8) 284#define GIB_LCL_LOOP_TXEN (1 << 8)
284#define GIB_RMT_LOOP_EN (1 << 9) 285#define GIB_RMT_LOOP_EN (1 << 9)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index da18aa239acb..a4a90b6cdb46 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -3388,14 +3388,18 @@ static int bnx2x_set_rss_flags(struct bnx2x *bp, struct ethtool_rxnfc *info)
3388 DP(BNX2X_MSG_ETHTOOL, 3388 DP(BNX2X_MSG_ETHTOOL,
3389 "rss re-configured, UDP 4-tupple %s\n", 3389 "rss re-configured, UDP 4-tupple %s\n",
3390 udp_rss_requested ? "enabled" : "disabled"); 3390 udp_rss_requested ? "enabled" : "disabled");
3391 return bnx2x_rss(bp, &bp->rss_conf_obj, false, true); 3391 if (bp->state == BNX2X_STATE_OPEN)
3392 return bnx2x_rss(bp, &bp->rss_conf_obj, false,
3393 true);
3392 } else if ((info->flow_type == UDP_V6_FLOW) && 3394 } else if ((info->flow_type == UDP_V6_FLOW) &&
3393 (bp->rss_conf_obj.udp_rss_v6 != udp_rss_requested)) { 3395 (bp->rss_conf_obj.udp_rss_v6 != udp_rss_requested)) {
3394 bp->rss_conf_obj.udp_rss_v6 = udp_rss_requested; 3396 bp->rss_conf_obj.udp_rss_v6 = udp_rss_requested;
3395 DP(BNX2X_MSG_ETHTOOL, 3397 DP(BNX2X_MSG_ETHTOOL,
3396 "rss re-configured, UDP 4-tupple %s\n", 3398 "rss re-configured, UDP 4-tupple %s\n",
3397 udp_rss_requested ? "enabled" : "disabled"); 3399 udp_rss_requested ? "enabled" : "disabled");
3398 return bnx2x_rss(bp, &bp->rss_conf_obj, false, true); 3400 if (bp->state == BNX2X_STATE_OPEN)
3401 return bnx2x_rss(bp, &bp->rss_conf_obj, false,
3402 true);
3399 } 3403 }
3400 return 0; 3404 return 0;
3401 3405
@@ -3509,7 +3513,10 @@ static int bnx2x_set_rxfh(struct net_device *dev, const u32 *indir,
3509 bp->rss_conf_obj.ind_table[i] = indir[i] + bp->fp->cl_id; 3513 bp->rss_conf_obj.ind_table[i] = indir[i] + bp->fp->cl_id;
3510 } 3514 }
3511 3515
3512 return bnx2x_config_rss_eth(bp, false); 3516 if (bp->state == BNX2X_STATE_OPEN)
3517 return bnx2x_config_rss_eth(bp, false);
3518
3519 return 0;
3513} 3520}
3514 3521
3515/** 3522/**
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 176fc9f4d7de..4394c1162be4 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -5712,7 +5712,9 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
5712 } 5712 }
5713 vnic->uc_filter_count = 1; 5713 vnic->uc_filter_count = 1;
5714 5714
5715 vnic->rx_mask = CFA_L2_SET_RX_MASK_REQ_MASK_BCAST; 5715 vnic->rx_mask = 0;
5716 if (bp->dev->flags & IFF_BROADCAST)
5717 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST;
5716 5718
5717 if ((bp->dev->flags & IFF_PROMISC) && bnxt_promisc_ok(bp)) 5719 if ((bp->dev->flags & IFF_PROMISC) && bnxt_promisc_ok(bp))
5718 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; 5720 vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS;
@@ -5917,7 +5919,7 @@ unsigned int bnxt_get_max_func_irqs(struct bnxt *bp)
5917 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings); 5919 return min_t(unsigned int, hw_resc->max_irqs, hw_resc->max_cp_rings);
5918} 5920}
5919 5921
5920void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs) 5922static void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)
5921{ 5923{
5922 bp->hw_resc.max_irqs = max_irqs; 5924 bp->hw_resc.max_irqs = max_irqs;
5923} 5925}
@@ -6888,7 +6890,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
6888 rc = bnxt_request_irq(bp); 6890 rc = bnxt_request_irq(bp);
6889 if (rc) { 6891 if (rc) {
6890 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc); 6892 netdev_err(bp->dev, "bnxt_request_irq err: %x\n", rc);
6891 goto open_err; 6893 goto open_err_irq;
6892 } 6894 }
6893 } 6895 }
6894 6896
@@ -6928,6 +6930,8 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
6928open_err: 6930open_err:
6929 bnxt_debug_dev_exit(bp); 6931 bnxt_debug_dev_exit(bp);
6930 bnxt_disable_napi(bp); 6932 bnxt_disable_napi(bp);
6933
6934open_err_irq:
6931 bnxt_del_napi(bp); 6935 bnxt_del_napi(bp);
6932 6936
6933open_err_free_mem: 6937open_err_free_mem:
@@ -7214,13 +7218,16 @@ static void bnxt_set_rx_mode(struct net_device *dev)
7214 7218
7215 mask &= ~(CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS | 7219 mask &= ~(CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS |
7216 CFA_L2_SET_RX_MASK_REQ_MASK_MCAST | 7220 CFA_L2_SET_RX_MASK_REQ_MASK_MCAST |
7217 CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST); 7221 CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST |
7222 CFA_L2_SET_RX_MASK_REQ_MASK_BCAST);
7218 7223
7219 if ((dev->flags & IFF_PROMISC) && bnxt_promisc_ok(bp)) 7224 if ((dev->flags & IFF_PROMISC) && bnxt_promisc_ok(bp))
7220 mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS; 7225 mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS;
7221 7226
7222 uc_update = bnxt_uc_list_updated(bp); 7227 uc_update = bnxt_uc_list_updated(bp);
7223 7228
7229 if (dev->flags & IFF_BROADCAST)
7230 mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST;
7224 if (dev->flags & IFF_ALLMULTI) { 7231 if (dev->flags & IFF_ALLMULTI) {
7225 mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST; 7232 mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST;
7226 vnic->mc_list_count = 0; 7233 vnic->mc_list_count = 0;
@@ -8502,11 +8509,11 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared)
8502 int rx, tx, cp; 8509 int rx, tx, cp;
8503 8510
8504 _bnxt_get_max_rings(bp, &rx, &tx, &cp); 8511 _bnxt_get_max_rings(bp, &rx, &tx, &cp);
8512 *max_rx = rx;
8513 *max_tx = tx;
8505 if (!rx || !tx || !cp) 8514 if (!rx || !tx || !cp)
8506 return -ENOMEM; 8515 return -ENOMEM;
8507 8516
8508 *max_rx = rx;
8509 *max_tx = tx;
8510 return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared); 8517 return bnxt_trim_rings(bp, max_rx, max_tx, cp, shared);
8511} 8518}
8512 8519
@@ -8520,8 +8527,11 @@ static int bnxt_get_dflt_rings(struct bnxt *bp, int *max_rx, int *max_tx,
8520 /* Not enough rings, try disabling agg rings. */ 8527 /* Not enough rings, try disabling agg rings. */
8521 bp->flags &= ~BNXT_FLAG_AGG_RINGS; 8528 bp->flags &= ~BNXT_FLAG_AGG_RINGS;
8522 rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared); 8529 rc = bnxt_get_max_rings(bp, max_rx, max_tx, shared);
8523 if (rc) 8530 if (rc) {
8531 /* set BNXT_FLAG_AGG_RINGS back for consistency */
8532 bp->flags |= BNXT_FLAG_AGG_RINGS;
8524 return rc; 8533 return rc;
8534 }
8525 bp->flags |= BNXT_FLAG_NO_AGG_RINGS; 8535 bp->flags |= BNXT_FLAG_NO_AGG_RINGS;
8526 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); 8536 bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
8527 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); 8537 bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 9b14eb610b9f..91575ef97c8c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1470,7 +1470,6 @@ void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max);
1470unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); 1470unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
1471void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max); 1471void bnxt_set_max_func_cp_rings(struct bnxt *bp, unsigned int max);
1472unsigned int bnxt_get_max_func_irqs(struct bnxt *bp); 1472unsigned int bnxt_get_max_func_irqs(struct bnxt *bp);
1473void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max);
1474int bnxt_get_avail_msix(struct bnxt *bp, int num); 1473int bnxt_get_avail_msix(struct bnxt *bp, int num);
1475int bnxt_reserve_rings(struct bnxt *bp); 1474int bnxt_reserve_rings(struct bnxt *bp);
1476void bnxt_tx_disable(struct bnxt *bp); 1475void bnxt_tx_disable(struct bnxt *bp);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index 795f45024c20..491bd40a254d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -27,6 +27,15 @@
27#define BNXT_FID_INVALID 0xffff 27#define BNXT_FID_INVALID 0xffff
28#define VLAN_TCI(vid, prio) ((vid) | ((prio) << VLAN_PRIO_SHIFT)) 28#define VLAN_TCI(vid, prio) ((vid) | ((prio) << VLAN_PRIO_SHIFT))
29 29
30#define is_vlan_pcp_wildcarded(vlan_tci_mask) \
31 ((ntohs(vlan_tci_mask) & VLAN_PRIO_MASK) == 0x0000)
32#define is_vlan_pcp_exactmatch(vlan_tci_mask) \
33 ((ntohs(vlan_tci_mask) & VLAN_PRIO_MASK) == VLAN_PRIO_MASK)
34#define is_vlan_pcp_zero(vlan_tci) \
35 ((ntohs(vlan_tci) & VLAN_PRIO_MASK) == 0x0000)
36#define is_vid_exactmatch(vlan_tci_mask) \
37 ((ntohs(vlan_tci_mask) & VLAN_VID_MASK) == VLAN_VID_MASK)
38
30/* Return the dst fid of the func for flow forwarding 39/* Return the dst fid of the func for flow forwarding
31 * For PFs: src_fid is the fid of the PF 40 * For PFs: src_fid is the fid of the PF
32 * For VF-reps: src_fid the fid of the VF 41 * For VF-reps: src_fid the fid of the VF
@@ -389,6 +398,21 @@ static bool is_exactmatch(void *mask, int len)
389 return true; 398 return true;
390} 399}
391 400
401static bool is_vlan_tci_allowed(__be16 vlan_tci_mask,
402 __be16 vlan_tci)
403{
404 /* VLAN priority must be either exactly zero or fully wildcarded and
405 * VLAN id must be exact match.
406 */
407 if (is_vid_exactmatch(vlan_tci_mask) &&
408 ((is_vlan_pcp_exactmatch(vlan_tci_mask) &&
409 is_vlan_pcp_zero(vlan_tci)) ||
410 is_vlan_pcp_wildcarded(vlan_tci_mask)))
411 return true;
412
413 return false;
414}
415
392static bool bits_set(void *key, int len) 416static bool bits_set(void *key, int len)
393{ 417{
394 const u8 *p = key; 418 const u8 *p = key;
@@ -803,9 +827,9 @@ static bool bnxt_tc_can_offload(struct bnxt *bp, struct bnxt_tc_flow *flow)
803 /* Currently VLAN fields cannot be partial wildcard */ 827 /* Currently VLAN fields cannot be partial wildcard */
804 if (bits_set(&flow->l2_key.inner_vlan_tci, 828 if (bits_set(&flow->l2_key.inner_vlan_tci,
805 sizeof(flow->l2_key.inner_vlan_tci)) && 829 sizeof(flow->l2_key.inner_vlan_tci)) &&
806 !is_exactmatch(&flow->l2_mask.inner_vlan_tci, 830 !is_vlan_tci_allowed(flow->l2_mask.inner_vlan_tci,
807 sizeof(flow->l2_mask.inner_vlan_tci))) { 831 flow->l2_key.inner_vlan_tci)) {
808 netdev_info(bp->dev, "Wildcard match unsupported for VLAN TCI\n"); 832 netdev_info(bp->dev, "Unsupported VLAN TCI\n");
809 return false; 833 return false;
810 } 834 }
811 if (bits_set(&flow->l2_key.inner_vlan_tpid, 835 if (bits_set(&flow->l2_key.inner_vlan_tpid,
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
index 347e4f946eb2..840f6e505f73 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
@@ -169,7 +169,6 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,
169 edev->ulp_tbl[ulp_id].msix_requested = avail_msix; 169 edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
170 } 170 }
171 bnxt_fill_msix_vecs(bp, ent); 171 bnxt_fill_msix_vecs(bp, ent);
172 bnxt_set_max_func_irqs(bp, bnxt_get_max_func_irqs(bp) - avail_msix);
173 bnxt_set_max_func_cp_rings(bp, max_cp_rings - avail_msix); 172 bnxt_set_max_func_cp_rings(bp, max_cp_rings - avail_msix);
174 edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED; 173 edev->flags |= BNXT_EN_FLAG_MSIX_REQUESTED;
175 return avail_msix; 174 return avail_msix;
@@ -192,7 +191,6 @@ static int bnxt_free_msix_vecs(struct bnxt_en_dev *edev, int ulp_id)
192 msix_requested = edev->ulp_tbl[ulp_id].msix_requested; 191 msix_requested = edev->ulp_tbl[ulp_id].msix_requested;
193 bnxt_set_max_func_cp_rings(bp, max_cp_rings + msix_requested); 192 bnxt_set_max_func_cp_rings(bp, max_cp_rings + msix_requested);
194 edev->ulp_tbl[ulp_id].msix_requested = 0; 193 edev->ulp_tbl[ulp_id].msix_requested = 0;
195 bnxt_set_max_func_irqs(bp, bnxt_get_max_func_irqs(bp) + msix_requested);
196 edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED; 194 edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
197 if (netif_running(dev)) { 195 if (netif_running(dev)) {
198 bnxt_close_nic(bp, true, false); 196 bnxt_close_nic(bp, true, false);
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 3be87efdc93d..aa1374d0af93 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -6,11 +6,15 @@
6 * Copyright (C) 2004 Sun Microsystems Inc. 6 * Copyright (C) 2004 Sun Microsystems Inc.
7 * Copyright (C) 2005-2016 Broadcom Corporation. 7 * Copyright (C) 2005-2016 Broadcom Corporation.
8 * Copyright (C) 2016-2017 Broadcom Limited. 8 * Copyright (C) 2016-2017 Broadcom Limited.
9 * Copyright (C) 2018 Broadcom. All Rights Reserved. The term "Broadcom"
10 * refers to Broadcom Inc. and/or its subsidiaries.
9 * 11 *
10 * Firmware is: 12 * Firmware is:
11 * Derived from proprietary unpublished source code, 13 * Derived from proprietary unpublished source code,
12 * Copyright (C) 2000-2016 Broadcom Corporation. 14 * Copyright (C) 2000-2016 Broadcom Corporation.
13 * Copyright (C) 2016-2017 Broadcom Ltd. 15 * Copyright (C) 2016-2017 Broadcom Ltd.
16 * Copyright (C) 2018 Broadcom. All Rights Reserved. The term "Broadcom"
17 * refers to Broadcom Inc. and/or its subsidiaries.
14 * 18 *
15 * Permission is hereby granted for the distribution of this firmware 19 * Permission is hereby granted for the distribution of this firmware
16 * data in hexadecimal or equivalent format, provided this copyright 20 * data in hexadecimal or equivalent format, provided this copyright
@@ -9290,6 +9294,15 @@ static int tg3_chip_reset(struct tg3 *tp)
9290 9294
9291 tg3_restore_clk(tp); 9295 tg3_restore_clk(tp);
9292 9296
9297 /* Increase the core clock speed to fix tx timeout issue for 5762
9298 * with 100Mbps link speed.
9299 */
9300 if (tg3_asic_rev(tp) == ASIC_REV_5762) {
9301 val = tr32(TG3_CPMU_CLCK_ORIDE_ENABLE);
9302 tw32(TG3_CPMU_CLCK_ORIDE_ENABLE, val |
9303 TG3_CPMU_MAC_ORIDE_ENABLE);
9304 }
9305
9293 /* Reprobe ASF enable state. */ 9306 /* Reprobe ASF enable state. */
9294 tg3_flag_clear(tp, ENABLE_ASF); 9307 tg3_flag_clear(tp, ENABLE_ASF);
9295 tp->phy_flags &= ~(TG3_PHYFLG_1G_ON_VAUX_OK | 9308 tp->phy_flags &= ~(TG3_PHYFLG_1G_ON_VAUX_OK |
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
index 1d61aa3efda1..a772a33b685c 100644
--- a/drivers/net/ethernet/broadcom/tg3.h
+++ b/drivers/net/ethernet/broadcom/tg3.h
@@ -7,6 +7,8 @@
7 * Copyright (C) 2004 Sun Microsystems Inc. 7 * Copyright (C) 2004 Sun Microsystems Inc.
8 * Copyright (C) 2007-2016 Broadcom Corporation. 8 * Copyright (C) 2007-2016 Broadcom Corporation.
9 * Copyright (C) 2016-2017 Broadcom Limited. 9 * Copyright (C) 2016-2017 Broadcom Limited.
10 * Copyright (C) 2018 Broadcom. All Rights Reserved. The term "Broadcom"
11 * refers to Broadcom Inc. and/or its subsidiaries.
10 */ 12 */
11 13
12#ifndef _T3_H 14#ifndef _T3_H
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 86659823b259..3d45f4c92cf6 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -166,6 +166,7 @@
166#define GEM_DCFG6 0x0294 /* Design Config 6 */ 166#define GEM_DCFG6 0x0294 /* Design Config 6 */
167#define GEM_DCFG7 0x0298 /* Design Config 7 */ 167#define GEM_DCFG7 0x0298 /* Design Config 7 */
168#define GEM_DCFG8 0x029C /* Design Config 8 */ 168#define GEM_DCFG8 0x029C /* Design Config 8 */
169#define GEM_DCFG10 0x02A4 /* Design Config 10 */
169 170
170#define GEM_TXBDCTRL 0x04cc /* TX Buffer Descriptor control register */ 171#define GEM_TXBDCTRL 0x04cc /* TX Buffer Descriptor control register */
171#define GEM_RXBDCTRL 0x04d0 /* RX Buffer Descriptor control register */ 172#define GEM_RXBDCTRL 0x04d0 /* RX Buffer Descriptor control register */
@@ -490,6 +491,12 @@
490#define GEM_SCR2CMP_OFFSET 0 491#define GEM_SCR2CMP_OFFSET 0
491#define GEM_SCR2CMP_SIZE 8 492#define GEM_SCR2CMP_SIZE 8
492 493
494/* Bitfields in DCFG10 */
495#define GEM_TXBD_RDBUFF_OFFSET 12
496#define GEM_TXBD_RDBUFF_SIZE 4
497#define GEM_RXBD_RDBUFF_OFFSET 8
498#define GEM_RXBD_RDBUFF_SIZE 4
499
493/* Bitfields in TISUBN */ 500/* Bitfields in TISUBN */
494#define GEM_SUBNSINCR_OFFSET 0 501#define GEM_SUBNSINCR_OFFSET 0
495#define GEM_SUBNSINCR_SIZE 16 502#define GEM_SUBNSINCR_SIZE 16
@@ -635,6 +642,7 @@
635#define MACB_CAPS_USRIO_DISABLED 0x00000010 642#define MACB_CAPS_USRIO_DISABLED 0x00000010
636#define MACB_CAPS_JUMBO 0x00000020 643#define MACB_CAPS_JUMBO 0x00000020
637#define MACB_CAPS_GEM_HAS_PTP 0x00000040 644#define MACB_CAPS_GEM_HAS_PTP 0x00000040
645#define MACB_CAPS_BD_RD_PREFETCH 0x00000080
638#define MACB_CAPS_FIFO_MODE 0x10000000 646#define MACB_CAPS_FIFO_MODE 0x10000000
639#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000 647#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
640#define MACB_CAPS_SG_DISABLED 0x40000000 648#define MACB_CAPS_SG_DISABLED 0x40000000
@@ -1203,6 +1211,9 @@ struct macb {
1203 unsigned int max_tuples; 1211 unsigned int max_tuples;
1204 1212
1205 struct tasklet_struct hresp_err_tasklet; 1213 struct tasklet_struct hresp_err_tasklet;
1214
1215 int rx_bd_rd_prefetch;
1216 int tx_bd_rd_prefetch;
1206}; 1217};
1207 1218
1208#ifdef CONFIG_MACB_USE_HWSTAMP 1219#ifdef CONFIG_MACB_USE_HWSTAMP
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 96cc03a6d942..a6c911bb5ce2 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -1811,23 +1811,25 @@ static void macb_free_consistent(struct macb *bp)
1811{ 1811{
1812 struct macb_queue *queue; 1812 struct macb_queue *queue;
1813 unsigned int q; 1813 unsigned int q;
1814 int size;
1814 1815
1815 queue = &bp->queues[0];
1816 bp->macbgem_ops.mog_free_rx_buffers(bp); 1816 bp->macbgem_ops.mog_free_rx_buffers(bp);
1817 if (queue->rx_ring) {
1818 dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES(bp),
1819 queue->rx_ring, queue->rx_ring_dma);
1820 queue->rx_ring = NULL;
1821 }
1822 1817
1823 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) { 1818 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1824 kfree(queue->tx_skb); 1819 kfree(queue->tx_skb);
1825 queue->tx_skb = NULL; 1820 queue->tx_skb = NULL;
1826 if (queue->tx_ring) { 1821 if (queue->tx_ring) {
1827 dma_free_coherent(&bp->pdev->dev, TX_RING_BYTES(bp), 1822 size = TX_RING_BYTES(bp) + bp->tx_bd_rd_prefetch;
1823 dma_free_coherent(&bp->pdev->dev, size,
1828 queue->tx_ring, queue->tx_ring_dma); 1824 queue->tx_ring, queue->tx_ring_dma);
1829 queue->tx_ring = NULL; 1825 queue->tx_ring = NULL;
1830 } 1826 }
1827 if (queue->rx_ring) {
1828 size = RX_RING_BYTES(bp) + bp->rx_bd_rd_prefetch;
1829 dma_free_coherent(&bp->pdev->dev, size,
1830 queue->rx_ring, queue->rx_ring_dma);
1831 queue->rx_ring = NULL;
1832 }
1831 } 1833 }
1832} 1834}
1833 1835
@@ -1874,7 +1876,7 @@ static int macb_alloc_consistent(struct macb *bp)
1874 int size; 1876 int size;
1875 1877
1876 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) { 1878 for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
1877 size = TX_RING_BYTES(bp); 1879 size = TX_RING_BYTES(bp) + bp->tx_bd_rd_prefetch;
1878 queue->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, 1880 queue->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
1879 &queue->tx_ring_dma, 1881 &queue->tx_ring_dma,
1880 GFP_KERNEL); 1882 GFP_KERNEL);
@@ -1890,7 +1892,7 @@ static int macb_alloc_consistent(struct macb *bp)
1890 if (!queue->tx_skb) 1892 if (!queue->tx_skb)
1891 goto out_err; 1893 goto out_err;
1892 1894
1893 size = RX_RING_BYTES(bp); 1895 size = RX_RING_BYTES(bp) + bp->rx_bd_rd_prefetch;
1894 queue->rx_ring = dma_alloc_coherent(&bp->pdev->dev, size, 1896 queue->rx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
1895 &queue->rx_ring_dma, GFP_KERNEL); 1897 &queue->rx_ring_dma, GFP_KERNEL);
1896 if (!queue->rx_ring) 1898 if (!queue->rx_ring)
@@ -3797,7 +3799,7 @@ static const struct macb_config np4_config = {
3797static const struct macb_config zynqmp_config = { 3799static const struct macb_config zynqmp_config = {
3798 .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | 3800 .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
3799 MACB_CAPS_JUMBO | 3801 MACB_CAPS_JUMBO |
3800 MACB_CAPS_GEM_HAS_PTP, 3802 MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_BD_RD_PREFETCH,
3801 .dma_burst_length = 16, 3803 .dma_burst_length = 16,
3802 .clk_init = macb_clk_init, 3804 .clk_init = macb_clk_init,
3803 .init = macb_init, 3805 .init = macb_init,
@@ -3858,7 +3860,7 @@ static int macb_probe(struct platform_device *pdev)
3858 void __iomem *mem; 3860 void __iomem *mem;
3859 const char *mac; 3861 const char *mac;
3860 struct macb *bp; 3862 struct macb *bp;
3861 int err; 3863 int err, val;
3862 3864
3863 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 3865 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
3864 mem = devm_ioremap_resource(&pdev->dev, regs); 3866 mem = devm_ioremap_resource(&pdev->dev, regs);
@@ -3947,6 +3949,18 @@ static int macb_probe(struct platform_device *pdev)
3947 else 3949 else
3948 dev->max_mtu = ETH_DATA_LEN; 3950 dev->max_mtu = ETH_DATA_LEN;
3949 3951
3952 if (bp->caps & MACB_CAPS_BD_RD_PREFETCH) {
3953 val = GEM_BFEXT(RXBD_RDBUFF, gem_readl(bp, DCFG10));
3954 if (val)
3955 bp->rx_bd_rd_prefetch = (2 << (val - 1)) *
3956 macb_dma_desc_get_size(bp);
3957
3958 val = GEM_BFEXT(TXBD_RDBUFF, gem_readl(bp, DCFG10));
3959 if (val)
3960 bp->tx_bd_rd_prefetch = (2 << (val - 1)) *
3961 macb_dma_desc_get_size(bp);
3962 }
3963
3950 mac = of_get_mac_address(np); 3964 mac = of_get_mac_address(np);
3951 if (mac) { 3965 if (mac) {
3952 ether_addr_copy(bp->dev->dev_addr, mac); 3966 ether_addr_copy(bp->dev->dev_addr, mac);
diff --git a/drivers/net/ethernet/cavium/Kconfig b/drivers/net/ethernet/cavium/Kconfig
index 043e3c11c42b..92d88c5f76fb 100644
--- a/drivers/net/ethernet/cavium/Kconfig
+++ b/drivers/net/ethernet/cavium/Kconfig
@@ -15,7 +15,7 @@ if NET_VENDOR_CAVIUM
15 15
16config THUNDER_NIC_PF 16config THUNDER_NIC_PF
17 tristate "Thunder Physical function driver" 17 tristate "Thunder Physical function driver"
18 depends on 64BIT 18 depends on 64BIT && PCI
19 select THUNDER_NIC_BGX 19 select THUNDER_NIC_BGX
20 ---help--- 20 ---help---
21 This driver supports Thunder's NIC physical function. 21 This driver supports Thunder's NIC physical function.
@@ -28,13 +28,13 @@ config THUNDER_NIC_PF
28config THUNDER_NIC_VF 28config THUNDER_NIC_VF
29 tristate "Thunder Virtual function driver" 29 tristate "Thunder Virtual function driver"
30 imply CAVIUM_PTP 30 imply CAVIUM_PTP
31 depends on 64BIT 31 depends on 64BIT && PCI
32 ---help--- 32 ---help---
33 This driver supports Thunder's NIC virtual function 33 This driver supports Thunder's NIC virtual function
34 34
35config THUNDER_NIC_BGX 35config THUNDER_NIC_BGX
36 tristate "Thunder MAC interface driver (BGX)" 36 tristate "Thunder MAC interface driver (BGX)"
37 depends on 64BIT 37 depends on 64BIT && PCI
38 select PHYLIB 38 select PHYLIB
39 select MDIO_THUNDER 39 select MDIO_THUNDER
40 select THUNDER_NIC_RGX 40 select THUNDER_NIC_RGX
@@ -44,7 +44,7 @@ config THUNDER_NIC_BGX
44 44
45config THUNDER_NIC_RGX 45config THUNDER_NIC_RGX
46 tristate "Thunder MAC interface driver (RGX)" 46 tristate "Thunder MAC interface driver (RGX)"
47 depends on 64BIT 47 depends on 64BIT && PCI
48 select PHYLIB 48 select PHYLIB
49 select MDIO_THUNDER 49 select MDIO_THUNDER
50 ---help--- 50 ---help---
@@ -53,7 +53,7 @@ config THUNDER_NIC_RGX
53 53
54config CAVIUM_PTP 54config CAVIUM_PTP
55 tristate "Cavium PTP coprocessor as PTP clock" 55 tristate "Cavium PTP coprocessor as PTP clock"
56 depends on 64BIT 56 depends on 64BIT && PCI
57 imply PTP_1588_CLOCK 57 imply PTP_1588_CLOCK
58 default y 58 default y
59 ---help--- 59 ---help---
@@ -65,7 +65,7 @@ config CAVIUM_PTP
65 65
66config LIQUIDIO 66config LIQUIDIO
67 tristate "Cavium LiquidIO support" 67 tristate "Cavium LiquidIO support"
68 depends on 64BIT 68 depends on 64BIT && PCI
69 depends on MAY_USE_DEVLINK 69 depends on MAY_USE_DEVLINK
70 imply PTP_1588_CLOCK 70 imply PTP_1588_CLOCK
71 select FW_LOADER 71 select FW_LOADER
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 8a815bb57177..7e8454d3b1ad 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -91,6 +91,9 @@ static int octeon_console_debug_enabled(u32 console)
91 */ 91 */
92#define LIO_SYNC_OCTEON_TIME_INTERVAL_MS 60000 92#define LIO_SYNC_OCTEON_TIME_INTERVAL_MS 60000
93 93
94/* time to wait for possible in-flight requests in milliseconds */
95#define WAIT_INFLIGHT_REQUEST msecs_to_jiffies(1000)
96
94struct lio_trusted_vf_ctx { 97struct lio_trusted_vf_ctx {
95 struct completion complete; 98 struct completion complete;
96 int status; 99 int status;
@@ -259,7 +262,7 @@ static inline void pcierror_quiesce_device(struct octeon_device *oct)
259 force_io_queues_off(oct); 262 force_io_queues_off(oct);
260 263
261 /* To allow for in-flight requests */ 264 /* To allow for in-flight requests */
262 schedule_timeout_uninterruptible(100); 265 schedule_timeout_uninterruptible(WAIT_INFLIGHT_REQUEST);
263 266
264 if (wait_for_pending_requests(oct)) 267 if (wait_for_pending_requests(oct))
265 dev_err(&oct->pci_dev->dev, "There were pending requests\n"); 268 dev_err(&oct->pci_dev->dev, "There were pending requests\n");
diff --git a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
index 3f6afb54a5eb..bb43ddb7539e 100644
--- a/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/cavium/octeon/octeon_mgmt.c
@@ -643,13 +643,21 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
643static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu) 643static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
644{ 644{
645 struct octeon_mgmt *p = netdev_priv(netdev); 645 struct octeon_mgmt *p = netdev_priv(netdev);
646 int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM; 646 int max_packet = new_mtu + ETH_HLEN + ETH_FCS_LEN;
647 647
648 netdev->mtu = new_mtu; 648 netdev->mtu = new_mtu;
649 649
650 cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs); 650 /* HW lifts the limit if the frame is VLAN tagged
651 * (+4 bytes per each tag, up to two tags)
652 */
653 cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, max_packet);
654 /* Set the hardware to truncate packets larger than the MTU. The jabber
655 * register must be set to a multiple of 8 bytes, so round up. JABBER is
656 * an unconditional limit, so we need to account for two possible VLAN
657 * tags.
658 */
651 cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER, 659 cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
652 (size_without_fcs + 7) & 0xfff8); 660 (max_packet + 7 + VLAN_HLEN * 2) & 0xfff8);
653 661
654 return 0; 662 return 0;
655} 663}
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 7b795edd9d3a..a19172dbe6be 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -51,6 +51,7 @@
51#include <linux/sched.h> 51#include <linux/sched.h>
52#include <linux/slab.h> 52#include <linux/slab.h>
53#include <linux/uaccess.h> 53#include <linux/uaccess.h>
54#include <linux/nospec.h>
54 55
55#include "common.h" 56#include "common.h"
56#include "cxgb3_ioctl.h" 57#include "cxgb3_ioctl.h"
@@ -2268,6 +2269,7 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
2268 2269
2269 if (t.qset_idx >= nqsets) 2270 if (t.qset_idx >= nqsets)
2270 return -EINVAL; 2271 return -EINVAL;
2272 t.qset_idx = array_index_nospec(t.qset_idx, nqsets);
2271 2273
2272 q = &adapter->params.sge.qset[q1 + t.qset_idx]; 2274 q = &adapter->params.sge.qset[q1 + t.qset_idx];
2273 t.rspq_size = q->rspq_size; 2275 t.rspq_size = q->rspq_size;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index bc03c175a3cd..a8926e97935e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3072,6 +3072,7 @@ static void cxgb_del_udp_tunnel(struct net_device *netdev,
3072 3072
3073 adapter->geneve_port = 0; 3073 adapter->geneve_port = 0;
3074 t4_write_reg(adapter, MPS_RX_GENEVE_TYPE_A, 0); 3074 t4_write_reg(adapter, MPS_RX_GENEVE_TYPE_A, 0);
3075 break;
3075 default: 3076 default:
3076 return; 3077 return;
3077 } 3078 }
@@ -3157,6 +3158,7 @@ static void cxgb_add_udp_tunnel(struct net_device *netdev,
3157 3158
3158 t4_write_reg(adapter, MPS_RX_GENEVE_TYPE_A, 3159 t4_write_reg(adapter, MPS_RX_GENEVE_TYPE_A,
3159 GENEVE_V(be16_to_cpu(ti->port)) | GENEVE_EN_F); 3160 GENEVE_V(be16_to_cpu(ti->port)) | GENEVE_EN_F);
3161 break;
3160 default: 3162 default:
3161 return; 3163 return;
3162 } 3164 }
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 974a868a4824..3720c3e11ebb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -8702,7 +8702,7 @@ static int t4_get_flash_params(struct adapter *adap)
8702 }; 8702 };
8703 8703
8704 unsigned int part, manufacturer; 8704 unsigned int part, manufacturer;
8705 unsigned int density, size; 8705 unsigned int density, size = 0;
8706 u32 flashid = 0; 8706 u32 flashid = 0;
8707 int ret; 8707 int ret;
8708 8708
@@ -8772,11 +8772,6 @@ static int t4_get_flash_params(struct adapter *adap)
8772 case 0x22: /* 256MB */ 8772 case 0x22: /* 256MB */
8773 size = 1 << 28; 8773 size = 1 << 28;
8774 break; 8774 break;
8775
8776 default:
8777 dev_err(adap->pdev_dev, "Micron Flash Part has bad size, ID = %#x, Density code = %#x\n",
8778 flashid, density);
8779 return -EINVAL;
8780 } 8775 }
8781 break; 8776 break;
8782 } 8777 }
@@ -8792,10 +8787,6 @@ static int t4_get_flash_params(struct adapter *adap)
8792 case 0x17: /* 64MB */ 8787 case 0x17: /* 64MB */
8793 size = 1 << 26; 8788 size = 1 << 26;
8794 break; 8789 break;
8795 default:
8796 dev_err(adap->pdev_dev, "ISSI Flash Part has bad size, ID = %#x, Density code = %#x\n",
8797 flashid, density);
8798 return -EINVAL;
8799 } 8790 }
8800 break; 8791 break;
8801 } 8792 }
@@ -8811,10 +8802,6 @@ static int t4_get_flash_params(struct adapter *adap)
8811 case 0x18: /* 16MB */ 8802 case 0x18: /* 16MB */
8812 size = 1 << 24; 8803 size = 1 << 24;
8813 break; 8804 break;
8814 default:
8815 dev_err(adap->pdev_dev, "Macronix Flash Part has bad size, ID = %#x, Density code = %#x\n",
8816 flashid, density);
8817 return -EINVAL;
8818 } 8805 }
8819 break; 8806 break;
8820 } 8807 }
@@ -8830,17 +8817,21 @@ static int t4_get_flash_params(struct adapter *adap)
8830 case 0x18: /* 16MB */ 8817 case 0x18: /* 16MB */
8831 size = 1 << 24; 8818 size = 1 << 24;
8832 break; 8819 break;
8833 default:
8834 dev_err(adap->pdev_dev, "Winbond Flash Part has bad size, ID = %#x, Density code = %#x\n",
8835 flashid, density);
8836 return -EINVAL;
8837 } 8820 }
8838 break; 8821 break;
8839 } 8822 }
8840 default: 8823 }
8841 dev_err(adap->pdev_dev, "Unsupported Flash Part, ID = %#x\n", 8824
8842 flashid); 8825 /* If we didn't recognize the FLASH part, that's no real issue: the
8843 return -EINVAL; 8826 * Hardware/Software contract says that Hardware will _*ALWAYS*_
8827 * use a FLASH part which is at least 4MB in size and has 64KB
8828 * sectors. The unrecognized FLASH part is likely to be much larger
8829 * than 4MB, but that's all we really need.
8830 */
8831 if (size == 0) {
8832 dev_warn(adap->pdev_dev, "Unknown Flash Part, ID = %#x, assuming 4MB\n",
8833 flashid);
8834 size = 1 << 22;
8844 } 8835 }
8845 8836
8846 /* Store decoded Flash size and fall through into vetting code. */ 8837 /* Store decoded Flash size and fall through into vetting code. */
diff --git a/drivers/net/ethernet/cirrus/Kconfig b/drivers/net/ethernet/cirrus/Kconfig
index 5ab912937aff..ec0b545197e2 100644
--- a/drivers/net/ethernet/cirrus/Kconfig
+++ b/drivers/net/ethernet/cirrus/Kconfig
@@ -19,6 +19,7 @@ if NET_VENDOR_CIRRUS
19config CS89x0 19config CS89x0
20 tristate "CS89x0 support" 20 tristate "CS89x0 support"
21 depends on ISA || EISA || ARM 21 depends on ISA || EISA || ARM
22 depends on !PPC32
22 ---help--- 23 ---help---
23 Support for CS89x0 chipset based Ethernet cards. If you have a 24 Support for CS89x0 chipset based Ethernet cards. If you have a
24 network (Ethernet) card of this type, say Y and read the file 25 network (Ethernet) card of this type, say Y and read the file
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 90c645b8538e..60641e202534 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2047,28 +2047,42 @@ static int enic_stop(struct net_device *netdev)
2047 return 0; 2047 return 0;
2048} 2048}
2049 2049
2050static int _enic_change_mtu(struct net_device *netdev, int new_mtu)
2051{
2052 bool running = netif_running(netdev);
2053 int err = 0;
2054
2055 ASSERT_RTNL();
2056 if (running) {
2057 err = enic_stop(netdev);
2058 if (err)
2059 return err;
2060 }
2061
2062 netdev->mtu = new_mtu;
2063
2064 if (running) {
2065 err = enic_open(netdev);
2066 if (err)
2067 return err;
2068 }
2069
2070 return 0;
2071}
2072
2050static int enic_change_mtu(struct net_device *netdev, int new_mtu) 2073static int enic_change_mtu(struct net_device *netdev, int new_mtu)
2051{ 2074{
2052 struct enic *enic = netdev_priv(netdev); 2075 struct enic *enic = netdev_priv(netdev);
2053 int running = netif_running(netdev);
2054 2076
2055 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic)) 2077 if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))
2056 return -EOPNOTSUPP; 2078 return -EOPNOTSUPP;
2057 2079
2058 if (running)
2059 enic_stop(netdev);
2060
2061 netdev->mtu = new_mtu;
2062
2063 if (netdev->mtu > enic->port_mtu) 2080 if (netdev->mtu > enic->port_mtu)
2064 netdev_warn(netdev, 2081 netdev_warn(netdev,
2065 "interface MTU (%d) set higher than port MTU (%d)\n", 2082 "interface MTU (%d) set higher than port MTU (%d)\n",
2066 netdev->mtu, enic->port_mtu); 2083 netdev->mtu, enic->port_mtu);
2067 2084
2068 if (running) 2085 return _enic_change_mtu(netdev, new_mtu);
2069 enic_open(netdev);
2070
2071 return 0;
2072} 2086}
2073 2087
2074static void enic_change_mtu_work(struct work_struct *work) 2088static void enic_change_mtu_work(struct work_struct *work)
@@ -2076,47 +2090,9 @@ static void enic_change_mtu_work(struct work_struct *work)
2076 struct enic *enic = container_of(work, struct enic, change_mtu_work); 2090 struct enic *enic = container_of(work, struct enic, change_mtu_work);
2077 struct net_device *netdev = enic->netdev; 2091 struct net_device *netdev = enic->netdev;
2078 int new_mtu = vnic_dev_mtu(enic->vdev); 2092 int new_mtu = vnic_dev_mtu(enic->vdev);
2079 int err;
2080 unsigned int i;
2081
2082 new_mtu = max_t(int, ENIC_MIN_MTU, min_t(int, ENIC_MAX_MTU, new_mtu));
2083 2093
2084 rtnl_lock(); 2094 rtnl_lock();
2085 2095 (void)_enic_change_mtu(netdev, new_mtu);
2086 /* Stop RQ */
2087 del_timer_sync(&enic->notify_timer);
2088
2089 for (i = 0; i < enic->rq_count; i++)
2090 napi_disable(&enic->napi[i]);
2091
2092 vnic_intr_mask(&enic->intr[0]);
2093 enic_synchronize_irqs(enic);
2094 err = vnic_rq_disable(&enic->rq[0]);
2095 if (err) {
2096 rtnl_unlock();
2097 netdev_err(netdev, "Unable to disable RQ.\n");
2098 return;
2099 }
2100 vnic_rq_clean(&enic->rq[0], enic_free_rq_buf);
2101 vnic_cq_clean(&enic->cq[0]);
2102 vnic_intr_clean(&enic->intr[0]);
2103
2104 /* Fill RQ with new_mtu-sized buffers */
2105 netdev->mtu = new_mtu;
2106 vnic_rq_fill(&enic->rq[0], enic_rq_alloc_buf);
2107 /* Need at least one buffer on ring to get going */
2108 if (vnic_rq_desc_used(&enic->rq[0]) == 0) {
2109 rtnl_unlock();
2110 netdev_err(netdev, "Unable to alloc receive buffers.\n");
2111 return;
2112 }
2113
2114 /* Start RQ */
2115 vnic_rq_enable(&enic->rq[0]);
2116 napi_enable(&enic->napi[0]);
2117 vnic_intr_unmask(&enic->intr[0]);
2118 enic_notify_timer_start(enic);
2119
2120 rtnl_unlock(); 2096 rtnl_unlock();
2121 2097
2122 netdev_info(netdev, "interface MTU set as %d\n", netdev->mtu); 2098 netdev_info(netdev, "interface MTU set as %d\n", netdev->mtu);
@@ -2916,7 +2892,6 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2916 */ 2892 */
2917 2893
2918 enic->port_mtu = enic->config.mtu; 2894 enic->port_mtu = enic->config.mtu;
2919 (void)enic_change_mtu(netdev, enic->port_mtu);
2920 2895
2921 err = enic_set_mac_addr(netdev, enic->mac_addr); 2896 err = enic_set_mac_addr(netdev, enic->mac_addr);
2922 if (err) { 2897 if (err) {
@@ -3006,6 +2981,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3006 /* MTU range: 68 - 9000 */ 2981 /* MTU range: 68 - 9000 */
3007 netdev->min_mtu = ENIC_MIN_MTU; 2982 netdev->min_mtu = ENIC_MIN_MTU;
3008 netdev->max_mtu = ENIC_MAX_MTU; 2983 netdev->max_mtu = ENIC_MAX_MTU;
2984 netdev->mtu = enic->port_mtu;
3009 2985
3010 err = register_netdev(netdev); 2986 err = register_netdev(netdev);
3011 if (err) { 2987 if (err) {
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
index 5b122728dcb4..09e9da10b786 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
@@ -983,6 +983,7 @@ static int nic_dev_init(struct pci_dev *pdev)
983 hinic_hwdev_cb_register(nic_dev->hwdev, HINIC_MGMT_MSG_CMD_LINK_STATUS, 983 hinic_hwdev_cb_register(nic_dev->hwdev, HINIC_MGMT_MSG_CMD_LINK_STATUS,
984 nic_dev, link_status_event_handler); 984 nic_dev, link_status_event_handler);
985 985
986 SET_NETDEV_DEV(netdev, &pdev->dev);
986 err = register_netdev(netdev); 987 err = register_netdev(netdev);
987 if (err) { 988 if (err) {
988 dev_err(&pdev->dev, "Failed to register netdev\n"); 989 dev_err(&pdev->dev, "Failed to register netdev\n");
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
index 9128858479c4..2353ec829c04 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
@@ -229,6 +229,7 @@ netdev_tx_t hinic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
229 txq->txq_stats.tx_busy++; 229 txq->txq_stats.tx_busy++;
230 u64_stats_update_end(&txq->txq_stats.syncp); 230 u64_stats_update_end(&txq->txq_stats.syncp);
231 err = NETDEV_TX_BUSY; 231 err = NETDEV_TX_BUSY;
232 wqe_size = 0;
232 goto flush_skbs; 233 goto flush_skbs;
233 } 234 }
234 235
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index d0e196bff081..ffe7acbeaa22 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -329,7 +329,8 @@ static void replenish_rx_pool(struct ibmvnic_adapter *adapter,
329 return; 329 return;
330 330
331failure: 331failure:
332 dev_info(dev, "replenish pools failure\n"); 332 if (lpar_rc != H_PARAMETER && lpar_rc != H_CLOSED)
333 dev_err_ratelimited(dev, "rx: replenish packet buffer failed\n");
333 pool->free_map[pool->next_free] = index; 334 pool->free_map[pool->next_free] = index;
334 pool->rx_buff[index].skb = NULL; 335 pool->rx_buff[index].skb = NULL;
335 336
@@ -1617,7 +1618,8 @@ static int ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
1617 &tx_crq); 1618 &tx_crq);
1618 } 1619 }
1619 if (lpar_rc != H_SUCCESS) { 1620 if (lpar_rc != H_SUCCESS) {
1620 dev_err(dev, "tx failed with code %ld\n", lpar_rc); 1621 if (lpar_rc != H_CLOSED && lpar_rc != H_PARAMETER)
1622 dev_err_ratelimited(dev, "tx: send failed\n");
1621 dev_kfree_skb_any(skb); 1623 dev_kfree_skb_any(skb);
1622 tx_buff->skb = NULL; 1624 tx_buff->skb = NULL;
1623 1625
@@ -1825,8 +1827,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,
1825 1827
1826 rc = ibmvnic_login(netdev); 1828 rc = ibmvnic_login(netdev);
1827 if (rc) { 1829 if (rc) {
1828 adapter->state = VNIC_PROBED; 1830 adapter->state = reset_state;
1829 return 0; 1831 return rc;
1830 } 1832 }
1831 1833
1832 if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM || 1834 if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM ||
@@ -3204,6 +3206,25 @@ static union ibmvnic_crq *ibmvnic_next_crq(struct ibmvnic_adapter *adapter)
3204 return crq; 3206 return crq;
3205} 3207}
3206 3208
3209static void print_subcrq_error(struct device *dev, int rc, const char *func)
3210{
3211 switch (rc) {
3212 case H_PARAMETER:
3213 dev_warn_ratelimited(dev,
3214 "%s failed: Send request is malformed or adapter failover pending. (rc=%d)\n",
3215 func, rc);
3216 break;
3217 case H_CLOSED:
3218 dev_warn_ratelimited(dev,
3219 "%s failed: Backing queue closed. Adapter is down or failover pending. (rc=%d)\n",
3220 func, rc);
3221 break;
3222 default:
3223 dev_err_ratelimited(dev, "%s failed: (rc=%d)\n", func, rc);
3224 break;
3225 }
3226}
3227
3207static int send_subcrq(struct ibmvnic_adapter *adapter, u64 remote_handle, 3228static int send_subcrq(struct ibmvnic_adapter *adapter, u64 remote_handle,
3208 union sub_crq *sub_crq) 3229 union sub_crq *sub_crq)
3209{ 3230{
@@ -3230,11 +3251,8 @@ static int send_subcrq(struct ibmvnic_adapter *adapter, u64 remote_handle,
3230 cpu_to_be64(u64_crq[2]), 3251 cpu_to_be64(u64_crq[2]),
3231 cpu_to_be64(u64_crq[3])); 3252 cpu_to_be64(u64_crq[3]));
3232 3253
3233 if (rc) { 3254 if (rc)
3234 if (rc == H_CLOSED) 3255 print_subcrq_error(dev, rc, __func__);
3235 dev_warn(dev, "CRQ Queue closed\n");
3236 dev_err(dev, "Send error (rc=%d)\n", rc);
3237 }
3238 3256
3239 return rc; 3257 return rc;
3240} 3258}
@@ -3252,11 +3270,8 @@ static int send_subcrq_indirect(struct ibmvnic_adapter *adapter,
3252 cpu_to_be64(remote_handle), 3270 cpu_to_be64(remote_handle),
3253 ioba, num_entries); 3271 ioba, num_entries);
3254 3272
3255 if (rc) { 3273 if (rc)
3256 if (rc == H_CLOSED) 3274 print_subcrq_error(dev, rc, __func__);
3257 dev_warn(dev, "CRQ Queue closed\n");
3258 dev_err(dev, "Send (indirect) error (rc=%d)\n", rc);
3259 }
3260 3275
3261 return rc; 3276 return rc;
3262} 3277}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 3f5c350716bb..0bd1294ba517 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -1871,7 +1871,12 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
1871 if (enable_addr != 0) 1871 if (enable_addr != 0)
1872 rar_high |= IXGBE_RAH_AV; 1872 rar_high |= IXGBE_RAH_AV;
1873 1873
1874 /* Record lower 32 bits of MAC address and then make
1875 * sure that write is flushed to hardware before writing
1876 * the upper 16 bits and setting the valid bit.
1877 */
1874 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low); 1878 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);
1879 IXGBE_WRITE_FLUSH(hw);
1875 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high); 1880 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1876 1881
1877 return 0; 1882 return 0;
@@ -1903,8 +1908,13 @@ s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)
1903 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index)); 1908 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));
1904 rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV); 1909 rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);
1905 1910
1906 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0); 1911 /* Clear the address valid bit and upper 16 bits of the address
1912 * before clearing the lower bits. This way we aren't updating
1913 * a live filter.
1914 */
1907 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high); 1915 IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);
1916 IXGBE_WRITE_FLUSH(hw);
1917 IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);
1908 1918
1909 /* clear VMDq pool/queue selection for this RAR */ 1919 /* clear VMDq pool/queue selection for this RAR */
1910 hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL); 1920 hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index c116f459945d..da4322e4daed 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -839,7 +839,7 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
839 } 839 }
840 840
841 itd->sa_idx = xs->xso.offload_handle - IXGBE_IPSEC_BASE_TX_INDEX; 841 itd->sa_idx = xs->xso.offload_handle - IXGBE_IPSEC_BASE_TX_INDEX;
842 if (unlikely(itd->sa_idx > IXGBE_IPSEC_MAX_SA_COUNT)) { 842 if (unlikely(itd->sa_idx >= IXGBE_IPSEC_MAX_SA_COUNT)) {
843 netdev_err(tx_ring->netdev, "%s: bad sa_idx=%d handle=%lu\n", 843 netdev_err(tx_ring->netdev, "%s: bad sa_idx=%d handle=%lu\n",
844 __func__, itd->sa_idx, xs->xso.offload_handle); 844 __func__, itd->sa_idx, xs->xso.offload_handle);
845 return 0; 845 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 9f54ccbddea7..3360f7b9ee73 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -474,10 +474,10 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
474{ 474{
475 const struct mlx4_en_frag_info *frag_info = priv->frag_info; 475 const struct mlx4_en_frag_info *frag_info = priv->frag_info;
476 unsigned int truesize = 0; 476 unsigned int truesize = 0;
477 bool release = true;
477 int nr, frag_size; 478 int nr, frag_size;
478 struct page *page; 479 struct page *page;
479 dma_addr_t dma; 480 dma_addr_t dma;
480 bool release;
481 481
482 /* Collect used fragments while replacing them in the HW descriptors */ 482 /* Collect used fragments while replacing them in the HW descriptors */
483 for (nr = 0;; frags++) { 483 for (nr = 0;; frags++) {
@@ -500,7 +500,11 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
500 release = page_count(page) != 1 || 500 release = page_count(page) != 1 ||
501 page_is_pfmemalloc(page) || 501 page_is_pfmemalloc(page) ||
502 page_to_nid(page) != numa_mem_id(); 502 page_to_nid(page) != numa_mem_id();
503 } else { 503 } else if (!priv->rx_headroom) {
504 /* rx_headroom for non XDP setup is always 0.
505 * When XDP is set, the above condition will
506 * guarantee page is always released.
507 */
504 u32 sz_align = ALIGN(frag_size, SMP_CACHE_BYTES); 508 u32 sz_align = ALIGN(frag_size, SMP_CACHE_BYTES);
505 509
506 frags->page_offset += sz_align; 510 frags->page_offset += sz_align;
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 7b1b5ac986d0..31bd56727022 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -2958,7 +2958,7 @@ int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
2958 u32 srqn = qp_get_srqn(qpc) & 0xffffff; 2958 u32 srqn = qp_get_srqn(qpc) & 0xffffff;
2959 int use_srq = (qp_get_srqn(qpc) >> 24) & 1; 2959 int use_srq = (qp_get_srqn(qpc) >> 24) & 1;
2960 struct res_srq *srq; 2960 struct res_srq *srq;
2961 int local_qpn = be32_to_cpu(qpc->local_qpn) & 0xffffff; 2961 int local_qpn = vhcr->in_modifier & 0xffffff;
2962 2962
2963 err = adjust_qp_sched_queue(dev, slave, qpc, inbox); 2963 err = adjust_qp_sched_queue(dev, slave, qpc, inbox);
2964 if (err) 2964 if (err)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
index 323ffe8bf7e4..456f30007ad6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
@@ -123,7 +123,7 @@ int mlx5_frag_buf_alloc_node(struct mlx5_core_dev *dev, int size,
123 int i; 123 int i;
124 124
125 buf->size = size; 125 buf->size = size;
126 buf->npages = 1 << get_order(size); 126 buf->npages = DIV_ROUND_UP(size, PAGE_SIZE);
127 buf->page_shift = PAGE_SHIFT; 127 buf->page_shift = PAGE_SHIFT;
128 buf->frags = kcalloc(buf->npages, sizeof(struct mlx5_buf_list), 128 buf->frags = kcalloc(buf->npages, sizeof(struct mlx5_buf_list),
129 GFP_KERNEL); 129 GFP_KERNEL);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
index 75e4308ba786..d258bb679271 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
@@ -381,14 +381,14 @@ static void arfs_may_expire_flow(struct mlx5e_priv *priv)
381 HLIST_HEAD(del_list); 381 HLIST_HEAD(del_list);
382 spin_lock_bh(&priv->fs.arfs.arfs_lock); 382 spin_lock_bh(&priv->fs.arfs.arfs_lock);
383 mlx5e_for_each_arfs_rule(arfs_rule, htmp, priv->fs.arfs.arfs_tables, i, j) { 383 mlx5e_for_each_arfs_rule(arfs_rule, htmp, priv->fs.arfs.arfs_tables, i, j) {
384 if (quota++ > MLX5E_ARFS_EXPIRY_QUOTA)
385 break;
386 if (!work_pending(&arfs_rule->arfs_work) && 384 if (!work_pending(&arfs_rule->arfs_work) &&
387 rps_may_expire_flow(priv->netdev, 385 rps_may_expire_flow(priv->netdev,
388 arfs_rule->rxq, arfs_rule->flow_id, 386 arfs_rule->rxq, arfs_rule->flow_id,
389 arfs_rule->filter_id)) { 387 arfs_rule->filter_id)) {
390 hlist_del_init(&arfs_rule->hlist); 388 hlist_del_init(&arfs_rule->hlist);
391 hlist_add_head(&arfs_rule->hlist, &del_list); 389 hlist_add_head(&arfs_rule->hlist, &del_list);
390 if (quota++ > MLX5E_ARFS_EXPIRY_QUOTA)
391 break;
392 } 392 }
393 } 393 }
394 spin_unlock_bh(&priv->fs.arfs.arfs_lock); 394 spin_unlock_bh(&priv->fs.arfs.arfs_lock);
@@ -711,6 +711,9 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
711 skb->protocol != htons(ETH_P_IPV6)) 711 skb->protocol != htons(ETH_P_IPV6))
712 return -EPROTONOSUPPORT; 712 return -EPROTONOSUPPORT;
713 713
714 if (skb->encapsulation)
715 return -EPROTONOSUPPORT;
716
714 arfs_t = arfs_get_table(arfs, arfs_get_ip_proto(skb), skb->protocol); 717 arfs_t = arfs_get_table(arfs, arfs_get_ip_proto(skb), skb->protocol);
715 if (!arfs_t) 718 if (!arfs_t)
716 return -EPROTONOSUPPORT; 719 return -EPROTONOSUPPORT;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index 0a52f31fef37..e33afa8d2417 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -275,7 +275,8 @@ int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets)
275} 275}
276 276
277static int mlx5e_dbcnl_validate_ets(struct net_device *netdev, 277static int mlx5e_dbcnl_validate_ets(struct net_device *netdev,
278 struct ieee_ets *ets) 278 struct ieee_ets *ets,
279 bool zero_sum_allowed)
279{ 280{
280 bool have_ets_tc = false; 281 bool have_ets_tc = false;
281 int bw_sum = 0; 282 int bw_sum = 0;
@@ -300,8 +301,9 @@ static int mlx5e_dbcnl_validate_ets(struct net_device *netdev,
300 } 301 }
301 302
302 if (have_ets_tc && bw_sum != 100) { 303 if (have_ets_tc && bw_sum != 100) {
303 netdev_err(netdev, 304 if (bw_sum || (!bw_sum && !zero_sum_allowed))
304 "Failed to validate ETS: BW sum is illegal\n"); 305 netdev_err(netdev,
306 "Failed to validate ETS: BW sum is illegal\n");
305 return -EINVAL; 307 return -EINVAL;
306 } 308 }
307 return 0; 309 return 0;
@@ -316,7 +318,7 @@ static int mlx5e_dcbnl_ieee_setets(struct net_device *netdev,
316 if (!MLX5_CAP_GEN(priv->mdev, ets)) 318 if (!MLX5_CAP_GEN(priv->mdev, ets))
317 return -EOPNOTSUPP; 319 return -EOPNOTSUPP;
318 320
319 err = mlx5e_dbcnl_validate_ets(netdev, ets); 321 err = mlx5e_dbcnl_validate_ets(netdev, ets, false);
320 if (err) 322 if (err)
321 return err; 323 return err;
322 324
@@ -642,12 +644,9 @@ static u8 mlx5e_dcbnl_setall(struct net_device *netdev)
642 ets.prio_tc[i]); 644 ets.prio_tc[i]);
643 } 645 }
644 646
645 err = mlx5e_dbcnl_validate_ets(netdev, &ets); 647 err = mlx5e_dbcnl_validate_ets(netdev, &ets, true);
646 if (err) { 648 if (err)
647 netdev_err(netdev,
648 "%s, Failed to validate ETS: %d\n", __func__, err);
649 goto out; 649 goto out;
650 }
651 650
652 err = mlx5e_dcbnl_ieee_setets_core(priv, &ets); 651 err = mlx5e_dcbnl_ieee_setets_core(priv, &ets);
653 if (err) { 652 if (err) {
@@ -1173,6 +1172,8 @@ static int mlx5e_trust_initialize(struct mlx5e_priv *priv)
1173 struct mlx5_core_dev *mdev = priv->mdev; 1172 struct mlx5_core_dev *mdev = priv->mdev;
1174 int err; 1173 int err;
1175 1174
1175 priv->dcbx_dp.trust_state = MLX5_QPTS_TRUST_PCP;
1176
1176 if (!MLX5_DSCP_SUPPORTED(mdev)) 1177 if (!MLX5_DSCP_SUPPORTED(mdev))
1177 return 0; 1178 return 0;
1178 1179
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index dae4156a710d..c592678ab5f1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3712,7 +3712,8 @@ int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
3712 3712
3713 if (!reset) { 3713 if (!reset) {
3714 params->sw_mtu = new_mtu; 3714 params->sw_mtu = new_mtu;
3715 set_mtu_cb(priv); 3715 if (set_mtu_cb)
3716 set_mtu_cb(priv);
3716 netdev->mtu = params->sw_mtu; 3717 netdev->mtu = params->sw_mtu;
3717 goto out; 3718 goto out;
3718 } 3719 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 0edf4751a8ba..3a2c4e548226 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1957,6 +1957,10 @@ static bool actions_match_supported(struct mlx5e_priv *priv,
1957 else 1957 else
1958 actions = flow->nic_attr->action; 1958 actions = flow->nic_attr->action;
1959 1959
1960 if (flow->flags & MLX5E_TC_FLOW_EGRESS &&
1961 !(actions & MLX5_FLOW_CONTEXT_ACTION_DECAP))
1962 return false;
1963
1960 if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) 1964 if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
1961 return modify_header_match_supported(&parse_attr->spec, exts); 1965 return modify_header_match_supported(&parse_attr->spec, exts);
1962 1966
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index b79d74860a30..40dba9e8af92 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1696,7 +1696,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
1696 int vport_num; 1696 int vport_num;
1697 int err; 1697 int err;
1698 1698
1699 if (!MLX5_VPORT_MANAGER(dev)) 1699 if (!MLX5_ESWITCH_MANAGER(dev))
1700 return 0; 1700 return 0;
1701 1701
1702 esw_info(dev, 1702 esw_info(dev,
@@ -1765,7 +1765,7 @@ abort:
1765 1765
1766void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) 1766void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
1767{ 1767{
1768 if (!esw || !MLX5_VPORT_MANAGER(esw->dev)) 1768 if (!esw || !MLX5_ESWITCH_MANAGER(esw->dev))
1769 return; 1769 return;
1770 1770
1771 esw_info(esw->dev, "cleanup\n"); 1771 esw_info(esw->dev, "cleanup\n");
@@ -2216,6 +2216,6 @@ free_out:
2216 2216
2217u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw) 2217u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw)
2218{ 2218{
2219 return esw->mode; 2219 return ESW_ALLOWED(esw) ? esw->mode : SRIOV_NONE;
2220} 2220}
2221EXPORT_SYMBOL_GPL(mlx5_eswitch_mode); 2221EXPORT_SYMBOL_GPL(mlx5_eswitch_mode);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index f1a86cea86a0..6ddb2565884d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1887,7 +1887,7 @@ mlx5_add_flow_rules(struct mlx5_flow_table *ft,
1887 if (flow_act->action == MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO) { 1887 if (flow_act->action == MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO) {
1888 if (!fwd_next_prio_supported(ft)) 1888 if (!fwd_next_prio_supported(ft))
1889 return ERR_PTR(-EOPNOTSUPP); 1889 return ERR_PTR(-EOPNOTSUPP);
1890 if (dest) 1890 if (dest_num)
1891 return ERR_PTR(-EINVAL); 1891 return ERR_PTR(-EINVAL);
1892 mutex_lock(&root->chain_lock); 1892 mutex_lock(&root->chain_lock);
1893 next_ft = find_next_chained_ft(prio); 1893 next_ft = find_next_chained_ft(prio);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index af3bb2f7a504..b7c21eb21a21 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -76,6 +76,7 @@ void mlx5i_init(struct mlx5_core_dev *mdev,
76 void *ppriv) 76 void *ppriv)
77{ 77{
78 struct mlx5e_priv *priv = mlx5i_epriv(netdev); 78 struct mlx5e_priv *priv = mlx5i_epriv(netdev);
79 u16 max_mtu;
79 80
80 /* priv init */ 81 /* priv init */
81 priv->mdev = mdev; 82 priv->mdev = mdev;
@@ -84,6 +85,9 @@ void mlx5i_init(struct mlx5_core_dev *mdev,
84 priv->ppriv = ppriv; 85 priv->ppriv = ppriv;
85 mutex_init(&priv->state_lock); 86 mutex_init(&priv->state_lock);
86 87
88 mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
89 netdev->mtu = max_mtu;
90
87 mlx5e_build_nic_params(mdev, &priv->channels.params, 91 mlx5e_build_nic_params(mdev, &priv->channels.params,
88 profile->max_nch(mdev), netdev->mtu); 92 profile->max_nch(mdev), netdev->mtu);
89 mlx5i_build_nic_params(mdev, &priv->channels.params); 93 mlx5i_build_nic_params(mdev, &priv->channels.params);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 1e062e6b2587..3f767cde4c1d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -488,6 +488,7 @@ void mlx5_pps_event(struct mlx5_core_dev *mdev,
488void mlx5_init_clock(struct mlx5_core_dev *mdev) 488void mlx5_init_clock(struct mlx5_core_dev *mdev)
489{ 489{
490 struct mlx5_clock *clock = &mdev->clock; 490 struct mlx5_clock *clock = &mdev->clock;
491 u64 overflow_cycles;
491 u64 ns; 492 u64 ns;
492 u64 frac = 0; 493 u64 frac = 0;
493 u32 dev_freq; 494 u32 dev_freq;
@@ -511,10 +512,17 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
511 512
512 /* Calculate period in seconds to call the overflow watchdog - to make 513 /* Calculate period in seconds to call the overflow watchdog - to make
513 * sure counter is checked at least once every wrap around. 514 * sure counter is checked at least once every wrap around.
515 * The period is calculated as the minimum between max HW cycles count
516 * (The clock source mask) and max amount of cycles that can be
517 * multiplied by clock multiplier where the result doesn't exceed
518 * 64bits.
514 */ 519 */
515 ns = cyclecounter_cyc2ns(&clock->cycles, clock->cycles.mask, 520 overflow_cycles = div64_u64(~0ULL >> 1, clock->cycles.mult);
521 overflow_cycles = min(overflow_cycles, clock->cycles.mask >> 1);
522
523 ns = cyclecounter_cyc2ns(&clock->cycles, overflow_cycles,
516 frac, &frac); 524 frac, &frac);
517 do_div(ns, NSEC_PER_SEC / 2 / HZ); 525 do_div(ns, NSEC_PER_SEC / HZ);
518 clock->overflow_period = ns; 526 clock->overflow_period = ns;
519 527
520 mdev->clock_info_page = alloc_page(GFP_KERNEL); 528 mdev->clock_info_page = alloc_page(GFP_KERNEL);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.c b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
index b97bb72b4db4..86478a6b99c5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/wq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.c
@@ -113,35 +113,45 @@ err_db_free:
113 return err; 113 return err;
114} 114}
115 115
116static void mlx5e_qp_set_frag_buf(struct mlx5_frag_buf *buf, 116static void mlx5_qp_set_frag_buf(struct mlx5_frag_buf *buf,
117 struct mlx5_wq_qp *qp) 117 struct mlx5_wq_qp *qp)
118{ 118{
119 struct mlx5_frag_buf_ctrl *sq_fbc;
119 struct mlx5_frag_buf *rqb, *sqb; 120 struct mlx5_frag_buf *rqb, *sqb;
120 121
121 rqb = &qp->rq.fbc.frag_buf; 122 rqb = &qp->rq.fbc.frag_buf;
122 *rqb = *buf; 123 *rqb = *buf;
123 rqb->size = mlx5_wq_cyc_get_byte_size(&qp->rq); 124 rqb->size = mlx5_wq_cyc_get_byte_size(&qp->rq);
124 rqb->npages = 1 << get_order(rqb->size); 125 rqb->npages = DIV_ROUND_UP(rqb->size, PAGE_SIZE);
125 126
126 sqb = &qp->sq.fbc.frag_buf; 127 sq_fbc = &qp->sq.fbc;
127 *sqb = *buf; 128 sqb = &sq_fbc->frag_buf;
128 sqb->size = mlx5_wq_cyc_get_byte_size(&qp->rq); 129 *sqb = *buf;
129 sqb->npages = 1 << get_order(sqb->size); 130 sqb->size = mlx5_wq_cyc_get_byte_size(&qp->sq);
131 sqb->npages = DIV_ROUND_UP(sqb->size, PAGE_SIZE);
130 sqb->frags += rqb->npages; /* first part is for the rq */ 132 sqb->frags += rqb->npages; /* first part is for the rq */
133 if (sq_fbc->strides_offset)
134 sqb->frags--;
131} 135}
132 136
133int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, 137int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
134 void *qpc, struct mlx5_wq_qp *wq, 138 void *qpc, struct mlx5_wq_qp *wq,
135 struct mlx5_wq_ctrl *wq_ctrl) 139 struct mlx5_wq_ctrl *wq_ctrl)
136{ 140{
141 u32 sq_strides_offset;
137 int err; 142 int err;
138 143
139 mlx5_fill_fbc(MLX5_GET(qpc, qpc, log_rq_stride) + 4, 144 mlx5_fill_fbc(MLX5_GET(qpc, qpc, log_rq_stride) + 4,
140 MLX5_GET(qpc, qpc, log_rq_size), 145 MLX5_GET(qpc, qpc, log_rq_size),
141 &wq->rq.fbc); 146 &wq->rq.fbc);
142 mlx5_fill_fbc(ilog2(MLX5_SEND_WQE_BB), 147
143 MLX5_GET(qpc, qpc, log_sq_size), 148 sq_strides_offset =
144 &wq->sq.fbc); 149 ((wq->rq.fbc.frag_sz_m1 + 1) % PAGE_SIZE) / MLX5_SEND_WQE_BB;
150
151 mlx5_fill_fbc_offset(ilog2(MLX5_SEND_WQE_BB),
152 MLX5_GET(qpc, qpc, log_sq_size),
153 sq_strides_offset,
154 &wq->sq.fbc);
145 155
146 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node); 156 err = mlx5_db_alloc_node(mdev, &wq_ctrl->db, param->db_numa_node);
147 if (err) { 157 if (err) {
@@ -156,7 +166,7 @@ int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
156 goto err_db_free; 166 goto err_db_free;
157 } 167 }
158 168
159 mlx5e_qp_set_frag_buf(&wq_ctrl->buf, wq); 169 mlx5_qp_set_frag_buf(&wq_ctrl->buf, wq);
160 170
161 wq->rq.db = &wq_ctrl->db.db[MLX5_RCV_DBR]; 171 wq->rq.db = &wq_ctrl->db.db[MLX5_RCV_DBR];
162 wq->sq.db = &wq_ctrl->db.db[MLX5_SND_DBR]; 172 wq->sq.db = &wq_ctrl->db.db[MLX5_SND_DBR];
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
index 3c0d882ba183..f6f6a568d66a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
@@ -327,12 +327,16 @@ static void mlxsw_afa_resource_add(struct mlxsw_afa_block *block,
327 list_add(&resource->list, &block->resource_list); 327 list_add(&resource->list, &block->resource_list);
328} 328}
329 329
330static void mlxsw_afa_resource_del(struct mlxsw_afa_resource *resource)
331{
332 list_del(&resource->list);
333}
334
330static void mlxsw_afa_resources_destroy(struct mlxsw_afa_block *block) 335static void mlxsw_afa_resources_destroy(struct mlxsw_afa_block *block)
331{ 336{
332 struct mlxsw_afa_resource *resource, *tmp; 337 struct mlxsw_afa_resource *resource, *tmp;
333 338
334 list_for_each_entry_safe(resource, tmp, &block->resource_list, list) { 339 list_for_each_entry_safe(resource, tmp, &block->resource_list, list) {
335 list_del(&resource->list);
336 resource->destructor(block, resource); 340 resource->destructor(block, resource);
337 } 341 }
338} 342}
@@ -530,6 +534,7 @@ static void
530mlxsw_afa_fwd_entry_ref_destroy(struct mlxsw_afa_block *block, 534mlxsw_afa_fwd_entry_ref_destroy(struct mlxsw_afa_block *block,
531 struct mlxsw_afa_fwd_entry_ref *fwd_entry_ref) 535 struct mlxsw_afa_fwd_entry_ref *fwd_entry_ref)
532{ 536{
537 mlxsw_afa_resource_del(&fwd_entry_ref->resource);
533 mlxsw_afa_fwd_entry_put(block->afa, fwd_entry_ref->fwd_entry); 538 mlxsw_afa_fwd_entry_put(block->afa, fwd_entry_ref->fwd_entry);
534 kfree(fwd_entry_ref); 539 kfree(fwd_entry_ref);
535} 540}
@@ -579,6 +584,7 @@ static void
579mlxsw_afa_counter_destroy(struct mlxsw_afa_block *block, 584mlxsw_afa_counter_destroy(struct mlxsw_afa_block *block,
580 struct mlxsw_afa_counter *counter) 585 struct mlxsw_afa_counter *counter)
581{ 586{
587 mlxsw_afa_resource_del(&counter->resource);
582 block->afa->ops->counter_index_put(block->afa->ops_priv, 588 block->afa->ops->counter_index_put(block->afa->ops_priv,
583 counter->counter_index); 589 counter->counter_index);
584 kfree(counter); 590 kfree(counter);
@@ -626,8 +632,8 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block,
626 char *oneact; 632 char *oneact;
627 char *actions; 633 char *actions;
628 634
629 if (WARN_ON(block->finished)) 635 if (block->finished)
630 return NULL; 636 return ERR_PTR(-EINVAL);
631 if (block->cur_act_index + action_size > 637 if (block->cur_act_index + action_size >
632 block->afa->max_acts_per_set) { 638 block->afa->max_acts_per_set) {
633 struct mlxsw_afa_set *set; 639 struct mlxsw_afa_set *set;
@@ -637,7 +643,7 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block,
637 */ 643 */
638 set = mlxsw_afa_set_create(false); 644 set = mlxsw_afa_set_create(false);
639 if (!set) 645 if (!set)
640 return NULL; 646 return ERR_PTR(-ENOBUFS);
641 set->prev = block->cur_set; 647 set->prev = block->cur_set;
642 block->cur_act_index = 0; 648 block->cur_act_index = 0;
643 block->cur_set->next = set; 649 block->cur_set->next = set;
@@ -724,8 +730,8 @@ int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
724 MLXSW_AFA_VLAN_CODE, 730 MLXSW_AFA_VLAN_CODE,
725 MLXSW_AFA_VLAN_SIZE); 731 MLXSW_AFA_VLAN_SIZE);
726 732
727 if (!act) 733 if (IS_ERR(act))
728 return -ENOBUFS; 734 return PTR_ERR(act);
729 mlxsw_afa_vlan_pack(act, MLXSW_AFA_VLAN_VLAN_TAG_CMD_NOP, 735 mlxsw_afa_vlan_pack(act, MLXSW_AFA_VLAN_VLAN_TAG_CMD_NOP,
730 MLXSW_AFA_VLAN_CMD_SET_OUTER, vid, 736 MLXSW_AFA_VLAN_CMD_SET_OUTER, vid,
731 MLXSW_AFA_VLAN_CMD_SET_OUTER, pcp, 737 MLXSW_AFA_VLAN_CMD_SET_OUTER, pcp,
@@ -806,8 +812,8 @@ int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block)
806 MLXSW_AFA_TRAPDISC_CODE, 812 MLXSW_AFA_TRAPDISC_CODE,
807 MLXSW_AFA_TRAPDISC_SIZE); 813 MLXSW_AFA_TRAPDISC_SIZE);
808 814
809 if (!act) 815 if (IS_ERR(act))
810 return -ENOBUFS; 816 return PTR_ERR(act);
811 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP, 817 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
812 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 0); 818 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 0);
813 return 0; 819 return 0;
@@ -820,8 +826,8 @@ int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id)
820 MLXSW_AFA_TRAPDISC_CODE, 826 MLXSW_AFA_TRAPDISC_CODE,
821 MLXSW_AFA_TRAPDISC_SIZE); 827 MLXSW_AFA_TRAPDISC_SIZE);
822 828
823 if (!act) 829 if (IS_ERR(act))
824 return -ENOBUFS; 830 return PTR_ERR(act);
825 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP, 831 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
826 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 832 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD,
827 trap_id); 833 trap_id);
@@ -836,8 +842,8 @@ int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
836 MLXSW_AFA_TRAPDISC_CODE, 842 MLXSW_AFA_TRAPDISC_CODE,
837 MLXSW_AFA_TRAPDISC_SIZE); 843 MLXSW_AFA_TRAPDISC_SIZE);
838 844
839 if (!act) 845 if (IS_ERR(act))
840 return -ENOBUFS; 846 return PTR_ERR(act);
841 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP, 847 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
842 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, 848 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD,
843 trap_id); 849 trap_id);
@@ -856,6 +862,7 @@ static void
856mlxsw_afa_mirror_destroy(struct mlxsw_afa_block *block, 862mlxsw_afa_mirror_destroy(struct mlxsw_afa_block *block,
857 struct mlxsw_afa_mirror *mirror) 863 struct mlxsw_afa_mirror *mirror)
858{ 864{
865 mlxsw_afa_resource_del(&mirror->resource);
859 block->afa->ops->mirror_del(block->afa->ops_priv, 866 block->afa->ops->mirror_del(block->afa->ops_priv,
860 mirror->local_in_port, 867 mirror->local_in_port,
861 mirror->span_id, 868 mirror->span_id,
@@ -908,8 +915,8 @@ mlxsw_afa_block_append_allocated_mirror(struct mlxsw_afa_block *block,
908 char *act = mlxsw_afa_block_append_action(block, 915 char *act = mlxsw_afa_block_append_action(block,
909 MLXSW_AFA_TRAPDISC_CODE, 916 MLXSW_AFA_TRAPDISC_CODE,
910 MLXSW_AFA_TRAPDISC_SIZE); 917 MLXSW_AFA_TRAPDISC_SIZE);
911 if (!act) 918 if (IS_ERR(act))
912 return -ENOBUFS; 919 return PTR_ERR(act);
913 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP, 920 mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
914 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, 0); 921 MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, 0);
915 mlxsw_afa_trapdisc_mirror_pack(act, true, mirror_agent); 922 mlxsw_afa_trapdisc_mirror_pack(act, true, mirror_agent);
@@ -996,8 +1003,8 @@ int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
996 1003
997 act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE, 1004 act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE,
998 MLXSW_AFA_FORWARD_SIZE); 1005 MLXSW_AFA_FORWARD_SIZE);
999 if (!act) { 1006 if (IS_ERR(act)) {
1000 err = -ENOBUFS; 1007 err = PTR_ERR(act);
1001 goto err_append_action; 1008 goto err_append_action;
1002 } 1009 }
1003 mlxsw_afa_forward_pack(act, MLXSW_AFA_FORWARD_TYPE_PBS, 1010 mlxsw_afa_forward_pack(act, MLXSW_AFA_FORWARD_TYPE_PBS,
@@ -1052,8 +1059,8 @@ int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
1052{ 1059{
1053 char *act = mlxsw_afa_block_append_action(block, MLXSW_AFA_POLCNT_CODE, 1060 char *act = mlxsw_afa_block_append_action(block, MLXSW_AFA_POLCNT_CODE,
1054 MLXSW_AFA_POLCNT_SIZE); 1061 MLXSW_AFA_POLCNT_SIZE);
1055 if (!act) 1062 if (IS_ERR(act))
1056 return -ENOBUFS; 1063 return PTR_ERR(act);
1057 mlxsw_afa_polcnt_pack(act, MLXSW_AFA_POLCNT_COUNTER_SET_TYPE_PACKETS_BYTES, 1064 mlxsw_afa_polcnt_pack(act, MLXSW_AFA_POLCNT_COUNTER_SET_TYPE_PACKETS_BYTES,
1058 counter_index); 1065 counter_index);
1059 return 0; 1066 return 0;
@@ -1123,8 +1130,8 @@ int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid)
1123 char *act = mlxsw_afa_block_append_action(block, 1130 char *act = mlxsw_afa_block_append_action(block,
1124 MLXSW_AFA_VIRFWD_CODE, 1131 MLXSW_AFA_VIRFWD_CODE,
1125 MLXSW_AFA_VIRFWD_SIZE); 1132 MLXSW_AFA_VIRFWD_SIZE);
1126 if (!act) 1133 if (IS_ERR(act))
1127 return -ENOBUFS; 1134 return PTR_ERR(act);
1128 mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid); 1135 mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid);
1129 return 0; 1136 return 0;
1130} 1137}
@@ -1193,8 +1200,8 @@ int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block,
1193 char *act = mlxsw_afa_block_append_action(block, 1200 char *act = mlxsw_afa_block_append_action(block,
1194 MLXSW_AFA_MCROUTER_CODE, 1201 MLXSW_AFA_MCROUTER_CODE,
1195 MLXSW_AFA_MCROUTER_SIZE); 1202 MLXSW_AFA_MCROUTER_SIZE);
1196 if (!act) 1203 if (IS_ERR(act))
1197 return -ENOBUFS; 1204 return PTR_ERR(act);
1198 mlxsw_afa_mcrouter_pack(act, MLXSW_AFA_MCROUTER_RPF_ACTION_TRAP, 1205 mlxsw_afa_mcrouter_pack(act, MLXSW_AFA_MCROUTER_RPF_ACTION_TRAP,
1199 expected_irif, min_mtu, rmid_valid, kvdl_index); 1206 expected_irif, min_mtu, rmid_valid, kvdl_index);
1200 return 0; 1207 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 6aaaf3d9ba31..77b2adb29341 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -4756,6 +4756,12 @@ static void mlxsw_sp_rt6_destroy(struct mlxsw_sp_rt6 *mlxsw_sp_rt6)
4756 kfree(mlxsw_sp_rt6); 4756 kfree(mlxsw_sp_rt6);
4757} 4757}
4758 4758
4759static bool mlxsw_sp_fib6_rt_can_mp(const struct fib6_info *rt)
4760{
4761 /* RTF_CACHE routes are ignored */
4762 return (rt->fib6_flags & (RTF_GATEWAY | RTF_ADDRCONF)) == RTF_GATEWAY;
4763}
4764
4759static struct fib6_info * 4765static struct fib6_info *
4760mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry) 4766mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
4761{ 4767{
@@ -4765,11 +4771,11 @@ mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
4765 4771
4766static struct mlxsw_sp_fib6_entry * 4772static struct mlxsw_sp_fib6_entry *
4767mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node, 4773mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
4768 const struct fib6_info *nrt, bool append) 4774 const struct fib6_info *nrt, bool replace)
4769{ 4775{
4770 struct mlxsw_sp_fib6_entry *fib6_entry; 4776 struct mlxsw_sp_fib6_entry *fib6_entry;
4771 4777
4772 if (!append) 4778 if (!mlxsw_sp_fib6_rt_can_mp(nrt) || replace)
4773 return NULL; 4779 return NULL;
4774 4780
4775 list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) { 4781 list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
@@ -4784,7 +4790,8 @@ mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
4784 break; 4790 break;
4785 if (rt->fib6_metric < nrt->fib6_metric) 4791 if (rt->fib6_metric < nrt->fib6_metric)
4786 continue; 4792 continue;
4787 if (rt->fib6_metric == nrt->fib6_metric) 4793 if (rt->fib6_metric == nrt->fib6_metric &&
4794 mlxsw_sp_fib6_rt_can_mp(rt))
4788 return fib6_entry; 4795 return fib6_entry;
4789 if (rt->fib6_metric > nrt->fib6_metric) 4796 if (rt->fib6_metric > nrt->fib6_metric)
4790 break; 4797 break;
@@ -5163,7 +5170,7 @@ static struct mlxsw_sp_fib6_entry *
5163mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node, 5170mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
5164 const struct fib6_info *nrt, bool replace) 5171 const struct fib6_info *nrt, bool replace)
5165{ 5172{
5166 struct mlxsw_sp_fib6_entry *fib6_entry; 5173 struct mlxsw_sp_fib6_entry *fib6_entry, *fallback = NULL;
5167 5174
5168 list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) { 5175 list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
5169 struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(fib6_entry); 5176 struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(fib6_entry);
@@ -5172,13 +5179,18 @@ mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
5172 continue; 5179 continue;
5173 if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id) 5180 if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id)
5174 break; 5181 break;
5175 if (replace && rt->fib6_metric == nrt->fib6_metric) 5182 if (replace && rt->fib6_metric == nrt->fib6_metric) {
5176 return fib6_entry; 5183 if (mlxsw_sp_fib6_rt_can_mp(rt) ==
5184 mlxsw_sp_fib6_rt_can_mp(nrt))
5185 return fib6_entry;
5186 if (mlxsw_sp_fib6_rt_can_mp(nrt))
5187 fallback = fallback ?: fib6_entry;
5188 }
5177 if (rt->fib6_metric > nrt->fib6_metric) 5189 if (rt->fib6_metric > nrt->fib6_metric)
5178 return fib6_entry; 5190 return fallback ?: fib6_entry;
5179 } 5191 }
5180 5192
5181 return NULL; 5193 return fallback;
5182} 5194}
5183 5195
5184static int 5196static int
@@ -5304,8 +5316,7 @@ static void mlxsw_sp_fib6_entry_replace(struct mlxsw_sp *mlxsw_sp,
5304} 5316}
5305 5317
5306static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp, 5318static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5307 struct fib6_info *rt, bool replace, 5319 struct fib6_info *rt, bool replace)
5308 bool append)
5309{ 5320{
5310 struct mlxsw_sp_fib6_entry *fib6_entry; 5321 struct mlxsw_sp_fib6_entry *fib6_entry;
5311 struct mlxsw_sp_fib_node *fib_node; 5322 struct mlxsw_sp_fib_node *fib_node;
@@ -5331,7 +5342,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5331 /* Before creating a new entry, try to append route to an existing 5342 /* Before creating a new entry, try to append route to an existing
5332 * multipath entry. 5343 * multipath entry.
5333 */ 5344 */
5334 fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, append); 5345 fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, replace);
5335 if (fib6_entry) { 5346 if (fib6_entry) {
5336 err = mlxsw_sp_fib6_entry_nexthop_add(mlxsw_sp, fib6_entry, rt); 5347 err = mlxsw_sp_fib6_entry_nexthop_add(mlxsw_sp, fib6_entry, rt);
5337 if (err) 5348 if (err)
@@ -5339,14 +5350,6 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5339 return 0; 5350 return 0;
5340 } 5351 }
5341 5352
5342 /* We received an append event, yet did not find any route to
5343 * append to.
5344 */
5345 if (WARN_ON(append)) {
5346 err = -EINVAL;
5347 goto err_fib6_entry_append;
5348 }
5349
5350 fib6_entry = mlxsw_sp_fib6_entry_create(mlxsw_sp, fib_node, rt); 5353 fib6_entry = mlxsw_sp_fib6_entry_create(mlxsw_sp, fib_node, rt);
5351 if (IS_ERR(fib6_entry)) { 5354 if (IS_ERR(fib6_entry)) {
5352 err = PTR_ERR(fib6_entry); 5355 err = PTR_ERR(fib6_entry);
@@ -5364,7 +5367,6 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5364err_fib6_node_entry_link: 5367err_fib6_node_entry_link:
5365 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry); 5368 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry);
5366err_fib6_entry_create: 5369err_fib6_entry_create:
5367err_fib6_entry_append:
5368err_fib6_entry_nexthop_add: 5370err_fib6_entry_nexthop_add:
5369 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); 5371 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node);
5370 return err; 5372 return err;
@@ -5715,7 +5717,7 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
5715 struct mlxsw_sp_fib_event_work *fib_work = 5717 struct mlxsw_sp_fib_event_work *fib_work =
5716 container_of(work, struct mlxsw_sp_fib_event_work, work); 5718 container_of(work, struct mlxsw_sp_fib_event_work, work);
5717 struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp; 5719 struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp;
5718 bool replace, append; 5720 bool replace;
5719 int err; 5721 int err;
5720 5722
5721 rtnl_lock(); 5723 rtnl_lock();
@@ -5726,10 +5728,8 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
5726 case FIB_EVENT_ENTRY_APPEND: /* fall through */ 5728 case FIB_EVENT_ENTRY_APPEND: /* fall through */
5727 case FIB_EVENT_ENTRY_ADD: 5729 case FIB_EVENT_ENTRY_ADD:
5728 replace = fib_work->event == FIB_EVENT_ENTRY_REPLACE; 5730 replace = fib_work->event == FIB_EVENT_ENTRY_REPLACE;
5729 append = fib_work->event == FIB_EVENT_ENTRY_APPEND;
5730 err = mlxsw_sp_router_fib6_add(mlxsw_sp, 5731 err = mlxsw_sp_router_fib6_add(mlxsw_sp,
5731 fib_work->fen6_info.rt, replace, 5732 fib_work->fen6_info.rt, replace);
5732 append);
5733 if (err) 5733 if (err)
5734 mlxsw_sp_router_fib_abort(mlxsw_sp); 5734 mlxsw_sp_router_fib_abort(mlxsw_sp);
5735 mlxsw_sp_rt6_release(fib_work->fen6_info.rt); 5735 mlxsw_sp_rt6_release(fib_work->fen6_info.rt);
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c
index 1decf3a1cad3..e57d23746585 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/main.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/main.c
@@ -80,7 +80,7 @@ nfp_flower_repr_get_type_and_port(struct nfp_app *app, u32 port_id, u8 *port)
80 return NFP_REPR_TYPE_VF; 80 return NFP_REPR_TYPE_VF;
81 } 81 }
82 82
83 return NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC; 83 return __NFP_REPR_TYPE_MAX;
84} 84}
85 85
86static struct net_device * 86static struct net_device *
@@ -91,6 +91,8 @@ nfp_flower_repr_get(struct nfp_app *app, u32 port_id)
91 u8 port = 0; 91 u8 port = 0;
92 92
93 repr_type = nfp_flower_repr_get_type_and_port(app, port_id, &port); 93 repr_type = nfp_flower_repr_get_type_and_port(app, port_id, &port);
94 if (repr_type > NFP_REPR_TYPE_MAX)
95 return NULL;
94 96
95 reprs = rcu_dereference(app->reprs[repr_type]); 97 reprs = rcu_dereference(app->reprs[repr_type]);
96 if (!reprs) 98 if (!reprs)
diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
index 78afe75129ab..382bb93cb090 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
@@ -317,7 +317,7 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
317 payload.dst_ipv4 = flow->daddr; 317 payload.dst_ipv4 = flow->daddr;
318 318
319 /* If entry has expired send dst IP with all other fields 0. */ 319 /* If entry has expired send dst IP with all other fields 0. */
320 if (!(neigh->nud_state & NUD_VALID)) { 320 if (!(neigh->nud_state & NUD_VALID) || neigh->dead) {
321 nfp_tun_del_route_from_cache(app, payload.dst_ipv4); 321 nfp_tun_del_route_from_cache(app, payload.dst_ipv4);
322 /* Trigger ARP to verify invalid neighbour state. */ 322 /* Trigger ARP to verify invalid neighbour state. */
323 neigh_event_send(neigh, NULL); 323 neigh_event_send(neigh, NULL);
diff --git a/drivers/net/ethernet/qlogic/qed/qed.h b/drivers/net/ethernet/qlogic/qed/qed.h
index 00db3401b898..1dfaccd151f0 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -502,6 +502,7 @@ enum BAR_ID {
502struct qed_nvm_image_info { 502struct qed_nvm_image_info {
503 u32 num_images; 503 u32 num_images;
504 struct bist_nvm_image_att *image_att; 504 struct bist_nvm_image_att *image_att;
505 bool valid;
505}; 506};
506 507
507#define DRV_MODULE_VERSION \ 508#define DRV_MODULE_VERSION \
diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index a14e48489029..4340c4c90bcb 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -6723,7 +6723,7 @@ static enum dbg_status qed_parse_mcp_trace_buf(u8 *trace_buf,
6723 format_idx = header & MFW_TRACE_EVENTID_MASK; 6723 format_idx = header & MFW_TRACE_EVENTID_MASK;
6724 6724
6725 /* Skip message if its index doesn't exist in the meta data */ 6725 /* Skip message if its index doesn't exist in the meta data */
6726 if (format_idx > s_mcp_trace_meta.formats_num) { 6726 if (format_idx >= s_mcp_trace_meta.formats_num) {
6727 u8 format_size = 6727 u8 format_size =
6728 (u8)((header & MFW_TRACE_PRM_SIZE_MASK) >> 6728 (u8)((header & MFW_TRACE_PRM_SIZE_MASK) >>
6729 MFW_TRACE_PRM_SIZE_SHIFT); 6729 MFW_TRACE_PRM_SIZE_SHIFT);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index 99973e10b179..5ede6408649d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -665,7 +665,7 @@ qed_sp_update_mcast_bin(struct qed_hwfn *p_hwfn,
665 665
666 p_ramrod->common.update_approx_mcast_flg = 1; 666 p_ramrod->common.update_approx_mcast_flg = 1;
667 for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) { 667 for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) {
668 u32 *p_bins = (u32 *)p_params->bins; 668 u32 *p_bins = p_params->bins;
669 669
670 p_ramrod->approx_mcast.bins[i] = cpu_to_le32(p_bins[i]); 670 p_ramrod->approx_mcast.bins[i] = cpu_to_le32(p_bins[i]);
671 } 671 }
@@ -1476,8 +1476,8 @@ qed_sp_eth_filter_mcast(struct qed_hwfn *p_hwfn,
1476 enum spq_mode comp_mode, 1476 enum spq_mode comp_mode,
1477 struct qed_spq_comp_cb *p_comp_data) 1477 struct qed_spq_comp_cb *p_comp_data)
1478{ 1478{
1479 unsigned long bins[ETH_MULTICAST_MAC_BINS_IN_REGS];
1480 struct vport_update_ramrod_data *p_ramrod = NULL; 1479 struct vport_update_ramrod_data *p_ramrod = NULL;
1480 u32 bins[ETH_MULTICAST_MAC_BINS_IN_REGS];
1481 struct qed_spq_entry *p_ent = NULL; 1481 struct qed_spq_entry *p_ent = NULL;
1482 struct qed_sp_init_data init_data; 1482 struct qed_sp_init_data init_data;
1483 u8 abs_vport_id = 0; 1483 u8 abs_vport_id = 0;
@@ -1513,26 +1513,25 @@ qed_sp_eth_filter_mcast(struct qed_hwfn *p_hwfn,
1513 /* explicitly clear out the entire vector */ 1513 /* explicitly clear out the entire vector */
1514 memset(&p_ramrod->approx_mcast.bins, 0, 1514 memset(&p_ramrod->approx_mcast.bins, 0,
1515 sizeof(p_ramrod->approx_mcast.bins)); 1515 sizeof(p_ramrod->approx_mcast.bins));
1516 memset(bins, 0, sizeof(unsigned long) * 1516 memset(bins, 0, sizeof(bins));
1517 ETH_MULTICAST_MAC_BINS_IN_REGS);
1518 /* filter ADD op is explicit set op and it removes 1517 /* filter ADD op is explicit set op and it removes
1519 * any existing filters for the vport 1518 * any existing filters for the vport
1520 */ 1519 */
1521 if (p_filter_cmd->opcode == QED_FILTER_ADD) { 1520 if (p_filter_cmd->opcode == QED_FILTER_ADD) {
1522 for (i = 0; i < p_filter_cmd->num_mc_addrs; i++) { 1521 for (i = 0; i < p_filter_cmd->num_mc_addrs; i++) {
1523 u32 bit; 1522 u32 bit, nbits;
1524 1523
1525 bit = qed_mcast_bin_from_mac(p_filter_cmd->mac[i]); 1524 bit = qed_mcast_bin_from_mac(p_filter_cmd->mac[i]);
1526 __set_bit(bit, bins); 1525 nbits = sizeof(u32) * BITS_PER_BYTE;
1526 bins[bit / nbits] |= 1 << (bit % nbits);
1527 } 1527 }
1528 1528
1529 /* Convert to correct endianity */ 1529 /* Convert to correct endianity */
1530 for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) { 1530 for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) {
1531 struct vport_update_ramrod_mcast *p_ramrod_bins; 1531 struct vport_update_ramrod_mcast *p_ramrod_bins;
1532 u32 *p_bins = (u32 *)bins;
1533 1532
1534 p_ramrod_bins = &p_ramrod->approx_mcast; 1533 p_ramrod_bins = &p_ramrod->approx_mcast;
1535 p_ramrod_bins->bins[i] = cpu_to_le32(p_bins[i]); 1534 p_ramrod_bins->bins[i] = cpu_to_le32(bins[i]);
1536 } 1535 }
1537 } 1536 }
1538 1537
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.h b/drivers/net/ethernet/qlogic/qed/qed_l2.h
index 806a8da257e9..8d80f1095d17 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.h
@@ -215,7 +215,7 @@ struct qed_sp_vport_update_params {
215 u8 anti_spoofing_en; 215 u8 anti_spoofing_en;
216 u8 update_accept_any_vlan_flg; 216 u8 update_accept_any_vlan_flg;
217 u8 accept_any_vlan; 217 u8 accept_any_vlan;
218 unsigned long bins[8]; 218 u32 bins[8];
219 struct qed_rss_params *rss_params; 219 struct qed_rss_params *rss_params;
220 struct qed_filter_accept_flags accept_flags; 220 struct qed_filter_accept_flags accept_flags;
221 struct qed_sge_tpa_params *sge_tpa_params; 221 struct qed_sge_tpa_params *sge_tpa_params;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 0cbc74d6ca8b..758a9a5127fa 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -371,7 +371,7 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
371 goto err2; 371 goto err2;
372 } 372 }
373 373
374 DP_INFO(cdev, "qed_probe completed successffuly\n"); 374 DP_INFO(cdev, "qed_probe completed successfully\n");
375 375
376 return cdev; 376 return cdev;
377 377
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 4e0b443c9519..cdd645024a32 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -592,6 +592,9 @@ int qed_mcp_nvm_wr_cmd(struct qed_hwfn *p_hwfn,
592 *o_mcp_resp = mb_params.mcp_resp; 592 *o_mcp_resp = mb_params.mcp_resp;
593 *o_mcp_param = mb_params.mcp_param; 593 *o_mcp_param = mb_params.mcp_param;
594 594
595 /* nvm_info needs to be updated */
596 p_hwfn->nvm_info.valid = false;
597
595 return 0; 598 return 0;
596} 599}
597 600
@@ -1208,6 +1211,7 @@ static void qed_mcp_handle_link_change(struct qed_hwfn *p_hwfn,
1208 break; 1211 break;
1209 default: 1212 default:
1210 p_link->speed = 0; 1213 p_link->speed = 0;
1214 p_link->link_up = 0;
1211 } 1215 }
1212 1216
1213 if (p_link->link_up && p_link->speed) 1217 if (p_link->link_up && p_link->speed)
@@ -1305,9 +1309,15 @@ int qed_mcp_set_link(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, bool b_up)
1305 phy_cfg.pause |= (params->pause.forced_tx) ? ETH_PAUSE_TX : 0; 1309 phy_cfg.pause |= (params->pause.forced_tx) ? ETH_PAUSE_TX : 0;
1306 phy_cfg.adv_speed = params->speed.advertised_speeds; 1310 phy_cfg.adv_speed = params->speed.advertised_speeds;
1307 phy_cfg.loopback_mode = params->loopback_mode; 1311 phy_cfg.loopback_mode = params->loopback_mode;
1308 if (p_hwfn->mcp_info->capabilities & FW_MB_PARAM_FEATURE_SUPPORT_EEE) { 1312
1309 if (params->eee.enable) 1313 /* There are MFWs that share this capability regardless of whether
1310 phy_cfg.eee_cfg |= EEE_CFG_EEE_ENABLED; 1314 * this is feasible or not. And given that at the very least adv_caps
1315 * would be set internally by qed, we want to make sure LFA would
1316 * still work.
1317 */
1318 if ((p_hwfn->mcp_info->capabilities &
1319 FW_MB_PARAM_FEATURE_SUPPORT_EEE) && params->eee.enable) {
1320 phy_cfg.eee_cfg |= EEE_CFG_EEE_ENABLED;
1311 if (params->eee.tx_lpi_enable) 1321 if (params->eee.tx_lpi_enable)
1312 phy_cfg.eee_cfg |= EEE_CFG_TX_LPI; 1322 phy_cfg.eee_cfg |= EEE_CFG_TX_LPI;
1313 if (params->eee.adv_caps & QED_EEE_1G_ADV) 1323 if (params->eee.adv_caps & QED_EEE_1G_ADV)
@@ -2555,11 +2565,14 @@ int qed_mcp_bist_nvm_get_image_att(struct qed_hwfn *p_hwfn,
2555 2565
2556int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn) 2566int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
2557{ 2567{
2558 struct qed_nvm_image_info *nvm_info = &p_hwfn->nvm_info; 2568 struct qed_nvm_image_info nvm_info;
2559 struct qed_ptt *p_ptt; 2569 struct qed_ptt *p_ptt;
2560 int rc; 2570 int rc;
2561 u32 i; 2571 u32 i;
2562 2572
2573 if (p_hwfn->nvm_info.valid)
2574 return 0;
2575
2563 p_ptt = qed_ptt_acquire(p_hwfn); 2576 p_ptt = qed_ptt_acquire(p_hwfn);
2564 if (!p_ptt) { 2577 if (!p_ptt) {
2565 DP_ERR(p_hwfn, "failed to acquire ptt\n"); 2578 DP_ERR(p_hwfn, "failed to acquire ptt\n");
@@ -2567,29 +2580,29 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
2567 } 2580 }
2568 2581
2569 /* Acquire from MFW the amount of available images */ 2582 /* Acquire from MFW the amount of available images */
2570 nvm_info->num_images = 0; 2583 nvm_info.num_images = 0;
2571 rc = qed_mcp_bist_nvm_get_num_images(p_hwfn, 2584 rc = qed_mcp_bist_nvm_get_num_images(p_hwfn,
2572 p_ptt, &nvm_info->num_images); 2585 p_ptt, &nvm_info.num_images);
2573 if (rc == -EOPNOTSUPP) { 2586 if (rc == -EOPNOTSUPP) {
2574 DP_INFO(p_hwfn, "DRV_MSG_CODE_BIST_TEST is not supported\n"); 2587 DP_INFO(p_hwfn, "DRV_MSG_CODE_BIST_TEST is not supported\n");
2575 goto out; 2588 goto out;
2576 } else if (rc || !nvm_info->num_images) { 2589 } else if (rc || !nvm_info.num_images) {
2577 DP_ERR(p_hwfn, "Failed getting number of images\n"); 2590 DP_ERR(p_hwfn, "Failed getting number of images\n");
2578 goto err0; 2591 goto err0;
2579 } 2592 }
2580 2593
2581 nvm_info->image_att = kmalloc_array(nvm_info->num_images, 2594 nvm_info.image_att = kmalloc_array(nvm_info.num_images,
2582 sizeof(struct bist_nvm_image_att), 2595 sizeof(struct bist_nvm_image_att),
2583 GFP_KERNEL); 2596 GFP_KERNEL);
2584 if (!nvm_info->image_att) { 2597 if (!nvm_info.image_att) {
2585 rc = -ENOMEM; 2598 rc = -ENOMEM;
2586 goto err0; 2599 goto err0;
2587 } 2600 }
2588 2601
2589 /* Iterate over images and get their attributes */ 2602 /* Iterate over images and get their attributes */
2590 for (i = 0; i < nvm_info->num_images; i++) { 2603 for (i = 0; i < nvm_info.num_images; i++) {
2591 rc = qed_mcp_bist_nvm_get_image_att(p_hwfn, p_ptt, 2604 rc = qed_mcp_bist_nvm_get_image_att(p_hwfn, p_ptt,
2592 &nvm_info->image_att[i], i); 2605 &nvm_info.image_att[i], i);
2593 if (rc) { 2606 if (rc) {
2594 DP_ERR(p_hwfn, 2607 DP_ERR(p_hwfn,
2595 "Failed getting image index %d attributes\n", i); 2608 "Failed getting image index %d attributes\n", i);
@@ -2597,14 +2610,22 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
2597 } 2610 }
2598 2611
2599 DP_VERBOSE(p_hwfn, QED_MSG_SP, "image index %d, size %x\n", i, 2612 DP_VERBOSE(p_hwfn, QED_MSG_SP, "image index %d, size %x\n", i,
2600 nvm_info->image_att[i].len); 2613 nvm_info.image_att[i].len);
2601 } 2614 }
2602out: 2615out:
2616 /* Update hwfn's nvm_info */
2617 if (nvm_info.num_images) {
2618 p_hwfn->nvm_info.num_images = nvm_info.num_images;
2619 kfree(p_hwfn->nvm_info.image_att);
2620 p_hwfn->nvm_info.image_att = nvm_info.image_att;
2621 p_hwfn->nvm_info.valid = true;
2622 }
2623
2603 qed_ptt_release(p_hwfn, p_ptt); 2624 qed_ptt_release(p_hwfn, p_ptt);
2604 return 0; 2625 return 0;
2605 2626
2606err1: 2627err1:
2607 kfree(nvm_info->image_att); 2628 kfree(nvm_info.image_att);
2608err0: 2629err0:
2609 qed_ptt_release(p_hwfn, p_ptt); 2630 qed_ptt_release(p_hwfn, p_ptt);
2610 return rc; 2631 return rc;
@@ -2641,6 +2662,7 @@ qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
2641 return -EINVAL; 2662 return -EINVAL;
2642 } 2663 }
2643 2664
2665 qed_mcp_nvm_info_populate(p_hwfn);
2644 for (i = 0; i < p_hwfn->nvm_info.num_images; i++) 2666 for (i = 0; i < p_hwfn->nvm_info.num_images; i++)
2645 if (type == p_hwfn->nvm_info.image_att[i].image_type) 2667 if (type == p_hwfn->nvm_info.image_att[i].image_type)
2646 break; 2668 break;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
index fd59cf45f4be..26e918d7f2f9 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
@@ -2831,7 +2831,7 @@ qed_iov_vp_update_mcast_bin_param(struct qed_hwfn *p_hwfn,
2831 2831
2832 p_data->update_approx_mcast_flg = 1; 2832 p_data->update_approx_mcast_flg = 1;
2833 memcpy(p_data->bins, p_mcast_tlv->bins, 2833 memcpy(p_data->bins, p_mcast_tlv->bins,
2834 sizeof(unsigned long) * ETH_MULTICAST_MAC_BINS_IN_REGS); 2834 sizeof(u32) * ETH_MULTICAST_MAC_BINS_IN_REGS);
2835 *tlvs_mask |= 1 << QED_IOV_VP_UPDATE_MCAST; 2835 *tlvs_mask |= 1 << QED_IOV_VP_UPDATE_MCAST;
2836} 2836}
2837 2837
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index 2d7fcd6a0777..be6ddde1a104 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -1126,7 +1126,7 @@ int qed_vf_pf_vport_update(struct qed_hwfn *p_hwfn,
1126 resp_size += sizeof(struct pfvf_def_resp_tlv); 1126 resp_size += sizeof(struct pfvf_def_resp_tlv);
1127 1127
1128 memcpy(p_mcast_tlv->bins, p_params->bins, 1128 memcpy(p_mcast_tlv->bins, p_params->bins,
1129 sizeof(unsigned long) * ETH_MULTICAST_MAC_BINS_IN_REGS); 1129 sizeof(u32) * ETH_MULTICAST_MAC_BINS_IN_REGS);
1130 } 1130 }
1131 1131
1132 update_rx = p_params->accept_flags.update_rx_mode_config; 1132 update_rx = p_params->accept_flags.update_rx_mode_config;
@@ -1272,7 +1272,7 @@ void qed_vf_pf_filter_mcast(struct qed_hwfn *p_hwfn,
1272 u32 bit; 1272 u32 bit;
1273 1273
1274 bit = qed_mcast_bin_from_mac(p_filter_cmd->mac[i]); 1274 bit = qed_mcast_bin_from_mac(p_filter_cmd->mac[i]);
1275 __set_bit(bit, sp_params.bins); 1275 sp_params.bins[bit / 32] |= 1 << (bit % 32);
1276 } 1276 }
1277 } 1277 }
1278 1278
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.h b/drivers/net/ethernet/qlogic/qed/qed_vf.h
index 4f05d5eb3cf5..033409db86ae 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.h
@@ -392,7 +392,12 @@ struct vfpf_vport_update_mcast_bin_tlv {
392 struct channel_tlv tl; 392 struct channel_tlv tl;
393 u8 padding[4]; 393 u8 padding[4];
394 394
395 u64 bins[8]; 395 /* There are only 256 approx bins, and in HSI they're divided into
396 * 32-bit values. As old VFs used to set-bit to the values on its side,
397 * the upper half of the array is never expected to contain any data.
398 */
399 u64 bins[4];
400 u64 obsolete_bins[4];
396}; 401};
397 402
398struct vfpf_vport_update_accept_param_tlv { 403struct vfpf_vport_update_accept_param_tlv {
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
index 891f03a7a33d..8d7b9bb910f2 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
@@ -1128,6 +1128,8 @@ static ssize_t qlcnic_83xx_sysfs_flash_write_handler(struct file *filp,
1128 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 1128 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
1129 1129
1130 ret = kstrtoul(buf, 16, &data); 1130 ret = kstrtoul(buf, 16, &data);
1131 if (ret)
1132 return ret;
1131 1133
1132 switch (data) { 1134 switch (data) {
1133 case QLC_83XX_FLASH_SECTOR_ERASE_CMD: 1135 case QLC_83XX_FLASH_SECTOR_ERASE_CMD:
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 5803cd6db406..206f0266463e 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -658,7 +658,7 @@ qcaspi_netdev_open(struct net_device *dev)
658 return ret; 658 return ret;
659 } 659 }
660 660
661 netif_start_queue(qca->net_dev); 661 /* SPI thread takes care of TX queue */
662 662
663 return 0; 663 return 0;
664} 664}
@@ -760,6 +760,9 @@ qcaspi_netdev_tx_timeout(struct net_device *dev)
760 qca->net_dev->stats.tx_errors++; 760 qca->net_dev->stats.tx_errors++;
761 /* Trigger tx queue flush and QCA7000 reset */ 761 /* Trigger tx queue flush and QCA7000 reset */
762 qca->sync = QCASPI_SYNC_UNKNOWN; 762 qca->sync = QCASPI_SYNC_UNKNOWN;
763
764 if (qca->spi_thread)
765 wake_up_process(qca->spi_thread);
763} 766}
764 767
765static int 768static int
@@ -878,22 +881,22 @@ qca_spi_probe(struct spi_device *spi)
878 881
879 if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) || 882 if ((qcaspi_clkspeed < QCASPI_CLK_SPEED_MIN) ||
880 (qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) { 883 (qcaspi_clkspeed > QCASPI_CLK_SPEED_MAX)) {
881 dev_info(&spi->dev, "Invalid clkspeed: %d\n", 884 dev_err(&spi->dev, "Invalid clkspeed: %d\n",
882 qcaspi_clkspeed); 885 qcaspi_clkspeed);
883 return -EINVAL; 886 return -EINVAL;
884 } 887 }
885 888
886 if ((qcaspi_burst_len < QCASPI_BURST_LEN_MIN) || 889 if ((qcaspi_burst_len < QCASPI_BURST_LEN_MIN) ||
887 (qcaspi_burst_len > QCASPI_BURST_LEN_MAX)) { 890 (qcaspi_burst_len > QCASPI_BURST_LEN_MAX)) {
888 dev_info(&spi->dev, "Invalid burst len: %d\n", 891 dev_err(&spi->dev, "Invalid burst len: %d\n",
889 qcaspi_burst_len); 892 qcaspi_burst_len);
890 return -EINVAL; 893 return -EINVAL;
891 } 894 }
892 895
893 if ((qcaspi_pluggable < QCASPI_PLUGGABLE_MIN) || 896 if ((qcaspi_pluggable < QCASPI_PLUGGABLE_MIN) ||
894 (qcaspi_pluggable > QCASPI_PLUGGABLE_MAX)) { 897 (qcaspi_pluggable > QCASPI_PLUGGABLE_MAX)) {
895 dev_info(&spi->dev, "Invalid pluggable: %d\n", 898 dev_err(&spi->dev, "Invalid pluggable: %d\n",
896 qcaspi_pluggable); 899 qcaspi_pluggable);
897 return -EINVAL; 900 return -EINVAL;
898 } 901 }
899 902
@@ -955,8 +958,8 @@ qca_spi_probe(struct spi_device *spi)
955 } 958 }
956 959
957 if (register_netdev(qcaspi_devs)) { 960 if (register_netdev(qcaspi_devs)) {
958 dev_info(&spi->dev, "Unable to register net device %s\n", 961 dev_err(&spi->dev, "Unable to register net device %s\n",
959 qcaspi_devs->name); 962 qcaspi_devs->name);
960 free_netdev(qcaspi_devs); 963 free_netdev(qcaspi_devs);
961 return -EFAULT; 964 return -EFAULT;
962 } 965 }
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index f4cae2be0fda..eaedc11ed686 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7734,8 +7734,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7734 return rc; 7734 return rc;
7735 } 7735 }
7736 7736
7737 /* override BIOS settings, use userspace tools to enable WOL */ 7737 tp->saved_wolopts = __rtl8169_get_wol(tp);
7738 __rtl8169_set_wol(tp, 0);
7739 7738
7740 if (rtl_tbi_enabled(tp)) { 7739 if (rtl_tbi_enabled(tp)) {
7741 tp->set_speed = rtl8169_set_speed_tbi; 7740 tp->set_speed = rtl8169_set_speed_tbi;
@@ -7789,6 +7788,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7789 NETIF_F_HW_VLAN_CTAG_RX; 7788 NETIF_F_HW_VLAN_CTAG_RX;
7790 dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | 7789 dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
7791 NETIF_F_HIGHDMA; 7790 NETIF_F_HIGHDMA;
7791 dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
7792 7792
7793 tp->cp_cmd |= RxChkSum | RxVlan; 7793 tp->cp_cmd |= RxChkSum | RxVlan;
7794 7794
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 68f122140966..0d811c02ff34 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -980,6 +980,13 @@ static void ravb_adjust_link(struct net_device *ndev)
980 struct ravb_private *priv = netdev_priv(ndev); 980 struct ravb_private *priv = netdev_priv(ndev);
981 struct phy_device *phydev = ndev->phydev; 981 struct phy_device *phydev = ndev->phydev;
982 bool new_state = false; 982 bool new_state = false;
983 unsigned long flags;
984
985 spin_lock_irqsave(&priv->lock, flags);
986
987 /* Disable TX and RX right over here, if E-MAC change is ignored */
988 if (priv->no_avb_link)
989 ravb_rcv_snd_disable(ndev);
983 990
984 if (phydev->link) { 991 if (phydev->link) {
985 if (phydev->duplex != priv->duplex) { 992 if (phydev->duplex != priv->duplex) {
@@ -997,18 +1004,21 @@ static void ravb_adjust_link(struct net_device *ndev)
997 ravb_modify(ndev, ECMR, ECMR_TXF, 0); 1004 ravb_modify(ndev, ECMR, ECMR_TXF, 0);
998 new_state = true; 1005 new_state = true;
999 priv->link = phydev->link; 1006 priv->link = phydev->link;
1000 if (priv->no_avb_link)
1001 ravb_rcv_snd_enable(ndev);
1002 } 1007 }
1003 } else if (priv->link) { 1008 } else if (priv->link) {
1004 new_state = true; 1009 new_state = true;
1005 priv->link = 0; 1010 priv->link = 0;
1006 priv->speed = 0; 1011 priv->speed = 0;
1007 priv->duplex = -1; 1012 priv->duplex = -1;
1008 if (priv->no_avb_link)
1009 ravb_rcv_snd_disable(ndev);
1010 } 1013 }
1011 1014
1015 /* Enable TX and RX right over here, if E-MAC change is ignored */
1016 if (priv->no_avb_link && phydev->link)
1017 ravb_rcv_snd_enable(ndev);
1018
1019 mmiowb();
1020 spin_unlock_irqrestore(&priv->lock, flags);
1021
1012 if (new_state && netif_msg_link(priv)) 1022 if (new_state && netif_msg_link(priv))
1013 phy_print_status(phydev); 1023 phy_print_status(phydev);
1014} 1024}
@@ -1096,75 +1106,6 @@ static int ravb_phy_start(struct net_device *ndev)
1096 return 0; 1106 return 0;
1097} 1107}
1098 1108
1099static int ravb_get_link_ksettings(struct net_device *ndev,
1100 struct ethtool_link_ksettings *cmd)
1101{
1102 struct ravb_private *priv = netdev_priv(ndev);
1103 unsigned long flags;
1104
1105 if (!ndev->phydev)
1106 return -ENODEV;
1107
1108 spin_lock_irqsave(&priv->lock, flags);
1109 phy_ethtool_ksettings_get(ndev->phydev, cmd);
1110 spin_unlock_irqrestore(&priv->lock, flags);
1111
1112 return 0;
1113}
1114
1115static int ravb_set_link_ksettings(struct net_device *ndev,
1116 const struct ethtool_link_ksettings *cmd)
1117{
1118 struct ravb_private *priv = netdev_priv(ndev);
1119 unsigned long flags;
1120 int error;
1121
1122 if (!ndev->phydev)
1123 return -ENODEV;
1124
1125 spin_lock_irqsave(&priv->lock, flags);
1126
1127 /* Disable TX and RX */
1128 ravb_rcv_snd_disable(ndev);
1129
1130 error = phy_ethtool_ksettings_set(ndev->phydev, cmd);
1131 if (error)
1132 goto error_exit;
1133
1134 if (cmd->base.duplex == DUPLEX_FULL)
1135 priv->duplex = 1;
1136 else
1137 priv->duplex = 0;
1138
1139 ravb_set_duplex(ndev);
1140
1141error_exit:
1142 mdelay(1);
1143
1144 /* Enable TX and RX */
1145 ravb_rcv_snd_enable(ndev);
1146
1147 mmiowb();
1148 spin_unlock_irqrestore(&priv->lock, flags);
1149
1150 return error;
1151}
1152
1153static int ravb_nway_reset(struct net_device *ndev)
1154{
1155 struct ravb_private *priv = netdev_priv(ndev);
1156 int error = -ENODEV;
1157 unsigned long flags;
1158
1159 if (ndev->phydev) {
1160 spin_lock_irqsave(&priv->lock, flags);
1161 error = phy_start_aneg(ndev->phydev);
1162 spin_unlock_irqrestore(&priv->lock, flags);
1163 }
1164
1165 return error;
1166}
1167
1168static u32 ravb_get_msglevel(struct net_device *ndev) 1109static u32 ravb_get_msglevel(struct net_device *ndev)
1169{ 1110{
1170 struct ravb_private *priv = netdev_priv(ndev); 1111 struct ravb_private *priv = netdev_priv(ndev);
@@ -1377,7 +1318,7 @@ static int ravb_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
1377} 1318}
1378 1319
1379static const struct ethtool_ops ravb_ethtool_ops = { 1320static const struct ethtool_ops ravb_ethtool_ops = {
1380 .nway_reset = ravb_nway_reset, 1321 .nway_reset = phy_ethtool_nway_reset,
1381 .get_msglevel = ravb_get_msglevel, 1322 .get_msglevel = ravb_get_msglevel,
1382 .set_msglevel = ravb_set_msglevel, 1323 .set_msglevel = ravb_set_msglevel,
1383 .get_link = ethtool_op_get_link, 1324 .get_link = ethtool_op_get_link,
@@ -1387,8 +1328,8 @@ static const struct ethtool_ops ravb_ethtool_ops = {
1387 .get_ringparam = ravb_get_ringparam, 1328 .get_ringparam = ravb_get_ringparam,
1388 .set_ringparam = ravb_set_ringparam, 1329 .set_ringparam = ravb_set_ringparam,
1389 .get_ts_info = ravb_get_ts_info, 1330 .get_ts_info = ravb_get_ts_info,
1390 .get_link_ksettings = ravb_get_link_ksettings, 1331 .get_link_ksettings = phy_ethtool_get_link_ksettings,
1391 .set_link_ksettings = ravb_set_link_ksettings, 1332 .set_link_ksettings = phy_ethtool_set_link_ksettings,
1392 .get_wol = ravb_get_wol, 1333 .get_wol = ravb_get_wol,
1393 .set_wol = ravb_set_wol, 1334 .set_wol = ravb_set_wol,
1394}; 1335};
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index e9007b613f17..5614fd231bbe 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1927,8 +1927,15 @@ static void sh_eth_adjust_link(struct net_device *ndev)
1927{ 1927{
1928 struct sh_eth_private *mdp = netdev_priv(ndev); 1928 struct sh_eth_private *mdp = netdev_priv(ndev);
1929 struct phy_device *phydev = ndev->phydev; 1929 struct phy_device *phydev = ndev->phydev;
1930 unsigned long flags;
1930 int new_state = 0; 1931 int new_state = 0;
1931 1932
1933 spin_lock_irqsave(&mdp->lock, flags);
1934
1935 /* Disable TX and RX right over here, if E-MAC change is ignored */
1936 if (mdp->cd->no_psr || mdp->no_ether_link)
1937 sh_eth_rcv_snd_disable(ndev);
1938
1932 if (phydev->link) { 1939 if (phydev->link) {
1933 if (phydev->duplex != mdp->duplex) { 1940 if (phydev->duplex != mdp->duplex) {
1934 new_state = 1; 1941 new_state = 1;
@@ -1947,18 +1954,21 @@ static void sh_eth_adjust_link(struct net_device *ndev)
1947 sh_eth_modify(ndev, ECMR, ECMR_TXF, 0); 1954 sh_eth_modify(ndev, ECMR, ECMR_TXF, 0);
1948 new_state = 1; 1955 new_state = 1;
1949 mdp->link = phydev->link; 1956 mdp->link = phydev->link;
1950 if (mdp->cd->no_psr || mdp->no_ether_link)
1951 sh_eth_rcv_snd_enable(ndev);
1952 } 1957 }
1953 } else if (mdp->link) { 1958 } else if (mdp->link) {
1954 new_state = 1; 1959 new_state = 1;
1955 mdp->link = 0; 1960 mdp->link = 0;
1956 mdp->speed = 0; 1961 mdp->speed = 0;
1957 mdp->duplex = -1; 1962 mdp->duplex = -1;
1958 if (mdp->cd->no_psr || mdp->no_ether_link)
1959 sh_eth_rcv_snd_disable(ndev);
1960 } 1963 }
1961 1964
1965 /* Enable TX and RX right over here, if E-MAC change is ignored */
1966 if ((mdp->cd->no_psr || mdp->no_ether_link) && phydev->link)
1967 sh_eth_rcv_snd_enable(ndev);
1968
1969 mmiowb();
1970 spin_unlock_irqrestore(&mdp->lock, flags);
1971
1962 if (new_state && netif_msg_link(mdp)) 1972 if (new_state && netif_msg_link(mdp))
1963 phy_print_status(phydev); 1973 phy_print_status(phydev);
1964} 1974}
@@ -2030,60 +2040,6 @@ static int sh_eth_phy_start(struct net_device *ndev)
2030 return 0; 2040 return 0;
2031} 2041}
2032 2042
2033static int sh_eth_get_link_ksettings(struct net_device *ndev,
2034 struct ethtool_link_ksettings *cmd)
2035{
2036 struct sh_eth_private *mdp = netdev_priv(ndev);
2037 unsigned long flags;
2038
2039 if (!ndev->phydev)
2040 return -ENODEV;
2041
2042 spin_lock_irqsave(&mdp->lock, flags);
2043 phy_ethtool_ksettings_get(ndev->phydev, cmd);
2044 spin_unlock_irqrestore(&mdp->lock, flags);
2045
2046 return 0;
2047}
2048
2049static int sh_eth_set_link_ksettings(struct net_device *ndev,
2050 const struct ethtool_link_ksettings *cmd)
2051{
2052 struct sh_eth_private *mdp = netdev_priv(ndev);
2053 unsigned long flags;
2054 int ret;
2055
2056 if (!ndev->phydev)
2057 return -ENODEV;
2058
2059 spin_lock_irqsave(&mdp->lock, flags);
2060
2061 /* disable tx and rx */
2062 sh_eth_rcv_snd_disable(ndev);
2063
2064 ret = phy_ethtool_ksettings_set(ndev->phydev, cmd);
2065 if (ret)
2066 goto error_exit;
2067
2068 if (cmd->base.duplex == DUPLEX_FULL)
2069 mdp->duplex = 1;
2070 else
2071 mdp->duplex = 0;
2072
2073 if (mdp->cd->set_duplex)
2074 mdp->cd->set_duplex(ndev);
2075
2076error_exit:
2077 mdelay(1);
2078
2079 /* enable tx and rx */
2080 sh_eth_rcv_snd_enable(ndev);
2081
2082 spin_unlock_irqrestore(&mdp->lock, flags);
2083
2084 return ret;
2085}
2086
2087/* If it is ever necessary to increase SH_ETH_REG_DUMP_MAX_REGS, the 2043/* If it is ever necessary to increase SH_ETH_REG_DUMP_MAX_REGS, the
2088 * version must be bumped as well. Just adding registers up to that 2044 * version must be bumped as well. Just adding registers up to that
2089 * limit is fine, as long as the existing register indices don't 2045 * limit is fine, as long as the existing register indices don't
@@ -2263,22 +2219,6 @@ static void sh_eth_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
2263 pm_runtime_put_sync(&mdp->pdev->dev); 2219 pm_runtime_put_sync(&mdp->pdev->dev);
2264} 2220}
2265 2221
2266static int sh_eth_nway_reset(struct net_device *ndev)
2267{
2268 struct sh_eth_private *mdp = netdev_priv(ndev);
2269 unsigned long flags;
2270 int ret;
2271
2272 if (!ndev->phydev)
2273 return -ENODEV;
2274
2275 spin_lock_irqsave(&mdp->lock, flags);
2276 ret = phy_start_aneg(ndev->phydev);
2277 spin_unlock_irqrestore(&mdp->lock, flags);
2278
2279 return ret;
2280}
2281
2282static u32 sh_eth_get_msglevel(struct net_device *ndev) 2222static u32 sh_eth_get_msglevel(struct net_device *ndev)
2283{ 2223{
2284 struct sh_eth_private *mdp = netdev_priv(ndev); 2224 struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -2429,7 +2369,7 @@ static int sh_eth_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
2429static const struct ethtool_ops sh_eth_ethtool_ops = { 2369static const struct ethtool_ops sh_eth_ethtool_ops = {
2430 .get_regs_len = sh_eth_get_regs_len, 2370 .get_regs_len = sh_eth_get_regs_len,
2431 .get_regs = sh_eth_get_regs, 2371 .get_regs = sh_eth_get_regs,
2432 .nway_reset = sh_eth_nway_reset, 2372 .nway_reset = phy_ethtool_nway_reset,
2433 .get_msglevel = sh_eth_get_msglevel, 2373 .get_msglevel = sh_eth_get_msglevel,
2434 .set_msglevel = sh_eth_set_msglevel, 2374 .set_msglevel = sh_eth_set_msglevel,
2435 .get_link = ethtool_op_get_link, 2375 .get_link = ethtool_op_get_link,
@@ -2438,8 +2378,8 @@ static const struct ethtool_ops sh_eth_ethtool_ops = {
2438 .get_sset_count = sh_eth_get_sset_count, 2378 .get_sset_count = sh_eth_get_sset_count,
2439 .get_ringparam = sh_eth_get_ringparam, 2379 .get_ringparam = sh_eth_get_ringparam,
2440 .set_ringparam = sh_eth_set_ringparam, 2380 .set_ringparam = sh_eth_set_ringparam,
2441 .get_link_ksettings = sh_eth_get_link_ksettings, 2381 .get_link_ksettings = phy_ethtool_get_link_ksettings,
2442 .set_link_ksettings = sh_eth_set_link_ksettings, 2382 .set_link_ksettings = phy_ethtool_set_link_ksettings,
2443 .get_wol = sh_eth_get_wol, 2383 .get_wol = sh_eth_get_wol,
2444 .set_wol = sh_eth_set_wol, 2384 .set_wol = sh_eth_set_wol,
2445}; 2385};
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 23f0785c0573..7eeac3d6cfe8 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -4288,9 +4288,9 @@ static int efx_ef10_filter_pri(struct efx_ef10_filter_table *table,
4288 return -EPROTONOSUPPORT; 4288 return -EPROTONOSUPPORT;
4289} 4289}
4290 4290
4291static s32 efx_ef10_filter_insert(struct efx_nic *efx, 4291static s32 efx_ef10_filter_insert_locked(struct efx_nic *efx,
4292 struct efx_filter_spec *spec, 4292 struct efx_filter_spec *spec,
4293 bool replace_equal) 4293 bool replace_equal)
4294{ 4294{
4295 DECLARE_BITMAP(mc_rem_map, EFX_EF10_FILTER_SEARCH_LIMIT); 4295 DECLARE_BITMAP(mc_rem_map, EFX_EF10_FILTER_SEARCH_LIMIT);
4296 struct efx_ef10_nic_data *nic_data = efx->nic_data; 4296 struct efx_ef10_nic_data *nic_data = efx->nic_data;
@@ -4307,7 +4307,7 @@ static s32 efx_ef10_filter_insert(struct efx_nic *efx,
4307 bool is_mc_recip; 4307 bool is_mc_recip;
4308 s32 rc; 4308 s32 rc;
4309 4309
4310 down_read(&efx->filter_sem); 4310 WARN_ON(!rwsem_is_locked(&efx->filter_sem));
4311 table = efx->filter_state; 4311 table = efx->filter_state;
4312 down_write(&table->lock); 4312 down_write(&table->lock);
4313 4313
@@ -4498,10 +4498,22 @@ out_unlock:
4498 if (rss_locked) 4498 if (rss_locked)
4499 mutex_unlock(&efx->rss_lock); 4499 mutex_unlock(&efx->rss_lock);
4500 up_write(&table->lock); 4500 up_write(&table->lock);
4501 up_read(&efx->filter_sem);
4502 return rc; 4501 return rc;
4503} 4502}
4504 4503
4504static s32 efx_ef10_filter_insert(struct efx_nic *efx,
4505 struct efx_filter_spec *spec,
4506 bool replace_equal)
4507{
4508 s32 ret;
4509
4510 down_read(&efx->filter_sem);
4511 ret = efx_ef10_filter_insert_locked(efx, spec, replace_equal);
4512 up_read(&efx->filter_sem);
4513
4514 return ret;
4515}
4516
4505static void efx_ef10_filter_update_rx_scatter(struct efx_nic *efx) 4517static void efx_ef10_filter_update_rx_scatter(struct efx_nic *efx)
4506{ 4518{
4507 /* no need to do anything here on EF10 */ 4519 /* no need to do anything here on EF10 */
@@ -5285,7 +5297,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
5285 EFX_WARN_ON_PARANOID(ids[i] != EFX_EF10_FILTER_ID_INVALID); 5297 EFX_WARN_ON_PARANOID(ids[i] != EFX_EF10_FILTER_ID_INVALID);
5286 efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0); 5298 efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
5287 efx_filter_set_eth_local(&spec, vlan->vid, addr_list[i].addr); 5299 efx_filter_set_eth_local(&spec, vlan->vid, addr_list[i].addr);
5288 rc = efx_ef10_filter_insert(efx, &spec, true); 5300 rc = efx_ef10_filter_insert_locked(efx, &spec, true);
5289 if (rc < 0) { 5301 if (rc < 0) {
5290 if (rollback) { 5302 if (rollback) {
5291 netif_info(efx, drv, efx->net_dev, 5303 netif_info(efx, drv, efx->net_dev,
@@ -5314,7 +5326,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
5314 efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0); 5326 efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0);
5315 eth_broadcast_addr(baddr); 5327 eth_broadcast_addr(baddr);
5316 efx_filter_set_eth_local(&spec, vlan->vid, baddr); 5328 efx_filter_set_eth_local(&spec, vlan->vid, baddr);
5317 rc = efx_ef10_filter_insert(efx, &spec, true); 5329 rc = efx_ef10_filter_insert_locked(efx, &spec, true);
5318 if (rc < 0) { 5330 if (rc < 0) {
5319 netif_warn(efx, drv, efx->net_dev, 5331 netif_warn(efx, drv, efx->net_dev,
5320 "Broadcast filter insert failed rc=%d\n", rc); 5332 "Broadcast filter insert failed rc=%d\n", rc);
@@ -5370,7 +5382,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx,
5370 if (vlan->vid != EFX_FILTER_VID_UNSPEC) 5382 if (vlan->vid != EFX_FILTER_VID_UNSPEC)
5371 efx_filter_set_eth_local(&spec, vlan->vid, NULL); 5383 efx_filter_set_eth_local(&spec, vlan->vid, NULL);
5372 5384
5373 rc = efx_ef10_filter_insert(efx, &spec, true); 5385 rc = efx_ef10_filter_insert_locked(efx, &spec, true);
5374 if (rc < 0) { 5386 if (rc < 0) {
5375 const char *um = multicast ? "Multicast" : "Unicast"; 5387 const char *um = multicast ? "Multicast" : "Unicast";
5376 const char *encap_name = ""; 5388 const char *encap_name = "";
@@ -5430,7 +5442,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx,
5430 filter_flags, 0); 5442 filter_flags, 0);
5431 eth_broadcast_addr(baddr); 5443 eth_broadcast_addr(baddr);
5432 efx_filter_set_eth_local(&spec, vlan->vid, baddr); 5444 efx_filter_set_eth_local(&spec, vlan->vid, baddr);
5433 rc = efx_ef10_filter_insert(efx, &spec, true); 5445 rc = efx_ef10_filter_insert_locked(efx, &spec, true);
5434 if (rc < 0) { 5446 if (rc < 0) {
5435 netif_warn(efx, drv, efx->net_dev, 5447 netif_warn(efx, drv, efx->net_dev,
5436 "Broadcast filter insert failed rc=%d\n", 5448 "Broadcast filter insert failed rc=%d\n",
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 570ec72266f3..ce3a177081a8 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -1871,12 +1871,6 @@ static void efx_remove_filters(struct efx_nic *efx)
1871 up_write(&efx->filter_sem); 1871 up_write(&efx->filter_sem);
1872} 1872}
1873 1873
1874static void efx_restore_filters(struct efx_nic *efx)
1875{
1876 down_read(&efx->filter_sem);
1877 efx->type->filter_table_restore(efx);
1878 up_read(&efx->filter_sem);
1879}
1880 1874
1881/************************************************************************** 1875/**************************************************************************
1882 * 1876 *
@@ -2688,6 +2682,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method)
2688 efx_disable_interrupts(efx); 2682 efx_disable_interrupts(efx);
2689 2683
2690 mutex_lock(&efx->mac_lock); 2684 mutex_lock(&efx->mac_lock);
2685 down_write(&efx->filter_sem);
2691 mutex_lock(&efx->rss_lock); 2686 mutex_lock(&efx->rss_lock);
2692 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && 2687 if (efx->port_initialized && method != RESET_TYPE_INVISIBLE &&
2693 method != RESET_TYPE_DATAPATH) 2688 method != RESET_TYPE_DATAPATH)
@@ -2745,9 +2740,8 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
2745 if (efx->type->rx_restore_rss_contexts) 2740 if (efx->type->rx_restore_rss_contexts)
2746 efx->type->rx_restore_rss_contexts(efx); 2741 efx->type->rx_restore_rss_contexts(efx);
2747 mutex_unlock(&efx->rss_lock); 2742 mutex_unlock(&efx->rss_lock);
2748 down_read(&efx->filter_sem); 2743 efx->type->filter_table_restore(efx);
2749 efx_restore_filters(efx); 2744 up_write(&efx->filter_sem);
2750 up_read(&efx->filter_sem);
2751 if (efx->type->sriov_reset) 2745 if (efx->type->sriov_reset)
2752 efx->type->sriov_reset(efx); 2746 efx->type->sriov_reset(efx);
2753 2747
@@ -2764,6 +2758,7 @@ fail:
2764 efx->port_initialized = false; 2758 efx->port_initialized = false;
2765 2759
2766 mutex_unlock(&efx->rss_lock); 2760 mutex_unlock(&efx->rss_lock);
2761 up_write(&efx->filter_sem);
2767 mutex_unlock(&efx->mac_lock); 2762 mutex_unlock(&efx->mac_lock);
2768 2763
2769 return rc; 2764 return rc;
@@ -3473,7 +3468,9 @@ static int efx_pci_probe_main(struct efx_nic *efx)
3473 3468
3474 efx_init_napi(efx); 3469 efx_init_napi(efx);
3475 3470
3471 down_write(&efx->filter_sem);
3476 rc = efx->type->init(efx); 3472 rc = efx->type->init(efx);
3473 up_write(&efx->filter_sem);
3477 if (rc) { 3474 if (rc) {
3478 netif_err(efx, probe, efx->net_dev, 3475 netif_err(efx, probe, efx->net_dev,
3479 "failed to initialise NIC\n"); 3476 "failed to initialise NIC\n");
@@ -3765,7 +3762,9 @@ static int efx_pm_resume(struct device *dev)
3765 rc = efx->type->reset(efx, RESET_TYPE_ALL); 3762 rc = efx->type->reset(efx, RESET_TYPE_ALL);
3766 if (rc) 3763 if (rc)
3767 return rc; 3764 return rc;
3765 down_write(&efx->filter_sem);
3768 rc = efx->type->init(efx); 3766 rc = efx->type->init(efx);
3767 up_write(&efx->filter_sem);
3769 if (rc) 3768 if (rc)
3770 return rc; 3769 return rc;
3771 rc = efx_pm_thaw(dev); 3770 rc = efx_pm_thaw(dev);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 2e6e2a96b4f2..f9a61f90cfbc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -37,7 +37,7 @@
37 * is done in the "stmmac files" 37 * is done in the "stmmac files"
38 */ 38 */
39 39
40/* struct emac_variant - Descrive dwmac-sun8i hardware variant 40/* struct emac_variant - Describe dwmac-sun8i hardware variant
41 * @default_syscon_value: The default value of the EMAC register in syscon 41 * @default_syscon_value: The default value of the EMAC register in syscon
42 * This value is used for disabling properly EMAC 42 * This value is used for disabling properly EMAC
43 * and used as a good starting value in case of the 43 * and used as a good starting value in case of the
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 60f59abab009..ef6a8d39db2f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -53,7 +53,7 @@
53#include "dwmac1000.h" 53#include "dwmac1000.h"
54#include "hwif.h" 54#include "hwif.h"
55 55
56#define STMMAC_ALIGN(x) L1_CACHE_ALIGN(x) 56#define STMMAC_ALIGN(x) __ALIGN_KERNEL(x, SMP_CACHE_BYTES)
57#define TSO_MAX_BUFF_SIZE (SZ_16K - 1) 57#define TSO_MAX_BUFF_SIZE (SZ_16K - 1)
58 58
59/* Module parameters */ 59/* Module parameters */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 8d375e51a526..6a393b16a1fc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -257,7 +257,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
257 return -ENOMEM; 257 return -ENOMEM;
258 258
259 /* Enable pci device */ 259 /* Enable pci device */
260 ret = pcim_enable_device(pdev); 260 ret = pci_enable_device(pdev);
261 if (ret) { 261 if (ret) {
262 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n", 262 dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
263 __func__); 263 __func__);
@@ -300,9 +300,45 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
300static void stmmac_pci_remove(struct pci_dev *pdev) 300static void stmmac_pci_remove(struct pci_dev *pdev)
301{ 301{
302 stmmac_dvr_remove(&pdev->dev); 302 stmmac_dvr_remove(&pdev->dev);
303 pci_disable_device(pdev);
303} 304}
304 305
305static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_suspend, stmmac_resume); 306static int stmmac_pci_suspend(struct device *dev)
307{
308 struct pci_dev *pdev = to_pci_dev(dev);
309 int ret;
310
311 ret = stmmac_suspend(dev);
312 if (ret)
313 return ret;
314
315 ret = pci_save_state(pdev);
316 if (ret)
317 return ret;
318
319 pci_disable_device(pdev);
320 pci_wake_from_d3(pdev, true);
321 return 0;
322}
323
324static int stmmac_pci_resume(struct device *dev)
325{
326 struct pci_dev *pdev = to_pci_dev(dev);
327 int ret;
328
329 pci_restore_state(pdev);
330 pci_set_power_state(pdev, PCI_D0);
331
332 ret = pci_enable_device(pdev);
333 if (ret)
334 return ret;
335
336 pci_set_master(pdev);
337
338 return stmmac_resume(dev);
339}
340
341static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_pci_suspend, stmmac_pci_resume);
306 342
307/* synthetic ID, no official vendor */ 343/* synthetic ID, no official vendor */
308#define PCI_VENDOR_ID_STMMAC 0x700 344#define PCI_VENDOR_ID_STMMAC 0x700
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 6d141f3931eb..72da77b94ecd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -94,7 +94,6 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
94/** 94/**
95 * stmmac_axi_setup - parse DT parameters for programming the AXI register 95 * stmmac_axi_setup - parse DT parameters for programming the AXI register
96 * @pdev: platform device 96 * @pdev: platform device
97 * @priv: driver private struct.
98 * Description: 97 * Description:
99 * if required, from device-tree the AXI internal register can be tuned 98 * if required, from device-tree the AXI internal register can be tuned
100 * by using platform parameters. 99 * by using platform parameters.
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
index 16c3bfbe1992..757a3b37ae8a 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
@@ -218,6 +218,7 @@ issue:
218 ret = of_mdiobus_register(bus, np1); 218 ret = of_mdiobus_register(bus, np1);
219 if (ret) { 219 if (ret) {
220 mdiobus_free(bus); 220 mdiobus_free(bus);
221 lp->mii_bus = NULL;
221 return ret; 222 return ret;
222 } 223 }
223 return 0; 224 return 0;
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 8e9d0ee1572b..31c3d77b4733 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1274,6 +1274,7 @@ int netvsc_poll(struct napi_struct *napi, int budget)
1274 struct hv_device *device = netvsc_channel_to_device(channel); 1274 struct hv_device *device = netvsc_channel_to_device(channel);
1275 struct net_device *ndev = hv_get_drvdata(device); 1275 struct net_device *ndev = hv_get_drvdata(device);
1276 int work_done = 0; 1276 int work_done = 0;
1277 int ret;
1277 1278
1278 /* If starting a new interval */ 1279 /* If starting a new interval */
1279 if (!nvchan->desc) 1280 if (!nvchan->desc)
@@ -1285,16 +1286,18 @@ int netvsc_poll(struct napi_struct *napi, int budget)
1285 nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc); 1286 nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc);
1286 } 1287 }
1287 1288
1288 /* If send of pending receive completions suceeded 1289 /* Send any pending receive completions */
1289 * and did not exhaust NAPI budget this time 1290 ret = send_recv_completions(ndev, net_device, nvchan);
1290 * and not doing busy poll 1291
1292 /* If it did not exhaust NAPI budget this time
1293 * and not doing busy poll
1291 * then re-enable host interrupts 1294 * then re-enable host interrupts
1292 * and reschedule if ring is not empty. 1295 * and reschedule if ring is not empty
1296 * or sending receive completion failed.
1293 */ 1297 */
1294 if (send_recv_completions(ndev, net_device, nvchan) == 0 && 1298 if (work_done < budget &&
1295 work_done < budget &&
1296 napi_complete_done(napi, work_done) && 1299 napi_complete_done(napi, work_done) &&
1297 hv_end_read(&channel->inbound) && 1300 (ret || hv_end_read(&channel->inbound)) &&
1298 napi_schedule_prep(napi)) { 1301 napi_schedule_prep(napi)) {
1299 hv_begin_read(&channel->inbound); 1302 hv_begin_read(&channel->inbound);
1300 __napi_schedule(napi); 1303 __napi_schedule(napi);
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 9b4e3c3787e5..408ece27131c 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1338,6 +1338,7 @@ out:
1338 /* setting up multiple channels failed */ 1338 /* setting up multiple channels failed */
1339 net_device->max_chn = 1; 1339 net_device->max_chn = 1;
1340 net_device->num_chn = 1; 1340 net_device->num_chn = 1;
1341 return 0;
1341 1342
1342err_dev_remv: 1343err_dev_remv:
1343 rndis_filter_device_remove(dev, net_device); 1344 rndis_filter_device_remove(dev, net_device);
diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
index 64f1b1e77bc0..23a52b9293f3 100644
--- a/drivers/net/ieee802154/adf7242.c
+++ b/drivers/net/ieee802154/adf7242.c
@@ -275,6 +275,8 @@ struct adf7242_local {
275 struct spi_message stat_msg; 275 struct spi_message stat_msg;
276 struct spi_transfer stat_xfer; 276 struct spi_transfer stat_xfer;
277 struct dentry *debugfs_root; 277 struct dentry *debugfs_root;
278 struct delayed_work work;
279 struct workqueue_struct *wqueue;
278 unsigned long flags; 280 unsigned long flags;
279 int tx_stat; 281 int tx_stat;
280 bool promiscuous; 282 bool promiscuous;
@@ -575,10 +577,26 @@ static int adf7242_cmd_rx(struct adf7242_local *lp)
575 /* Wait until the ACK is sent */ 577 /* Wait until the ACK is sent */
576 adf7242_wait_status(lp, RC_STATUS_PHY_RDY, RC_STATUS_MASK, __LINE__); 578 adf7242_wait_status(lp, RC_STATUS_PHY_RDY, RC_STATUS_MASK, __LINE__);
577 adf7242_clear_irqstat(lp); 579 adf7242_clear_irqstat(lp);
580 mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
578 581
579 return adf7242_cmd(lp, CMD_RC_RX); 582 return adf7242_cmd(lp, CMD_RC_RX);
580} 583}
581 584
585static void adf7242_rx_cal_work(struct work_struct *work)
586{
587 struct adf7242_local *lp =
588 container_of(work, struct adf7242_local, work.work);
589
590 /* Reissuing RC_RX every 400ms - to adjust for offset
591 * drift in receiver (datasheet page 61, OCL section)
592 */
593
594 if (!test_bit(FLAG_XMIT, &lp->flags)) {
595 adf7242_cmd(lp, CMD_RC_PHY_RDY);
596 adf7242_cmd_rx(lp);
597 }
598}
599
582static int adf7242_set_txpower(struct ieee802154_hw *hw, int mbm) 600static int adf7242_set_txpower(struct ieee802154_hw *hw, int mbm)
583{ 601{
584 struct adf7242_local *lp = hw->priv; 602 struct adf7242_local *lp = hw->priv;
@@ -686,7 +704,7 @@ static int adf7242_start(struct ieee802154_hw *hw)
686 enable_irq(lp->spi->irq); 704 enable_irq(lp->spi->irq);
687 set_bit(FLAG_START, &lp->flags); 705 set_bit(FLAG_START, &lp->flags);
688 706
689 return adf7242_cmd(lp, CMD_RC_RX); 707 return adf7242_cmd_rx(lp);
690} 708}
691 709
692static void adf7242_stop(struct ieee802154_hw *hw) 710static void adf7242_stop(struct ieee802154_hw *hw)
@@ -694,6 +712,7 @@ static void adf7242_stop(struct ieee802154_hw *hw)
694 struct adf7242_local *lp = hw->priv; 712 struct adf7242_local *lp = hw->priv;
695 713
696 disable_irq(lp->spi->irq); 714 disable_irq(lp->spi->irq);
715 cancel_delayed_work_sync(&lp->work);
697 adf7242_cmd(lp, CMD_RC_IDLE); 716 adf7242_cmd(lp, CMD_RC_IDLE);
698 clear_bit(FLAG_START, &lp->flags); 717 clear_bit(FLAG_START, &lp->flags);
699 adf7242_clear_irqstat(lp); 718 adf7242_clear_irqstat(lp);
@@ -719,7 +738,10 @@ static int adf7242_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
719 adf7242_write_reg(lp, REG_CH_FREQ1, freq >> 8); 738 adf7242_write_reg(lp, REG_CH_FREQ1, freq >> 8);
720 adf7242_write_reg(lp, REG_CH_FREQ2, freq >> 16); 739 adf7242_write_reg(lp, REG_CH_FREQ2, freq >> 16);
721 740
722 return adf7242_cmd(lp, CMD_RC_RX); 741 if (test_bit(FLAG_START, &lp->flags))
742 return adf7242_cmd_rx(lp);
743 else
744 return adf7242_cmd(lp, CMD_RC_PHY_RDY);
723} 745}
724 746
725static int adf7242_set_hw_addr_filt(struct ieee802154_hw *hw, 747static int adf7242_set_hw_addr_filt(struct ieee802154_hw *hw,
@@ -814,6 +836,7 @@ static int adf7242_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
814 /* ensure existing instances of the IRQ handler have completed */ 836 /* ensure existing instances of the IRQ handler have completed */
815 disable_irq(lp->spi->irq); 837 disable_irq(lp->spi->irq);
816 set_bit(FLAG_XMIT, &lp->flags); 838 set_bit(FLAG_XMIT, &lp->flags);
839 cancel_delayed_work_sync(&lp->work);
817 reinit_completion(&lp->tx_complete); 840 reinit_completion(&lp->tx_complete);
818 adf7242_cmd(lp, CMD_RC_PHY_RDY); 841 adf7242_cmd(lp, CMD_RC_PHY_RDY);
819 adf7242_clear_irqstat(lp); 842 adf7242_clear_irqstat(lp);
@@ -952,6 +975,7 @@ static irqreturn_t adf7242_isr(int irq, void *data)
952 unsigned int xmit; 975 unsigned int xmit;
953 u8 irq1; 976 u8 irq1;
954 977
978 mod_delayed_work(lp->wqueue, &lp->work, msecs_to_jiffies(400));
955 adf7242_read_reg(lp, REG_IRQ1_SRC1, &irq1); 979 adf7242_read_reg(lp, REG_IRQ1_SRC1, &irq1);
956 980
957 if (!(irq1 & (IRQ_RX_PKT_RCVD | IRQ_CSMA_CA))) 981 if (!(irq1 & (IRQ_RX_PKT_RCVD | IRQ_CSMA_CA)))
@@ -1241,6 +1265,9 @@ static int adf7242_probe(struct spi_device *spi)
1241 spi_message_add_tail(&lp->stat_xfer, &lp->stat_msg); 1265 spi_message_add_tail(&lp->stat_xfer, &lp->stat_msg);
1242 1266
1243 spi_set_drvdata(spi, lp); 1267 spi_set_drvdata(spi, lp);
1268 INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work);
1269 lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev),
1270 WQ_MEM_RECLAIM);
1244 1271
1245 ret = adf7242_hw_init(lp); 1272 ret = adf7242_hw_init(lp);
1246 if (ret) 1273 if (ret)
@@ -1284,6 +1311,9 @@ static int adf7242_remove(struct spi_device *spi)
1284 if (!IS_ERR_OR_NULL(lp->debugfs_root)) 1311 if (!IS_ERR_OR_NULL(lp->debugfs_root))
1285 debugfs_remove_recursive(lp->debugfs_root); 1312 debugfs_remove_recursive(lp->debugfs_root);
1286 1313
1314 cancel_delayed_work_sync(&lp->work);
1315 destroy_workqueue(lp->wqueue);
1316
1287 ieee802154_unregister_hw(lp->hw); 1317 ieee802154_unregister_hw(lp->hw);
1288 mutex_destroy(&lp->bmux); 1318 mutex_destroy(&lp->bmux);
1289 ieee802154_free_hw(lp->hw); 1319 ieee802154_free_hw(lp->hw);
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 77abedf0b524..3d9e91579866 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -940,7 +940,7 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
940static int 940static int
941at86rf230_ed(struct ieee802154_hw *hw, u8 *level) 941at86rf230_ed(struct ieee802154_hw *hw, u8 *level)
942{ 942{
943 BUG_ON(!level); 943 WARN_ON(!level);
944 *level = 0xbe; 944 *level = 0xbe;
945 return 0; 945 return 0;
946} 946}
@@ -1121,8 +1121,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1121 if (changed & IEEE802154_AFILT_SADDR_CHANGED) { 1121 if (changed & IEEE802154_AFILT_SADDR_CHANGED) {
1122 u16 addr = le16_to_cpu(filt->short_addr); 1122 u16 addr = le16_to_cpu(filt->short_addr);
1123 1123
1124 dev_vdbg(&lp->spi->dev, 1124 dev_vdbg(&lp->spi->dev, "%s called for saddr\n", __func__);
1125 "at86rf230_set_hw_addr_filt called for saddr\n");
1126 __at86rf230_write(lp, RG_SHORT_ADDR_0, addr); 1125 __at86rf230_write(lp, RG_SHORT_ADDR_0, addr);
1127 __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8); 1126 __at86rf230_write(lp, RG_SHORT_ADDR_1, addr >> 8);
1128 } 1127 }
@@ -1130,8 +1129,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1130 if (changed & IEEE802154_AFILT_PANID_CHANGED) { 1129 if (changed & IEEE802154_AFILT_PANID_CHANGED) {
1131 u16 pan = le16_to_cpu(filt->pan_id); 1130 u16 pan = le16_to_cpu(filt->pan_id);
1132 1131
1133 dev_vdbg(&lp->spi->dev, 1132 dev_vdbg(&lp->spi->dev, "%s called for pan id\n", __func__);
1134 "at86rf230_set_hw_addr_filt called for pan id\n");
1135 __at86rf230_write(lp, RG_PAN_ID_0, pan); 1133 __at86rf230_write(lp, RG_PAN_ID_0, pan);
1136 __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8); 1134 __at86rf230_write(lp, RG_PAN_ID_1, pan >> 8);
1137 } 1135 }
@@ -1140,15 +1138,13 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1140 u8 i, addr[8]; 1138 u8 i, addr[8];
1141 1139
1142 memcpy(addr, &filt->ieee_addr, 8); 1140 memcpy(addr, &filt->ieee_addr, 8);
1143 dev_vdbg(&lp->spi->dev, 1141 dev_vdbg(&lp->spi->dev, "%s called for IEEE addr\n", __func__);
1144 "at86rf230_set_hw_addr_filt called for IEEE addr\n");
1145 for (i = 0; i < 8; i++) 1142 for (i = 0; i < 8; i++)
1146 __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]); 1143 __at86rf230_write(lp, RG_IEEE_ADDR_0 + i, addr[i]);
1147 } 1144 }
1148 1145
1149 if (changed & IEEE802154_AFILT_PANC_CHANGED) { 1146 if (changed & IEEE802154_AFILT_PANC_CHANGED) {
1150 dev_vdbg(&lp->spi->dev, 1147 dev_vdbg(&lp->spi->dev, "%s called for panc change\n", __func__);
1151 "at86rf230_set_hw_addr_filt called for panc change\n");
1152 if (filt->pan_coord) 1148 if (filt->pan_coord)
1153 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1); 1149 at86rf230_write_subreg(lp, SR_AACK_I_AM_COORD, 1);
1154 else 1150 else
@@ -1252,7 +1248,6 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw,
1252 return at86rf230_write_subreg(lp, SR_CCA_MODE, val); 1248 return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
1253} 1249}
1254 1250
1255
1256static int 1251static int
1257at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm) 1252at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
1258{ 1253{
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index 0d673f7682ee..176395e4b7bb 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -49,7 +49,7 @@ struct fakelb_phy {
49 49
50static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) 50static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
51{ 51{
52 BUG_ON(!level); 52 WARN_ON(!level);
53 *level = 0xbe; 53 *level = 0xbe;
54 54
55 return 0; 55 return 0;
diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index de0d7f28a181..e428277781ac 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -15,10 +15,11 @@
15 */ 15 */
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/gpio.h> 18#include <linux/gpio/consumer.h>
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/workqueue.h> 20#include <linux/workqueue.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h>
22#include <linux/skbuff.h> 23#include <linux/skbuff.h>
23#include <linux/of_gpio.h> 24#include <linux/of_gpio.h>
24#include <linux/regmap.h> 25#include <linux/regmap.h>
diff --git a/drivers/net/netdevsim/devlink.c b/drivers/net/netdevsim/devlink.c
index ba663e5af168..5135fc371f01 100644
--- a/drivers/net/netdevsim/devlink.c
+++ b/drivers/net/netdevsim/devlink.c
@@ -207,6 +207,7 @@ void nsim_devlink_teardown(struct netdevsim *ns)
207 struct net *net = nsim_to_net(ns); 207 struct net *net = nsim_to_net(ns);
208 bool *reg_devlink = net_generic(net, nsim_devlink_id); 208 bool *reg_devlink = net_generic(net, nsim_devlink_id);
209 209
210 devlink_resources_unregister(ns->devlink, NULL);
210 devlink_unregister(ns->devlink); 211 devlink_unregister(ns->devlink);
211 devlink_free(ns->devlink); 212 devlink_free(ns->devlink);
212 ns->devlink = NULL; 213 ns->devlink = NULL;
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index b8f57e9b9379..1cd439bdf608 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -130,8 +130,9 @@
130#define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12) 130#define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
131#define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14) 131#define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
132 132
133#define MII_88E1121_PHY_LED_CTRL 16 133#define MII_PHY_LED_CTRL 16
134#define MII_88E1121_PHY_LED_DEF 0x0030 134#define MII_88E1121_PHY_LED_DEF 0x0030
135#define MII_88E1510_PHY_LED_DEF 0x1177
135 136
136#define MII_M1011_PHY_STATUS 0x11 137#define MII_M1011_PHY_STATUS 0x11
137#define MII_M1011_PHY_STATUS_1000 0x8000 138#define MII_M1011_PHY_STATUS_1000 0x8000
@@ -632,8 +633,40 @@ error:
632 return err; 633 return err;
633} 634}
634 635
636static void marvell_config_led(struct phy_device *phydev)
637{
638 u16 def_config;
639 int err;
640
641 switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) {
642 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
643 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1121R):
644 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1318S):
645 def_config = MII_88E1121_PHY_LED_DEF;
646 break;
647 /* Default PHY LED config:
648 * LED[0] .. 1000Mbps Link
649 * LED[1] .. 100Mbps Link
650 * LED[2] .. Blink, Activity
651 */
652 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510):
653 def_config = MII_88E1510_PHY_LED_DEF;
654 break;
655 default:
656 return;
657 }
658
659 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL,
660 def_config);
661 if (err < 0)
662 pr_warn("Fail to config marvell phy LED.\n");
663}
664
635static int marvell_config_init(struct phy_device *phydev) 665static int marvell_config_init(struct phy_device *phydev)
636{ 666{
667 /* Set defalut LED */
668 marvell_config_led(phydev);
669
637 /* Set registers from marvell,reg-init DT property */ 670 /* Set registers from marvell,reg-init DT property */
638 return marvell_of_reg_init(phydev); 671 return marvell_of_reg_init(phydev);
639} 672}
@@ -813,21 +846,6 @@ static int m88e1111_config_init(struct phy_device *phydev)
813 return genphy_soft_reset(phydev); 846 return genphy_soft_reset(phydev);
814} 847}
815 848
816static int m88e1121_config_init(struct phy_device *phydev)
817{
818 int err;
819
820 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
821 err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE,
822 MII_88E1121_PHY_LED_CTRL,
823 MII_88E1121_PHY_LED_DEF);
824 if (err < 0)
825 return err;
826
827 /* Set marvell,reg-init configuration from device tree */
828 return marvell_config_init(phydev);
829}
830
831static int m88e1318_config_init(struct phy_device *phydev) 849static int m88e1318_config_init(struct phy_device *phydev)
832{ 850{
833 if (phy_interrupt_is_valid(phydev)) { 851 if (phy_interrupt_is_valid(phydev)) {
@@ -841,7 +859,7 @@ static int m88e1318_config_init(struct phy_device *phydev)
841 return err; 859 return err;
842 } 860 }
843 861
844 return m88e1121_config_init(phydev); 862 return marvell_config_init(phydev);
845} 863}
846 864
847static int m88e1510_config_init(struct phy_device *phydev) 865static int m88e1510_config_init(struct phy_device *phydev)
@@ -2087,7 +2105,7 @@ static struct phy_driver marvell_drivers[] = {
2087 .features = PHY_GBIT_FEATURES, 2105 .features = PHY_GBIT_FEATURES,
2088 .flags = PHY_HAS_INTERRUPT, 2106 .flags = PHY_HAS_INTERRUPT,
2089 .probe = &m88e1121_probe, 2107 .probe = &m88e1121_probe,
2090 .config_init = &m88e1121_config_init, 2108 .config_init = &marvell_config_init,
2091 .config_aneg = &m88e1121_config_aneg, 2109 .config_aneg = &m88e1121_config_aneg,
2092 .read_status = &marvell_read_status, 2110 .read_status = &marvell_read_status,
2093 .ack_interrupt = &marvell_ack_interrupt, 2111 .ack_interrupt = &marvell_ack_interrupt,
diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 0831b7142df7..0c5b68e7da51 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -218,7 +218,7 @@ out:
218 218
219static int mdio_mux_iproc_remove(struct platform_device *pdev) 219static int mdio_mux_iproc_remove(struct platform_device *pdev)
220{ 220{
221 struct iproc_mdiomux_desc *md = dev_get_platdata(&pdev->dev); 221 struct iproc_mdiomux_desc *md = platform_get_drvdata(pdev);
222 222
223 mdio_mux_uninit(md->mux_handle); 223 mdio_mux_uninit(md->mux_handle);
224 mdiobus_unregister(md->mii_bus); 224 mdiobus_unregister(md->mii_bus);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 537297d2b4b4..6c9b24fe3148 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -514,7 +514,7 @@ static int phy_start_aneg_priv(struct phy_device *phydev, bool sync)
514 * negotiation may already be done and aneg interrupt may not be 514 * negotiation may already be done and aneg interrupt may not be
515 * generated. 515 * generated.
516 */ 516 */
517 if (phy_interrupt_is_valid(phydev) && (phydev->state == PHY_AN)) { 517 if (phydev->irq != PHY_POLL && phydev->state == PHY_AN) {
518 err = phy_aneg_done(phydev); 518 err = phy_aneg_done(phydev);
519 if (err > 0) { 519 if (err > 0) {
520 trigger = true; 520 trigger = true;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bd0f339f69fd..b9f5f40a7ac1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1724,11 +1724,8 @@ EXPORT_SYMBOL(genphy_loopback);
1724 1724
1725static int __set_phy_supported(struct phy_device *phydev, u32 max_speed) 1725static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
1726{ 1726{
1727 /* The default values for phydev->supported are provided by the PHY 1727 phydev->supported &= ~(PHY_1000BT_FEATURES | PHY_100BT_FEATURES |
1728 * driver "features" member, we want to reset to sane defaults first 1728 PHY_10BT_FEATURES);
1729 * before supporting higher speeds.
1730 */
1731 phydev->supported &= PHY_DEFAULT_FEATURES;
1732 1729
1733 switch (max_speed) { 1730 switch (max_speed) {
1734 default: 1731 default:
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index d437f4f5ed52..740655261e5b 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -349,7 +349,6 @@ static int sfp_register_bus(struct sfp_bus *bus)
349 } 349 }
350 if (bus->started) 350 if (bus->started)
351 bus->socket_ops->start(bus->sfp); 351 bus->socket_ops->start(bus->sfp);
352 bus->netdev->sfp_bus = bus;
353 bus->registered = true; 352 bus->registered = true;
354 return 0; 353 return 0;
355} 354}
@@ -364,7 +363,6 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
364 if (bus->phydev && ops && ops->disconnect_phy) 363 if (bus->phydev && ops && ops->disconnect_phy)
365 ops->disconnect_phy(bus->upstream); 364 ops->disconnect_phy(bus->upstream);
366 } 365 }
367 bus->netdev->sfp_bus = NULL;
368 bus->registered = false; 366 bus->registered = false;
369} 367}
370 368
@@ -436,6 +434,14 @@ void sfp_upstream_stop(struct sfp_bus *bus)
436} 434}
437EXPORT_SYMBOL_GPL(sfp_upstream_stop); 435EXPORT_SYMBOL_GPL(sfp_upstream_stop);
438 436
437static void sfp_upstream_clear(struct sfp_bus *bus)
438{
439 bus->upstream_ops = NULL;
440 bus->upstream = NULL;
441 bus->netdev->sfp_bus = NULL;
442 bus->netdev = NULL;
443}
444
439/** 445/**
440 * sfp_register_upstream() - Register the neighbouring device 446 * sfp_register_upstream() - Register the neighbouring device
441 * @fwnode: firmware node for the SFP bus 447 * @fwnode: firmware node for the SFP bus
@@ -461,9 +467,13 @@ struct sfp_bus *sfp_register_upstream(struct fwnode_handle *fwnode,
461 bus->upstream_ops = ops; 467 bus->upstream_ops = ops;
462 bus->upstream = upstream; 468 bus->upstream = upstream;
463 bus->netdev = ndev; 469 bus->netdev = ndev;
470 ndev->sfp_bus = bus;
464 471
465 if (bus->sfp) 472 if (bus->sfp) {
466 ret = sfp_register_bus(bus); 473 ret = sfp_register_bus(bus);
474 if (ret)
475 sfp_upstream_clear(bus);
476 }
467 rtnl_unlock(); 477 rtnl_unlock();
468 } 478 }
469 479
@@ -488,8 +498,7 @@ void sfp_unregister_upstream(struct sfp_bus *bus)
488 rtnl_lock(); 498 rtnl_lock();
489 if (bus->sfp) 499 if (bus->sfp)
490 sfp_unregister_bus(bus); 500 sfp_unregister_bus(bus);
491 bus->upstream = NULL; 501 sfp_upstream_clear(bus);
492 bus->netdev = NULL;
493 rtnl_unlock(); 502 rtnl_unlock();
494 503
495 sfp_bus_put(bus); 504 sfp_bus_put(bus);
@@ -561,6 +570,13 @@ void sfp_module_remove(struct sfp_bus *bus)
561} 570}
562EXPORT_SYMBOL_GPL(sfp_module_remove); 571EXPORT_SYMBOL_GPL(sfp_module_remove);
563 572
573static void sfp_socket_clear(struct sfp_bus *bus)
574{
575 bus->sfp_dev = NULL;
576 bus->sfp = NULL;
577 bus->socket_ops = NULL;
578}
579
564struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp, 580struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp,
565 const struct sfp_socket_ops *ops) 581 const struct sfp_socket_ops *ops)
566{ 582{
@@ -573,8 +589,11 @@ struct sfp_bus *sfp_register_socket(struct device *dev, struct sfp *sfp,
573 bus->sfp = sfp; 589 bus->sfp = sfp;
574 bus->socket_ops = ops; 590 bus->socket_ops = ops;
575 591
576 if (bus->netdev) 592 if (bus->netdev) {
577 ret = sfp_register_bus(bus); 593 ret = sfp_register_bus(bus);
594 if (ret)
595 sfp_socket_clear(bus);
596 }
578 rtnl_unlock(); 597 rtnl_unlock();
579 } 598 }
580 599
@@ -592,9 +611,7 @@ void sfp_unregister_socket(struct sfp_bus *bus)
592 rtnl_lock(); 611 rtnl_lock();
593 if (bus->netdev) 612 if (bus->netdev)
594 sfp_unregister_bus(bus); 613 sfp_unregister_bus(bus);
595 bus->sfp_dev = NULL; 614 sfp_socket_clear(bus);
596 bus->sfp = NULL;
597 bus->socket_ops = NULL;
598 rtnl_unlock(); 615 rtnl_unlock();
599 616
600 sfp_bus_put(bus); 617 sfp_bus_put(bus);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a192a017cc68..f5727baac84a 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1688,7 +1688,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
1688 case XDP_TX: 1688 case XDP_TX:
1689 get_page(alloc_frag->page); 1689 get_page(alloc_frag->page);
1690 alloc_frag->offset += buflen; 1690 alloc_frag->offset += buflen;
1691 if (tun_xdp_tx(tun->dev, &xdp)) 1691 if (tun_xdp_tx(tun->dev, &xdp) < 0)
1692 goto err_redirect; 1692 goto err_redirect;
1693 rcu_read_unlock(); 1693 rcu_read_unlock();
1694 local_bh_enable(); 1694 local_bh_enable();
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 3d4f7959dabb..b1b3d8f7e67d 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -642,10 +642,12 @@ static void ax88772_restore_phy(struct usbnet *dev)
642 priv->presvd_phy_advertise); 642 priv->presvd_phy_advertise);
643 643
644 /* Restore BMCR */ 644 /* Restore BMCR */
645 if (priv->presvd_phy_bmcr & BMCR_ANENABLE)
646 priv->presvd_phy_bmcr |= BMCR_ANRESTART;
647
645 asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_BMCR, 648 asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_BMCR,
646 priv->presvd_phy_bmcr); 649 priv->presvd_phy_bmcr);
647 650
648 mii_nway_restart(&dev->mii);
649 priv->presvd_phy_advertise = 0; 651 priv->presvd_phy_advertise = 0;
650 priv->presvd_phy_bmcr = 0; 652 priv->presvd_phy_bmcr = 0;
651 } 653 }
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 2e4130746c40..aeca484a75b8 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1242,6 +1242,8 @@ static int lan78xx_link_reset(struct lan78xx_net *dev)
1242 mod_timer(&dev->stat_monitor, 1242 mod_timer(&dev->stat_monitor,
1243 jiffies + STAT_UPDATE_TIMER); 1243 jiffies + STAT_UPDATE_TIMER);
1244 } 1244 }
1245
1246 tasklet_schedule(&dev->bh);
1245 } 1247 }
1246 1248
1247 return ret; 1249 return ret;
@@ -3344,6 +3346,7 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)
3344 pkt_cnt = 0; 3346 pkt_cnt = 0;
3345 count = 0; 3347 count = 0;
3346 length = 0; 3348 length = 0;
3349 spin_lock_irqsave(&tqp->lock, flags);
3347 for (skb = tqp->next; pkt_cnt < tqp->qlen; skb = skb->next) { 3350 for (skb = tqp->next; pkt_cnt < tqp->qlen; skb = skb->next) {
3348 if (skb_is_gso(skb)) { 3351 if (skb_is_gso(skb)) {
3349 if (pkt_cnt) { 3352 if (pkt_cnt) {
@@ -3352,7 +3355,8 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)
3352 } 3355 }
3353 count = 1; 3356 count = 1;
3354 length = skb->len - TX_OVERHEAD; 3357 length = skb->len - TX_OVERHEAD;
3355 skb2 = skb_dequeue(tqp); 3358 __skb_unlink(skb, tqp);
3359 spin_unlock_irqrestore(&tqp->lock, flags);
3356 goto gso_skb; 3360 goto gso_skb;
3357 } 3361 }
3358 3362
@@ -3361,6 +3365,7 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)
3361 skb_totallen = skb->len + roundup(skb_totallen, sizeof(u32)); 3365 skb_totallen = skb->len + roundup(skb_totallen, sizeof(u32));
3362 pkt_cnt++; 3366 pkt_cnt++;
3363 } 3367 }
3368 spin_unlock_irqrestore(&tqp->lock, flags);
3364 3369
3365 /* copy to a single skb */ 3370 /* copy to a single skb */
3366 skb = alloc_skb(skb_totallen, GFP_ATOMIC); 3371 skb = alloc_skb(skb_totallen, GFP_ATOMIC);
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 8fac8e132c5b..cb0cc30c3d6a 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -1246,13 +1246,14 @@ static const struct usb_device_id products[] = {
1246 {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ 1246 {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
1247 {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ 1247 {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */
1248 {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ 1248 {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */
1249 {QMI_FIXED_INTF(0x413c, 0x81d7, 1)}, /* Dell Wireless 5821e */ 1249 {QMI_FIXED_INTF(0x413c, 0x81d7, 0)}, /* Dell Wireless 5821e */
1250 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ 1250 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
1251 {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ 1251 {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */
1252 {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ 1252 {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
1253 {QMI_QUIRK_SET_DTR(0x1e0e, 0x9001, 5)}, /* SIMCom 7100E, 7230E, 7600E ++ */ 1253 {QMI_QUIRK_SET_DTR(0x1e0e, 0x9001, 5)}, /* SIMCom 7100E, 7230E, 7600E ++ */
1254 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ 1254 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
1255 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */ 1255 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */
1256 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0191, 4)}, /* Quectel EG91 */
1256 {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */ 1257 {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */
1257 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0306, 4)}, /* Quectel EP06 Mini PCIe */ 1258 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0306, 4)}, /* Quectel EP06 Mini PCIe */
1258 1259
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 5f565bd574da..48ba80a8ca5c 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -681,7 +681,7 @@ static void rtl8150_set_multicast(struct net_device *netdev)
681 (netdev->flags & IFF_ALLMULTI)) { 681 (netdev->flags & IFF_ALLMULTI)) {
682 rx_creg &= 0xfffe; 682 rx_creg &= 0xfffe;
683 rx_creg |= 0x0002; 683 rx_creg |= 0x0002;
684 dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name); 684 dev_dbg(&netdev->dev, "%s: allmulti set\n", netdev->name);
685 } else { 685 } else {
686 /* ~RX_MULTICAST, ~RX_PROMISCUOUS */ 686 /* ~RX_MULTICAST, ~RX_PROMISCUOUS */
687 rx_creg &= 0x00fc; 687 rx_creg &= 0x00fc;
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 7a6a1fe79309..05553d252446 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -82,6 +82,9 @@ static bool turbo_mode = true;
82module_param(turbo_mode, bool, 0644); 82module_param(turbo_mode, bool, 0644);
83MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); 83MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
84 84
85static int smsc75xx_link_ok_nopm(struct usbnet *dev);
86static int smsc75xx_phy_gig_workaround(struct usbnet *dev);
87
85static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index, 88static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index,
86 u32 *data, int in_pm) 89 u32 *data, int in_pm)
87{ 90{
@@ -852,6 +855,9 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
852 return -EIO; 855 return -EIO;
853 } 856 }
854 857
858 /* phy workaround for gig link */
859 smsc75xx_phy_gig_workaround(dev);
860
855 smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, 861 smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
856 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | 862 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
857 ADVERTISE_PAUSE_ASYM); 863 ADVERTISE_PAUSE_ASYM);
@@ -987,6 +993,62 @@ static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm)
987 return -EIO; 993 return -EIO;
988} 994}
989 995
996static int smsc75xx_phy_gig_workaround(struct usbnet *dev)
997{
998 struct mii_if_info *mii = &dev->mii;
999 int ret = 0, timeout = 0;
1000 u32 buf, link_up = 0;
1001
1002 /* Set the phy in Gig loopback */
1003 smsc75xx_mdio_write(dev->net, mii->phy_id, MII_BMCR, 0x4040);
1004
1005 /* Wait for the link up */
1006 do {
1007 link_up = smsc75xx_link_ok_nopm(dev);
1008 usleep_range(10000, 20000);
1009 timeout++;
1010 } while ((!link_up) && (timeout < 1000));
1011
1012 if (timeout >= 1000) {
1013 netdev_warn(dev->net, "Timeout waiting for PHY link up\n");
1014 return -EIO;
1015 }
1016
1017 /* phy reset */
1018 ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
1019 if (ret < 0) {
1020 netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret);
1021 return ret;
1022 }
1023
1024 buf |= PMT_CTL_PHY_RST;
1025
1026 ret = smsc75xx_write_reg(dev, PMT_CTL, buf);
1027 if (ret < 0) {
1028 netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret);
1029 return ret;
1030 }
1031
1032 timeout = 0;
1033 do {
1034 usleep_range(10000, 20000);
1035 ret = smsc75xx_read_reg(dev, PMT_CTL, &buf);
1036 if (ret < 0) {
1037 netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n",
1038 ret);
1039 return ret;
1040 }
1041 timeout++;
1042 } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100));
1043
1044 if (timeout >= 100) {
1045 netdev_warn(dev->net, "timeout waiting for PHY Reset\n");
1046 return -EIO;
1047 }
1048
1049 return 0;
1050}
1051
990static int smsc75xx_reset(struct usbnet *dev) 1052static int smsc75xx_reset(struct usbnet *dev)
991{ 1053{
992 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); 1054 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 53085c63277b..2b6ec927809e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -586,7 +586,8 @@ static struct sk_buff *receive_small(struct net_device *dev,
586 struct receive_queue *rq, 586 struct receive_queue *rq,
587 void *buf, void *ctx, 587 void *buf, void *ctx,
588 unsigned int len, 588 unsigned int len,
589 unsigned int *xdp_xmit) 589 unsigned int *xdp_xmit,
590 unsigned int *rbytes)
590{ 591{
591 struct sk_buff *skb; 592 struct sk_buff *skb;
592 struct bpf_prog *xdp_prog; 593 struct bpf_prog *xdp_prog;
@@ -601,6 +602,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
601 int err; 602 int err;
602 603
603 len -= vi->hdr_len; 604 len -= vi->hdr_len;
605 *rbytes += len;
604 606
605 rcu_read_lock(); 607 rcu_read_lock();
606 xdp_prog = rcu_dereference(rq->xdp_prog); 608 xdp_prog = rcu_dereference(rq->xdp_prog);
@@ -705,11 +707,13 @@ static struct sk_buff *receive_big(struct net_device *dev,
705 struct virtnet_info *vi, 707 struct virtnet_info *vi,
706 struct receive_queue *rq, 708 struct receive_queue *rq,
707 void *buf, 709 void *buf,
708 unsigned int len) 710 unsigned int len,
711 unsigned int *rbytes)
709{ 712{
710 struct page *page = buf; 713 struct page *page = buf;
711 struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE); 714 struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
712 715
716 *rbytes += len - vi->hdr_len;
713 if (unlikely(!skb)) 717 if (unlikely(!skb))
714 goto err; 718 goto err;
715 719
@@ -727,7 +731,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
727 void *buf, 731 void *buf,
728 void *ctx, 732 void *ctx,
729 unsigned int len, 733 unsigned int len,
730 unsigned int *xdp_xmit) 734 unsigned int *xdp_xmit,
735 unsigned int *rbytes)
731{ 736{
732 struct virtio_net_hdr_mrg_rxbuf *hdr = buf; 737 struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
733 u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers); 738 u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers);
@@ -740,6 +745,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
740 int err; 745 int err;
741 746
742 head_skb = NULL; 747 head_skb = NULL;
748 *rbytes += len - vi->hdr_len;
743 749
744 rcu_read_lock(); 750 rcu_read_lock();
745 xdp_prog = rcu_dereference(rq->xdp_prog); 751 xdp_prog = rcu_dereference(rq->xdp_prog);
@@ -877,6 +883,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
877 goto err_buf; 883 goto err_buf;
878 } 884 }
879 885
886 *rbytes += len;
880 page = virt_to_head_page(buf); 887 page = virt_to_head_page(buf);
881 888
882 truesize = mergeable_ctx_to_truesize(ctx); 889 truesize = mergeable_ctx_to_truesize(ctx);
@@ -932,6 +939,7 @@ err_skb:
932 dev->stats.rx_length_errors++; 939 dev->stats.rx_length_errors++;
933 break; 940 break;
934 } 941 }
942 *rbytes += len;
935 page = virt_to_head_page(buf); 943 page = virt_to_head_page(buf);
936 put_page(page); 944 put_page(page);
937 } 945 }
@@ -942,14 +950,13 @@ xdp_xmit:
942 return NULL; 950 return NULL;
943} 951}
944 952
945static int receive_buf(struct virtnet_info *vi, struct receive_queue *rq, 953static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
946 void *buf, unsigned int len, void **ctx, 954 void *buf, unsigned int len, void **ctx,
947 unsigned int *xdp_xmit) 955 unsigned int *xdp_xmit, unsigned int *rbytes)
948{ 956{
949 struct net_device *dev = vi->dev; 957 struct net_device *dev = vi->dev;
950 struct sk_buff *skb; 958 struct sk_buff *skb;
951 struct virtio_net_hdr_mrg_rxbuf *hdr; 959 struct virtio_net_hdr_mrg_rxbuf *hdr;
952 int ret;
953 960
954 if (unlikely(len < vi->hdr_len + ETH_HLEN)) { 961 if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
955 pr_debug("%s: short packet %i\n", dev->name, len); 962 pr_debug("%s: short packet %i\n", dev->name, len);
@@ -961,23 +968,22 @@ static int receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
961 } else { 968 } else {
962 put_page(virt_to_head_page(buf)); 969 put_page(virt_to_head_page(buf));
963 } 970 }
964 return 0; 971 return;
965 } 972 }
966 973
967 if (vi->mergeable_rx_bufs) 974 if (vi->mergeable_rx_bufs)
968 skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit); 975 skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
976 rbytes);
969 else if (vi->big_packets) 977 else if (vi->big_packets)
970 skb = receive_big(dev, vi, rq, buf, len); 978 skb = receive_big(dev, vi, rq, buf, len, rbytes);
971 else 979 else
972 skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit); 980 skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, rbytes);
973 981
974 if (unlikely(!skb)) 982 if (unlikely(!skb))
975 return 0; 983 return;
976 984
977 hdr = skb_vnet_hdr(skb); 985 hdr = skb_vnet_hdr(skb);
978 986
979 ret = skb->len;
980
981 if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID) 987 if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID)
982 skb->ip_summed = CHECKSUM_UNNECESSARY; 988 skb->ip_summed = CHECKSUM_UNNECESSARY;
983 989
@@ -994,12 +1000,11 @@ static int receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
994 ntohs(skb->protocol), skb->len, skb->pkt_type); 1000 ntohs(skb->protocol), skb->len, skb->pkt_type);
995 1001
996 napi_gro_receive(&rq->napi, skb); 1002 napi_gro_receive(&rq->napi, skb);
997 return ret; 1003 return;
998 1004
999frame_err: 1005frame_err:
1000 dev->stats.rx_frame_errors++; 1006 dev->stats.rx_frame_errors++;
1001 dev_kfree_skb(skb); 1007 dev_kfree_skb(skb);
1002 return 0;
1003} 1008}
1004 1009
1005/* Unlike mergeable buffers, all buffers are allocated to the 1010/* Unlike mergeable buffers, all buffers are allocated to the
@@ -1249,13 +1254,13 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
1249 1254
1250 while (received < budget && 1255 while (received < budget &&
1251 (buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx))) { 1256 (buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx))) {
1252 bytes += receive_buf(vi, rq, buf, len, ctx, xdp_xmit); 1257 receive_buf(vi, rq, buf, len, ctx, xdp_xmit, &bytes);
1253 received++; 1258 received++;
1254 } 1259 }
1255 } else { 1260 } else {
1256 while (received < budget && 1261 while (received < budget &&
1257 (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { 1262 (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) {
1258 bytes += receive_buf(vi, rq, buf, len, NULL, xdp_xmit); 1263 receive_buf(vi, rq, buf, len, NULL, xdp_xmit, &bytes);
1259 received++; 1264 received++;
1260 } 1265 }
1261 } 1266 }
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index f6bb1d54d4bd..e857cb3335f6 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -636,9 +636,62 @@ static int vxlan_gro_complete(struct sock *sk, struct sk_buff *skb, int nhoff)
636 return eth_gro_complete(skb, nhoff + sizeof(struct vxlanhdr)); 636 return eth_gro_complete(skb, nhoff + sizeof(struct vxlanhdr));
637} 637}
638 638
639/* Add new entry to forwarding table -- assumes lock held */ 639static struct vxlan_fdb *vxlan_fdb_alloc(struct vxlan_dev *vxlan,
640 const u8 *mac, __u16 state,
641 __be32 src_vni, __u8 ndm_flags)
642{
643 struct vxlan_fdb *f;
644
645 f = kmalloc(sizeof(*f), GFP_ATOMIC);
646 if (!f)
647 return NULL;
648 f->state = state;
649 f->flags = ndm_flags;
650 f->updated = f->used = jiffies;
651 f->vni = src_vni;
652 INIT_LIST_HEAD(&f->remotes);
653 memcpy(f->eth_addr, mac, ETH_ALEN);
654
655 return f;
656}
657
640static int vxlan_fdb_create(struct vxlan_dev *vxlan, 658static int vxlan_fdb_create(struct vxlan_dev *vxlan,
641 const u8 *mac, union vxlan_addr *ip, 659 const u8 *mac, union vxlan_addr *ip,
660 __u16 state, __be16 port, __be32 src_vni,
661 __be32 vni, __u32 ifindex, __u8 ndm_flags,
662 struct vxlan_fdb **fdb)
663{
664 struct vxlan_rdst *rd = NULL;
665 struct vxlan_fdb *f;
666 int rc;
667
668 if (vxlan->cfg.addrmax &&
669 vxlan->addrcnt >= vxlan->cfg.addrmax)
670 return -ENOSPC;
671
672 netdev_dbg(vxlan->dev, "add %pM -> %pIS\n", mac, ip);
673 f = vxlan_fdb_alloc(vxlan, mac, state, src_vni, ndm_flags);
674 if (!f)
675 return -ENOMEM;
676
677 rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
678 if (rc < 0) {
679 kfree(f);
680 return rc;
681 }
682
683 ++vxlan->addrcnt;
684 hlist_add_head_rcu(&f->hlist,
685 vxlan_fdb_head(vxlan, mac, src_vni));
686
687 *fdb = f;
688
689 return 0;
690}
691
692/* Add new entry to forwarding table -- assumes lock held */
693static int vxlan_fdb_update(struct vxlan_dev *vxlan,
694 const u8 *mac, union vxlan_addr *ip,
642 __u16 state, __u16 flags, 695 __u16 state, __u16 flags,
643 __be16 port, __be32 src_vni, __be32 vni, 696 __be16 port, __be32 src_vni, __be32 vni,
644 __u32 ifindex, __u8 ndm_flags) 697 __u32 ifindex, __u8 ndm_flags)
@@ -687,37 +740,17 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
687 if (!(flags & NLM_F_CREATE)) 740 if (!(flags & NLM_F_CREATE))
688 return -ENOENT; 741 return -ENOENT;
689 742
690 if (vxlan->cfg.addrmax &&
691 vxlan->addrcnt >= vxlan->cfg.addrmax)
692 return -ENOSPC;
693
694 /* Disallow replace to add a multicast entry */ 743 /* Disallow replace to add a multicast entry */
695 if ((flags & NLM_F_REPLACE) && 744 if ((flags & NLM_F_REPLACE) &&
696 (is_multicast_ether_addr(mac) || is_zero_ether_addr(mac))) 745 (is_multicast_ether_addr(mac) || is_zero_ether_addr(mac)))
697 return -EOPNOTSUPP; 746 return -EOPNOTSUPP;
698 747
699 netdev_dbg(vxlan->dev, "add %pM -> %pIS\n", mac, ip); 748 netdev_dbg(vxlan->dev, "add %pM -> %pIS\n", mac, ip);
700 f = kmalloc(sizeof(*f), GFP_ATOMIC); 749 rc = vxlan_fdb_create(vxlan, mac, ip, state, port, src_vni,
701 if (!f) 750 vni, ifindex, ndm_flags, &f);
702 return -ENOMEM; 751 if (rc < 0)
703
704 notify = 1;
705 f->state = state;
706 f->flags = ndm_flags;
707 f->updated = f->used = jiffies;
708 f->vni = src_vni;
709 INIT_LIST_HEAD(&f->remotes);
710 memcpy(f->eth_addr, mac, ETH_ALEN);
711
712 rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
713 if (rc < 0) {
714 kfree(f);
715 return rc; 752 return rc;
716 } 753 notify = 1;
717
718 ++vxlan->addrcnt;
719 hlist_add_head_rcu(&f->hlist,
720 vxlan_fdb_head(vxlan, mac, src_vni));
721 } 754 }
722 755
723 if (notify) { 756 if (notify) {
@@ -741,13 +774,15 @@ static void vxlan_fdb_free(struct rcu_head *head)
741 kfree(f); 774 kfree(f);
742} 775}
743 776
744static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f) 777static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f,
778 bool do_notify)
745{ 779{
746 netdev_dbg(vxlan->dev, 780 netdev_dbg(vxlan->dev,
747 "delete %pM\n", f->eth_addr); 781 "delete %pM\n", f->eth_addr);
748 782
749 --vxlan->addrcnt; 783 --vxlan->addrcnt;
750 vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_DELNEIGH); 784 if (do_notify)
785 vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_DELNEIGH);
751 786
752 hlist_del_rcu(&f->hlist); 787 hlist_del_rcu(&f->hlist);
753 call_rcu(&f->rcu, vxlan_fdb_free); 788 call_rcu(&f->rcu, vxlan_fdb_free);
@@ -863,7 +898,7 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
863 return -EAFNOSUPPORT; 898 return -EAFNOSUPPORT;
864 899
865 spin_lock_bh(&vxlan->hash_lock); 900 spin_lock_bh(&vxlan->hash_lock);
866 err = vxlan_fdb_create(vxlan, addr, &ip, ndm->ndm_state, flags, 901 err = vxlan_fdb_update(vxlan, addr, &ip, ndm->ndm_state, flags,
867 port, src_vni, vni, ifindex, ndm->ndm_flags); 902 port, src_vni, vni, ifindex, ndm->ndm_flags);
868 spin_unlock_bh(&vxlan->hash_lock); 903 spin_unlock_bh(&vxlan->hash_lock);
869 904
@@ -897,7 +932,7 @@ static int __vxlan_fdb_delete(struct vxlan_dev *vxlan,
897 goto out; 932 goto out;
898 } 933 }
899 934
900 vxlan_fdb_destroy(vxlan, f); 935 vxlan_fdb_destroy(vxlan, f, true);
901 936
902out: 937out:
903 return 0; 938 return 0;
@@ -1006,7 +1041,7 @@ static bool vxlan_snoop(struct net_device *dev,
1006 1041
1007 /* close off race between vxlan_flush and incoming packets */ 1042 /* close off race between vxlan_flush and incoming packets */
1008 if (netif_running(dev)) 1043 if (netif_running(dev))
1009 vxlan_fdb_create(vxlan, src_mac, src_ip, 1044 vxlan_fdb_update(vxlan, src_mac, src_ip,
1010 NUD_REACHABLE, 1045 NUD_REACHABLE,
1011 NLM_F_EXCL|NLM_F_CREATE, 1046 NLM_F_EXCL|NLM_F_CREATE,
1012 vxlan->cfg.dst_port, 1047 vxlan->cfg.dst_port,
@@ -2364,7 +2399,7 @@ static void vxlan_cleanup(struct timer_list *t)
2364 "garbage collect %pM\n", 2399 "garbage collect %pM\n",
2365 f->eth_addr); 2400 f->eth_addr);
2366 f->state = NUD_STALE; 2401 f->state = NUD_STALE;
2367 vxlan_fdb_destroy(vxlan, f); 2402 vxlan_fdb_destroy(vxlan, f, true);
2368 } else if (time_before(timeout, next_timer)) 2403 } else if (time_before(timeout, next_timer))
2369 next_timer = timeout; 2404 next_timer = timeout;
2370 } 2405 }
@@ -2415,7 +2450,7 @@ static void vxlan_fdb_delete_default(struct vxlan_dev *vxlan, __be32 vni)
2415 spin_lock_bh(&vxlan->hash_lock); 2450 spin_lock_bh(&vxlan->hash_lock);
2416 f = __vxlan_find_mac(vxlan, all_zeros_mac, vni); 2451 f = __vxlan_find_mac(vxlan, all_zeros_mac, vni);
2417 if (f) 2452 if (f)
2418 vxlan_fdb_destroy(vxlan, f); 2453 vxlan_fdb_destroy(vxlan, f, true);
2419 spin_unlock_bh(&vxlan->hash_lock); 2454 spin_unlock_bh(&vxlan->hash_lock);
2420} 2455}
2421 2456
@@ -2469,7 +2504,7 @@ static void vxlan_flush(struct vxlan_dev *vxlan, bool do_all)
2469 continue; 2504 continue;
2470 /* the all_zeros_mac entry is deleted at vxlan_uninit */ 2505 /* the all_zeros_mac entry is deleted at vxlan_uninit */
2471 if (!is_zero_ether_addr(f->eth_addr)) 2506 if (!is_zero_ether_addr(f->eth_addr))
2472 vxlan_fdb_destroy(vxlan, f); 2507 vxlan_fdb_destroy(vxlan, f, true);
2473 } 2508 }
2474 } 2509 }
2475 spin_unlock_bh(&vxlan->hash_lock); 2510 spin_unlock_bh(&vxlan->hash_lock);
@@ -3160,6 +3195,7 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3160{ 3195{
3161 struct vxlan_net *vn = net_generic(net, vxlan_net_id); 3196 struct vxlan_net *vn = net_generic(net, vxlan_net_id);
3162 struct vxlan_dev *vxlan = netdev_priv(dev); 3197 struct vxlan_dev *vxlan = netdev_priv(dev);
3198 struct vxlan_fdb *f = NULL;
3163 int err; 3199 int err;
3164 3200
3165 err = vxlan_dev_configure(net, dev, conf, false, extack); 3201 err = vxlan_dev_configure(net, dev, conf, false, extack);
@@ -3173,24 +3209,35 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev,
3173 err = vxlan_fdb_create(vxlan, all_zeros_mac, 3209 err = vxlan_fdb_create(vxlan, all_zeros_mac,
3174 &vxlan->default_dst.remote_ip, 3210 &vxlan->default_dst.remote_ip,
3175 NUD_REACHABLE | NUD_PERMANENT, 3211 NUD_REACHABLE | NUD_PERMANENT,
3176 NLM_F_EXCL | NLM_F_CREATE,
3177 vxlan->cfg.dst_port, 3212 vxlan->cfg.dst_port,
3178 vxlan->default_dst.remote_vni, 3213 vxlan->default_dst.remote_vni,
3179 vxlan->default_dst.remote_vni, 3214 vxlan->default_dst.remote_vni,
3180 vxlan->default_dst.remote_ifindex, 3215 vxlan->default_dst.remote_ifindex,
3181 NTF_SELF); 3216 NTF_SELF, &f);
3182 if (err) 3217 if (err)
3183 return err; 3218 return err;
3184 } 3219 }
3185 3220
3186 err = register_netdevice(dev); 3221 err = register_netdevice(dev);
3222 if (err)
3223 goto errout;
3224
3225 err = rtnl_configure_link(dev, NULL);
3187 if (err) { 3226 if (err) {
3188 vxlan_fdb_delete_default(vxlan, vxlan->default_dst.remote_vni); 3227 unregister_netdevice(dev);
3189 return err; 3228 goto errout;
3190 } 3229 }
3191 3230
3231 /* notify default fdb entry */
3232 if (f)
3233 vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_NEWNEIGH);
3234
3192 list_add(&vxlan->next, &vn->vxlan_list); 3235 list_add(&vxlan->next, &vn->vxlan_list);
3193 return 0; 3236 return 0;
3237errout:
3238 if (f)
3239 vxlan_fdb_destroy(vxlan, f, false);
3240 return err;
3194} 3241}
3195 3242
3196static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], 3243static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[],
@@ -3425,6 +3472,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
3425 struct vxlan_rdst *dst = &vxlan->default_dst; 3472 struct vxlan_rdst *dst = &vxlan->default_dst;
3426 struct vxlan_rdst old_dst; 3473 struct vxlan_rdst old_dst;
3427 struct vxlan_config conf; 3474 struct vxlan_config conf;
3475 struct vxlan_fdb *f = NULL;
3428 int err; 3476 int err;
3429 3477
3430 err = vxlan_nl2conf(tb, data, 3478 err = vxlan_nl2conf(tb, data,
@@ -3453,16 +3501,16 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
3453 err = vxlan_fdb_create(vxlan, all_zeros_mac, 3501 err = vxlan_fdb_create(vxlan, all_zeros_mac,
3454 &dst->remote_ip, 3502 &dst->remote_ip,
3455 NUD_REACHABLE | NUD_PERMANENT, 3503 NUD_REACHABLE | NUD_PERMANENT,
3456 NLM_F_CREATE | NLM_F_APPEND,
3457 vxlan->cfg.dst_port, 3504 vxlan->cfg.dst_port,
3458 dst->remote_vni, 3505 dst->remote_vni,
3459 dst->remote_vni, 3506 dst->remote_vni,
3460 dst->remote_ifindex, 3507 dst->remote_ifindex,
3461 NTF_SELF); 3508 NTF_SELF, &f);
3462 if (err) { 3509 if (err) {
3463 spin_unlock_bh(&vxlan->hash_lock); 3510 spin_unlock_bh(&vxlan->hash_lock);
3464 return err; 3511 return err;
3465 } 3512 }
3513 vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_NEWNEIGH);
3466 } 3514 }
3467 spin_unlock_bh(&vxlan->hash_lock); 3515 spin_unlock_bh(&vxlan->hash_lock);
3468 } 3516 }
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 90a4ad9a2d08..b3a1b6f5c406 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -1362,7 +1362,7 @@ static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
1362 case 0x001: 1362 case 0x001:
1363 printk(KERN_WARNING "%s: Master Abort (naughty)\n", dev->name); 1363 printk(KERN_WARNING "%s: Master Abort (naughty)\n", dev->name);
1364 break; 1364 break;
1365 case 0x010: 1365 case 0x002:
1366 printk(KERN_WARNING "%s: Target Abort (not so naughty)\n", dev->name); 1366 printk(KERN_WARNING "%s: Target Abort (not so naughty)\n", dev->name);
1367 break; 1367 break;
1368 default: 1368 default:
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index e9c2fb318c03..836e0a47b94a 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6058,8 +6058,19 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
6058 ath10k_mac_max_vht_nss(vht_mcs_mask))); 6058 ath10k_mac_max_vht_nss(vht_mcs_mask)));
6059 6059
6060 if (changed & IEEE80211_RC_BW_CHANGED) { 6060 if (changed & IEEE80211_RC_BW_CHANGED) {
6061 ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d\n", 6061 enum wmi_phy_mode mode;
6062 sta->addr, bw); 6062
6063 mode = chan_to_phymode(&def);
6064 ath10k_dbg(ar, ATH10K_DBG_MAC, "mac update sta %pM peer bw %d phymode %d\n",
6065 sta->addr, bw, mode);
6066
6067 err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
6068 WMI_PEER_PHYMODE, mode);
6069 if (err) {
6070 ath10k_warn(ar, "failed to update STA %pM peer phymode %d: %d\n",
6071 sta->addr, mode, err);
6072 goto exit;
6073 }
6063 6074
6064 err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr, 6075 err = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
6065 WMI_PEER_CHAN_WIDTH, bw); 6076 WMI_PEER_CHAN_WIDTH, bw);
@@ -6100,6 +6111,7 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
6100 sta->addr); 6111 sta->addr);
6101 } 6112 }
6102 6113
6114exit:
6103 mutex_unlock(&ar->conf_mutex); 6115 mutex_unlock(&ar->conf_mutex);
6104} 6116}
6105 6117
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index b48db54e9865..d68afb65402a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -6144,6 +6144,7 @@ enum wmi_peer_param {
6144 WMI_PEER_NSS = 0x5, 6144 WMI_PEER_NSS = 0x5,
6145 WMI_PEER_USE_4ADDR = 0x6, 6145 WMI_PEER_USE_4ADDR = 0x6,
6146 WMI_PEER_DEBUG = 0xa, 6146 WMI_PEER_DEBUG = 0xa,
6147 WMI_PEER_PHYMODE = 0xd,
6147 WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */ 6148 WMI_PEER_DUMMY_VAR = 0xff, /* dummy parameter for STA PS workaround */
6148}; 6149};
6149 6150
diff --git a/drivers/net/wireless/ath/wcn36xx/testmode.c b/drivers/net/wireless/ath/wcn36xx/testmode.c
index 1279064a3b71..51a038022c8b 100644
--- a/drivers/net/wireless/ath/wcn36xx/testmode.c
+++ b/drivers/net/wireless/ath/wcn36xx/testmode.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) 2018, The Linux Foundation. All rights reserved. 2 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
3 * 3 *
4 * Permission to use, copy, modify, and/or distribute this software for any 4 * Permission to use, copy, modify, and/or distribute this software for any
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 45928b5b8d97..4fffa6988087 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1785,7 +1785,8 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
1785 fwreq->items[BRCMF_PCIE_FW_CODE].type = BRCMF_FW_TYPE_BINARY; 1785 fwreq->items[BRCMF_PCIE_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
1786 fwreq->items[BRCMF_PCIE_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM; 1786 fwreq->items[BRCMF_PCIE_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
1787 fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL; 1787 fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL;
1788 fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus); 1788 /* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */
1789 fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
1789 fwreq->bus_nr = devinfo->pdev->bus->number; 1790 fwreq->bus_nr = devinfo->pdev->bus->number;
1790 1791
1791 return fwreq; 1792 return fwreq;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index c99a191e8d69..a907d7b065fa 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4296,6 +4296,13 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
4296 brcmf_dbg(TRACE, "Enter\n"); 4296 brcmf_dbg(TRACE, "Enter\n");
4297 4297
4298 if (bus) { 4298 if (bus) {
4299 /* Stop watchdog task */
4300 if (bus->watchdog_tsk) {
4301 send_sig(SIGTERM, bus->watchdog_tsk, 1);
4302 kthread_stop(bus->watchdog_tsk);
4303 bus->watchdog_tsk = NULL;
4304 }
4305
4299 /* De-register interrupt handler */ 4306 /* De-register interrupt handler */
4300 brcmf_sdiod_intr_unregister(bus->sdiodev); 4307 brcmf_sdiod_intr_unregister(bus->sdiodev);
4301 4308
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
index e20c30b29c03..c8ea63d02619 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
@@ -178,6 +178,17 @@ const struct iwl_cfg iwl9260_2ac_cfg = {
178 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K, 178 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
179}; 179};
180 180
181const struct iwl_cfg iwl9260_killer_2ac_cfg = {
182 .name = "Killer (R) Wireless-AC 1550 Wireless Network Adapter (9260NGW)",
183 .fw_name_pre = IWL9260A_FW_PRE,
184 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
185 IWL_DEVICE_9000,
186 .ht_params = &iwl9000_ht_params,
187 .nvm_ver = IWL9000_NVM_VERSION,
188 .nvm_calib_ver = IWL9000_TX_POWER_VERSION,
189 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
190};
191
181const struct iwl_cfg iwl9270_2ac_cfg = { 192const struct iwl_cfg iwl9270_2ac_cfg = {
182 .name = "Intel(R) Dual Band Wireless AC 9270", 193 .name = "Intel(R) Dual Band Wireless AC 9270",
183 .fw_name_pre = IWL9260A_FW_PRE, 194 .fw_name_pre = IWL9260A_FW_PRE,
@@ -267,6 +278,34 @@ const struct iwl_cfg iwl9560_2ac_cfg_soc = {
267 .soc_latency = 5000, 278 .soc_latency = 5000,
268}; 279};
269 280
281const struct iwl_cfg iwl9560_killer_2ac_cfg_soc = {
282 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)",
283 .fw_name_pre = IWL9000A_FW_PRE,
284 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
285 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
286 IWL_DEVICE_9000,
287 .ht_params = &iwl9000_ht_params,
288 .nvm_ver = IWL9000_NVM_VERSION,
289 .nvm_calib_ver = IWL9000_TX_POWER_VERSION,
290 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
291 .integrated = true,
292 .soc_latency = 5000,
293};
294
295const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc = {
296 .name = "Killer (R) Wireless-AC 1550s Wireless Network Adapter (9560NGW)",
297 .fw_name_pre = IWL9000A_FW_PRE,
298 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
299 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
300 IWL_DEVICE_9000,
301 .ht_params = &iwl9000_ht_params,
302 .nvm_ver = IWL9000_NVM_VERSION,
303 .nvm_calib_ver = IWL9000_TX_POWER_VERSION,
304 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
305 .integrated = true,
306 .soc_latency = 5000,
307};
308
270const struct iwl_cfg iwl9460_2ac_cfg_shared_clk = { 309const struct iwl_cfg iwl9460_2ac_cfg_shared_clk = {
271 .name = "Intel(R) Dual Band Wireless AC 9460", 310 .name = "Intel(R) Dual Band Wireless AC 9460",
272 .fw_name_pre = IWL9000A_FW_PRE, 311 .fw_name_pre = IWL9000A_FW_PRE,
@@ -327,6 +366,36 @@ const struct iwl_cfg iwl9560_2ac_cfg_shared_clk = {
327 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK 366 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK
328}; 367};
329 368
369const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk = {
370 .name = "Killer (R) Wireless-AC 1550i Wireless Network Adapter (9560NGW)",
371 .fw_name_pre = IWL9000A_FW_PRE,
372 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
373 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
374 IWL_DEVICE_9000,
375 .ht_params = &iwl9000_ht_params,
376 .nvm_ver = IWL9000_NVM_VERSION,
377 .nvm_calib_ver = IWL9000_TX_POWER_VERSION,
378 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
379 .integrated = true,
380 .soc_latency = 5000,
381 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK
382};
383
384const struct iwl_cfg iwl9560_killer_s_2ac_cfg_shared_clk = {
385 .name = "Killer (R) Wireless-AC 1550s Wireless Network Adapter (9560NGW)",
386 .fw_name_pre = IWL9000A_FW_PRE,
387 .fw_name_pre_b_or_c_step = IWL9000B_FW_PRE,
388 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
389 IWL_DEVICE_9000,
390 .ht_params = &iwl9000_ht_params,
391 .nvm_ver = IWL9000_NVM_VERSION,
392 .nvm_calib_ver = IWL9000_TX_POWER_VERSION,
393 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
394 .integrated = true,
395 .soc_latency = 5000,
396 .extra_phy_cfg_flags = FW_PHY_CFG_SHARED_CLK
397};
398
330MODULE_FIRMWARE(IWL9000A_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 399MODULE_FIRMWARE(IWL9000A_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
331MODULE_FIRMWARE(IWL9000B_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 400MODULE_FIRMWARE(IWL9000B_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
332MODULE_FIRMWARE(IWL9000RFB_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX)); 401MODULE_FIRMWARE(IWL9000RFB_MODULE_FIRMWARE(IWL9000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index c503b26793f6..84a816809723 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -551,6 +551,7 @@ extern const struct iwl_cfg iwl8275_2ac_cfg;
551extern const struct iwl_cfg iwl4165_2ac_cfg; 551extern const struct iwl_cfg iwl4165_2ac_cfg;
552extern const struct iwl_cfg iwl9160_2ac_cfg; 552extern const struct iwl_cfg iwl9160_2ac_cfg;
553extern const struct iwl_cfg iwl9260_2ac_cfg; 553extern const struct iwl_cfg iwl9260_2ac_cfg;
554extern const struct iwl_cfg iwl9260_killer_2ac_cfg;
554extern const struct iwl_cfg iwl9270_2ac_cfg; 555extern const struct iwl_cfg iwl9270_2ac_cfg;
555extern const struct iwl_cfg iwl9460_2ac_cfg; 556extern const struct iwl_cfg iwl9460_2ac_cfg;
556extern const struct iwl_cfg iwl9560_2ac_cfg; 557extern const struct iwl_cfg iwl9560_2ac_cfg;
@@ -558,10 +559,14 @@ extern const struct iwl_cfg iwl9460_2ac_cfg_soc;
558extern const struct iwl_cfg iwl9461_2ac_cfg_soc; 559extern const struct iwl_cfg iwl9461_2ac_cfg_soc;
559extern const struct iwl_cfg iwl9462_2ac_cfg_soc; 560extern const struct iwl_cfg iwl9462_2ac_cfg_soc;
560extern const struct iwl_cfg iwl9560_2ac_cfg_soc; 561extern const struct iwl_cfg iwl9560_2ac_cfg_soc;
562extern const struct iwl_cfg iwl9560_killer_2ac_cfg_soc;
563extern const struct iwl_cfg iwl9560_killer_s_2ac_cfg_soc;
561extern const struct iwl_cfg iwl9460_2ac_cfg_shared_clk; 564extern const struct iwl_cfg iwl9460_2ac_cfg_shared_clk;
562extern const struct iwl_cfg iwl9461_2ac_cfg_shared_clk; 565extern const struct iwl_cfg iwl9461_2ac_cfg_shared_clk;
563extern const struct iwl_cfg iwl9462_2ac_cfg_shared_clk; 566extern const struct iwl_cfg iwl9462_2ac_cfg_shared_clk;
564extern const struct iwl_cfg iwl9560_2ac_cfg_shared_clk; 567extern const struct iwl_cfg iwl9560_2ac_cfg_shared_clk;
568extern const struct iwl_cfg iwl9560_killer_2ac_cfg_shared_clk;
569extern const struct iwl_cfg iwl9560_killer_s_2ac_cfg_shared_clk;
565extern const struct iwl_cfg iwl22000_2ac_cfg_hr; 570extern const struct iwl_cfg iwl22000_2ac_cfg_hr;
566extern const struct iwl_cfg iwl22000_2ac_cfg_hr_cdb; 571extern const struct iwl_cfg iwl22000_2ac_cfg_hr_cdb;
567extern const struct iwl_cfg iwl22000_2ac_cfg_jf; 572extern const struct iwl_cfg iwl22000_2ac_cfg_jf;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 38234bda9017..8520523b91b4 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -545,6 +545,9 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
545 {IWL_PCI_DEVICE(0x2526, 0x1210, iwl9260_2ac_cfg)}, 545 {IWL_PCI_DEVICE(0x2526, 0x1210, iwl9260_2ac_cfg)},
546 {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)}, 546 {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)},
547 {IWL_PCI_DEVICE(0x2526, 0x1420, iwl9460_2ac_cfg_soc)}, 547 {IWL_PCI_DEVICE(0x2526, 0x1420, iwl9460_2ac_cfg_soc)},
548 {IWL_PCI_DEVICE(0x2526, 0x1550, iwl9260_killer_2ac_cfg)},
549 {IWL_PCI_DEVICE(0x2526, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
550 {IWL_PCI_DEVICE(0x2526, 0x1552, iwl9560_killer_2ac_cfg_soc)},
548 {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)}, 551 {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)},
549 {IWL_PCI_DEVICE(0x2526, 0x2030, iwl9560_2ac_cfg_soc)}, 552 {IWL_PCI_DEVICE(0x2526, 0x2030, iwl9560_2ac_cfg_soc)},
550 {IWL_PCI_DEVICE(0x2526, 0x2034, iwl9560_2ac_cfg_soc)}, 553 {IWL_PCI_DEVICE(0x2526, 0x2034, iwl9560_2ac_cfg_soc)},
@@ -554,6 +557,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
554 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)}, 557 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)},
555 {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)}, 558 {IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)},
556 {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)}, 559 {IWL_PCI_DEVICE(0x2526, 0x42A4, iwl9462_2ac_cfg_soc)},
560 {IWL_PCI_DEVICE(0x2526, 0x8014, iwl9260_2ac_cfg)},
557 {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)}, 561 {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)},
558 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)}, 562 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
559 {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)}, 563 {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)},
@@ -578,6 +582,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
578 {IWL_PCI_DEVICE(0x2720, 0x1010, iwl9260_2ac_cfg)}, 582 {IWL_PCI_DEVICE(0x2720, 0x1010, iwl9260_2ac_cfg)},
579 {IWL_PCI_DEVICE(0x2720, 0x1030, iwl9560_2ac_cfg_soc)}, 583 {IWL_PCI_DEVICE(0x2720, 0x1030, iwl9560_2ac_cfg_soc)},
580 {IWL_PCI_DEVICE(0x2720, 0x1210, iwl9260_2ac_cfg)}, 584 {IWL_PCI_DEVICE(0x2720, 0x1210, iwl9260_2ac_cfg)},
585 {IWL_PCI_DEVICE(0x2720, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
586 {IWL_PCI_DEVICE(0x2720, 0x1552, iwl9560_killer_2ac_cfg_soc)},
581 {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_cfg_soc)}, 587 {IWL_PCI_DEVICE(0x2720, 0x2030, iwl9560_2ac_cfg_soc)},
582 {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_cfg_soc)}, 588 {IWL_PCI_DEVICE(0x2720, 0x2034, iwl9560_2ac_cfg_soc)},
583 {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_cfg)}, 589 {IWL_PCI_DEVICE(0x2720, 0x4030, iwl9560_2ac_cfg)},
@@ -604,6 +610,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
604 {IWL_PCI_DEVICE(0x30DC, 0x1010, iwl9260_2ac_cfg)}, 610 {IWL_PCI_DEVICE(0x30DC, 0x1010, iwl9260_2ac_cfg)},
605 {IWL_PCI_DEVICE(0x30DC, 0x1030, iwl9560_2ac_cfg_soc)}, 611 {IWL_PCI_DEVICE(0x30DC, 0x1030, iwl9560_2ac_cfg_soc)},
606 {IWL_PCI_DEVICE(0x30DC, 0x1210, iwl9260_2ac_cfg)}, 612 {IWL_PCI_DEVICE(0x30DC, 0x1210, iwl9260_2ac_cfg)},
613 {IWL_PCI_DEVICE(0x30DC, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
614 {IWL_PCI_DEVICE(0x30DC, 0x1552, iwl9560_killer_2ac_cfg_soc)},
607 {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_cfg_soc)}, 615 {IWL_PCI_DEVICE(0x30DC, 0x2030, iwl9560_2ac_cfg_soc)},
608 {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_cfg_soc)}, 616 {IWL_PCI_DEVICE(0x30DC, 0x2034, iwl9560_2ac_cfg_soc)},
609 {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_cfg_soc)}, 617 {IWL_PCI_DEVICE(0x30DC, 0x4030, iwl9560_2ac_cfg_soc)},
@@ -630,6 +638,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
630 {IWL_PCI_DEVICE(0x31DC, 0x1010, iwl9260_2ac_cfg)}, 638 {IWL_PCI_DEVICE(0x31DC, 0x1010, iwl9260_2ac_cfg)},
631 {IWL_PCI_DEVICE(0x31DC, 0x1030, iwl9560_2ac_cfg_shared_clk)}, 639 {IWL_PCI_DEVICE(0x31DC, 0x1030, iwl9560_2ac_cfg_shared_clk)},
632 {IWL_PCI_DEVICE(0x31DC, 0x1210, iwl9260_2ac_cfg)}, 640 {IWL_PCI_DEVICE(0x31DC, 0x1210, iwl9260_2ac_cfg)},
641 {IWL_PCI_DEVICE(0x31DC, 0x1551, iwl9560_killer_s_2ac_cfg_shared_clk)},
642 {IWL_PCI_DEVICE(0x31DC, 0x1552, iwl9560_killer_2ac_cfg_shared_clk)},
633 {IWL_PCI_DEVICE(0x31DC, 0x2030, iwl9560_2ac_cfg_shared_clk)}, 643 {IWL_PCI_DEVICE(0x31DC, 0x2030, iwl9560_2ac_cfg_shared_clk)},
634 {IWL_PCI_DEVICE(0x31DC, 0x2034, iwl9560_2ac_cfg_shared_clk)}, 644 {IWL_PCI_DEVICE(0x31DC, 0x2034, iwl9560_2ac_cfg_shared_clk)},
635 {IWL_PCI_DEVICE(0x31DC, 0x4030, iwl9560_2ac_cfg_shared_clk)}, 645 {IWL_PCI_DEVICE(0x31DC, 0x4030, iwl9560_2ac_cfg_shared_clk)},
@@ -656,6 +666,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
656 {IWL_PCI_DEVICE(0x34F0, 0x1010, iwl9260_2ac_cfg)}, 666 {IWL_PCI_DEVICE(0x34F0, 0x1010, iwl9260_2ac_cfg)},
657 {IWL_PCI_DEVICE(0x34F0, 0x1030, iwl9560_2ac_cfg_soc)}, 667 {IWL_PCI_DEVICE(0x34F0, 0x1030, iwl9560_2ac_cfg_soc)},
658 {IWL_PCI_DEVICE(0x34F0, 0x1210, iwl9260_2ac_cfg)}, 668 {IWL_PCI_DEVICE(0x34F0, 0x1210, iwl9260_2ac_cfg)},
669 {IWL_PCI_DEVICE(0x34F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
670 {IWL_PCI_DEVICE(0x34F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
659 {IWL_PCI_DEVICE(0x34F0, 0x2030, iwl9560_2ac_cfg_soc)}, 671 {IWL_PCI_DEVICE(0x34F0, 0x2030, iwl9560_2ac_cfg_soc)},
660 {IWL_PCI_DEVICE(0x34F0, 0x2034, iwl9560_2ac_cfg_soc)}, 672 {IWL_PCI_DEVICE(0x34F0, 0x2034, iwl9560_2ac_cfg_soc)},
661 {IWL_PCI_DEVICE(0x34F0, 0x4030, iwl9560_2ac_cfg_soc)}, 673 {IWL_PCI_DEVICE(0x34F0, 0x4030, iwl9560_2ac_cfg_soc)},
@@ -682,6 +694,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
682 {IWL_PCI_DEVICE(0x3DF0, 0x1010, iwl9260_2ac_cfg)}, 694 {IWL_PCI_DEVICE(0x3DF0, 0x1010, iwl9260_2ac_cfg)},
683 {IWL_PCI_DEVICE(0x3DF0, 0x1030, iwl9560_2ac_cfg_soc)}, 695 {IWL_PCI_DEVICE(0x3DF0, 0x1030, iwl9560_2ac_cfg_soc)},
684 {IWL_PCI_DEVICE(0x3DF0, 0x1210, iwl9260_2ac_cfg)}, 696 {IWL_PCI_DEVICE(0x3DF0, 0x1210, iwl9260_2ac_cfg)},
697 {IWL_PCI_DEVICE(0x3DF0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
698 {IWL_PCI_DEVICE(0x3DF0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
685 {IWL_PCI_DEVICE(0x3DF0, 0x2030, iwl9560_2ac_cfg_soc)}, 699 {IWL_PCI_DEVICE(0x3DF0, 0x2030, iwl9560_2ac_cfg_soc)},
686 {IWL_PCI_DEVICE(0x3DF0, 0x2034, iwl9560_2ac_cfg_soc)}, 700 {IWL_PCI_DEVICE(0x3DF0, 0x2034, iwl9560_2ac_cfg_soc)},
687 {IWL_PCI_DEVICE(0x3DF0, 0x4030, iwl9560_2ac_cfg_soc)}, 701 {IWL_PCI_DEVICE(0x3DF0, 0x4030, iwl9560_2ac_cfg_soc)},
@@ -708,6 +722,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
708 {IWL_PCI_DEVICE(0x43F0, 0x1010, iwl9260_2ac_cfg)}, 722 {IWL_PCI_DEVICE(0x43F0, 0x1010, iwl9260_2ac_cfg)},
709 {IWL_PCI_DEVICE(0x43F0, 0x1030, iwl9560_2ac_cfg_soc)}, 723 {IWL_PCI_DEVICE(0x43F0, 0x1030, iwl9560_2ac_cfg_soc)},
710 {IWL_PCI_DEVICE(0x43F0, 0x1210, iwl9260_2ac_cfg)}, 724 {IWL_PCI_DEVICE(0x43F0, 0x1210, iwl9260_2ac_cfg)},
725 {IWL_PCI_DEVICE(0x43F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
726 {IWL_PCI_DEVICE(0x43F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
711 {IWL_PCI_DEVICE(0x43F0, 0x2030, iwl9560_2ac_cfg_soc)}, 727 {IWL_PCI_DEVICE(0x43F0, 0x2030, iwl9560_2ac_cfg_soc)},
712 {IWL_PCI_DEVICE(0x43F0, 0x2034, iwl9560_2ac_cfg_soc)}, 728 {IWL_PCI_DEVICE(0x43F0, 0x2034, iwl9560_2ac_cfg_soc)},
713 {IWL_PCI_DEVICE(0x43F0, 0x4030, iwl9560_2ac_cfg_soc)}, 729 {IWL_PCI_DEVICE(0x43F0, 0x4030, iwl9560_2ac_cfg_soc)},
@@ -743,6 +759,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
743 {IWL_PCI_DEVICE(0x9DF0, 0x1010, iwl9260_2ac_cfg)}, 759 {IWL_PCI_DEVICE(0x9DF0, 0x1010, iwl9260_2ac_cfg)},
744 {IWL_PCI_DEVICE(0x9DF0, 0x1030, iwl9560_2ac_cfg_soc)}, 760 {IWL_PCI_DEVICE(0x9DF0, 0x1030, iwl9560_2ac_cfg_soc)},
745 {IWL_PCI_DEVICE(0x9DF0, 0x1210, iwl9260_2ac_cfg)}, 761 {IWL_PCI_DEVICE(0x9DF0, 0x1210, iwl9260_2ac_cfg)},
762 {IWL_PCI_DEVICE(0x9DF0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
763 {IWL_PCI_DEVICE(0x9DF0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
746 {IWL_PCI_DEVICE(0x9DF0, 0x2010, iwl9460_2ac_cfg_soc)}, 764 {IWL_PCI_DEVICE(0x9DF0, 0x2010, iwl9460_2ac_cfg_soc)},
747 {IWL_PCI_DEVICE(0x9DF0, 0x2030, iwl9560_2ac_cfg_soc)}, 765 {IWL_PCI_DEVICE(0x9DF0, 0x2030, iwl9560_2ac_cfg_soc)},
748 {IWL_PCI_DEVICE(0x9DF0, 0x2034, iwl9560_2ac_cfg_soc)}, 766 {IWL_PCI_DEVICE(0x9DF0, 0x2034, iwl9560_2ac_cfg_soc)},
@@ -771,6 +789,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
771 {IWL_PCI_DEVICE(0xA0F0, 0x1010, iwl9260_2ac_cfg)}, 789 {IWL_PCI_DEVICE(0xA0F0, 0x1010, iwl9260_2ac_cfg)},
772 {IWL_PCI_DEVICE(0xA0F0, 0x1030, iwl9560_2ac_cfg_soc)}, 790 {IWL_PCI_DEVICE(0xA0F0, 0x1030, iwl9560_2ac_cfg_soc)},
773 {IWL_PCI_DEVICE(0xA0F0, 0x1210, iwl9260_2ac_cfg)}, 791 {IWL_PCI_DEVICE(0xA0F0, 0x1210, iwl9260_2ac_cfg)},
792 {IWL_PCI_DEVICE(0xA0F0, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
793 {IWL_PCI_DEVICE(0xA0F0, 0x1552, iwl9560_killer_2ac_cfg_soc)},
774 {IWL_PCI_DEVICE(0xA0F0, 0x2030, iwl9560_2ac_cfg_soc)}, 794 {IWL_PCI_DEVICE(0xA0F0, 0x2030, iwl9560_2ac_cfg_soc)},
775 {IWL_PCI_DEVICE(0xA0F0, 0x2034, iwl9560_2ac_cfg_soc)}, 795 {IWL_PCI_DEVICE(0xA0F0, 0x2034, iwl9560_2ac_cfg_soc)},
776 {IWL_PCI_DEVICE(0xA0F0, 0x4030, iwl9560_2ac_cfg_soc)}, 796 {IWL_PCI_DEVICE(0xA0F0, 0x4030, iwl9560_2ac_cfg_soc)},
@@ -797,6 +817,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
797 {IWL_PCI_DEVICE(0xA370, 0x1010, iwl9260_2ac_cfg)}, 817 {IWL_PCI_DEVICE(0xA370, 0x1010, iwl9260_2ac_cfg)},
798 {IWL_PCI_DEVICE(0xA370, 0x1030, iwl9560_2ac_cfg_soc)}, 818 {IWL_PCI_DEVICE(0xA370, 0x1030, iwl9560_2ac_cfg_soc)},
799 {IWL_PCI_DEVICE(0xA370, 0x1210, iwl9260_2ac_cfg)}, 819 {IWL_PCI_DEVICE(0xA370, 0x1210, iwl9260_2ac_cfg)},
820 {IWL_PCI_DEVICE(0xA370, 0x1551, iwl9560_killer_s_2ac_cfg_soc)},
821 {IWL_PCI_DEVICE(0xA370, 0x1552, iwl9560_killer_2ac_cfg_soc)},
800 {IWL_PCI_DEVICE(0xA370, 0x2030, iwl9560_2ac_cfg_soc)}, 822 {IWL_PCI_DEVICE(0xA370, 0x2030, iwl9560_2ac_cfg_soc)},
801 {IWL_PCI_DEVICE(0xA370, 0x2034, iwl9560_2ac_cfg_soc)}, 823 {IWL_PCI_DEVICE(0xA370, 0x2034, iwl9560_2ac_cfg_soc)},
802 {IWL_PCI_DEVICE(0xA370, 0x4030, iwl9560_2ac_cfg_soc)}, 824 {IWL_PCI_DEVICE(0xA370, 0x4030, iwl9560_2ac_cfg_soc)},
diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 6e3cf9817730..88f4c89f89ba 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -644,11 +644,6 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf)
644 MWIFIEX_FUNC_SHUTDOWN); 644 MWIFIEX_FUNC_SHUTDOWN);
645 } 645 }
646 646
647 if (adapter->workqueue)
648 flush_workqueue(adapter->workqueue);
649
650 mwifiex_usb_free(card);
651
652 mwifiex_dbg(adapter, FATAL, 647 mwifiex_dbg(adapter, FATAL,
653 "%s: removing card\n", __func__); 648 "%s: removing card\n", __func__);
654 mwifiex_remove_card(adapter); 649 mwifiex_remove_card(adapter);
@@ -1356,6 +1351,8 @@ static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
1356{ 1351{
1357 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; 1352 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card;
1358 1353
1354 mwifiex_usb_free(card);
1355
1359 mwifiex_usb_cleanup_tx_aggr(adapter); 1356 mwifiex_usb_cleanup_tx_aggr(adapter);
1360 1357
1361 card->adapter = NULL; 1358 card->adapter = NULL;
diff --git a/drivers/net/wireless/mediatek/mt7601u/phy.c b/drivers/net/wireless/mediatek/mt7601u/phy.c
index 9d2f9a776ef1..b804abd464ae 100644
--- a/drivers/net/wireless/mediatek/mt7601u/phy.c
+++ b/drivers/net/wireless/mediatek/mt7601u/phy.c
@@ -986,13 +986,15 @@ static void mt7601u_agc_tune(struct mt7601u_dev *dev)
986 */ 986 */
987 spin_lock_bh(&dev->con_mon_lock); 987 spin_lock_bh(&dev->con_mon_lock);
988 avg_rssi = ewma_rssi_read(&dev->avg_rssi); 988 avg_rssi = ewma_rssi_read(&dev->avg_rssi);
989 WARN_ON_ONCE(avg_rssi == 0); 989 spin_unlock_bh(&dev->con_mon_lock);
990 if (avg_rssi == 0)
991 return;
992
990 avg_rssi = -avg_rssi; 993 avg_rssi = -avg_rssi;
991 if (avg_rssi <= -70) 994 if (avg_rssi <= -70)
992 val -= 0x20; 995 val -= 0x20;
993 else if (avg_rssi <= -60) 996 else if (avg_rssi <= -60)
994 val -= 0x10; 997 val -= 0x10;
995 spin_unlock_bh(&dev->con_mon_lock);
996 998
997 if (val != mt7601u_bbp_rr(dev, 66)) 999 if (val != mt7601u_bbp_rr(dev, 66))
998 mt7601u_bbp_wr(dev, 66, val); 1000 mt7601u_bbp_wr(dev, 66, val);
diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index 220e2b710208..ae0ca8006849 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -654,8 +654,7 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,
654 vif = qtnf_mac_get_base_vif(mac); 654 vif = qtnf_mac_get_base_vif(mac);
655 if (!vif) { 655 if (!vif) {
656 pr_err("MAC%u: primary VIF is not configured\n", mac->macid); 656 pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
657 ret = -EFAULT; 657 return -EFAULT;
658 goto out;
659 } 658 }
660 659
661 if (vif->wdev.iftype != NL80211_IFTYPE_STATION) { 660 if (vif->wdev.iftype != NL80211_IFTYPE_STATION) {
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index 39c817eddd78..54c9f6ab0c8c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -484,18 +484,21 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
484 484
485} 485}
486 486
487void rtl_deinit_deferred_work(struct ieee80211_hw *hw) 487void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq)
488{ 488{
489 struct rtl_priv *rtlpriv = rtl_priv(hw); 489 struct rtl_priv *rtlpriv = rtl_priv(hw);
490 490
491 del_timer_sync(&rtlpriv->works.watchdog_timer); 491 del_timer_sync(&rtlpriv->works.watchdog_timer);
492 492
493 cancel_delayed_work(&rtlpriv->works.watchdog_wq); 493 cancel_delayed_work_sync(&rtlpriv->works.watchdog_wq);
494 cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq); 494 if (ips_wq)
495 cancel_delayed_work(&rtlpriv->works.ps_work); 495 cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq);
496 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); 496 else
497 cancel_delayed_work(&rtlpriv->works.fwevt_wq); 497 cancel_delayed_work_sync(&rtlpriv->works.ips_nic_off_wq);
498 cancel_delayed_work(&rtlpriv->works.c2hcmd_wq); 498 cancel_delayed_work_sync(&rtlpriv->works.ps_work);
499 cancel_delayed_work_sync(&rtlpriv->works.ps_rfon_wq);
500 cancel_delayed_work_sync(&rtlpriv->works.fwevt_wq);
501 cancel_delayed_work_sync(&rtlpriv->works.c2hcmd_wq);
499} 502}
500EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work); 503EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
501 504
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.h b/drivers/net/wireless/realtek/rtlwifi/base.h
index 912f205779c3..a7ae40eaa3cd 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -121,7 +121,7 @@ void rtl_init_rfkill(struct ieee80211_hw *hw);
121void rtl_deinit_rfkill(struct ieee80211_hw *hw); 121void rtl_deinit_rfkill(struct ieee80211_hw *hw);
122 122
123void rtl_watch_dog_timer_callback(struct timer_list *t); 123void rtl_watch_dog_timer_callback(struct timer_list *t);
124void rtl_deinit_deferred_work(struct ieee80211_hw *hw); 124void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq);
125 125
126bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx); 126bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
127int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht, 127int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht,
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index cfea57efa7f4..4bf7967590ca 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -130,7 +130,6 @@ found_alt:
130 firmware->size); 130 firmware->size);
131 rtlpriv->rtlhal.wowlan_fwsize = firmware->size; 131 rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
132 } 132 }
133 rtlpriv->rtlhal.fwsize = firmware->size;
134 release_firmware(firmware); 133 release_firmware(firmware);
135} 134}
136 135
@@ -196,7 +195,7 @@ static void rtl_op_stop(struct ieee80211_hw *hw)
196 /* reset sec info */ 195 /* reset sec info */
197 rtl_cam_reset_sec_info(hw); 196 rtl_cam_reset_sec_info(hw);
198 197
199 rtl_deinit_deferred_work(hw); 198 rtl_deinit_deferred_work(hw, false);
200 } 199 }
201 rtlpriv->intf_ops->adapter_stop(hw); 200 rtlpriv->intf_ops->adapter_stop(hw);
202 201
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index ae13bcfb3bf0..5d1fda16fc8c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -2377,7 +2377,7 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
2377 ieee80211_unregister_hw(hw); 2377 ieee80211_unregister_hw(hw);
2378 rtlmac->mac80211_registered = 0; 2378 rtlmac->mac80211_registered = 0;
2379 } else { 2379 } else {
2380 rtl_deinit_deferred_work(hw); 2380 rtl_deinit_deferred_work(hw, false);
2381 rtlpriv->intf_ops->adapter_stop(hw); 2381 rtlpriv->intf_ops->adapter_stop(hw);
2382 } 2382 }
2383 rtlpriv->cfg->ops->disable_interrupt(hw); 2383 rtlpriv->cfg->ops->disable_interrupt(hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c
index 71af24e2e051..479a4cfc245d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -71,7 +71,7 @@ bool rtl_ps_disable_nic(struct ieee80211_hw *hw)
71 struct rtl_priv *rtlpriv = rtl_priv(hw); 71 struct rtl_priv *rtlpriv = rtl_priv(hw);
72 72
73 /*<1> Stop all timer */ 73 /*<1> Stop all timer */
74 rtl_deinit_deferred_work(hw); 74 rtl_deinit_deferred_work(hw, true);
75 75
76 /*<2> Disable Interrupt */ 76 /*<2> Disable Interrupt */
77 rtlpriv->cfg->ops->disable_interrupt(hw); 77 rtlpriv->cfg->ops->disable_interrupt(hw);
@@ -292,7 +292,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
292 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 292 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
293 enum rf_pwrstate rtstate; 293 enum rf_pwrstate rtstate;
294 294
295 cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq); 295 cancel_delayed_work_sync(&rtlpriv->works.ips_nic_off_wq);
296 296
297 mutex_lock(&rtlpriv->locks.ips_mutex); 297 mutex_lock(&rtlpriv->locks.ips_mutex);
298 if (ppsc->inactiveps) { 298 if (ppsc->inactiveps) {
diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index f9faffc498bc..2ac5004d7a40 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1132,7 +1132,7 @@ void rtl_usb_disconnect(struct usb_interface *intf)
1132 ieee80211_unregister_hw(hw); 1132 ieee80211_unregister_hw(hw);
1133 rtlmac->mac80211_registered = 0; 1133 rtlmac->mac80211_registered = 0;
1134 } else { 1134 } else {
1135 rtl_deinit_deferred_work(hw); 1135 rtl_deinit_deferred_work(hw, false);
1136 rtlpriv->intf_ops->adapter_stop(hw); 1136 rtlpriv->intf_ops->adapter_stop(hw);
1137 } 1137 }
1138 /*deinit rfkill */ 1138 /*deinit rfkill */
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index a57daecf1d57..2d8812dd1534 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -87,6 +87,7 @@ struct netfront_cb {
87/* IRQ name is queue name with "-tx" or "-rx" appended */ 87/* IRQ name is queue name with "-tx" or "-rx" appended */
88#define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3) 88#define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
89 89
90static DECLARE_WAIT_QUEUE_HEAD(module_load_q);
90static DECLARE_WAIT_QUEUE_HEAD(module_unload_q); 91static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
91 92
92struct netfront_stats { 93struct netfront_stats {
@@ -1330,6 +1331,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
1330 netif_carrier_off(netdev); 1331 netif_carrier_off(netdev);
1331 1332
1332 xenbus_switch_state(dev, XenbusStateInitialising); 1333 xenbus_switch_state(dev, XenbusStateInitialising);
1334 wait_event(module_load_q,
1335 xenbus_read_driver_state(dev->otherend) !=
1336 XenbusStateClosed &&
1337 xenbus_read_driver_state(dev->otherend) !=
1338 XenbusStateUnknown);
1333 return netdev; 1339 return netdev;
1334 1340
1335 exit: 1341 exit:
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 46df030b2c3f..bf65501e6ed6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -100,6 +100,22 @@ static struct class *nvme_subsys_class;
100static void nvme_ns_remove(struct nvme_ns *ns); 100static void nvme_ns_remove(struct nvme_ns *ns);
101static int nvme_revalidate_disk(struct gendisk *disk); 101static int nvme_revalidate_disk(struct gendisk *disk);
102static void nvme_put_subsystem(struct nvme_subsystem *subsys); 102static void nvme_put_subsystem(struct nvme_subsystem *subsys);
103static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
104 unsigned nsid);
105
106static void nvme_set_queue_dying(struct nvme_ns *ns)
107{
108 /*
109 * Revalidating a dead namespace sets capacity to 0. This will end
110 * buffered writers dirtying pages that can't be synced.
111 */
112 if (!ns->disk || test_and_set_bit(NVME_NS_DEAD, &ns->flags))
113 return;
114 revalidate_disk(ns->disk);
115 blk_set_queue_dying(ns->queue);
116 /* Forcibly unquiesce queues to avoid blocking dispatch */
117 blk_mq_unquiesce_queue(ns->queue);
118}
103 119
104static void nvme_queue_scan(struct nvme_ctrl *ctrl) 120static void nvme_queue_scan(struct nvme_ctrl *ctrl)
105{ 121{
@@ -1044,14 +1060,17 @@ EXPORT_SYMBOL_GPL(nvme_set_queue_count);
1044 1060
1045static void nvme_enable_aen(struct nvme_ctrl *ctrl) 1061static void nvme_enable_aen(struct nvme_ctrl *ctrl)
1046{ 1062{
1047 u32 result; 1063 u32 result, supported_aens = ctrl->oaes & NVME_AEN_SUPPORTED;
1048 int status; 1064 int status;
1049 1065
1050 status = nvme_set_features(ctrl, NVME_FEAT_ASYNC_EVENT, 1066 if (!supported_aens)
1051 ctrl->oaes & NVME_AEN_SUPPORTED, NULL, 0, &result); 1067 return;
1068
1069 status = nvme_set_features(ctrl, NVME_FEAT_ASYNC_EVENT, supported_aens,
1070 NULL, 0, &result);
1052 if (status) 1071 if (status)
1053 dev_warn(ctrl->device, "Failed to configure AEN (cfg %x)\n", 1072 dev_warn(ctrl->device, "Failed to configure AEN (cfg %x)\n",
1054 ctrl->oaes & NVME_AEN_SUPPORTED); 1073 supported_aens);
1055} 1074}
1056 1075
1057static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) 1076static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
@@ -1151,19 +1170,15 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
1151 1170
1152static void nvme_update_formats(struct nvme_ctrl *ctrl) 1171static void nvme_update_formats(struct nvme_ctrl *ctrl)
1153{ 1172{
1154 struct nvme_ns *ns, *next; 1173 struct nvme_ns *ns;
1155 LIST_HEAD(rm_list);
1156 1174
1157 down_write(&ctrl->namespaces_rwsem); 1175 down_read(&ctrl->namespaces_rwsem);
1158 list_for_each_entry(ns, &ctrl->namespaces, list) { 1176 list_for_each_entry(ns, &ctrl->namespaces, list)
1159 if (ns->disk && nvme_revalidate_disk(ns->disk)) { 1177 if (ns->disk && nvme_revalidate_disk(ns->disk))
1160 list_move_tail(&ns->list, &rm_list); 1178 nvme_set_queue_dying(ns);
1161 } 1179 up_read(&ctrl->namespaces_rwsem);
1162 }
1163 up_write(&ctrl->namespaces_rwsem);
1164 1180
1165 list_for_each_entry_safe(ns, next, &rm_list, list) 1181 nvme_remove_invalid_namespaces(ctrl, NVME_NSID_ALL);
1166 nvme_ns_remove(ns);
1167} 1182}
1168 1183
1169static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) 1184static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects)
@@ -1218,7 +1233,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
1218 effects = nvme_passthru_start(ctrl, ns, cmd.opcode); 1233 effects = nvme_passthru_start(ctrl, ns, cmd.opcode);
1219 status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c, 1234 status = nvme_submit_user_cmd(ns ? ns->queue : ctrl->admin_q, &c,
1220 (void __user *)(uintptr_t)cmd.addr, cmd.data_len, 1235 (void __user *)(uintptr_t)cmd.addr, cmd.data_len,
1221 (void __user *)(uintptr_t)cmd.metadata, cmd.metadata, 1236 (void __user *)(uintptr_t)cmd.metadata, cmd.metadata_len,
1222 0, &cmd.result, timeout); 1237 0, &cmd.result, timeout);
1223 nvme_passthru_end(ctrl, effects); 1238 nvme_passthru_end(ctrl, effects);
1224 1239
@@ -3138,7 +3153,7 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
3138 3153
3139 down_write(&ctrl->namespaces_rwsem); 3154 down_write(&ctrl->namespaces_rwsem);
3140 list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) { 3155 list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) {
3141 if (ns->head->ns_id > nsid) 3156 if (ns->head->ns_id > nsid || test_bit(NVME_NS_DEAD, &ns->flags))
3142 list_move_tail(&ns->list, &rm_list); 3157 list_move_tail(&ns->list, &rm_list);
3143 } 3158 }
3144 up_write(&ctrl->namespaces_rwsem); 3159 up_write(&ctrl->namespaces_rwsem);
@@ -3542,19 +3557,9 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl)
3542 if (ctrl->admin_q) 3557 if (ctrl->admin_q)
3543 blk_mq_unquiesce_queue(ctrl->admin_q); 3558 blk_mq_unquiesce_queue(ctrl->admin_q);
3544 3559
3545 list_for_each_entry(ns, &ctrl->namespaces, list) { 3560 list_for_each_entry(ns, &ctrl->namespaces, list)
3546 /* 3561 nvme_set_queue_dying(ns);
3547 * Revalidating a dead namespace sets capacity to 0. This will
3548 * end buffered writers dirtying pages that can't be synced.
3549 */
3550 if (!ns->disk || test_and_set_bit(NVME_NS_DEAD, &ns->flags))
3551 continue;
3552 revalidate_disk(ns->disk);
3553 blk_set_queue_dying(ns->queue);
3554 3562
3555 /* Forcibly unquiesce queues to avoid blocking dispatch */
3556 blk_mq_unquiesce_queue(ns->queue);
3557 }
3558 up_read(&ctrl->namespaces_rwsem); 3563 up_read(&ctrl->namespaces_rwsem);
3559} 3564}
3560EXPORT_SYMBOL_GPL(nvme_kill_queues); 3565EXPORT_SYMBOL_GPL(nvme_kill_queues);
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 903eb4545e26..f7efe5a58cc7 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -539,14 +539,18 @@ static struct nvmf_transport_ops *nvmf_lookup_transport(
539/* 539/*
540 * For something we're not in a state to send to the device the default action 540 * For something we're not in a state to send to the device the default action
541 * is to busy it and retry it after the controller state is recovered. However, 541 * is to busy it and retry it after the controller state is recovered. However,
542 * anything marked for failfast or nvme multipath is immediately failed. 542 * if the controller is deleting or if anything is marked for failfast or
543 * nvme multipath it is immediately failed.
543 * 544 *
544 * Note: commands used to initialize the controller will be marked for failfast. 545 * Note: commands used to initialize the controller will be marked for failfast.
545 * Note: nvme cli/ioctl commands are marked for failfast. 546 * Note: nvme cli/ioctl commands are marked for failfast.
546 */ 547 */
547blk_status_t nvmf_fail_nonready_command(struct request *rq) 548blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl,
549 struct request *rq)
548{ 550{
549 if (!blk_noretry_request(rq) && !(rq->cmd_flags & REQ_NVME_MPATH)) 551 if (ctrl->state != NVME_CTRL_DELETING &&
552 ctrl->state != NVME_CTRL_DEAD &&
553 !blk_noretry_request(rq) && !(rq->cmd_flags & REQ_NVME_MPATH))
550 return BLK_STS_RESOURCE; 554 return BLK_STS_RESOURCE;
551 nvme_req(rq)->status = NVME_SC_ABORT_REQ; 555 nvme_req(rq)->status = NVME_SC_ABORT_REQ;
552 return BLK_STS_IOERR; 556 return BLK_STS_IOERR;
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index e1818a27aa2d..aa2fdb2a2e8f 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -162,7 +162,8 @@ void nvmf_unregister_transport(struct nvmf_transport_ops *ops);
162void nvmf_free_options(struct nvmf_ctrl_options *opts); 162void nvmf_free_options(struct nvmf_ctrl_options *opts);
163int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size); 163int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size);
164bool nvmf_should_reconnect(struct nvme_ctrl *ctrl); 164bool nvmf_should_reconnect(struct nvme_ctrl *ctrl);
165blk_status_t nvmf_fail_nonready_command(struct request *rq); 165blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl,
166 struct request *rq);
166bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq, 167bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
167 bool queue_live); 168 bool queue_live);
168 169
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 41d45a1b5c62..9bac912173ba 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2272,7 +2272,7 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx,
2272 2272
2273 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE || 2273 if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE ||
2274 !nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) 2274 !nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready))
2275 return nvmf_fail_nonready_command(rq); 2275 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, rq);
2276 2276
2277 ret = nvme_setup_cmd(ns, rq, sqe); 2277 ret = nvme_setup_cmd(ns, rq, sqe);
2278 if (ret) 2278 if (ret)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index ba943f211687..ddd441b1516a 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2556,11 +2556,6 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2556 2556
2557 quirks |= check_vendor_combination_bug(pdev); 2557 quirks |= check_vendor_combination_bug(pdev);
2558 2558
2559 result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops,
2560 quirks);
2561 if (result)
2562 goto release_pools;
2563
2564 /* 2559 /*
2565 * Double check that our mempool alloc size will cover the biggest 2560 * Double check that our mempool alloc size will cover the biggest
2566 * command we support. 2561 * command we support.
@@ -2578,6 +2573,11 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2578 goto release_pools; 2573 goto release_pools;
2579 } 2574 }
2580 2575
2576 result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops,
2577 quirks);
2578 if (result)
2579 goto release_mempool;
2580
2581 dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev)); 2581 dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
2582 2582
2583 nvme_get_ctrl(&dev->ctrl); 2583 nvme_get_ctrl(&dev->ctrl);
@@ -2585,6 +2585,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2585 2585
2586 return 0; 2586 return 0;
2587 2587
2588 release_mempool:
2589 mempool_destroy(dev->iod_mempool);
2588 release_pools: 2590 release_pools:
2589 nvme_release_prp_pools(dev); 2591 nvme_release_prp_pools(dev);
2590 unmap: 2592 unmap:
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 518c5b09038c..66ec5985c9f3 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1639,7 +1639,7 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
1639 WARN_ON_ONCE(rq->tag < 0); 1639 WARN_ON_ONCE(rq->tag < 0);
1640 1640
1641 if (!nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready)) 1641 if (!nvmf_check_ready(&queue->ctrl->ctrl, rq, queue_ready))
1642 return nvmf_fail_nonready_command(rq); 1642 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, rq);
1643 1643
1644 dev = queue->device->dev; 1644 dev = queue->device->dev;
1645 ib_dma_sync_single_for_cpu(dev, sqe->dma, 1645 ib_dma_sync_single_for_cpu(dev, sqe->dma,
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index d3f3b3ec4d1a..ebea1373d1b7 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -282,6 +282,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
282{ 282{
283 struct nvmet_ns *ns = to_nvmet_ns(item); 283 struct nvmet_ns *ns = to_nvmet_ns(item);
284 struct nvmet_subsys *subsys = ns->subsys; 284 struct nvmet_subsys *subsys = ns->subsys;
285 size_t len;
285 int ret; 286 int ret;
286 287
287 mutex_lock(&subsys->lock); 288 mutex_lock(&subsys->lock);
@@ -289,10 +290,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
289 if (ns->enabled) 290 if (ns->enabled)
290 goto out_unlock; 291 goto out_unlock;
291 292
292 kfree(ns->device_path); 293 ret = -EINVAL;
294 len = strcspn(page, "\n");
295 if (!len)
296 goto out_unlock;
293 297
298 kfree(ns->device_path);
294 ret = -ENOMEM; 299 ret = -ENOMEM;
295 ns->device_path = kstrndup(page, strcspn(page, "\n"), GFP_KERNEL); 300 ns->device_path = kstrndup(page, len, GFP_KERNEL);
296 if (!ns->device_path) 301 if (!ns->device_path)
297 goto out_unlock; 302 goto out_unlock;
298 303
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 74d4b785d2da..9838103f2d62 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -339,7 +339,7 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
339 goto out_unlock; 339 goto out_unlock;
340 340
341 ret = nvmet_bdev_ns_enable(ns); 341 ret = nvmet_bdev_ns_enable(ns);
342 if (ret) 342 if (ret == -ENOTBLK)
343 ret = nvmet_file_ns_enable(ns); 343 ret = nvmet_file_ns_enable(ns);
344 if (ret) 344 if (ret)
345 goto out_unlock; 345 goto out_unlock;
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 408279cb6f2c..29b4b236afd8 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -58,8 +58,8 @@ struct nvmet_fc_ls_iod {
58 struct work_struct work; 58 struct work_struct work;
59} __aligned(sizeof(unsigned long long)); 59} __aligned(sizeof(unsigned long long));
60 60
61/* desired maximum for a single sequence - if sg list allows it */
61#define NVMET_FC_MAX_SEQ_LENGTH (256 * 1024) 62#define NVMET_FC_MAX_SEQ_LENGTH (256 * 1024)
62#define NVMET_FC_MAX_XFR_SGENTS (NVMET_FC_MAX_SEQ_LENGTH / PAGE_SIZE)
63 63
64enum nvmet_fcp_datadir { 64enum nvmet_fcp_datadir {
65 NVMET_FCP_NODATA, 65 NVMET_FCP_NODATA,
@@ -74,6 +74,7 @@ struct nvmet_fc_fcp_iod {
74 struct nvme_fc_cmd_iu cmdiubuf; 74 struct nvme_fc_cmd_iu cmdiubuf;
75 struct nvme_fc_ersp_iu rspiubuf; 75 struct nvme_fc_ersp_iu rspiubuf;
76 dma_addr_t rspdma; 76 dma_addr_t rspdma;
77 struct scatterlist *next_sg;
77 struct scatterlist *data_sg; 78 struct scatterlist *data_sg;
78 int data_sg_cnt; 79 int data_sg_cnt;
79 u32 offset; 80 u32 offset;
@@ -1025,8 +1026,7 @@ nvmet_fc_register_targetport(struct nvmet_fc_port_info *pinfo,
1025 INIT_LIST_HEAD(&newrec->assoc_list); 1026 INIT_LIST_HEAD(&newrec->assoc_list);
1026 kref_init(&newrec->ref); 1027 kref_init(&newrec->ref);
1027 ida_init(&newrec->assoc_cnt); 1028 ida_init(&newrec->assoc_cnt);
1028 newrec->max_sg_cnt = min_t(u32, NVMET_FC_MAX_XFR_SGENTS, 1029 newrec->max_sg_cnt = template->max_sgl_segments;
1029 template->max_sgl_segments);
1030 1030
1031 ret = nvmet_fc_alloc_ls_iodlist(newrec); 1031 ret = nvmet_fc_alloc_ls_iodlist(newrec);
1032 if (ret) { 1032 if (ret) {
@@ -1722,6 +1722,7 @@ nvmet_fc_alloc_tgt_pgs(struct nvmet_fc_fcp_iod *fod)
1722 ((fod->io_dir == NVMET_FCP_WRITE) ? 1722 ((fod->io_dir == NVMET_FCP_WRITE) ?
1723 DMA_FROM_DEVICE : DMA_TO_DEVICE)); 1723 DMA_FROM_DEVICE : DMA_TO_DEVICE));
1724 /* note: write from initiator perspective */ 1724 /* note: write from initiator perspective */
1725 fod->next_sg = fod->data_sg;
1725 1726
1726 return 0; 1727 return 0;
1727 1728
@@ -1866,24 +1867,49 @@ nvmet_fc_transfer_fcp_data(struct nvmet_fc_tgtport *tgtport,
1866 struct nvmet_fc_fcp_iod *fod, u8 op) 1867 struct nvmet_fc_fcp_iod *fod, u8 op)
1867{ 1868{
1868 struct nvmefc_tgt_fcp_req *fcpreq = fod->fcpreq; 1869 struct nvmefc_tgt_fcp_req *fcpreq = fod->fcpreq;
1870 struct scatterlist *sg = fod->next_sg;
1869 unsigned long flags; 1871 unsigned long flags;
1870 u32 tlen; 1872 u32 remaininglen = fod->req.transfer_len - fod->offset;
1873 u32 tlen = 0;
1871 int ret; 1874 int ret;
1872 1875
1873 fcpreq->op = op; 1876 fcpreq->op = op;
1874 fcpreq->offset = fod->offset; 1877 fcpreq->offset = fod->offset;
1875 fcpreq->timeout = NVME_FC_TGTOP_TIMEOUT_SEC; 1878 fcpreq->timeout = NVME_FC_TGTOP_TIMEOUT_SEC;
1876 1879
1877 tlen = min_t(u32, tgtport->max_sg_cnt * PAGE_SIZE, 1880 /*
1878 (fod->req.transfer_len - fod->offset)); 1881 * for next sequence:
1882 * break at a sg element boundary
1883 * attempt to keep sequence length capped at
1884 * NVMET_FC_MAX_SEQ_LENGTH but allow sequence to
1885 * be longer if a single sg element is larger
1886 * than that amount. This is done to avoid creating
1887 * a new sg list to use for the tgtport api.
1888 */
1889 fcpreq->sg = sg;
1890 fcpreq->sg_cnt = 0;
1891 while (tlen < remaininglen &&
1892 fcpreq->sg_cnt < tgtport->max_sg_cnt &&
1893 tlen + sg_dma_len(sg) < NVMET_FC_MAX_SEQ_LENGTH) {
1894 fcpreq->sg_cnt++;
1895 tlen += sg_dma_len(sg);
1896 sg = sg_next(sg);
1897 }
1898 if (tlen < remaininglen && fcpreq->sg_cnt == 0) {
1899 fcpreq->sg_cnt++;
1900 tlen += min_t(u32, sg_dma_len(sg), remaininglen);
1901 sg = sg_next(sg);
1902 }
1903 if (tlen < remaininglen)
1904 fod->next_sg = sg;
1905 else
1906 fod->next_sg = NULL;
1907
1879 fcpreq->transfer_length = tlen; 1908 fcpreq->transfer_length = tlen;
1880 fcpreq->transferred_length = 0; 1909 fcpreq->transferred_length = 0;
1881 fcpreq->fcp_error = 0; 1910 fcpreq->fcp_error = 0;
1882 fcpreq->rsplen = 0; 1911 fcpreq->rsplen = 0;
1883 1912
1884 fcpreq->sg = &fod->data_sg[fod->offset / PAGE_SIZE];
1885 fcpreq->sg_cnt = DIV_ROUND_UP(tlen, PAGE_SIZE);
1886
1887 /* 1913 /*
1888 * If the last READDATA request: check if LLDD supports 1914 * If the last READDATA request: check if LLDD supports
1889 * combined xfr with response. 1915 * combined xfr with response.
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index d8d91f04bd7e..ae7586b8be07 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -162,7 +162,7 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
162 blk_status_t ret; 162 blk_status_t ret;
163 163
164 if (!nvmf_check_ready(&queue->ctrl->ctrl, req, queue_ready)) 164 if (!nvmf_check_ready(&queue->ctrl->ctrl, req, queue_ready))
165 return nvmf_fail_nonready_command(req); 165 return nvmf_fail_nonready_command(&queue->ctrl->ctrl, req);
166 166
167 ret = nvme_setup_cmd(ns, req, &iod->cmd); 167 ret = nvme_setup_cmd(ns, req, &iod->cmd);
168 if (ret) 168 if (ret)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 848f549164cd..466e3c8582f0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -102,7 +102,7 @@ static u32 phandle_cache_mask;
102 * - the phandle lookup overhead reduction provided by the cache 102 * - the phandle lookup overhead reduction provided by the cache
103 * will likely be less 103 * will likely be less
104 */ 104 */
105static void of_populate_phandle_cache(void) 105void of_populate_phandle_cache(void)
106{ 106{
107 unsigned long flags; 107 unsigned long flags;
108 u32 cache_entries; 108 u32 cache_entries;
@@ -134,8 +134,7 @@ out:
134 raw_spin_unlock_irqrestore(&devtree_lock, flags); 134 raw_spin_unlock_irqrestore(&devtree_lock, flags);
135} 135}
136 136
137#ifndef CONFIG_MODULES 137int of_free_phandle_cache(void)
138static int __init of_free_phandle_cache(void)
139{ 138{
140 unsigned long flags; 139 unsigned long flags;
141 140
@@ -148,6 +147,7 @@ static int __init of_free_phandle_cache(void)
148 147
149 return 0; 148 return 0;
150} 149}
150#if !defined(CONFIG_MODULES)
151late_initcall_sync(of_free_phandle_cache); 151late_initcall_sync(of_free_phandle_cache);
152#endif 152#endif
153 153
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 891d780c076a..216175d11d3d 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -79,6 +79,8 @@ int of_resolve_phandles(struct device_node *tree);
79#if defined(CONFIG_OF_OVERLAY) 79#if defined(CONFIG_OF_OVERLAY)
80void of_overlay_mutex_lock(void); 80void of_overlay_mutex_lock(void);
81void of_overlay_mutex_unlock(void); 81void of_overlay_mutex_unlock(void);
82int of_free_phandle_cache(void);
83void of_populate_phandle_cache(void);
82#else 84#else
83static inline void of_overlay_mutex_lock(void) {}; 85static inline void of_overlay_mutex_lock(void) {};
84static inline void of_overlay_mutex_unlock(void) {}; 86static inline void of_overlay_mutex_unlock(void) {};
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 7baa53e5b1d7..eda57ef12fd0 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -804,6 +804,8 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree,
804 goto err_free_overlay_changeset; 804 goto err_free_overlay_changeset;
805 } 805 }
806 806
807 of_populate_phandle_cache();
808
807 ret = __of_changeset_apply_notify(&ovcs->cset); 809 ret = __of_changeset_apply_notify(&ovcs->cset);
808 if (ret) 810 if (ret)
809 pr_err("overlay changeset entry notify error %d\n", ret); 811 pr_err("overlay changeset entry notify error %d\n", ret);
@@ -1046,8 +1048,17 @@ int of_overlay_remove(int *ovcs_id)
1046 1048
1047 list_del(&ovcs->ovcs_list); 1049 list_del(&ovcs->ovcs_list);
1048 1050
1051 /*
1052 * Disable phandle cache. Avoids race condition that would arise
1053 * from removing cache entry when the associated node is deleted.
1054 */
1055 of_free_phandle_cache();
1056
1049 ret_apply = 0; 1057 ret_apply = 0;
1050 ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply); 1058 ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply);
1059
1060 of_populate_phandle_cache();
1061
1051 if (ret) { 1062 if (ret) {
1052 if (ret_apply) 1063 if (ret_apply)
1053 devicetree_state_flags |= DTSF_REVERT_FAIL; 1064 devicetree_state_flags |= DTSF_REVERT_FAIL;
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 35b7fc87eac5..5cb40b2518f9 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -330,7 +330,7 @@ void pci_bus_add_device(struct pci_dev *dev)
330 return; 330 return;
331 } 331 }
332 332
333 dev->is_added = 1; 333 pci_dev_assign_added(dev, true);
334} 334}
335EXPORT_SYMBOL_GPL(pci_bus_add_device); 335EXPORT_SYMBOL_GPL(pci_bus_add_device);
336 336
@@ -347,14 +347,14 @@ void pci_bus_add_devices(const struct pci_bus *bus)
347 347
348 list_for_each_entry(dev, &bus->devices, bus_list) { 348 list_for_each_entry(dev, &bus->devices, bus_list) {
349 /* Skip already-added devices */ 349 /* Skip already-added devices */
350 if (dev->is_added) 350 if (pci_dev_is_added(dev))
351 continue; 351 continue;
352 pci_bus_add_device(dev); 352 pci_bus_add_device(dev);
353 } 353 }
354 354
355 list_for_each_entry(dev, &bus->devices, bus_list) { 355 list_for_each_entry(dev, &bus->devices, bus_list) {
356 /* Skip if device attach failed */ 356 /* Skip if device attach failed */
357 if (!dev->is_added) 357 if (!pci_dev_is_added(dev))
358 continue; 358 continue;
359 child = dev->subordinate; 359 child = dev->subordinate;
360 if (child) 360 if (child)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 781aa03aeede..29a05759a294 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -363,7 +363,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
363 resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { 363 resource_list_for_each_entry_safe(win, tmp, &bridge->windows) {
364 switch (resource_type(win->res)) { 364 switch (resource_type(win->res)) {
365 case IORESOURCE_IO: 365 case IORESOURCE_IO:
366 ret = pci_remap_iospace(win->res, pp->io_base); 366 ret = devm_pci_remap_iospace(dev, win->res,
367 pp->io_base);
367 if (ret) { 368 if (ret) {
368 dev_warn(dev, "Error %d: failed to map resource %pR\n", 369 dev_warn(dev, "Error %d: failed to map resource %pR\n",
369 ret, win->res); 370 ret, win->res);
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
index d3172d5d3d35..0fae816fba39 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -849,7 +849,7 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
849 0, 0xF8000000, 0, 849 0, 0xF8000000, 0,
850 lower_32_bits(res->start), 850 lower_32_bits(res->start),
851 OB_PCIE_IO); 851 OB_PCIE_IO);
852 err = pci_remap_iospace(res, iobase); 852 err = devm_pci_remap_iospace(dev, res, iobase);
853 if (err) { 853 if (err) {
854 dev_warn(dev, "error %d: failed to map resource %pR\n", 854 dev_warn(dev, "error %d: failed to map resource %pR\n",
855 err, res); 855 err, res);
diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c
index 20bb2564a6b3..bf5ece5d9291 100644
--- a/drivers/pci/controller/pci-ftpci100.c
+++ b/drivers/pci/controller/pci-ftpci100.c
@@ -503,7 +503,7 @@ static int faraday_pci_probe(struct platform_device *pdev)
503 dev_err(dev, "illegal IO mem size\n"); 503 dev_err(dev, "illegal IO mem size\n");
504 return -EINVAL; 504 return -EINVAL;
505 } 505 }
506 ret = pci_remap_iospace(io, io_base); 506 ret = devm_pci_remap_iospace(dev, io, io_base);
507 if (ret) { 507 if (ret) {
508 dev_warn(dev, "error %d: failed to map resource %pR\n", 508 dev_warn(dev, "error %d: failed to map resource %pR\n",
509 ret, io); 509 ret, io);
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 6cc5036ac83c..f6325f1a89e8 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1073,6 +1073,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
1073 struct pci_bus *pbus; 1073 struct pci_bus *pbus;
1074 struct pci_dev *pdev; 1074 struct pci_dev *pdev;
1075 struct cpumask *dest; 1075 struct cpumask *dest;
1076 unsigned long flags;
1076 struct compose_comp_ctxt comp; 1077 struct compose_comp_ctxt comp;
1077 struct tran_int_desc *int_desc; 1078 struct tran_int_desc *int_desc;
1078 struct { 1079 struct {
@@ -1164,14 +1165,15 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
1164 * the channel callback directly when channel->target_cpu is 1165 * the channel callback directly when channel->target_cpu is
1165 * the current CPU. When the higher level interrupt code 1166 * the current CPU. When the higher level interrupt code
1166 * calls us with interrupt enabled, let's add the 1167 * calls us with interrupt enabled, let's add the
1167 * local_bh_disable()/enable() to avoid race. 1168 * local_irq_save()/restore() to avoid race:
1169 * hv_pci_onchannelcallback() can also run in tasklet.
1168 */ 1170 */
1169 local_bh_disable(); 1171 local_irq_save(flags);
1170 1172
1171 if (hbus->hdev->channel->target_cpu == smp_processor_id()) 1173 if (hbus->hdev->channel->target_cpu == smp_processor_id())
1172 hv_pci_onchannelcallback(hbus); 1174 hv_pci_onchannelcallback(hbus);
1173 1175
1174 local_bh_enable(); 1176 local_irq_restore(flags);
1175 1177
1176 if (hpdev->state == hv_pcichild_ejecting) { 1178 if (hpdev->state == hv_pcichild_ejecting) {
1177 dev_err_once(&hbus->hdev->device, 1179 dev_err_once(&hbus->hdev->device,
diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c
index 68b8bfbdb867..d219404bad92 100644
--- a/drivers/pci/controller/pci-v3-semi.c
+++ b/drivers/pci/controller/pci-v3-semi.c
@@ -537,7 +537,7 @@ static int v3_pci_setup_resource(struct v3_pci *v3,
537 v3->io_bus_addr = io->start - win->offset; 537 v3->io_bus_addr = io->start - win->offset;
538 dev_dbg(dev, "I/O window %pR, bus addr %pap\n", 538 dev_dbg(dev, "I/O window %pR, bus addr %pap\n",
539 io, &v3->io_bus_addr); 539 io, &v3->io_bus_addr);
540 ret = pci_remap_iospace(io, io_base); 540 ret = devm_pci_remap_iospace(dev, io, io_base);
541 if (ret) { 541 if (ret) {
542 dev_warn(dev, 542 dev_warn(dev,
543 "error %d: failed to map resource %pR\n", 543 "error %d: failed to map resource %pR\n",
diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c
index 994f32061b32..f59ad2728c0b 100644
--- a/drivers/pci/controller/pci-versatile.c
+++ b/drivers/pci/controller/pci-versatile.c
@@ -82,7 +82,7 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev,
82 82
83 switch (resource_type(res)) { 83 switch (resource_type(res)) {
84 case IORESOURCE_IO: 84 case IORESOURCE_IO:
85 err = pci_remap_iospace(res, iobase); 85 err = devm_pci_remap_iospace(dev, res, iobase);
86 if (err) { 86 if (err) {
87 dev_warn(dev, "error %d: failed to map resource %pR\n", 87 dev_warn(dev, "error %d: failed to map resource %pR\n",
88 err, res); 88 err, res);
diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index d854d67e873c..ffda3e8b4742 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -423,7 +423,7 @@ static int xgene_pcie_map_ranges(struct xgene_pcie_port *port,
423 case IORESOURCE_IO: 423 case IORESOURCE_IO:
424 xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base, 424 xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base,
425 res->start - window->offset); 425 res->start - window->offset);
426 ret = pci_remap_iospace(res, io_base); 426 ret = devm_pci_remap_iospace(dev, res, io_base);
427 if (ret < 0) 427 if (ret < 0)
428 return ret; 428 return ret;
429 break; 429 break;
diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
index 0baabe30858f..861dda69f366 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -1109,7 +1109,7 @@ static int mtk_pcie_request_resources(struct mtk_pcie *pcie)
1109 if (err < 0) 1109 if (err < 0)
1110 return err; 1110 return err;
1111 1111
1112 pci_remap_iospace(&pcie->pio, pcie->io.start); 1112 devm_pci_remap_iospace(dev, &pcie->pio, pcie->io.start);
1113 1113
1114 return 0; 1114 return 0;
1115} 1115}
diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c
index 4d6c20e47bed..cf0aa7cee5b0 100644
--- a/drivers/pci/controller/pcie-mobiveil.c
+++ b/drivers/pci/controller/pcie-mobiveil.c
@@ -107,7 +107,7 @@
107#define CFG_WINDOW_TYPE 0 107#define CFG_WINDOW_TYPE 0
108#define IO_WINDOW_TYPE 1 108#define IO_WINDOW_TYPE 1
109#define MEM_WINDOW_TYPE 2 109#define MEM_WINDOW_TYPE 2
110#define IB_WIN_SIZE (256 * 1024 * 1024 * 1024) 110#define IB_WIN_SIZE ((u64)256 * 1024 * 1024 * 1024)
111#define MAX_PIO_WINDOWS 8 111#define MAX_PIO_WINDOWS 8
112 112
113/* Parameters for the waiting for link up routine */ 113/* Parameters for the waiting for link up routine */
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
index bf53fad636a5..825fa24427a3 100644
--- a/drivers/pci/endpoint/pci-epf-core.c
+++ b/drivers/pci/endpoint/pci-epf-core.c
@@ -137,25 +137,60 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar)
137} 137}
138EXPORT_SYMBOL_GPL(pci_epf_alloc_space); 138EXPORT_SYMBOL_GPL(pci_epf_alloc_space);
139 139
140/** 140static void pci_epf_remove_cfs(struct pci_epf_driver *driver)
141 * pci_epf_unregister_driver() - unregister the PCI EPF driver
142 * @driver: the PCI EPF driver that has to be unregistered
143 *
144 * Invoke to unregister the PCI EPF driver.
145 */
146void pci_epf_unregister_driver(struct pci_epf_driver *driver)
147{ 141{
148 struct config_group *group, *tmp; 142 struct config_group *group, *tmp;
149 143
144 if (!IS_ENABLED(CONFIG_PCI_ENDPOINT_CONFIGFS))
145 return;
146
150 mutex_lock(&pci_epf_mutex); 147 mutex_lock(&pci_epf_mutex);
151 list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry) 148 list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry)
152 pci_ep_cfs_remove_epf_group(group); 149 pci_ep_cfs_remove_epf_group(group);
153 list_del(&driver->epf_group); 150 list_del(&driver->epf_group);
154 mutex_unlock(&pci_epf_mutex); 151 mutex_unlock(&pci_epf_mutex);
152}
153
154/**
155 * pci_epf_unregister_driver() - unregister the PCI EPF driver
156 * @driver: the PCI EPF driver that has to be unregistered
157 *
158 * Invoke to unregister the PCI EPF driver.
159 */
160void pci_epf_unregister_driver(struct pci_epf_driver *driver)
161{
162 pci_epf_remove_cfs(driver);
155 driver_unregister(&driver->driver); 163 driver_unregister(&driver->driver);
156} 164}
157EXPORT_SYMBOL_GPL(pci_epf_unregister_driver); 165EXPORT_SYMBOL_GPL(pci_epf_unregister_driver);
158 166
167static int pci_epf_add_cfs(struct pci_epf_driver *driver)
168{
169 struct config_group *group;
170 const struct pci_epf_device_id *id;
171
172 if (!IS_ENABLED(CONFIG_PCI_ENDPOINT_CONFIGFS))
173 return 0;
174
175 INIT_LIST_HEAD(&driver->epf_group);
176
177 id = driver->id_table;
178 while (id->name[0]) {
179 group = pci_ep_cfs_add_epf_group(id->name);
180 if (IS_ERR(group)) {
181 pci_epf_remove_cfs(driver);
182 return PTR_ERR(group);
183 }
184
185 mutex_lock(&pci_epf_mutex);
186 list_add_tail(&group->group_entry, &driver->epf_group);
187 mutex_unlock(&pci_epf_mutex);
188 id++;
189 }
190
191 return 0;
192}
193
159/** 194/**
160 * __pci_epf_register_driver() - register a new PCI EPF driver 195 * __pci_epf_register_driver() - register a new PCI EPF driver
161 * @driver: structure representing PCI EPF driver 196 * @driver: structure representing PCI EPF driver
@@ -167,8 +202,6 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver,
167 struct module *owner) 202 struct module *owner)
168{ 203{
169 int ret; 204 int ret;
170 struct config_group *group;
171 const struct pci_epf_device_id *id;
172 205
173 if (!driver->ops) 206 if (!driver->ops)
174 return -EINVAL; 207 return -EINVAL;
@@ -183,16 +216,7 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver,
183 if (ret) 216 if (ret)
184 return ret; 217 return ret;
185 218
186 INIT_LIST_HEAD(&driver->epf_group); 219 pci_epf_add_cfs(driver);
187
188 id = driver->id_table;
189 while (id->name[0]) {
190 group = pci_ep_cfs_add_epf_group(id->name);
191 mutex_lock(&pci_epf_mutex);
192 list_add_tail(&group->group_entry, &driver->epf_group);
193 mutex_unlock(&pci_epf_mutex);
194 id++;
195 }
196 220
197 return 0; 221 return 0;
198} 222}
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3a17b290df5d..ef0b1b6ba86f 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -509,7 +509,7 @@ static void enable_slot(struct acpiphp_slot *slot)
509 509
510 list_for_each_entry(dev, &bus->devices, bus_list) { 510 list_for_each_entry(dev, &bus->devices, bus_list) {
511 /* Assume that newly added devices are powered on already. */ 511 /* Assume that newly added devices are powered on already. */
512 if (!dev->is_added) 512 if (!pci_dev_is_added(dev))
513 dev->current_state = PCI_D0; 513 dev->current_state = PCI_D0;
514 } 514 }
515 515
diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index d088c9147f10..69a60d6ebd73 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -612,7 +612,7 @@ int pci_parse_request_of_pci_ranges(struct device *dev,
612 612
613 switch (resource_type(res)) { 613 switch (resource_type(res)) {
614 case IORESOURCE_IO: 614 case IORESOURCE_IO:
615 err = pci_remap_iospace(res, iobase); 615 err = devm_pci_remap_iospace(dev, res, iobase);
616 if (err) { 616 if (err) {
617 dev_warn(dev, "error %d: failed to map resource %pR\n", 617 dev_warn(dev, "error %d: failed to map resource %pR\n",
618 err, res); 618 err, res);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 97acba712e4e..316496e99da9 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3579,6 +3579,44 @@ void pci_unmap_iospace(struct resource *res)
3579} 3579}
3580EXPORT_SYMBOL(pci_unmap_iospace); 3580EXPORT_SYMBOL(pci_unmap_iospace);
3581 3581
3582static void devm_pci_unmap_iospace(struct device *dev, void *ptr)
3583{
3584 struct resource **res = ptr;
3585
3586 pci_unmap_iospace(*res);
3587}
3588
3589/**
3590 * devm_pci_remap_iospace - Managed pci_remap_iospace()
3591 * @dev: Generic device to remap IO address for
3592 * @res: Resource describing the I/O space
3593 * @phys_addr: physical address of range to be mapped
3594 *
3595 * Managed pci_remap_iospace(). Map is automatically unmapped on driver
3596 * detach.
3597 */
3598int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
3599 phys_addr_t phys_addr)
3600{
3601 const struct resource **ptr;
3602 int error;
3603
3604 ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL);
3605 if (!ptr)
3606 return -ENOMEM;
3607
3608 error = pci_remap_iospace(res, phys_addr);
3609 if (error) {
3610 devres_free(ptr);
3611 } else {
3612 *ptr = res;
3613 devres_add(dev, ptr);
3614 }
3615
3616 return error;
3617}
3618EXPORT_SYMBOL(devm_pci_remap_iospace);
3619
3582/** 3620/**
3583 * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace() 3621 * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
3584 * @dev: Generic device to remap IO address for 3622 * @dev: Generic device to remap IO address for
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 882f1f9596df..08817253c8a2 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -288,6 +288,7 @@ struct pci_sriov {
288 288
289/* pci_dev priv_flags */ 289/* pci_dev priv_flags */
290#define PCI_DEV_DISCONNECTED 0 290#define PCI_DEV_DISCONNECTED 0
291#define PCI_DEV_ADDED 1
291 292
292static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused) 293static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused)
293{ 294{
@@ -300,6 +301,16 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
300 return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags); 301 return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags);
301} 302}
302 303
304static inline void pci_dev_assign_added(struct pci_dev *dev, bool added)
305{
306 assign_bit(PCI_DEV_ADDED, &dev->priv_flags, added);
307}
308
309static inline bool pci_dev_is_added(const struct pci_dev *dev)
310{
311 return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
312}
313
303#ifdef CONFIG_PCI_ATS 314#ifdef CONFIG_PCI_ATS
304void pci_restore_ats_state(struct pci_dev *dev); 315void pci_restore_ats_state(struct pci_dev *dev);
305#else 316#else
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index f7ce0cb0b0b7..f02e334beb45 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -295,6 +295,7 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service)
295 295
296 parent = udev->subordinate; 296 parent = udev->subordinate;
297 pci_lock_rescan_remove(); 297 pci_lock_rescan_remove();
298 pci_dev_get(dev);
298 list_for_each_entry_safe_reverse(pdev, temp, &parent->devices, 299 list_for_each_entry_safe_reverse(pdev, temp, &parent->devices,
299 bus_list) { 300 bus_list) {
300 pci_dev_get(pdev); 301 pci_dev_get(pdev);
@@ -328,6 +329,7 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service)
328 pci_info(dev, "Device recovery from fatal error failed\n"); 329 pci_info(dev, "Device recovery from fatal error failed\n");
329 } 330 }
330 331
332 pci_dev_put(dev);
331 pci_unlock_rescan_remove(); 333 pci_unlock_rescan_remove();
332} 334}
333 335
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ac876e32de4b..611adcd9c169 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2433,13 +2433,13 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
2433 dev = pci_scan_single_device(bus, devfn); 2433 dev = pci_scan_single_device(bus, devfn);
2434 if (!dev) 2434 if (!dev)
2435 return 0; 2435 return 0;
2436 if (!dev->is_added) 2436 if (!pci_dev_is_added(dev))
2437 nr++; 2437 nr++;
2438 2438
2439 for (fn = next_fn(bus, dev, 0); fn > 0; fn = next_fn(bus, dev, fn)) { 2439 for (fn = next_fn(bus, dev, 0); fn > 0; fn = next_fn(bus, dev, fn)) {
2440 dev = pci_scan_single_device(bus, devfn + fn); 2440 dev = pci_scan_single_device(bus, devfn + fn);
2441 if (dev) { 2441 if (dev) {
2442 if (!dev->is_added) 2442 if (!pci_dev_is_added(dev))
2443 nr++; 2443 nr++;
2444 dev->multifunction = 1; 2444 dev->multifunction = 1;
2445 } 2445 }
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 6f072eae4f7a..5e3d0dced2b8 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -19,11 +19,12 @@ static void pci_stop_dev(struct pci_dev *dev)
19{ 19{
20 pci_pme_active(dev, false); 20 pci_pme_active(dev, false);
21 21
22 if (dev->is_added) { 22 if (pci_dev_is_added(dev)) {
23 device_release_driver(&dev->dev); 23 device_release_driver(&dev->dev);
24 pci_proc_detach_device(dev); 24 pci_proc_detach_device(dev);
25 pci_remove_sysfs_dev_files(dev); 25 pci_remove_sysfs_dev_files(dev);
26 dev->is_added = 0; 26
27 pci_dev_assign_added(dev, false);
27 } 28 }
28 29
29 if (dev->bus->self) 30 if (dev->bus->self)
diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c
index 1b7febc43da9..29d2c3b1913a 100644
--- a/drivers/phy/broadcom/phy-brcm-usb-init.c
+++ b/drivers/phy/broadcom/phy-brcm-usb-init.c
@@ -962,6 +962,10 @@ void brcm_usb_init_xhci(struct brcm_usb_init_params *params)
962{ 962{
963 void __iomem *ctrl = params->ctrl_regs; 963 void __iomem *ctrl = params->ctrl_regs;
964 964
965 USB_CTRL_UNSET(ctrl, USB30_PCTL, PHY3_IDDQ_OVERRIDE);
966 /* 1 millisecond - for USB clocks to settle down */
967 usleep_range(1000, 2000);
968
965 if (BRCM_ID(params->family_id) == 0x7366) { 969 if (BRCM_ID(params->family_id) == 0x7366) {
966 /* 970 /*
967 * The PHY3_SOFT_RESETB bits default to the wrong state. 971 * The PHY3_SOFT_RESETB bits default to the wrong state.
diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c
index 23705e1a0023..0075fb0bef8c 100644
--- a/drivers/phy/motorola/phy-mapphone-mdm6600.c
+++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c
@@ -182,13 +182,13 @@ static void phy_mdm6600_status(struct work_struct *work)
182 ddata = container_of(work, struct phy_mdm6600, status_work.work); 182 ddata = container_of(work, struct phy_mdm6600, status_work.work);
183 dev = ddata->dev; 183 dev = ddata->dev;
184 184
185 error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES, 185 error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_STATUS_LINES,
186 ddata->status_gpios->desc, 186 ddata->status_gpios->desc,
187 values); 187 values);
188 if (error) 188 if (error)
189 return; 189 return;
190 190
191 for (i = 0; i < PHY_MDM6600_NR_CMD_LINES; i++) { 191 for (i = 0; i < PHY_MDM6600_NR_STATUS_LINES; i++) {
192 val |= values[i] << i; 192 val |= values[i] << i;
193 dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n", 193 dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n",
194 __func__, i, values[i], val); 194 __func__, i, values[i], val);
diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
index 35c17653c694..87618a4e90e4 100644
--- a/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
+++ b/drivers/pinctrl/bcm/pinctrl-nsp-mux.c
@@ -460,8 +460,8 @@ static int nsp_pinmux_enable(struct pinctrl_dev *pctrl_dev,
460 const struct nsp_pin_function *func; 460 const struct nsp_pin_function *func;
461 const struct nsp_pin_group *grp; 461 const struct nsp_pin_group *grp;
462 462
463 if (grp_select > pinctrl->num_groups || 463 if (grp_select >= pinctrl->num_groups ||
464 func_select > pinctrl->num_functions) 464 func_select >= pinctrl->num_functions)
465 return -EINVAL; 465 return -EINVAL;
466 466
467 func = &pinctrl->functions[func_select]; 467 func = &pinctrl->functions[func_select];
@@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
577 return PTR_ERR(pinctrl->base0); 577 return PTR_ERR(pinctrl->base0);
578 578
579 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 579 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
580 if (!res)
581 return -EINVAL;
580 pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start, 582 pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
581 resource_size(res)); 583 resource_size(res));
582 if (!pinctrl->base1) { 584 if (!pinctrl->base1) {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
index e3f1ab2290fc..4c4740ffeb9c 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
@@ -1424,7 +1424,7 @@ static struct pinctrl_desc mtk_desc = {
1424 1424
1425static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio) 1425static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
1426{ 1426{
1427 struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent); 1427 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1428 int value, err; 1428 int value, err;
1429 1429
1430 err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value); 1430 err = mtk_hw_get_value(hw, gpio, PINCTRL_PIN_REG_DI, &value);
@@ -1436,7 +1436,7 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
1436 1436
1437static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value) 1437static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
1438{ 1438{
1439 struct mtk_pinctrl *hw = dev_get_drvdata(chip->parent); 1439 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1440 1440
1441 mtk_hw_set_value(hw, gpio, PINCTRL_PIN_REG_DO, !!value); 1441 mtk_hw_set_value(hw, gpio, PINCTRL_PIN_REG_DO, !!value);
1442} 1442}
@@ -1508,11 +1508,20 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
1508 if (ret < 0) 1508 if (ret < 0)
1509 return ret; 1509 return ret;
1510 1510
1511 ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0, 1511 /* Just for backward compatible for these old pinctrl nodes without
1512 chip->ngpio); 1512 * "gpio-ranges" property. Otherwise, called directly from a
1513 if (ret < 0) { 1513 * DeviceTree-supported pinctrl driver is DEPRECATED.
1514 gpiochip_remove(chip); 1514 * Please see Section 2.1 of
1515 return ret; 1515 * Documentation/devicetree/bindings/gpio/gpio.txt on how to
1516 * bind pinctrl and gpio drivers via the "gpio-ranges" property.
1517 */
1518 if (!of_find_property(np, "gpio-ranges", NULL)) {
1519 ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
1520 chip->ngpio);
1521 if (ret < 0) {
1522 gpiochip_remove(chip);
1523 return ret;
1524 }
1516 } 1525 }
1517 1526
1518 return 0; 1527 return 0;
@@ -1695,15 +1704,16 @@ static int mtk_pinctrl_probe(struct platform_device *pdev)
1695 mtk_desc.custom_conf_items = mtk_conf_items; 1704 mtk_desc.custom_conf_items = mtk_conf_items;
1696#endif 1705#endif
1697 1706
1698 hw->pctrl = devm_pinctrl_register(&pdev->dev, &mtk_desc, hw); 1707 err = devm_pinctrl_register_and_init(&pdev->dev, &mtk_desc, hw,
1699 if (IS_ERR(hw->pctrl)) 1708 &hw->pctrl);
1700 return PTR_ERR(hw->pctrl); 1709 if (err)
1710 return err;
1701 1711
1702 /* Setup groups descriptions per SoC types */ 1712 /* Setup groups descriptions per SoC types */
1703 err = mtk_build_groups(hw); 1713 err = mtk_build_groups(hw);
1704 if (err) { 1714 if (err) {
1705 dev_err(&pdev->dev, "Failed to build groups\n"); 1715 dev_err(&pdev->dev, "Failed to build groups\n");
1706 return 0; 1716 return err;
1707 } 1717 }
1708 1718
1709 /* Setup functions descriptions per SoC types */ 1719 /* Setup functions descriptions per SoC types */
@@ -1713,17 +1723,25 @@ static int mtk_pinctrl_probe(struct platform_device *pdev)
1713 return err; 1723 return err;
1714 } 1724 }
1715 1725
1716 err = mtk_build_gpiochip(hw, pdev->dev.of_node); 1726 /* For able to make pinctrl_claim_hogs, we must not enable pinctrl
1717 if (err) { 1727 * until all groups and functions are being added one.
1718 dev_err(&pdev->dev, "Failed to add gpio_chip\n"); 1728 */
1729 err = pinctrl_enable(hw->pctrl);
1730 if (err)
1719 return err; 1731 return err;
1720 }
1721 1732
1722 err = mtk_build_eint(hw, pdev); 1733 err = mtk_build_eint(hw, pdev);
1723 if (err) 1734 if (err)
1724 dev_warn(&pdev->dev, 1735 dev_warn(&pdev->dev,
1725 "Failed to add EINT, but pinctrl still can work\n"); 1736 "Failed to add EINT, but pinctrl still can work\n");
1726 1737
1738 /* Build gpiochip should be after pinctrl_enable is done */
1739 err = mtk_build_gpiochip(hw, pdev->dev.of_node);
1740 if (err) {
1741 dev_err(&pdev->dev, "Failed to add gpio_chip\n");
1742 return err;
1743 }
1744
1727 platform_set_drvdata(pdev, hw); 1745 platform_set_drvdata(pdev, hw);
1728 1746
1729 return 0; 1747 return 0;
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index a1d7156d0a43..6a1b6058b991 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -536,7 +536,7 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
536 ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input); 536 ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
537 } else { 537 } else {
538 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false); 538 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
539 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, input); 539 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
540 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false); 540 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
541 } 541 }
542 542
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77970.c b/drivers/pinctrl/sh-pfc/pfc-r8a77970.c
index b02caf316711..eeb58b3bbc9a 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a77970.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a77970.c
@@ -21,15 +21,13 @@
21#include "core.h" 21#include "core.h"
22#include "sh_pfc.h" 22#include "sh_pfc.h"
23 23
24#define CFG_FLAGS SH_PFC_PIN_CFG_DRIVE_STRENGTH
25
26#define CPU_ALL_PORT(fn, sfx) \ 24#define CPU_ALL_PORT(fn, sfx) \
27 PORT_GP_CFG_22(0, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \ 25 PORT_GP_CFG_22(0, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
28 PORT_GP_CFG_28(1, fn, sfx, CFG_FLAGS), \ 26 PORT_GP_28(1, fn, sfx), \
29 PORT_GP_CFG_17(2, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \ 27 PORT_GP_CFG_17(2, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
30 PORT_GP_CFG_17(3, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \ 28 PORT_GP_CFG_17(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE), \
31 PORT_GP_CFG_6(4, fn, sfx, CFG_FLAGS), \ 29 PORT_GP_6(4, fn, sfx), \
32 PORT_GP_CFG_15(5, fn, sfx, CFG_FLAGS) 30 PORT_GP_15(5, fn, sfx)
33/* 31/*
34 * F_() : just information 32 * F_() : just information
35 * FM() : macro for FN_xxx / xxx_MARK 33 * FM() : macro for FN_xxx / xxx_MARK
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index f1fa8612db40..06978c14c83b 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2185,7 +2185,7 @@ static int __init dell_init(void)
2185 dell_fill_request(&buffer, token->location, 0, 0, 0); 2185 dell_fill_request(&buffer, token->location, 0, 0, 0);
2186 ret = dell_send_request(&buffer, 2186 ret = dell_send_request(&buffer,
2187 CLASS_TOKEN_READ, SELECT_TOKEN_AC); 2187 CLASS_TOKEN_READ, SELECT_TOKEN_AC);
2188 if (ret) 2188 if (ret == 0)
2189 max_intensity = buffer.output[3]; 2189 max_intensity = buffer.output[3];
2190 } 2190 }
2191 2191
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 547dbdac9d54..01b0e2bb3319 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -89,6 +89,7 @@ int ptp_set_pinfunc(struct ptp_clock *ptp, unsigned int pin,
89 case PTP_PF_PHYSYNC: 89 case PTP_PF_PHYSYNC:
90 if (chan != 0) 90 if (chan != 0)
91 return -EINVAL; 91 return -EINVAL;
92 break;
92 default: 93 default:
93 return -EINVAL; 94 return -EINVAL;
94 } 95 }
diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h
index 2a3977823812..a39be94d110c 100644
--- a/drivers/scsi/cxlflash/main.h
+++ b/drivers/scsi/cxlflash/main.h
@@ -107,12 +107,12 @@ cxlflash_assign_ops(struct dev_dependent_vals *ddv)
107{ 107{
108 const struct cxlflash_backend_ops *ops = NULL; 108 const struct cxlflash_backend_ops *ops = NULL;
109 109
110#ifdef CONFIG_OCXL 110#ifdef CONFIG_OCXL_BASE
111 if (ddv->flags & CXLFLASH_OCXL_DEV) 111 if (ddv->flags & CXLFLASH_OCXL_DEV)
112 ops = &cxlflash_ocxl_ops; 112 ops = &cxlflash_ocxl_ops;
113#endif 113#endif
114 114
115#ifdef CONFIG_CXL 115#ifdef CONFIG_CXL_BASE
116 if (!(ddv->flags & CXLFLASH_OCXL_DEV)) 116 if (!(ddv->flags & CXLFLASH_OCXL_DEV))
117 ops = &cxlflash_cxl_ops; 117 ops = &cxlflash_cxl_ops;
118#endif 118#endif
diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 0a95b5f25380..497a68389461 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -134,15 +134,14 @@ static struct file *ocxlflash_getfile(struct device *dev, const char *name,
134 rc = PTR_ERR(file); 134 rc = PTR_ERR(file);
135 dev_err(dev, "%s: alloc_file failed rc=%d\n", 135 dev_err(dev, "%s: alloc_file failed rc=%d\n",
136 __func__, rc); 136 __func__, rc);
137 goto err5; 137 path_put(&path);
138 goto err3;
138 } 139 }
139 140
140 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); 141 file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
141 file->private_data = priv; 142 file->private_data = priv;
142out: 143out:
143 return file; 144 return file;
144err5:
145 path_put(&path);
146err4: 145err4:
147 iput(inode); 146 iput(inode);
148err3: 147err3:
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 15c7f3b6f35e..58bb70b886d7 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3440,11 +3440,11 @@ static void hpsa_get_enclosure_info(struct ctlr_info *h,
3440 struct ext_report_lun_entry *rle = &rlep->LUN[rle_index]; 3440 struct ext_report_lun_entry *rle = &rlep->LUN[rle_index];
3441 u16 bmic_device_index = 0; 3441 u16 bmic_device_index = 0;
3442 3442
3443 bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]); 3443 encl_dev->eli =
3444
3445 encl_dev->sas_address =
3446 hpsa_get_enclosure_logical_identifier(h, scsi3addr); 3444 hpsa_get_enclosure_logical_identifier(h, scsi3addr);
3447 3445
3446 bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]);
3447
3448 if (encl_dev->target == -1 || encl_dev->lun == -1) { 3448 if (encl_dev->target == -1 || encl_dev->lun == -1) {
3449 rc = IO_OK; 3449 rc = IO_OK;
3450 goto out; 3450 goto out;
@@ -9697,7 +9697,24 @@ hpsa_sas_get_linkerrors(struct sas_phy *phy)
9697static int 9697static int
9698hpsa_sas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier) 9698hpsa_sas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier)
9699{ 9699{
9700 *identifier = rphy->identify.sas_address; 9700 struct Scsi_Host *shost = phy_to_shost(rphy);
9701 struct ctlr_info *h;
9702 struct hpsa_scsi_dev_t *sd;
9703
9704 if (!shost)
9705 return -ENXIO;
9706
9707 h = shost_to_hba(shost);
9708
9709 if (!h)
9710 return -ENXIO;
9711
9712 sd = hpsa_find_device_by_sas_rphy(h, rphy);
9713 if (!sd)
9714 return -ENXIO;
9715
9716 *identifier = sd->eli;
9717
9701 return 0; 9718 return 0;
9702} 9719}
9703 9720
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index fb9f5e7f8209..59e023696fff 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -68,6 +68,7 @@ struct hpsa_scsi_dev_t {
68#define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0" 68#define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
69 unsigned char device_id[16]; /* from inquiry pg. 0x83 */ 69 unsigned char device_id[16]; /* from inquiry pg. 0x83 */
70 u64 sas_address; 70 u64 sas_address;
71 u64 eli; /* from report diags. */
71 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */ 72 unsigned char vendor[8]; /* bytes 8-15 of inquiry data */
72 unsigned char model[16]; /* bytes 16-31 of inquiry data */ 73 unsigned char model[16]; /* bytes 16-31 of inquiry data */
73 unsigned char rev; /* byte 2 of inquiry data */ 74 unsigned char rev; /* byte 2 of inquiry data */
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index d6093838f5f2..c972cc2b3d5b 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -284,11 +284,11 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
284 */ 284 */
285 if (opcode != ISCSI_OP_SCSI_DATA_OUT) { 285 if (opcode != ISCSI_OP_SCSI_DATA_OUT) {
286 iscsi_conn_printk(KERN_INFO, conn, 286 iscsi_conn_printk(KERN_INFO, conn,
287 "task [op %x/%x itt " 287 "task [op %x itt "
288 "0x%x/0x%x] " 288 "0x%x/0x%x] "
289 "rejected.\n", 289 "rejected.\n",
290 task->hdr->opcode, opcode, 290 opcode, task->itt,
291 task->itt, task->hdr_itt); 291 task->hdr_itt);
292 return -EACCES; 292 return -EACCES;
293 } 293 }
294 /* 294 /*
@@ -297,10 +297,10 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
297 */ 297 */
298 if (conn->session->fast_abort) { 298 if (conn->session->fast_abort) {
299 iscsi_conn_printk(KERN_INFO, conn, 299 iscsi_conn_printk(KERN_INFO, conn,
300 "task [op %x/%x itt " 300 "task [op %x itt "
301 "0x%x/0x%x] fast abort.\n", 301 "0x%x/0x%x] fast abort.\n",
302 task->hdr->opcode, opcode, 302 opcode, task->itt,
303 task->itt, task->hdr_itt); 303 task->hdr_itt);
304 return -EACCES; 304 return -EACCES;
305 } 305 }
306 break; 306 break;
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 90394cef0f41..0a5dd5595dd3 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3295,6 +3295,11 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
3295 3295
3296 init_completion(&qedf->flogi_compl); 3296 init_completion(&qedf->flogi_compl);
3297 3297
3298 status = qed_ops->common->update_drv_state(qedf->cdev, true);
3299 if (status)
3300 QEDF_ERR(&(qedf->dbg_ctx),
3301 "Failed to send drv state to MFW.\n");
3302
3298 memset(&link_params, 0, sizeof(struct qed_link_params)); 3303 memset(&link_params, 0, sizeof(struct qed_link_params));
3299 link_params.link_up = true; 3304 link_params.link_up = true;
3300 status = qed_ops->common->set_link(qedf->cdev, &link_params); 3305 status = qed_ops->common->set_link(qedf->cdev, &link_params);
@@ -3343,6 +3348,7 @@ static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3343static void __qedf_remove(struct pci_dev *pdev, int mode) 3348static void __qedf_remove(struct pci_dev *pdev, int mode)
3344{ 3349{
3345 struct qedf_ctx *qedf; 3350 struct qedf_ctx *qedf;
3351 int rc;
3346 3352
3347 if (!pdev) { 3353 if (!pdev) {
3348 QEDF_ERR(NULL, "pdev is NULL.\n"); 3354 QEDF_ERR(NULL, "pdev is NULL.\n");
@@ -3437,6 +3443,12 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
3437 qed_ops->common->set_power_state(qedf->cdev, PCI_D0); 3443 qed_ops->common->set_power_state(qedf->cdev, PCI_D0);
3438 pci_set_drvdata(pdev, NULL); 3444 pci_set_drvdata(pdev, NULL);
3439 } 3445 }
3446
3447 rc = qed_ops->common->update_drv_state(qedf->cdev, false);
3448 if (rc)
3449 QEDF_ERR(&(qedf->dbg_ctx),
3450 "Failed to send drv state to MFW.\n");
3451
3440 qed_ops->common->slowpath_stop(qedf->cdev); 3452 qed_ops->common->slowpath_stop(qedf->cdev);
3441 qed_ops->common->remove(qedf->cdev); 3453 qed_ops->common->remove(qedf->cdev);
3442 3454
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index cf274a79e77a..091ec1207bea 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -2273,6 +2273,7 @@ kset_free:
2273static void __qedi_remove(struct pci_dev *pdev, int mode) 2273static void __qedi_remove(struct pci_dev *pdev, int mode)
2274{ 2274{
2275 struct qedi_ctx *qedi = pci_get_drvdata(pdev); 2275 struct qedi_ctx *qedi = pci_get_drvdata(pdev);
2276 int rval;
2276 2277
2277 if (qedi->tmf_thread) { 2278 if (qedi->tmf_thread) {
2278 flush_workqueue(qedi->tmf_thread); 2279 flush_workqueue(qedi->tmf_thread);
@@ -2302,6 +2303,10 @@ static void __qedi_remove(struct pci_dev *pdev, int mode)
2302 if (mode == QEDI_MODE_NORMAL) 2303 if (mode == QEDI_MODE_NORMAL)
2303 qedi_free_iscsi_pf_param(qedi); 2304 qedi_free_iscsi_pf_param(qedi);
2304 2305
2306 rval = qedi_ops->common->update_drv_state(qedi->cdev, false);
2307 if (rval)
2308 QEDI_ERR(&qedi->dbg_ctx, "Failed to send drv state to MFW\n");
2309
2305 if (!test_bit(QEDI_IN_OFFLINE, &qedi->flags)) { 2310 if (!test_bit(QEDI_IN_OFFLINE, &qedi->flags)) {
2306 qedi_ops->common->slowpath_stop(qedi->cdev); 2311 qedi_ops->common->slowpath_stop(qedi->cdev);
2307 qedi_ops->common->remove(qedi->cdev); 2312 qedi_ops->common->remove(qedi->cdev);
@@ -2576,6 +2581,12 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
2576 if (qedi_setup_boot_info(qedi)) 2581 if (qedi_setup_boot_info(qedi))
2577 QEDI_ERR(&qedi->dbg_ctx, 2582 QEDI_ERR(&qedi->dbg_ctx,
2578 "No iSCSI boot target configured\n"); 2583 "No iSCSI boot target configured\n");
2584
2585 rc = qedi_ops->common->update_drv_state(qedi->cdev, true);
2586 if (rc)
2587 QEDI_ERR(&qedi->dbg_ctx,
2588 "Failed to send drv state to MFW\n");
2589
2579 } 2590 }
2580 2591
2581 return 0; 2592 return 0;
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 89a4999fa631..c8731568f9c4 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -2141,6 +2141,7 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
2141 msleep(1000); 2141 msleep(1000);
2142 2142
2143 qla24xx_disable_vp(vha); 2143 qla24xx_disable_vp(vha);
2144 qla2x00_wait_for_sess_deletion(vha);
2144 2145
2145 vha->flags.delete_progress = 1; 2146 vha->flags.delete_progress = 1;
2146 2147
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9442e18aef6f..0f94b1d62d3f 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -361,6 +361,8 @@ struct ct_arg {
361 dma_addr_t rsp_dma; 361 dma_addr_t rsp_dma;
362 u32 req_size; 362 u32 req_size;
363 u32 rsp_size; 363 u32 rsp_size;
364 u32 req_allocated_size;
365 u32 rsp_allocated_size;
364 void *req; 366 void *req;
365 void *rsp; 367 void *rsp;
366 port_id_t id; 368 port_id_t id;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index f68eb6096559..2660a48d918a 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -214,6 +214,7 @@ void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
214int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *); 214int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *);
215int qla24xx_async_abort_cmd(srb_t *); 215int qla24xx_async_abort_cmd(srb_t *);
216int qla24xx_post_relogin_work(struct scsi_qla_host *vha); 216int qla24xx_post_relogin_work(struct scsi_qla_host *vha);
217void qla2x00_wait_for_sess_deletion(scsi_qla_host_t *);
217 218
218/* 219/*
219 * Global Functions in qla_mid.c source file. 220 * Global Functions in qla_mid.c source file.
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 4bc2b66b299f..7a3744006419 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -556,7 +556,7 @@ err2:
556 /* please ignore kernel warning. otherwise, we have mem leak. */ 556 /* please ignore kernel warning. otherwise, we have mem leak. */
557 if (sp->u.iocb_cmd.u.ctarg.req) { 557 if (sp->u.iocb_cmd.u.ctarg.req) {
558 dma_free_coherent(&vha->hw->pdev->dev, 558 dma_free_coherent(&vha->hw->pdev->dev,
559 sizeof(struct ct_sns_pkt), 559 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
560 sp->u.iocb_cmd.u.ctarg.req, 560 sp->u.iocb_cmd.u.ctarg.req,
561 sp->u.iocb_cmd.u.ctarg.req_dma); 561 sp->u.iocb_cmd.u.ctarg.req_dma);
562 sp->u.iocb_cmd.u.ctarg.req = NULL; 562 sp->u.iocb_cmd.u.ctarg.req = NULL;
@@ -564,7 +564,7 @@ err2:
564 564
565 if (sp->u.iocb_cmd.u.ctarg.rsp) { 565 if (sp->u.iocb_cmd.u.ctarg.rsp) {
566 dma_free_coherent(&vha->hw->pdev->dev, 566 dma_free_coherent(&vha->hw->pdev->dev,
567 sizeof(struct ct_sns_pkt), 567 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
568 sp->u.iocb_cmd.u.ctarg.rsp, 568 sp->u.iocb_cmd.u.ctarg.rsp,
569 sp->u.iocb_cmd.u.ctarg.rsp_dma); 569 sp->u.iocb_cmd.u.ctarg.rsp_dma);
570 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 570 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
@@ -617,6 +617,7 @@ static int qla_async_rftid(scsi_qla_host_t *vha, port_id_t *d_id)
617 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev, 617 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev,
618 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, 618 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma,
619 GFP_KERNEL); 619 GFP_KERNEL);
620 sp->u.iocb_cmd.u.ctarg.req_allocated_size = sizeof(struct ct_sns_pkt);
620 if (!sp->u.iocb_cmd.u.ctarg.req) { 621 if (!sp->u.iocb_cmd.u.ctarg.req) {
621 ql_log(ql_log_warn, vha, 0xd041, 622 ql_log(ql_log_warn, vha, 0xd041,
622 "%s: Failed to allocate ct_sns request.\n", 623 "%s: Failed to allocate ct_sns request.\n",
@@ -627,6 +628,7 @@ static int qla_async_rftid(scsi_qla_host_t *vha, port_id_t *d_id)
627 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, 628 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev,
628 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma, 629 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma,
629 GFP_KERNEL); 630 GFP_KERNEL);
631 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
630 if (!sp->u.iocb_cmd.u.ctarg.rsp) { 632 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
631 ql_log(ql_log_warn, vha, 0xd042, 633 ql_log(ql_log_warn, vha, 0xd042,
632 "%s: Failed to allocate ct_sns request.\n", 634 "%s: Failed to allocate ct_sns request.\n",
@@ -712,6 +714,7 @@ static int qla_async_rffid(scsi_qla_host_t *vha, port_id_t *d_id,
712 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev, 714 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev,
713 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, 715 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma,
714 GFP_KERNEL); 716 GFP_KERNEL);
717 sp->u.iocb_cmd.u.ctarg.req_allocated_size = sizeof(struct ct_sns_pkt);
715 if (!sp->u.iocb_cmd.u.ctarg.req) { 718 if (!sp->u.iocb_cmd.u.ctarg.req) {
716 ql_log(ql_log_warn, vha, 0xd041, 719 ql_log(ql_log_warn, vha, 0xd041,
717 "%s: Failed to allocate ct_sns request.\n", 720 "%s: Failed to allocate ct_sns request.\n",
@@ -722,6 +725,7 @@ static int qla_async_rffid(scsi_qla_host_t *vha, port_id_t *d_id,
722 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, 725 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev,
723 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma, 726 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma,
724 GFP_KERNEL); 727 GFP_KERNEL);
728 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
725 if (!sp->u.iocb_cmd.u.ctarg.rsp) { 729 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
726 ql_log(ql_log_warn, vha, 0xd042, 730 ql_log(ql_log_warn, vha, 0xd042,
727 "%s: Failed to allocate ct_sns request.\n", 731 "%s: Failed to allocate ct_sns request.\n",
@@ -802,6 +806,7 @@ static int qla_async_rnnid(scsi_qla_host_t *vha, port_id_t *d_id,
802 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev, 806 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev,
803 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, 807 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma,
804 GFP_KERNEL); 808 GFP_KERNEL);
809 sp->u.iocb_cmd.u.ctarg.req_allocated_size = sizeof(struct ct_sns_pkt);
805 if (!sp->u.iocb_cmd.u.ctarg.req) { 810 if (!sp->u.iocb_cmd.u.ctarg.req) {
806 ql_log(ql_log_warn, vha, 0xd041, 811 ql_log(ql_log_warn, vha, 0xd041,
807 "%s: Failed to allocate ct_sns request.\n", 812 "%s: Failed to allocate ct_sns request.\n",
@@ -812,6 +817,7 @@ static int qla_async_rnnid(scsi_qla_host_t *vha, port_id_t *d_id,
812 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, 817 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev,
813 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma, 818 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma,
814 GFP_KERNEL); 819 GFP_KERNEL);
820 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
815 if (!sp->u.iocb_cmd.u.ctarg.rsp) { 821 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
816 ql_log(ql_log_warn, vha, 0xd042, 822 ql_log(ql_log_warn, vha, 0xd042,
817 "%s: Failed to allocate ct_sns request.\n", 823 "%s: Failed to allocate ct_sns request.\n",
@@ -909,6 +915,7 @@ static int qla_async_rsnn_nn(scsi_qla_host_t *vha)
909 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev, 915 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev,
910 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, 916 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma,
911 GFP_KERNEL); 917 GFP_KERNEL);
918 sp->u.iocb_cmd.u.ctarg.req_allocated_size = sizeof(struct ct_sns_pkt);
912 if (!sp->u.iocb_cmd.u.ctarg.req) { 919 if (!sp->u.iocb_cmd.u.ctarg.req) {
913 ql_log(ql_log_warn, vha, 0xd041, 920 ql_log(ql_log_warn, vha, 0xd041,
914 "%s: Failed to allocate ct_sns request.\n", 921 "%s: Failed to allocate ct_sns request.\n",
@@ -919,6 +926,7 @@ static int qla_async_rsnn_nn(scsi_qla_host_t *vha)
919 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, 926 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev,
920 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma, 927 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma,
921 GFP_KERNEL); 928 GFP_KERNEL);
929 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
922 if (!sp->u.iocb_cmd.u.ctarg.rsp) { 930 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
923 ql_log(ql_log_warn, vha, 0xd042, 931 ql_log(ql_log_warn, vha, 0xd042,
924 "%s: Failed to allocate ct_sns request.\n", 932 "%s: Failed to allocate ct_sns request.\n",
@@ -3388,14 +3396,14 @@ void qla24xx_sp_unmap(scsi_qla_host_t *vha, srb_t *sp)
3388{ 3396{
3389 if (sp->u.iocb_cmd.u.ctarg.req) { 3397 if (sp->u.iocb_cmd.u.ctarg.req) {
3390 dma_free_coherent(&vha->hw->pdev->dev, 3398 dma_free_coherent(&vha->hw->pdev->dev,
3391 sizeof(struct ct_sns_pkt), 3399 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
3392 sp->u.iocb_cmd.u.ctarg.req, 3400 sp->u.iocb_cmd.u.ctarg.req,
3393 sp->u.iocb_cmd.u.ctarg.req_dma); 3401 sp->u.iocb_cmd.u.ctarg.req_dma);
3394 sp->u.iocb_cmd.u.ctarg.req = NULL; 3402 sp->u.iocb_cmd.u.ctarg.req = NULL;
3395 } 3403 }
3396 if (sp->u.iocb_cmd.u.ctarg.rsp) { 3404 if (sp->u.iocb_cmd.u.ctarg.rsp) {
3397 dma_free_coherent(&vha->hw->pdev->dev, 3405 dma_free_coherent(&vha->hw->pdev->dev,
3398 sizeof(struct ct_sns_pkt), 3406 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
3399 sp->u.iocb_cmd.u.ctarg.rsp, 3407 sp->u.iocb_cmd.u.ctarg.rsp,
3400 sp->u.iocb_cmd.u.ctarg.rsp_dma); 3408 sp->u.iocb_cmd.u.ctarg.rsp_dma);
3401 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 3409 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
@@ -3596,14 +3604,14 @@ static void qla2x00_async_gpnid_sp_done(void *s, int res)
3596 /* please ignore kernel warning. otherwise, we have mem leak. */ 3604 /* please ignore kernel warning. otherwise, we have mem leak. */
3597 if (sp->u.iocb_cmd.u.ctarg.req) { 3605 if (sp->u.iocb_cmd.u.ctarg.req) {
3598 dma_free_coherent(&vha->hw->pdev->dev, 3606 dma_free_coherent(&vha->hw->pdev->dev,
3599 sizeof(struct ct_sns_pkt), 3607 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
3600 sp->u.iocb_cmd.u.ctarg.req, 3608 sp->u.iocb_cmd.u.ctarg.req,
3601 sp->u.iocb_cmd.u.ctarg.req_dma); 3609 sp->u.iocb_cmd.u.ctarg.req_dma);
3602 sp->u.iocb_cmd.u.ctarg.req = NULL; 3610 sp->u.iocb_cmd.u.ctarg.req = NULL;
3603 } 3611 }
3604 if (sp->u.iocb_cmd.u.ctarg.rsp) { 3612 if (sp->u.iocb_cmd.u.ctarg.rsp) {
3605 dma_free_coherent(&vha->hw->pdev->dev, 3613 dma_free_coherent(&vha->hw->pdev->dev,
3606 sizeof(struct ct_sns_pkt), 3614 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
3607 sp->u.iocb_cmd.u.ctarg.rsp, 3615 sp->u.iocb_cmd.u.ctarg.rsp,
3608 sp->u.iocb_cmd.u.ctarg.rsp_dma); 3616 sp->u.iocb_cmd.u.ctarg.rsp_dma);
3609 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 3617 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
@@ -3654,6 +3662,7 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id)
3654 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev, 3662 sp->u.iocb_cmd.u.ctarg.req = dma_alloc_coherent(&vha->hw->pdev->dev,
3655 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, 3663 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma,
3656 GFP_KERNEL); 3664 GFP_KERNEL);
3665 sp->u.iocb_cmd.u.ctarg.req_allocated_size = sizeof(struct ct_sns_pkt);
3657 if (!sp->u.iocb_cmd.u.ctarg.req) { 3666 if (!sp->u.iocb_cmd.u.ctarg.req) {
3658 ql_log(ql_log_warn, vha, 0xd041, 3667 ql_log(ql_log_warn, vha, 0xd041,
3659 "Failed to allocate ct_sns request.\n"); 3668 "Failed to allocate ct_sns request.\n");
@@ -3663,6 +3672,7 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id)
3663 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev, 3672 sp->u.iocb_cmd.u.ctarg.rsp = dma_alloc_coherent(&vha->hw->pdev->dev,
3664 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma, 3673 sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.rsp_dma,
3665 GFP_KERNEL); 3674 GFP_KERNEL);
3675 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
3666 if (!sp->u.iocb_cmd.u.ctarg.rsp) { 3676 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
3667 ql_log(ql_log_warn, vha, 0xd042, 3677 ql_log(ql_log_warn, vha, 0xd042,
3668 "Failed to allocate ct_sns request.\n"); 3678 "Failed to allocate ct_sns request.\n");
@@ -3698,6 +3708,10 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id)
3698 return rval; 3708 return rval;
3699 3709
3700done_free_sp: 3710done_free_sp:
3711 spin_lock_irqsave(&vha->hw->vport_slock, flags);
3712 list_del(&sp->elem);
3713 spin_unlock_irqrestore(&vha->hw->vport_slock, flags);
3714
3701 if (sp->u.iocb_cmd.u.ctarg.req) { 3715 if (sp->u.iocb_cmd.u.ctarg.req) {
3702 dma_free_coherent(&vha->hw->pdev->dev, 3716 dma_free_coherent(&vha->hw->pdev->dev,
3703 sizeof(struct ct_sns_pkt), 3717 sizeof(struct ct_sns_pkt),
@@ -4142,14 +4156,14 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res)
4142 */ 4156 */
4143 if (sp->u.iocb_cmd.u.ctarg.req) { 4157 if (sp->u.iocb_cmd.u.ctarg.req) {
4144 dma_free_coherent(&vha->hw->pdev->dev, 4158 dma_free_coherent(&vha->hw->pdev->dev,
4145 sizeof(struct ct_sns_pkt), 4159 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
4146 sp->u.iocb_cmd.u.ctarg.req, 4160 sp->u.iocb_cmd.u.ctarg.req,
4147 sp->u.iocb_cmd.u.ctarg.req_dma); 4161 sp->u.iocb_cmd.u.ctarg.req_dma);
4148 sp->u.iocb_cmd.u.ctarg.req = NULL; 4162 sp->u.iocb_cmd.u.ctarg.req = NULL;
4149 } 4163 }
4150 if (sp->u.iocb_cmd.u.ctarg.rsp) { 4164 if (sp->u.iocb_cmd.u.ctarg.rsp) {
4151 dma_free_coherent(&vha->hw->pdev->dev, 4165 dma_free_coherent(&vha->hw->pdev->dev,
4152 sizeof(struct ct_sns_pkt), 4166 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
4153 sp->u.iocb_cmd.u.ctarg.rsp, 4167 sp->u.iocb_cmd.u.ctarg.rsp,
4154 sp->u.iocb_cmd.u.ctarg.rsp_dma); 4168 sp->u.iocb_cmd.u.ctarg.rsp_dma);
4155 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 4169 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
@@ -4179,14 +4193,14 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res)
4179 /* please ignore kernel warning. Otherwise, we have mem leak. */ 4193 /* please ignore kernel warning. Otherwise, we have mem leak. */
4180 if (sp->u.iocb_cmd.u.ctarg.req) { 4194 if (sp->u.iocb_cmd.u.ctarg.req) {
4181 dma_free_coherent(&vha->hw->pdev->dev, 4195 dma_free_coherent(&vha->hw->pdev->dev,
4182 sizeof(struct ct_sns_pkt), 4196 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
4183 sp->u.iocb_cmd.u.ctarg.req, 4197 sp->u.iocb_cmd.u.ctarg.req,
4184 sp->u.iocb_cmd.u.ctarg.req_dma); 4198 sp->u.iocb_cmd.u.ctarg.req_dma);
4185 sp->u.iocb_cmd.u.ctarg.req = NULL; 4199 sp->u.iocb_cmd.u.ctarg.req = NULL;
4186 } 4200 }
4187 if (sp->u.iocb_cmd.u.ctarg.rsp) { 4201 if (sp->u.iocb_cmd.u.ctarg.rsp) {
4188 dma_free_coherent(&vha->hw->pdev->dev, 4202 dma_free_coherent(&vha->hw->pdev->dev,
4189 sizeof(struct ct_sns_pkt), 4203 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
4190 sp->u.iocb_cmd.u.ctarg.rsp, 4204 sp->u.iocb_cmd.u.ctarg.rsp,
4191 sp->u.iocb_cmd.u.ctarg.rsp_dma); 4205 sp->u.iocb_cmd.u.ctarg.rsp_dma);
4192 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 4206 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
@@ -4281,14 +4295,14 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp,
4281done_free_sp: 4295done_free_sp:
4282 if (sp->u.iocb_cmd.u.ctarg.req) { 4296 if (sp->u.iocb_cmd.u.ctarg.req) {
4283 dma_free_coherent(&vha->hw->pdev->dev, 4297 dma_free_coherent(&vha->hw->pdev->dev,
4284 sizeof(struct ct_sns_pkt), 4298 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
4285 sp->u.iocb_cmd.u.ctarg.req, 4299 sp->u.iocb_cmd.u.ctarg.req,
4286 sp->u.iocb_cmd.u.ctarg.req_dma); 4300 sp->u.iocb_cmd.u.ctarg.req_dma);
4287 sp->u.iocb_cmd.u.ctarg.req = NULL; 4301 sp->u.iocb_cmd.u.ctarg.req = NULL;
4288 } 4302 }
4289 if (sp->u.iocb_cmd.u.ctarg.rsp) { 4303 if (sp->u.iocb_cmd.u.ctarg.rsp) {
4290 dma_free_coherent(&vha->hw->pdev->dev, 4304 dma_free_coherent(&vha->hw->pdev->dev,
4291 sizeof(struct ct_sns_pkt), 4305 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
4292 sp->u.iocb_cmd.u.ctarg.rsp, 4306 sp->u.iocb_cmd.u.ctarg.rsp,
4293 sp->u.iocb_cmd.u.ctarg.rsp_dma); 4307 sp->u.iocb_cmd.u.ctarg.rsp_dma);
4294 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 4308 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
@@ -4349,6 +4363,7 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp)
4349 sp->u.iocb_cmd.u.ctarg.req = dma_zalloc_coherent( 4363 sp->u.iocb_cmd.u.ctarg.req = dma_zalloc_coherent(
4350 &vha->hw->pdev->dev, sizeof(struct ct_sns_pkt), 4364 &vha->hw->pdev->dev, sizeof(struct ct_sns_pkt),
4351 &sp->u.iocb_cmd.u.ctarg.req_dma, GFP_KERNEL); 4365 &sp->u.iocb_cmd.u.ctarg.req_dma, GFP_KERNEL);
4366 sp->u.iocb_cmd.u.ctarg.req_allocated_size = sizeof(struct ct_sns_pkt);
4352 if (!sp->u.iocb_cmd.u.ctarg.req) { 4367 if (!sp->u.iocb_cmd.u.ctarg.req) {
4353 ql_log(ql_log_warn, vha, 0xffff, 4368 ql_log(ql_log_warn, vha, 0xffff,
4354 "Failed to allocate ct_sns request.\n"); 4369 "Failed to allocate ct_sns request.\n");
@@ -4366,6 +4381,7 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp)
4366 sp->u.iocb_cmd.u.ctarg.rsp = dma_zalloc_coherent( 4381 sp->u.iocb_cmd.u.ctarg.rsp = dma_zalloc_coherent(
4367 &vha->hw->pdev->dev, rspsz, 4382 &vha->hw->pdev->dev, rspsz,
4368 &sp->u.iocb_cmd.u.ctarg.rsp_dma, GFP_KERNEL); 4383 &sp->u.iocb_cmd.u.ctarg.rsp_dma, GFP_KERNEL);
4384 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size = sizeof(struct ct_sns_pkt);
4369 if (!sp->u.iocb_cmd.u.ctarg.rsp) { 4385 if (!sp->u.iocb_cmd.u.ctarg.rsp) {
4370 ql_log(ql_log_warn, vha, 0xffff, 4386 ql_log(ql_log_warn, vha, 0xffff,
4371 "Failed to allocate ct_sns request.\n"); 4387 "Failed to allocate ct_sns request.\n");
@@ -4425,14 +4441,14 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp)
4425done_free_sp: 4441done_free_sp:
4426 if (sp->u.iocb_cmd.u.ctarg.req) { 4442 if (sp->u.iocb_cmd.u.ctarg.req) {
4427 dma_free_coherent(&vha->hw->pdev->dev, 4443 dma_free_coherent(&vha->hw->pdev->dev,
4428 sizeof(struct ct_sns_pkt), 4444 sp->u.iocb_cmd.u.ctarg.req_allocated_size,
4429 sp->u.iocb_cmd.u.ctarg.req, 4445 sp->u.iocb_cmd.u.ctarg.req,
4430 sp->u.iocb_cmd.u.ctarg.req_dma); 4446 sp->u.iocb_cmd.u.ctarg.req_dma);
4431 sp->u.iocb_cmd.u.ctarg.req = NULL; 4447 sp->u.iocb_cmd.u.ctarg.req = NULL;
4432 } 4448 }
4433 if (sp->u.iocb_cmd.u.ctarg.rsp) { 4449 if (sp->u.iocb_cmd.u.ctarg.rsp) {
4434 dma_free_coherent(&vha->hw->pdev->dev, 4450 dma_free_coherent(&vha->hw->pdev->dev,
4435 sizeof(struct ct_sns_pkt), 4451 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
4436 sp->u.iocb_cmd.u.ctarg.rsp, 4452 sp->u.iocb_cmd.u.ctarg.rsp,
4437 sp->u.iocb_cmd.u.ctarg.rsp_dma); 4453 sp->u.iocb_cmd.u.ctarg.rsp_dma);
4438 sp->u.iocb_cmd.u.ctarg.rsp = NULL; 4454 sp->u.iocb_cmd.u.ctarg.rsp = NULL;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 7b675243bd16..1b19b954bbae 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -591,12 +591,14 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
591 conflict_fcport = 591 conflict_fcport =
592 qla2x00_find_fcport_by_wwpn(vha, 592 qla2x00_find_fcport_by_wwpn(vha,
593 e->port_name, 0); 593 e->port_name, 0);
594 ql_dbg(ql_dbg_disc, vha, 0x20e6, 594 if (conflict_fcport) {
595 "%s %d %8phC post del sess\n", 595 qlt_schedule_sess_for_deletion
596 __func__, __LINE__, 596 (conflict_fcport);
597 conflict_fcport->port_name); 597 ql_dbg(ql_dbg_disc, vha, 0x20e6,
598 qlt_schedule_sess_for_deletion 598 "%s %d %8phC post del sess\n",
599 (conflict_fcport); 599 __func__, __LINE__,
600 conflict_fcport->port_name);
601 }
600 } 602 }
601 603
602 /* FW already picked this loop id for another fcport */ 604 /* FW already picked this loop id for another fcport */
@@ -1487,11 +1489,10 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun,
1487 1489
1488 wait_for_completion(&tm_iocb->u.tmf.comp); 1490 wait_for_completion(&tm_iocb->u.tmf.comp);
1489 1491
1490 rval = tm_iocb->u.tmf.comp_status == CS_COMPLETE ? 1492 rval = tm_iocb->u.tmf.data;
1491 QLA_SUCCESS : QLA_FUNCTION_FAILED;
1492 1493
1493 if ((rval != QLA_SUCCESS) || tm_iocb->u.tmf.data) { 1494 if (rval != QLA_SUCCESS) {
1494 ql_dbg(ql_dbg_taskm, vha, 0x8030, 1495 ql_log(ql_log_warn, vha, 0x8030,
1495 "TM IOCB failed (%x).\n", rval); 1496 "TM IOCB failed (%x).\n", rval);
1496 } 1497 }
1497 1498
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 37ae0f6d8ae5..59fd5a9dfeb8 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -222,6 +222,8 @@ qla2xxx_get_qpair_sp(struct qla_qpair *qpair, fc_port_t *fcport, gfp_t flag)
222 sp->fcport = fcport; 222 sp->fcport = fcport;
223 sp->iocbs = 1; 223 sp->iocbs = 1;
224 sp->vha = qpair->vha; 224 sp->vha = qpair->vha;
225 INIT_LIST_HEAD(&sp->elem);
226
225done: 227done:
226 if (!sp) 228 if (!sp)
227 QLA_QPAIR_MARK_NOT_BUSY(qpair); 229 QLA_QPAIR_MARK_NOT_BUSY(qpair);
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 9fa5a2557f2c..7756106d4555 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -631,6 +631,9 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
631 unsigned long flags; 631 unsigned long flags;
632 fc_port_t *fcport = NULL; 632 fc_port_t *fcport = NULL;
633 633
634 if (!vha->hw->flags.fw_started)
635 return;
636
634 /* Setup to process RIO completion. */ 637 /* Setup to process RIO completion. */
635 handle_cnt = 0; 638 handle_cnt = 0;
636 if (IS_CNA_CAPABLE(ha)) 639 if (IS_CNA_CAPABLE(ha))
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 7e875f575229..f0ec13d48bf3 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -4220,6 +4220,9 @@ qla25xx_init_req_que(struct scsi_qla_host *vha, struct req_que *req)
4220 mbx_cmd_t *mcp = &mc; 4220 mbx_cmd_t *mcp = &mc;
4221 struct qla_hw_data *ha = vha->hw; 4221 struct qla_hw_data *ha = vha->hw;
4222 4222
4223 if (!ha->flags.fw_started)
4224 return QLA_SUCCESS;
4225
4223 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3, 4226 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d3,
4224 "Entered %s.\n", __func__); 4227 "Entered %s.\n", __func__);
4225 4228
@@ -4289,6 +4292,9 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
4289 mbx_cmd_t *mcp = &mc; 4292 mbx_cmd_t *mcp = &mc;
4290 struct qla_hw_data *ha = vha->hw; 4293 struct qla_hw_data *ha = vha->hw;
4291 4294
4295 if (!ha->flags.fw_started)
4296 return QLA_SUCCESS;
4297
4292 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6, 4298 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10d6,
4293 "Entered %s.\n", __func__); 4299 "Entered %s.\n", __func__);
4294 4300
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index f6f0a759a7c2..aa727d07b702 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -152,11 +152,18 @@ int
152qla24xx_disable_vp(scsi_qla_host_t *vha) 152qla24xx_disable_vp(scsi_qla_host_t *vha)
153{ 153{
154 unsigned long flags; 154 unsigned long flags;
155 int ret; 155 int ret = QLA_SUCCESS;
156 fc_port_t *fcport;
157
158 if (vha->hw->flags.fw_started)
159 ret = qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
156 160
157 ret = qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
158 atomic_set(&vha->loop_state, LOOP_DOWN); 161 atomic_set(&vha->loop_state, LOOP_DOWN);
159 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 162 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
163 list_for_each_entry(fcport, &vha->vp_fcports, list)
164 fcport->logout_on_delete = 0;
165
166 qla2x00_mark_all_devices_lost(vha, 0);
160 167
161 /* Remove port id from vp target map */ 168 /* Remove port id from vp target map */
162 spin_lock_irqsave(&vha->hw->hardware_lock, flags); 169 spin_lock_irqsave(&vha->hw->hardware_lock, flags);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index e881fce7477a..1fbd16c8c9a7 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -303,6 +303,7 @@ static void qla2x00_free_device(scsi_qla_host_t *);
303static int qla2xxx_map_queues(struct Scsi_Host *shost); 303static int qla2xxx_map_queues(struct Scsi_Host *shost);
304static void qla2x00_destroy_deferred_work(struct qla_hw_data *); 304static void qla2x00_destroy_deferred_work(struct qla_hw_data *);
305 305
306
306struct scsi_host_template qla2xxx_driver_template = { 307struct scsi_host_template qla2xxx_driver_template = {
307 .module = THIS_MODULE, 308 .module = THIS_MODULE,
308 .name = QLA2XXX_DRIVER_NAME, 309 .name = QLA2XXX_DRIVER_NAME,
@@ -1147,7 +1148,7 @@ static inline int test_fcport_count(scsi_qla_host_t *vha)
1147 * qla2x00_wait_for_sess_deletion can only be called from remove_one. 1148 * qla2x00_wait_for_sess_deletion can only be called from remove_one.
1148 * it has dependency on UNLOADING flag to stop device discovery 1149 * it has dependency on UNLOADING flag to stop device discovery
1149 */ 1150 */
1150static void 1151void
1151qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) 1152qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha)
1152{ 1153{
1153 qla2x00_mark_all_devices_lost(vha, 0); 1154 qla2x00_mark_all_devices_lost(vha, 0);
@@ -3180,6 +3181,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3180 "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", 3181 "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n",
3181 req->req_q_in, req->req_q_out, rsp->rsp_q_in, rsp->rsp_q_out); 3182 req->req_q_in, req->req_q_out, rsp->rsp_q_in, rsp->rsp_q_out);
3182 3183
3184 ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0);
3185
3183 if (ha->isp_ops->initialize_adapter(base_vha)) { 3186 if (ha->isp_ops->initialize_adapter(base_vha)) {
3184 ql_log(ql_log_fatal, base_vha, 0x00d6, 3187 ql_log(ql_log_fatal, base_vha, 0x00d6,
3185 "Failed to initialize adapter - Adapter flags %x.\n", 3188 "Failed to initialize adapter - Adapter flags %x.\n",
@@ -3216,8 +3219,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3216 host->can_queue, base_vha->req, 3219 host->can_queue, base_vha->req,
3217 base_vha->mgmt_svr_loop_id, host->sg_tablesize); 3220 base_vha->mgmt_svr_loop_id, host->sg_tablesize);
3218 3221
3219 ha->wq = alloc_workqueue("qla2xxx_wq", 0, 0);
3220
3221 if (ha->mqenable) { 3222 if (ha->mqenable) {
3222 bool mq = false; 3223 bool mq = false;
3223 bool startit = false; 3224 bool startit = false;
@@ -3603,6 +3604,8 @@ qla2x00_remove_one(struct pci_dev *pdev)
3603 3604
3604 base_vha = pci_get_drvdata(pdev); 3605 base_vha = pci_get_drvdata(pdev);
3605 ha = base_vha->hw; 3606 ha = base_vha->hw;
3607 ql_log(ql_log_info, base_vha, 0xb079,
3608 "Removing driver\n");
3606 3609
3607 /* Indicate device removal to prevent future board_disable and wait 3610 /* Indicate device removal to prevent future board_disable and wait
3608 * until any pending board_disable has completed. */ 3611 * until any pending board_disable has completed. */
@@ -3625,6 +3628,21 @@ qla2x00_remove_one(struct pci_dev *pdev)
3625 } 3628 }
3626 qla2x00_wait_for_hba_ready(base_vha); 3629 qla2x00_wait_for_hba_ready(base_vha);
3627 3630
3631 if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) {
3632 if (ha->flags.fw_started)
3633 qla2x00_abort_isp_cleanup(base_vha);
3634 } else if (!IS_QLAFX00(ha)) {
3635 if (IS_QLA8031(ha)) {
3636 ql_dbg(ql_dbg_p3p, base_vha, 0xb07e,
3637 "Clearing fcoe driver presence.\n");
3638 if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS)
3639 ql_dbg(ql_dbg_p3p, base_vha, 0xb079,
3640 "Error while clearing DRV-Presence.\n");
3641 }
3642
3643 qla2x00_try_to_stop_firmware(base_vha);
3644 }
3645
3628 qla2x00_wait_for_sess_deletion(base_vha); 3646 qla2x00_wait_for_sess_deletion(base_vha);
3629 3647
3630 /* 3648 /*
@@ -3648,14 +3666,6 @@ qla2x00_remove_one(struct pci_dev *pdev)
3648 3666
3649 qla2x00_delete_all_vps(ha, base_vha); 3667 qla2x00_delete_all_vps(ha, base_vha);
3650 3668
3651 if (IS_QLA8031(ha)) {
3652 ql_dbg(ql_dbg_p3p, base_vha, 0xb07e,
3653 "Clearing fcoe driver presence.\n");
3654 if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS)
3655 ql_dbg(ql_dbg_p3p, base_vha, 0xb079,
3656 "Error while clearing DRV-Presence.\n");
3657 }
3658
3659 qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); 3669 qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16);
3660 3670
3661 qla2x00_dfs_remove(base_vha); 3671 qla2x00_dfs_remove(base_vha);
@@ -3715,24 +3725,6 @@ qla2x00_free_device(scsi_qla_host_t *vha)
3715 qla2x00_stop_timer(vha); 3725 qla2x00_stop_timer(vha);
3716 3726
3717 qla25xx_delete_queues(vha); 3727 qla25xx_delete_queues(vha);
3718
3719 if (ha->flags.fce_enabled)
3720 qla2x00_disable_fce_trace(vha, NULL, NULL);
3721
3722 if (ha->eft)
3723 qla2x00_disable_eft_trace(vha);
3724
3725 if (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) {
3726 if (ha->flags.fw_started)
3727 qla2x00_abort_isp_cleanup(vha);
3728 } else {
3729 if (ha->flags.fw_started) {
3730 /* Stop currently executing firmware. */
3731 qla2x00_try_to_stop_firmware(vha);
3732 ha->flags.fw_started = 0;
3733 }
3734 }
3735
3736 vha->flags.online = 0; 3728 vha->flags.online = 0;
3737 3729
3738 /* turn-off interrupts on the card */ 3730 /* turn-off interrupts on the card */
@@ -6028,8 +6020,9 @@ qla2x00_do_dpc(void *data)
6028 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 6020 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
6029 } 6021 }
6030 6022
6031 if (test_and_clear_bit(ISP_ABORT_NEEDED, 6023 if (test_and_clear_bit
6032 &base_vha->dpc_flags)) { 6024 (ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
6025 !test_bit(UNLOADING, &base_vha->dpc_flags)) {
6033 6026
6034 ql_dbg(ql_dbg_dpc, base_vha, 0x4007, 6027 ql_dbg(ql_dbg_dpc, base_vha, 0x4007,
6035 "ISP abort scheduled.\n"); 6028 "ISP abort scheduled.\n");
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 04458eb19d38..4499c787165f 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -1880,6 +1880,9 @@ qla24xx_beacon_off(struct scsi_qla_host *vha)
1880 if (IS_P3P_TYPE(ha)) 1880 if (IS_P3P_TYPE(ha))
1881 return QLA_SUCCESS; 1881 return QLA_SUCCESS;
1882 1882
1883 if (!ha->flags.fw_started)
1884 return QLA_SUCCESS;
1885
1883 ha->beacon_blink_led = 0; 1886 ha->beacon_blink_led = 0;
1884 1887
1885 if (IS_QLA2031(ha) || IS_QLA27XX(ha)) 1888 if (IS_QLA2031(ha) || IS_QLA27XX(ha))
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 8932ae81a15a..2715cdaa669c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -296,6 +296,20 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
296 rtn = host->hostt->eh_timed_out(scmd); 296 rtn = host->hostt->eh_timed_out(scmd);
297 297
298 if (rtn == BLK_EH_DONE) { 298 if (rtn == BLK_EH_DONE) {
299 /*
300 * For blk-mq, we must set the request state to complete now
301 * before sending the request to the scsi error handler. This
302 * will prevent a use-after-free in the event the LLD manages
303 * to complete the request before the error handler finishes
304 * processing this timed out request.
305 *
306 * If the request was already completed, then the LLD beat the
307 * time out handler from transferring the request to the scsi
308 * error handler. In that case we can return immediately as no
309 * further action is required.
310 */
311 if (req->q->mq_ops && !blk_mq_mark_complete(req))
312 return rtn;
299 if (scsi_abort_command(scmd) != SUCCESS) { 313 if (scsi_abort_command(scmd) != SUCCESS) {
300 set_host_byte(scmd, DID_TIME_OUT); 314 set_host_byte(scmd, DID_TIME_OUT);
301 scsi_eh_scmd_add(scmd); 315 scsi_eh_scmd_add(scmd);
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index a14fef11776e..2bf3bf73886e 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -391,7 +391,8 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf)
391 * Check that all zones of the device are equal. The last zone can however 391 * Check that all zones of the device are equal. The last zone can however
392 * be smaller. The zone size must also be a power of two number of LBAs. 392 * be smaller. The zone size must also be a power of two number of LBAs.
393 * 393 *
394 * Returns the zone size in bytes upon success or an error code upon failure. 394 * Returns the zone size in number of blocks upon success or an error code
395 * upon failure.
395 */ 396 */
396static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp) 397static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp)
397{ 398{
@@ -401,7 +402,7 @@ static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp)
401 unsigned char *rec; 402 unsigned char *rec;
402 unsigned int buf_len; 403 unsigned int buf_len;
403 unsigned int list_length; 404 unsigned int list_length;
404 int ret; 405 s64 ret;
405 u8 same; 406 u8 same;
406 407
407 /* Get a buffer */ 408 /* Get a buffer */
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index cd2fdac000c9..ba9ba0e04f42 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1741,15 +1741,11 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
1741 * 1741 *
1742 * With scsi-mq enabled, there are a fixed number of preallocated 1742 * With scsi-mq enabled, there are a fixed number of preallocated
1743 * requests equal in number to shost->can_queue. If all of the 1743 * requests equal in number to shost->can_queue. If all of the
1744 * preallocated requests are already in use, then using GFP_ATOMIC with 1744 * preallocated requests are already in use, then blk_get_request()
1745 * blk_get_request() will return -EWOULDBLOCK, whereas using GFP_KERNEL 1745 * will sleep until an active command completes, freeing up a request.
1746 * will cause blk_get_request() to sleep until an active command 1746 * Although waiting in an asynchronous interface is less than ideal, we
1747 * completes, freeing up a request. Neither option is ideal, but 1747 * do not want to use BLK_MQ_REQ_NOWAIT here because userspace might
1748 * GFP_KERNEL is the better choice to prevent userspace from getting an 1748 * not expect an EWOULDBLOCK from this condition.
1749 * unexpected EWOULDBLOCK.
1750 *
1751 * With scsi-mq disabled, blk_get_request() with GFP_KERNEL usually
1752 * does not sleep except under memory pressure.
1753 */ 1749 */
1754 rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ? 1750 rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ?
1755 REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0); 1751 REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0);
@@ -2185,6 +2181,7 @@ sg_add_sfp(Sg_device * sdp)
2185 write_lock_irqsave(&sdp->sfd_lock, iflags); 2181 write_lock_irqsave(&sdp->sfd_lock, iflags);
2186 if (atomic_read(&sdp->detaching)) { 2182 if (atomic_read(&sdp->detaching)) {
2187 write_unlock_irqrestore(&sdp->sfd_lock, iflags); 2183 write_unlock_irqrestore(&sdp->sfd_lock, iflags);
2184 kfree(sfp);
2188 return ERR_PTR(-ENODEV); 2185 return ERR_PTR(-ENODEV);
2189 } 2186 }
2190 list_add_tail(&sfp->sfd_siblings, &sdp->sfds); 2187 list_add_tail(&sfp->sfd_siblings, &sdp->sfds);
diff --git a/drivers/soc/imx/gpc.c b/drivers/soc/imx/gpc.c
index 32f0748fd067..0097a939487f 100644
--- a/drivers/soc/imx/gpc.c
+++ b/drivers/soc/imx/gpc.c
@@ -27,9 +27,16 @@
27#define GPC_PGC_SW2ISO_SHIFT 0x8 27#define GPC_PGC_SW2ISO_SHIFT 0x8
28#define GPC_PGC_SW_SHIFT 0x0 28#define GPC_PGC_SW_SHIFT 0x0
29 29
30#define GPC_PGC_PCI_PDN 0x200
31#define GPC_PGC_PCI_SR 0x20c
32
30#define GPC_PGC_GPU_PDN 0x260 33#define GPC_PGC_GPU_PDN 0x260
31#define GPC_PGC_GPU_PUPSCR 0x264 34#define GPC_PGC_GPU_PUPSCR 0x264
32#define GPC_PGC_GPU_PDNSCR 0x268 35#define GPC_PGC_GPU_PDNSCR 0x268
36#define GPC_PGC_GPU_SR 0x26c
37
38#define GPC_PGC_DISP_PDN 0x240
39#define GPC_PGC_DISP_SR 0x24c
33 40
34#define GPU_VPU_PUP_REQ BIT(1) 41#define GPU_VPU_PUP_REQ BIT(1)
35#define GPU_VPU_PDN_REQ BIT(0) 42#define GPU_VPU_PDN_REQ BIT(0)
@@ -318,10 +325,24 @@ static const struct of_device_id imx_gpc_dt_ids[] = {
318 { } 325 { }
319}; 326};
320 327
328static const struct regmap_range yes_ranges[] = {
329 regmap_reg_range(GPC_CNTR, GPC_CNTR),
330 regmap_reg_range(GPC_PGC_PCI_PDN, GPC_PGC_PCI_SR),
331 regmap_reg_range(GPC_PGC_GPU_PDN, GPC_PGC_GPU_SR),
332 regmap_reg_range(GPC_PGC_DISP_PDN, GPC_PGC_DISP_SR),
333};
334
335static const struct regmap_access_table access_table = {
336 .yes_ranges = yes_ranges,
337 .n_yes_ranges = ARRAY_SIZE(yes_ranges),
338};
339
321static const struct regmap_config imx_gpc_regmap_config = { 340static const struct regmap_config imx_gpc_regmap_config = {
322 .reg_bits = 32, 341 .reg_bits = 32,
323 .val_bits = 32, 342 .val_bits = 32,
324 .reg_stride = 4, 343 .reg_stride = 4,
344 .rd_table = &access_table,
345 .wr_table = &access_table,
325 .max_register = 0x2ac, 346 .max_register = 0x2ac,
326}; 347};
327 348
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index a1a0025b59e0..d5d33e12e952 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -402,6 +402,8 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
402 fput(asma->file); 402 fput(asma->file);
403 goto out; 403 goto out;
404 } 404 }
405 } else {
406 vma_set_anonymous(vma);
405 } 407 }
406 408
407 if (vma->vm_file) 409 if (vma->vm_file)
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 0ecffab52ec2..abdaf7cf8162 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1842,15 +1842,15 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
1842 memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN); 1842 memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
1843 1843
1844 if (dev->flags & IFF_PROMISC) { 1844 if (dev->flags & IFF_PROMISC) {
1845 hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER, 1845 hostif_mib_set_request_int(priv, LOCAL_MULTICAST_FILTER,
1846 MCAST_FILTER_PROMISC); 1846 MCAST_FILTER_PROMISC);
1847 goto spin_unlock; 1847 goto spin_unlock;
1848 } 1848 }
1849 1849
1850 if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) || 1850 if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) ||
1851 (dev->flags & IFF_ALLMULTI)) { 1851 (dev->flags & IFF_ALLMULTI)) {
1852 hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER, 1852 hostif_mib_set_request_int(priv, LOCAL_MULTICAST_FILTER,
1853 MCAST_FILTER_MCASTALL); 1853 MCAST_FILTER_MCASTALL);
1854 goto spin_unlock; 1854 goto spin_unlock;
1855 } 1855 }
1856 1856
@@ -1866,8 +1866,8 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
1866 ETH_ALEN * mc_count); 1866 ETH_ALEN * mc_count);
1867 } else { 1867 } else {
1868 priv->sme_i.sme_flag |= SME_MULTICAST; 1868 priv->sme_i.sme_flag |= SME_MULTICAST;
1869 hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER, 1869 hostif_mib_set_request_int(priv, LOCAL_MULTICAST_FILTER,
1870 MCAST_FILTER_MCAST); 1870 MCAST_FILTER_MCAST);
1871 } 1871 }
1872 1872
1873spin_unlock: 1873spin_unlock:
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index a3a83424a926..16478fe9e3f8 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -11,7 +11,6 @@
11 * (at your option) any later version. 11 * (at your option) any later version.
12 */ 12 */
13 13
14#include <asm/cacheflush.h>
15#include <linux/clk.h> 14#include <linux/clk.h>
16#include <linux/mm.h> 15#include <linux/mm.h>
17#include <linux/pagemap.h> 16#include <linux/pagemap.h>
@@ -24,6 +23,8 @@
24#include <media/v4l2-ioctl.h> 23#include <media/v4l2-ioctl.h>
25#include <media/v4l2-mc.h> 24#include <media/v4l2-mc.h>
26 25
26#include <asm/cacheflush.h>
27
27#include "iss_video.h" 28#include "iss_video.h"
28#include "iss.h" 29#include "iss.h"
29 30
diff --git a/drivers/staging/rtl8188eu/Kconfig b/drivers/staging/rtl8188eu/Kconfig
index 673fdce25530..ff7832798a77 100644
--- a/drivers/staging/rtl8188eu/Kconfig
+++ b/drivers/staging/rtl8188eu/Kconfig
@@ -7,7 +7,6 @@ config R8188EU
7 select LIB80211 7 select LIB80211
8 select LIB80211_CRYPT_WEP 8 select LIB80211_CRYPT_WEP
9 select LIB80211_CRYPT_CCMP 9 select LIB80211_CRYPT_CCMP
10 select LIB80211_CRYPT_TKIP
11 ---help--- 10 ---help---
12 This option adds the Realtek RTL8188EU USB device such as TP-Link TL-WN725N. 11 This option adds the Realtek RTL8188EU USB device such as TP-Link TL-WN725N.
13 If built as a module, it will be called r8188eu. 12 If built as a module, it will be called r8188eu.
diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 05936a45eb93..c6857a5be12a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -23,7 +23,6 @@
23#include <mon.h> 23#include <mon.h>
24#include <wifi.h> 24#include <wifi.h>
25#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
26#include <net/lib80211.h>
27 26
28#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ 27#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */
29#define LLC_HEADER_SIZE 6 /* LLC Header Length */ 28#define LLC_HEADER_SIZE 6 /* LLC Header Length */
@@ -221,20 +220,31 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter)
221static int recvframe_chkmic(struct adapter *adapter, 220static int recvframe_chkmic(struct adapter *adapter,
222 struct recv_frame *precvframe) 221 struct recv_frame *precvframe)
223{ 222{
224 int res = _SUCCESS; 223 int i, res = _SUCCESS;
225 struct rx_pkt_attrib *prxattrib = &precvframe->attrib; 224 u32 datalen;
226 struct sta_info *stainfo = rtw_get_stainfo(&adapter->stapriv, prxattrib->ta); 225 u8 miccode[8];
226 u8 bmic_err = false, brpt_micerror = true;
227 u8 *pframe, *payload, *pframemic;
228 u8 *mickey;
229 struct sta_info *stainfo;
230 struct rx_pkt_attrib *prxattrib = &precvframe->attrib;
231 struct security_priv *psecuritypriv = &adapter->securitypriv;
232
233 struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
234 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
235
236 stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
227 237
228 if (prxattrib->encrypt == _TKIP_) { 238 if (prxattrib->encrypt == _TKIP_) {
239 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
240 ("\n %s: prxattrib->encrypt==_TKIP_\n", __func__));
241 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
242 ("\n %s: da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
243 __func__, prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2],
244 prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5]));
245
246 /* calculate mic code */
229 if (stainfo) { 247 if (stainfo) {
230 int key_idx;
231 const int iv_len = 8, icv_len = 4, key_length = 32;
232 struct sk_buff *skb = precvframe->pkt;
233 u8 key[32], iv[8], icv[4], *pframe = skb->data;
234 void *crypto_private = NULL;
235 struct lib80211_crypto_ops *crypto_ops = try_then_request_module(lib80211_get_crypto_ops("TKIP"), "lib80211_crypt_tkip");
236 struct security_priv *psecuritypriv = &adapter->securitypriv;
237
238 if (IS_MCAST(prxattrib->ra)) { 248 if (IS_MCAST(prxattrib->ra)) {
239 if (!psecuritypriv) { 249 if (!psecuritypriv) {
240 res = _FAIL; 250 res = _FAIL;
@@ -243,58 +253,115 @@ static int recvframe_chkmic(struct adapter *adapter,
243 DBG_88E("\n %s: didn't install group key!!!!!!!!!!\n", __func__); 253 DBG_88E("\n %s: didn't install group key!!!!!!!!!!\n", __func__);
244 goto exit; 254 goto exit;
245 } 255 }
246 key_idx = prxattrib->key_index; 256 mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
247 memcpy(key, psecuritypriv->dot118021XGrpKey[key_idx].skey, 16); 257
248 memcpy(key + 16, psecuritypriv->dot118021XGrprxmickey[key_idx].skey, 16); 258 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
259 ("\n %s: bcmc key\n", __func__));
249 } else { 260 } else {
250 key_idx = 0; 261 mickey = &stainfo->dot11tkiprxmickey.skey[0];
251 memcpy(key, stainfo->dot118021x_UncstKey.skey, 16); 262 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
252 memcpy(key + 16, stainfo->dot11tkiprxmickey.skey, 16); 263 ("\n %s: unicast key\n", __func__));
253 } 264 }
254 265
255 if (!crypto_ops) { 266 /* icv_len included the mic code */
256 res = _FAIL; 267 datalen = precvframe->pkt->len-prxattrib->hdrlen -
257 goto exit_lib80211_tkip; 268 prxattrib->iv_len-prxattrib->icv_len-8;
258 } 269 pframe = precvframe->pkt->data;
270 payload = pframe+prxattrib->hdrlen+prxattrib->iv_len;
259 271
260 memcpy(iv, pframe + prxattrib->hdrlen, iv_len); 272 RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len));
261 memcpy(icv, pframe + skb->len - icv_len, icv_len); 273 rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0],
262 memmove(pframe + iv_len, pframe, prxattrib->hdrlen); 274 (unsigned char)prxattrib->priority); /* care the length of the data */
263 275
264 skb_pull(skb, iv_len); 276 pframemic = payload+datalen;
265 skb_trim(skb, skb->len - icv_len);
266 277
267 crypto_private = crypto_ops->init(key_idx); 278 bmic_err = false;
268 if (!crypto_private) { 279
269 res = _FAIL; 280 for (i = 0; i < 8; i++) {
270 goto exit_lib80211_tkip; 281 if (miccode[i] != *(pframemic+i)) {
271 } 282 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
272 if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { 283 ("%s: miccode[%d](%02x)!=*(pframemic+%d)(%02x) ",
273 res = _FAIL; 284 __func__, i, miccode[i], i, *(pframemic + i)));
274 goto exit_lib80211_tkip; 285 bmic_err = true;
275 } 286 }
276 if (crypto_ops->decrypt_msdu(skb, key_idx, prxattrib->hdrlen, crypto_private)) {
277 res = _FAIL;
278 goto exit_lib80211_tkip;
279 } 287 }
280 288
281 memmove(pframe, pframe + iv_len, prxattrib->hdrlen); 289 if (bmic_err) {
282 skb_push(skb, iv_len); 290 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
283 skb_put(skb, icv_len); 291 ("\n *(pframemic-8)-*(pframemic-1)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
292 *(pframemic-8), *(pframemic-7), *(pframemic-6),
293 *(pframemic-5), *(pframemic-4), *(pframemic-3),
294 *(pframemic-2), *(pframemic-1)));
295 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
296 ("\n *(pframemic-16)-*(pframemic-9)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
297 *(pframemic-16), *(pframemic-15), *(pframemic-14),
298 *(pframemic-13), *(pframemic-12), *(pframemic-11),
299 *(pframemic-10), *(pframemic-9)));
300 {
301 uint i;
284 302
285 memcpy(pframe + prxattrib->hdrlen, iv, iv_len); 303 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
286 memcpy(pframe + skb->len - icv_len, icv, icv_len); 304 ("\n ======demp packet (len=%d)======\n",
305 precvframe->pkt->len));
306 for (i = 0; i < precvframe->pkt->len; i += 8) {
307 RT_TRACE(_module_rtl871x_recv_c_,
308 _drv_err_,
309 ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x",
310 *(precvframe->pkt->data+i),
311 *(precvframe->pkt->data+i+1),
312 *(precvframe->pkt->data+i+2),
313 *(precvframe->pkt->data+i+3),
314 *(precvframe->pkt->data+i+4),
315 *(precvframe->pkt->data+i+5),
316 *(precvframe->pkt->data+i+6),
317 *(precvframe->pkt->data+i+7)));
318 }
319 RT_TRACE(_module_rtl871x_recv_c_,
320 _drv_err_,
321 ("\n ====== demp packet end [len=%d]======\n",
322 precvframe->pkt->len));
323 RT_TRACE(_module_rtl871x_recv_c_,
324 _drv_err_,
325 ("\n hrdlen=%d,\n",
326 prxattrib->hdrlen));
327 }
287 328
288exit_lib80211_tkip: 329 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
289 if (crypto_ops && crypto_private) 330 ("ra=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x psecuritypriv->binstallGrpkey=%d ",
290 crypto_ops->deinit(crypto_private); 331 prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2],
332 prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5], psecuritypriv->binstallGrpkey));
333
334 /* double check key_index for some timing issue , */
335 /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */
336 if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index))
337 brpt_micerror = false;
338
339 if ((prxattrib->bdecrypted) && (brpt_micerror)) {
340 rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra));
341 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted));
342 DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted);
343 } else {
344 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted));
345 DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted);
346 }
347 res = _FAIL;
348 } else {
349 /* mic checked ok */
350 if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST(prxattrib->ra))) {
351 psecuritypriv->bcheck_grpkey = true;
352 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grpkey = true"));
353 }
354 }
291 } else { 355 } else {
292 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 356 RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
293 ("%s: rtw_get_stainfo==NULL!!!\n", __func__)); 357 ("%s: rtw_get_stainfo==NULL!!!\n", __func__));
294 } 358 }
359
360 skb_trim(precvframe->pkt, precvframe->pkt->len - 8);
295 } 361 }
296 362
297exit: 363exit:
364
298 return res; 365 return res;
299} 366}
300 367
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index bfe0b217e679..67a2490f055e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -650,71 +650,71 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
650 return res; 650 return res;
651} 651}
652 652
653/* The hlen isn't include the IV */
653u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) 654u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
654{ 655{ /* exclude ICV */
655 struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; 656 u16 pnl;
656 u32 res = _SUCCESS; 657 u32 pnh;
658 u8 rc4key[16];
659 u8 ttkey[16];
660 u8 crc[4];
661 struct arc4context mycontext;
662 int length;
663
664 u8 *pframe, *payload, *iv, *prwskey;
665 union pn48 dot11txpn;
666 struct sta_info *stainfo;
667 struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib;
668 struct security_priv *psecuritypriv = &padapter->securitypriv;
669 u32 res = _SUCCESS;
670
671
672 pframe = (unsigned char *)((struct recv_frame *)precvframe)->pkt->data;
657 673
658 /* 4 start to decrypt recvframe */ 674 /* 4 start to decrypt recvframe */
659 if (prxattrib->encrypt == _TKIP_) { 675 if (prxattrib->encrypt == _TKIP_) {
660 struct sta_info *stainfo = rtw_get_stainfo(&padapter->stapriv, prxattrib->ta); 676 stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
661
662 if (stainfo) { 677 if (stainfo) {
663 int key_idx;
664 const int iv_len = 8, icv_len = 4, key_length = 32;
665 void *crypto_private = NULL;
666 struct sk_buff *skb = ((struct recv_frame *)precvframe)->pkt;
667 u8 key[32], iv[8], icv[4], *pframe = skb->data;
668 struct lib80211_crypto_ops *crypto_ops = try_then_request_module(lib80211_get_crypto_ops("TKIP"), "lib80211_crypt_tkip");
669 struct security_priv *psecuritypriv = &padapter->securitypriv;
670
671 if (IS_MCAST(prxattrib->ra)) { 678 if (IS_MCAST(prxattrib->ra)) {
672 if (!psecuritypriv->binstallGrpkey) { 679 if (!psecuritypriv->binstallGrpkey) {
673 res = _FAIL; 680 res = _FAIL;
674 DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); 681 DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__);
675 goto exit; 682 goto exit;
676 } 683 }
677 key_idx = prxattrib->key_index; 684 prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
678 memcpy(key, psecuritypriv->dot118021XGrpKey[key_idx].skey, 16);
679 memcpy(key + 16, psecuritypriv->dot118021XGrprxmickey[key_idx].skey, 16);
680 } else { 685 } else {
681 key_idx = 0; 686 RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__));
682 memcpy(key, stainfo->dot118021x_UncstKey.skey, 16); 687 prwskey = &stainfo->dot118021x_UncstKey.skey[0];
683 memcpy(key + 16, stainfo->dot11tkiprxmickey.skey, 16);
684 } 688 }
685 689
686 if (!crypto_ops) { 690 iv = pframe+prxattrib->hdrlen;
687 res = _FAIL; 691 payload = pframe+prxattrib->iv_len+prxattrib->hdrlen;
688 goto exit_lib80211_tkip; 692 length = ((struct recv_frame *)precvframe)->pkt->len-prxattrib->hdrlen-prxattrib->iv_len;
689 }
690 693
691 memcpy(iv, pframe + prxattrib->hdrlen, iv_len); 694 GET_TKIP_PN(iv, dot11txpn);
692 memcpy(icv, pframe + skb->len - icv_len, icv_len);
693 695
694 crypto_private = crypto_ops->init(key_idx); 696 pnl = (u16)(dot11txpn.val);
695 if (!crypto_private) { 697 pnh = (u32)(dot11txpn.val>>16);
696 res = _FAIL;
697 goto exit_lib80211_tkip;
698 }
699 if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) {
700 res = _FAIL;
701 goto exit_lib80211_tkip;
702 }
703 if (crypto_ops->decrypt_mpdu(skb, prxattrib->hdrlen, crypto_private)) {
704 res = _FAIL;
705 goto exit_lib80211_tkip;
706 }
707 698
708 memmove(pframe, pframe + iv_len, prxattrib->hdrlen); 699 phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh);
709 skb_push(skb, iv_len); 700 phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);
710 skb_put(skb, icv_len);
711 701
712 memcpy(pframe + prxattrib->hdrlen, iv, iv_len); 702 /* 4 decrypt payload include icv */
713 memcpy(pframe + skb->len - icv_len, icv, icv_len);
714 703
715exit_lib80211_tkip: 704 arcfour_init(&mycontext, rc4key, 16);
716 if (crypto_ops && crypto_private) 705 arcfour_encrypt(&mycontext, payload, payload, length);
717 crypto_ops->deinit(crypto_private); 706
707 *((__le32 *)crc) = getcrc32(payload, length-4);
708
709 if (crc[3] != payload[length-1] ||
710 crc[2] != payload[length-2] ||
711 crc[1] != payload[length-3] ||
712 crc[0] != payload[length-4]) {
713 RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
714 ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n",
715 &crc, &payload[length-4]));
716 res = _FAIL;
717 }
718 } else { 718 } else {
719 RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo==NULL!!!\n")); 719 RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo==NULL!!!\n"));
720 res = _FAIL; 720 res = _FAIL;
diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c
index a61bc41b82d7..947c79532e10 100644
--- a/drivers/staging/speakup/speakup_soft.c
+++ b/drivers/staging/speakup/speakup_soft.c
@@ -198,11 +198,15 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
198 int chars_sent = 0; 198 int chars_sent = 0;
199 char __user *cp; 199 char __user *cp;
200 char *init; 200 char *init;
201 size_t bytes_per_ch = unicode ? 3 : 1;
201 u16 ch; 202 u16 ch;
202 int empty; 203 int empty;
203 unsigned long flags; 204 unsigned long flags;
204 DEFINE_WAIT(wait); 205 DEFINE_WAIT(wait);
205 206
207 if (count < bytes_per_ch)
208 return -EINVAL;
209
206 spin_lock_irqsave(&speakup_info.spinlock, flags); 210 spin_lock_irqsave(&speakup_info.spinlock, flags);
207 while (1) { 211 while (1) {
208 prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); 212 prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE);
@@ -228,7 +232,7 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
228 init = get_initstring(); 232 init = get_initstring();
229 233
230 /* Keep 3 bytes available for a 16bit UTF-8-encoded character */ 234 /* Keep 3 bytes available for a 16bit UTF-8-encoded character */
231 while (chars_sent <= count - 3) { 235 while (chars_sent <= count - bytes_per_ch) {
232 if (speakup_info.flushing) { 236 if (speakup_info.flushing) {
233 speakup_info.flushing = 0; 237 speakup_info.flushing = 0;
234 ch = '\x18'; 238 ch = '\x18';
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c
index 514986b57c2d..25eb3891e34b 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
@@ -652,6 +652,7 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)
652 struct iscsi_param *param; 652 struct iscsi_param *param;
653 u32 mrdsl, mbl; 653 u32 mrdsl, mbl;
654 u32 max_npdu, max_iso_npdu; 654 u32 max_npdu, max_iso_npdu;
655 u32 max_iso_payload;
655 656
656 if (conn->login->leading_connection) { 657 if (conn->login->leading_connection) {
657 param = iscsi_find_param_from_key(MAXBURSTLENGTH, 658 param = iscsi_find_param_from_key(MAXBURSTLENGTH,
@@ -670,8 +671,10 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)
670 mrdsl = conn_ops->MaxRecvDataSegmentLength; 671 mrdsl = conn_ops->MaxRecvDataSegmentLength;
671 max_npdu = mbl / mrdsl; 672 max_npdu = mbl / mrdsl;
672 673
673 max_iso_npdu = CXGBIT_MAX_ISO_PAYLOAD / 674 max_iso_payload = rounddown(CXGBIT_MAX_ISO_PAYLOAD, csk->emss);
674 (ISCSI_HDR_LEN + mrdsl + 675
676 max_iso_npdu = max_iso_payload /
677 (ISCSI_HDR_LEN + mrdsl +
675 cxgbit_digest_len[csk->submode]); 678 cxgbit_digest_len[csk->submode]);
676 679
677 csk->max_iso_npdu = min(max_npdu, max_iso_npdu); 680 csk->max_iso_npdu = min(max_npdu, max_iso_npdu);
@@ -741,6 +744,9 @@ static int cxgbit_set_params(struct iscsi_conn *conn)
741 if (conn_ops->MaxRecvDataSegmentLength > cdev->mdsl) 744 if (conn_ops->MaxRecvDataSegmentLength > cdev->mdsl)
742 conn_ops->MaxRecvDataSegmentLength = cdev->mdsl; 745 conn_ops->MaxRecvDataSegmentLength = cdev->mdsl;
743 746
747 if (cxgbit_set_digest(csk))
748 return -1;
749
744 if (conn->login->leading_connection) { 750 if (conn->login->leading_connection) {
745 param = iscsi_find_param_from_key(ERRORRECOVERYLEVEL, 751 param = iscsi_find_param_from_key(ERRORRECOVERYLEVEL,
746 conn->param_list); 752 conn->param_list);
@@ -764,7 +770,7 @@ static int cxgbit_set_params(struct iscsi_conn *conn)
764 if (is_t5(cdev->lldi.adapter_type)) 770 if (is_t5(cdev->lldi.adapter_type))
765 goto enable_ddp; 771 goto enable_ddp;
766 else 772 else
767 goto enable_digest; 773 return 0;
768 } 774 }
769 775
770 if (test_bit(CDEV_ISO_ENABLE, &cdev->flags)) { 776 if (test_bit(CDEV_ISO_ENABLE, &cdev->flags)) {
@@ -781,10 +787,6 @@ enable_ddp:
781 } 787 }
782 } 788 }
783 789
784enable_digest:
785 if (cxgbit_set_digest(csk))
786 return -1;
787
788 return 0; 790 return 0;
789} 791}
790 792
diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index 785f0ed037f7..ee34e9046f7e 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -3,6 +3,7 @@ config USB_CHIPIDEA
3 depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA 3 depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
4 select EXTCON 4 select EXTCON
5 select RESET_CONTROLLER 5 select RESET_CONTROLLER
6 select USB_ULPI_BUS
6 help 7 help
7 Say Y here if your system has a dual role high speed USB 8 Say Y here if your system has a dual role high speed USB
8 controller based on ChipIdea silicon IP. It supports: 9 controller based on ChipIdea silicon IP. It supports:
@@ -38,12 +39,4 @@ config USB_CHIPIDEA_HOST
38 help 39 help
39 Say Y here to enable host controller functionality of the 40 Say Y here to enable host controller functionality of the
40 ChipIdea driver. 41 ChipIdea driver.
41
42config USB_CHIPIDEA_ULPI
43 bool "ChipIdea ULPI PHY support"
44 depends on USB_ULPI_BUS=y || USB_ULPI_BUS=USB_CHIPIDEA
45 help
46 Say Y here if you have a ULPI PHY attached to your ChipIdea
47 controller.
48
49endif 42endif
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index e3d5e728fa53..12df94f78f72 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -1,11 +1,10 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o 2obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o
3 3
4ci_hdrc-y := core.o otg.o debug.o 4ci_hdrc-y := core.o otg.o debug.o ulpi.o
5ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o 5ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
6ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o 6ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o
7ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o 7ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o
8ci_hdrc-$(CONFIG_USB_CHIPIDEA_ULPI) += ulpi.o
9 8
10# Glue/Bridge layers go here 9# Glue/Bridge layers go here
11 10
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 0bf244d50544..6a2cc5cd0281 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -240,10 +240,8 @@ struct ci_hdrc {
240 240
241 struct ci_hdrc_platform_data *platdata; 241 struct ci_hdrc_platform_data *platdata;
242 int vbus_active; 242 int vbus_active;
243#ifdef CONFIG_USB_CHIPIDEA_ULPI
244 struct ulpi *ulpi; 243 struct ulpi *ulpi;
245 struct ulpi_ops ulpi_ops; 244 struct ulpi_ops ulpi_ops;
246#endif
247 struct phy *phy; 245 struct phy *phy;
248 /* old usb_phy interface */ 246 /* old usb_phy interface */
249 struct usb_phy *usb_phy; 247 struct usb_phy *usb_phy;
@@ -426,15 +424,9 @@ static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
426#endif 424#endif
427} 425}
428 426
429#if IS_ENABLED(CONFIG_USB_CHIPIDEA_ULPI)
430int ci_ulpi_init(struct ci_hdrc *ci); 427int ci_ulpi_init(struct ci_hdrc *ci);
431void ci_ulpi_exit(struct ci_hdrc *ci); 428void ci_ulpi_exit(struct ci_hdrc *ci);
432int ci_ulpi_resume(struct ci_hdrc *ci); 429int ci_ulpi_resume(struct ci_hdrc *ci);
433#else
434static inline int ci_ulpi_init(struct ci_hdrc *ci) { return 0; }
435static inline void ci_ulpi_exit(struct ci_hdrc *ci) { }
436static inline int ci_ulpi_resume(struct ci_hdrc *ci) { return 0; }
437#endif
438 430
439u32 hw_read_intr_enable(struct ci_hdrc *ci); 431u32 hw_read_intr_enable(struct ci_hdrc *ci);
440 432
diff --git a/drivers/usb/chipidea/ulpi.c b/drivers/usb/chipidea/ulpi.c
index 6da42dcd2888..dfec07e8ae1d 100644
--- a/drivers/usb/chipidea/ulpi.c
+++ b/drivers/usb/chipidea/ulpi.c
@@ -95,6 +95,9 @@ int ci_ulpi_resume(struct ci_hdrc *ci)
95{ 95{
96 int cnt = 100000; 96 int cnt = 100000;
97 97
98 if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI)
99 return 0;
100
98 while (cnt-- > 0) { 101 while (cnt-- > 0) {
99 if (hw_read(ci, OP_ULPI_VIEWPORT, ULPI_SYNC_STATE)) 102 if (hw_read(ci, OP_ULPI_VIEWPORT, ULPI_SYNC_STATE))
100 return 0; 103 return 0;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 998b32d0167e..75c4623ad779 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1831,6 +1831,9 @@ static const struct usb_device_id acm_ids[] = {
1831 { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */ 1831 { USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */
1832 .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */ 1832 .driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */
1833 }, 1833 },
1834 { USB_DEVICE(0x0ca6, 0xa050), /* Castles VEGA3000 */
1835 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1836 },
1834 1837
1835 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */ 1838 { USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
1836 .driver_info = CLEAR_HALT_CONDITIONS, 1839 .driver_info = CLEAR_HALT_CONDITIONS,
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index fcae521df29b..1fb266809966 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1142,10 +1142,14 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
1142 1142
1143 if (!udev || udev->state == USB_STATE_NOTATTACHED) { 1143 if (!udev || udev->state == USB_STATE_NOTATTACHED) {
1144 /* Tell hub_wq to disconnect the device or 1144 /* Tell hub_wq to disconnect the device or
1145 * check for a new connection 1145 * check for a new connection or over current condition.
1146 * Based on USB2.0 Spec Section 11.12.5,
1147 * C_PORT_OVER_CURRENT could be set while
1148 * PORT_OVER_CURRENT is not. So check for any of them.
1146 */ 1149 */
1147 if (udev || (portstatus & USB_PORT_STAT_CONNECTION) || 1150 if (udev || (portstatus & USB_PORT_STAT_CONNECTION) ||
1148 (portstatus & USB_PORT_STAT_OVERCURRENT)) 1151 (portstatus & USB_PORT_STAT_OVERCURRENT) ||
1152 (portchange & USB_PORT_STAT_C_OVERCURRENT))
1149 set_bit(port1, hub->change_bits); 1153 set_bit(port1, hub->change_bits);
1150 1154
1151 } else if (portstatus & USB_PORT_STAT_ENABLE) { 1155 } else if (portstatus & USB_PORT_STAT_ENABLE) {
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index a0f82cca2d9a..cefc99ae69b2 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3430,7 +3430,7 @@ static void dwc2_gadget_handle_incomplete_isoc_in(struct dwc2_hsotg *hsotg)
3430 for (idx = 1; idx < hsotg->num_of_eps; idx++) { 3430 for (idx = 1; idx < hsotg->num_of_eps; idx++) {
3431 hs_ep = hsotg->eps_in[idx]; 3431 hs_ep = hsotg->eps_in[idx];
3432 /* Proceed only unmasked ISOC EPs */ 3432 /* Proceed only unmasked ISOC EPs */
3433 if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) 3433 if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
3434 continue; 3434 continue;
3435 3435
3436 epctrl = dwc2_readl(hsotg->regs + DIEPCTL(idx)); 3436 epctrl = dwc2_readl(hsotg->regs + DIEPCTL(idx));
@@ -3476,7 +3476,7 @@ static void dwc2_gadget_handle_incomplete_isoc_out(struct dwc2_hsotg *hsotg)
3476 for (idx = 1; idx < hsotg->num_of_eps; idx++) { 3476 for (idx = 1; idx < hsotg->num_of_eps; idx++) {
3477 hs_ep = hsotg->eps_out[idx]; 3477 hs_ep = hsotg->eps_out[idx];
3478 /* Proceed only unmasked ISOC EPs */ 3478 /* Proceed only unmasked ISOC EPs */
3479 if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) 3479 if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
3480 continue; 3480 continue;
3481 3481
3482 epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx)); 3482 epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));
@@ -3650,7 +3650,7 @@ irq_retry:
3650 for (idx = 1; idx < hsotg->num_of_eps; idx++) { 3650 for (idx = 1; idx < hsotg->num_of_eps; idx++) {
3651 hs_ep = hsotg->eps_out[idx]; 3651 hs_ep = hsotg->eps_out[idx];
3652 /* Proceed only unmasked ISOC EPs */ 3652 /* Proceed only unmasked ISOC EPs */
3653 if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) 3653 if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
3654 continue; 3654 continue;
3655 3655
3656 epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx)); 3656 epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index b1104be3429c..6e2cdd7b93d4 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2665,34 +2665,35 @@ static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
2665 2665
2666#define DWC2_USB_DMA_ALIGN 4 2666#define DWC2_USB_DMA_ALIGN 4
2667 2667
2668struct dma_aligned_buffer {
2669 void *kmalloc_ptr;
2670 void *old_xfer_buffer;
2671 u8 data[0];
2672};
2673
2674static void dwc2_free_dma_aligned_buffer(struct urb *urb) 2668static void dwc2_free_dma_aligned_buffer(struct urb *urb)
2675{ 2669{
2676 struct dma_aligned_buffer *temp; 2670 void *stored_xfer_buffer;
2671 size_t length;
2677 2672
2678 if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) 2673 if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
2679 return; 2674 return;
2680 2675
2681 temp = container_of(urb->transfer_buffer, 2676 /* Restore urb->transfer_buffer from the end of the allocated area */
2682 struct dma_aligned_buffer, data); 2677 memcpy(&stored_xfer_buffer, urb->transfer_buffer +
2678 urb->transfer_buffer_length, sizeof(urb->transfer_buffer));
2683 2679
2684 if (usb_urb_dir_in(urb)) 2680 if (usb_urb_dir_in(urb)) {
2685 memcpy(temp->old_xfer_buffer, temp->data, 2681 if (usb_pipeisoc(urb->pipe))
2686 urb->transfer_buffer_length); 2682 length = urb->transfer_buffer_length;
2687 urb->transfer_buffer = temp->old_xfer_buffer; 2683 else
2688 kfree(temp->kmalloc_ptr); 2684 length = urb->actual_length;
2685
2686 memcpy(stored_xfer_buffer, urb->transfer_buffer, length);
2687 }
2688 kfree(urb->transfer_buffer);
2689 urb->transfer_buffer = stored_xfer_buffer;
2689 2690
2690 urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER; 2691 urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
2691} 2692}
2692 2693
2693static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags) 2694static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
2694{ 2695{
2695 struct dma_aligned_buffer *temp, *kmalloc_ptr; 2696 void *kmalloc_ptr;
2696 size_t kmalloc_size; 2697 size_t kmalloc_size;
2697 2698
2698 if (urb->num_sgs || urb->sg || 2699 if (urb->num_sgs || urb->sg ||
@@ -2700,22 +2701,29 @@ static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
2700 !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1))) 2701 !((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
2701 return 0; 2702 return 0;
2702 2703
2703 /* Allocate a buffer with enough padding for alignment */ 2704 /*
2705 * Allocate a buffer with enough padding for original transfer_buffer
2706 * pointer. This allocation is guaranteed to be aligned properly for
2707 * DMA
2708 */
2704 kmalloc_size = urb->transfer_buffer_length + 2709 kmalloc_size = urb->transfer_buffer_length +
2705 sizeof(struct dma_aligned_buffer) + DWC2_USB_DMA_ALIGN - 1; 2710 sizeof(urb->transfer_buffer);
2706 2711
2707 kmalloc_ptr = kmalloc(kmalloc_size, mem_flags); 2712 kmalloc_ptr = kmalloc(kmalloc_size, mem_flags);
2708 if (!kmalloc_ptr) 2713 if (!kmalloc_ptr)
2709 return -ENOMEM; 2714 return -ENOMEM;
2710 2715
2711 /* Position our struct dma_aligned_buffer such that data is aligned */ 2716 /*
2712 temp = PTR_ALIGN(kmalloc_ptr + 1, DWC2_USB_DMA_ALIGN) - 1; 2717 * Position value of original urb->transfer_buffer pointer to the end
2713 temp->kmalloc_ptr = kmalloc_ptr; 2718 * of allocation for later referencing
2714 temp->old_xfer_buffer = urb->transfer_buffer; 2719 */
2720 memcpy(kmalloc_ptr + urb->transfer_buffer_length,
2721 &urb->transfer_buffer, sizeof(urb->transfer_buffer));
2722
2715 if (usb_urb_dir_out(urb)) 2723 if (usb_urb_dir_out(urb))
2716 memcpy(temp->data, urb->transfer_buffer, 2724 memcpy(kmalloc_ptr, urb->transfer_buffer,
2717 urb->transfer_buffer_length); 2725 urb->transfer_buffer_length);
2718 urb->transfer_buffer = temp->data; 2726 urb->transfer_buffer = kmalloc_ptr;
2719 2727
2720 urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER; 2728 urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;
2721 2729
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index ed7f05cf4906..8ce10caf3e19 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -1231,7 +1231,10 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
1231 * avoid interrupt storms we'll wait before retrying if we've got 1231 * avoid interrupt storms we'll wait before retrying if we've got
1232 * several NAKs. If we didn't do this we'd retry directly from the 1232 * several NAKs. If we didn't do this we'd retry directly from the
1233 * interrupt handler and could end up quickly getting another 1233 * interrupt handler and could end up quickly getting another
1234 * interrupt (another NAK), which we'd retry. 1234 * interrupt (another NAK), which we'd retry. Note that we do not
1235 * delay retries for IN parts of control requests, as those are expected
1236 * to complete fairly quickly, and if we delay them we risk confusing
1237 * the device and cause it issue STALL.
1235 * 1238 *
1236 * Note that in DMA mode software only gets involved to re-send NAKed 1239 * Note that in DMA mode software only gets involved to re-send NAKed
1237 * transfers for split transactions, so we only need to apply this 1240 * transfers for split transactions, so we only need to apply this
@@ -1244,7 +1247,9 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
1244 qtd->error_count = 0; 1247 qtd->error_count = 0;
1245 qtd->complete_split = 0; 1248 qtd->complete_split = 0;
1246 qtd->num_naks++; 1249 qtd->num_naks++;
1247 qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY; 1250 qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY &&
1251 !(chan->ep_type == USB_ENDPOINT_XFER_CONTROL &&
1252 chan->ep_is_in);
1248 dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_NAK); 1253 dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_NAK);
1249 goto handle_nak_done; 1254 goto handle_nak_done;
1250 } 1255 }
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index c77ff50a88a2..8efde178eef4 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -973,15 +973,12 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
973 ret = dwc3_ep0_start_trans(dep); 973 ret = dwc3_ep0_start_trans(dep);
974 } else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) && 974 } else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) &&
975 req->request.length && req->request.zero) { 975 req->request.length && req->request.zero) {
976 u32 maxpacket;
977 976
978 ret = usb_gadget_map_request_by_dev(dwc->sysdev, 977 ret = usb_gadget_map_request_by_dev(dwc->sysdev,
979 &req->request, dep->number); 978 &req->request, dep->number);
980 if (ret) 979 if (ret)
981 return; 980 return;
982 981
983 maxpacket = dep->endpoint.maxpacket;
984
985 /* prepare normal TRB */ 982 /* prepare normal TRB */
986 dwc3_ep0_prepare_one_trb(dep, req->request.dma, 983 dwc3_ep0_prepare_one_trb(dep, req->request.dma,
987 req->request.length, 984 req->request.length,
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index d2fa071c21b1..b8a15840b4ff 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1819,7 +1819,6 @@ unknown:
1819 if (cdev->use_os_string && cdev->os_desc_config && 1819 if (cdev->use_os_string && cdev->os_desc_config &&
1820 (ctrl->bRequestType & USB_TYPE_VENDOR) && 1820 (ctrl->bRequestType & USB_TYPE_VENDOR) &&
1821 ctrl->bRequest == cdev->b_vendor_code) { 1821 ctrl->bRequest == cdev->b_vendor_code) {
1822 struct usb_request *req;
1823 struct usb_configuration *os_desc_cfg; 1822 struct usb_configuration *os_desc_cfg;
1824 u8 *buf; 1823 u8 *buf;
1825 int interface; 1824 int interface;
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 33e2030503fa..3ada83d81bda 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3263,7 +3263,7 @@ static int ffs_func_setup(struct usb_function *f,
3263 __ffs_event_add(ffs, FUNCTIONFS_SETUP); 3263 __ffs_event_add(ffs, FUNCTIONFS_SETUP);
3264 spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags); 3264 spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags);
3265 3265
3266 return USB_GADGET_DELAYED_STATUS; 3266 return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
3267} 3267}
3268 3268
3269static bool ffs_func_req_match(struct usb_function *f, 3269static bool ffs_func_req_match(struct usb_function *f,
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index d2dc1f00180b..d582921f7257 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -438,14 +438,14 @@ static struct usb_descriptor_header *hs_audio_desc[] = {
438}; 438};
439 439
440struct cntrl_cur_lay3 { 440struct cntrl_cur_lay3 {
441 __u32 dCUR; 441 __le32 dCUR;
442}; 442};
443 443
444struct cntrl_range_lay3 { 444struct cntrl_range_lay3 {
445 __u16 wNumSubRanges; 445 __le16 wNumSubRanges;
446 __u32 dMIN; 446 __le32 dMIN;
447 __u32 dMAX; 447 __le32 dMAX;
448 __u32 dRES; 448 __le32 dRES;
449} __packed; 449} __packed;
450 450
451static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts, 451static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
@@ -559,13 +559,13 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
559 agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); 559 agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
560 if (!agdev->out_ep) { 560 if (!agdev->out_ep) {
561 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); 561 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
562 return ret; 562 return -ENODEV;
563 } 563 }
564 564
565 agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc); 565 agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
566 if (!agdev->in_ep) { 566 if (!agdev->in_ep) {
567 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); 567 dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
568 return ret; 568 return -ENODEV;
569 } 569 }
570 570
571 agdev->in_ep_maxpsize = max_t(u16, 571 agdev->in_ep_maxpsize = max_t(u16,
@@ -703,9 +703,9 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
703 memset(&c, 0, sizeof(struct cntrl_cur_lay3)); 703 memset(&c, 0, sizeof(struct cntrl_cur_lay3));
704 704
705 if (entity_id == USB_IN_CLK_ID) 705 if (entity_id == USB_IN_CLK_ID)
706 c.dCUR = p_srate; 706 c.dCUR = cpu_to_le32(p_srate);
707 else if (entity_id == USB_OUT_CLK_ID) 707 else if (entity_id == USB_OUT_CLK_ID)
708 c.dCUR = c_srate; 708 c.dCUR = cpu_to_le32(c_srate);
709 709
710 value = min_t(unsigned, w_length, sizeof c); 710 value = min_t(unsigned, w_length, sizeof c);
711 memcpy(req->buf, &c, value); 711 memcpy(req->buf, &c, value);
@@ -742,15 +742,15 @@ in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)
742 742
743 if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { 743 if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) {
744 if (entity_id == USB_IN_CLK_ID) 744 if (entity_id == USB_IN_CLK_ID)
745 r.dMIN = p_srate; 745 r.dMIN = cpu_to_le32(p_srate);
746 else if (entity_id == USB_OUT_CLK_ID) 746 else if (entity_id == USB_OUT_CLK_ID)
747 r.dMIN = c_srate; 747 r.dMIN = cpu_to_le32(c_srate);
748 else 748 else
749 return -EOPNOTSUPP; 749 return -EOPNOTSUPP;
750 750
751 r.dMAX = r.dMIN; 751 r.dMAX = r.dMIN;
752 r.dRES = 0; 752 r.dRES = 0;
753 r.wNumSubRanges = 1; 753 r.wNumSubRanges = cpu_to_le16(1);
754 754
755 value = min_t(unsigned, w_length, sizeof r); 755 value = min_t(unsigned, w_length, sizeof r);
756 memcpy(req->buf, &r, value); 756 memcpy(req->buf, &r, value);
diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index a72295c953bb..fb5ed97572e5 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -32,9 +32,6 @@ struct uac_req {
32struct uac_rtd_params { 32struct uac_rtd_params {
33 struct snd_uac_chip *uac; /* parent chip */ 33 struct snd_uac_chip *uac; /* parent chip */
34 bool ep_enabled; /* if the ep is enabled */ 34 bool ep_enabled; /* if the ep is enabled */
35 /* Size of the ring buffer */
36 size_t dma_bytes;
37 unsigned char *dma_area;
38 35
39 struct snd_pcm_substream *ss; 36 struct snd_pcm_substream *ss;
40 37
@@ -43,8 +40,6 @@ struct uac_rtd_params {
43 40
44 void *rbuf; 41 void *rbuf;
45 42
46 size_t period_size;
47
48 unsigned max_psize; /* MaxPacketSize of endpoint */ 43 unsigned max_psize; /* MaxPacketSize of endpoint */
49 struct uac_req *ureq; 44 struct uac_req *ureq;
50 45
@@ -84,12 +79,12 @@ static const struct snd_pcm_hardware uac_pcm_hardware = {
84static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) 79static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
85{ 80{
86 unsigned pending; 81 unsigned pending;
87 unsigned long flags; 82 unsigned long flags, flags2;
88 unsigned int hw_ptr; 83 unsigned int hw_ptr;
89 bool update_alsa = false;
90 int status = req->status; 84 int status = req->status;
91 struct uac_req *ur = req->context; 85 struct uac_req *ur = req->context;
92 struct snd_pcm_substream *substream; 86 struct snd_pcm_substream *substream;
87 struct snd_pcm_runtime *runtime;
93 struct uac_rtd_params *prm = ur->pp; 88 struct uac_rtd_params *prm = ur->pp;
94 struct snd_uac_chip *uac = prm->uac; 89 struct snd_uac_chip *uac = prm->uac;
95 90
@@ -111,6 +106,14 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
111 if (!substream) 106 if (!substream)
112 goto exit; 107 goto exit;
113 108
109 snd_pcm_stream_lock_irqsave(substream, flags2);
110
111 runtime = substream->runtime;
112 if (!runtime || !snd_pcm_running(substream)) {
113 snd_pcm_stream_unlock_irqrestore(substream, flags2);
114 goto exit;
115 }
116
114 spin_lock_irqsave(&prm->lock, flags); 117 spin_lock_irqsave(&prm->lock, flags);
115 118
116 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 119 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -137,43 +140,46 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
137 req->actual = req->length; 140 req->actual = req->length;
138 } 141 }
139 142
140 pending = prm->hw_ptr % prm->period_size;
141 pending += req->actual;
142 if (pending >= prm->period_size)
143 update_alsa = true;
144
145 hw_ptr = prm->hw_ptr; 143 hw_ptr = prm->hw_ptr;
146 prm->hw_ptr = (prm->hw_ptr + req->actual) % prm->dma_bytes;
147 144
148 spin_unlock_irqrestore(&prm->lock, flags); 145 spin_unlock_irqrestore(&prm->lock, flags);
149 146
150 /* Pack USB load in ALSA ring buffer */ 147 /* Pack USB load in ALSA ring buffer */
151 pending = prm->dma_bytes - hw_ptr; 148 pending = runtime->dma_bytes - hw_ptr;
152 149
153 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 150 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
154 if (unlikely(pending < req->actual)) { 151 if (unlikely(pending < req->actual)) {
155 memcpy(req->buf, prm->dma_area + hw_ptr, pending); 152 memcpy(req->buf, runtime->dma_area + hw_ptr, pending);
156 memcpy(req->buf + pending, prm->dma_area, 153 memcpy(req->buf + pending, runtime->dma_area,
157 req->actual - pending); 154 req->actual - pending);
158 } else { 155 } else {
159 memcpy(req->buf, prm->dma_area + hw_ptr, req->actual); 156 memcpy(req->buf, runtime->dma_area + hw_ptr,
157 req->actual);
160 } 158 }
161 } else { 159 } else {
162 if (unlikely(pending < req->actual)) { 160 if (unlikely(pending < req->actual)) {
163 memcpy(prm->dma_area + hw_ptr, req->buf, pending); 161 memcpy(runtime->dma_area + hw_ptr, req->buf, pending);
164 memcpy(prm->dma_area, req->buf + pending, 162 memcpy(runtime->dma_area, req->buf + pending,
165 req->actual - pending); 163 req->actual - pending);
166 } else { 164 } else {
167 memcpy(prm->dma_area + hw_ptr, req->buf, req->actual); 165 memcpy(runtime->dma_area + hw_ptr, req->buf,
166 req->actual);
168 } 167 }
169 } 168 }
170 169
170 spin_lock_irqsave(&prm->lock, flags);
171 /* update hw_ptr after data is copied to memory */
172 prm->hw_ptr = (hw_ptr + req->actual) % runtime->dma_bytes;
173 hw_ptr = prm->hw_ptr;
174 spin_unlock_irqrestore(&prm->lock, flags);
175 snd_pcm_stream_unlock_irqrestore(substream, flags2);
176
177 if ((hw_ptr % snd_pcm_lib_period_bytes(substream)) < req->actual)
178 snd_pcm_period_elapsed(substream);
179
171exit: 180exit:
172 if (usb_ep_queue(ep, req, GFP_ATOMIC)) 181 if (usb_ep_queue(ep, req, GFP_ATOMIC))
173 dev_err(uac->card->dev, "%d Error!\n", __LINE__); 182 dev_err(uac->card->dev, "%d Error!\n", __LINE__);
174
175 if (update_alsa)
176 snd_pcm_period_elapsed(substream);
177} 183}
178 184
179static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 185static int uac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
@@ -236,40 +242,12 @@ static snd_pcm_uframes_t uac_pcm_pointer(struct snd_pcm_substream *substream)
236static int uac_pcm_hw_params(struct snd_pcm_substream *substream, 242static int uac_pcm_hw_params(struct snd_pcm_substream *substream,
237 struct snd_pcm_hw_params *hw_params) 243 struct snd_pcm_hw_params *hw_params)
238{ 244{
239 struct snd_uac_chip *uac = snd_pcm_substream_chip(substream); 245 return snd_pcm_lib_malloc_pages(substream,
240 struct uac_rtd_params *prm;
241 int err;
242
243 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
244 prm = &uac->p_prm;
245 else
246 prm = &uac->c_prm;
247
248 err = snd_pcm_lib_malloc_pages(substream,
249 params_buffer_bytes(hw_params)); 246 params_buffer_bytes(hw_params));
250 if (err >= 0) {
251 prm->dma_bytes = substream->runtime->dma_bytes;
252 prm->dma_area = substream->runtime->dma_area;
253 prm->period_size = params_period_bytes(hw_params);
254 }
255
256 return err;
257} 247}
258 248
259static int uac_pcm_hw_free(struct snd_pcm_substream *substream) 249static int uac_pcm_hw_free(struct snd_pcm_substream *substream)
260{ 250{
261 struct snd_uac_chip *uac = snd_pcm_substream_chip(substream);
262 struct uac_rtd_params *prm;
263
264 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
265 prm = &uac->p_prm;
266 else
267 prm = &uac->c_prm;
268
269 prm->dma_area = NULL;
270 prm->dma_bytes = 0;
271 prm->period_size = 0;
272
273 return snd_pcm_lib_free_pages(substream); 251 return snd_pcm_lib_free_pages(substream);
274} 252}
275 253
@@ -595,15 +573,15 @@ int g_audio_setup(struct g_audio *g_audio, const char *pcm_name,
595 if (err < 0) 573 if (err < 0)
596 goto snd_fail; 574 goto snd_fail;
597 575
598 strcpy(pcm->name, pcm_name); 576 strlcpy(pcm->name, pcm_name, sizeof(pcm->name));
599 pcm->private_data = uac; 577 pcm->private_data = uac;
600 uac->pcm = pcm; 578 uac->pcm = pcm;
601 579
602 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &uac_pcm_ops); 580 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &uac_pcm_ops);
603 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &uac_pcm_ops); 581 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &uac_pcm_ops);
604 582
605 strcpy(card->driver, card_name); 583 strlcpy(card->driver, card_name, sizeof(card->driver));
606 strcpy(card->shortname, card_name); 584 strlcpy(card->shortname, card_name, sizeof(card->shortname));
607 sprintf(card->longname, "%s %i", card_name, card->dev->id); 585 sprintf(card->longname, "%s %i", card_name, card->dev->id);
608 586
609 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, 587 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/ep0.c b/drivers/usb/gadget/udc/aspeed-vhub/ep0.c
index 20ffb03ff6ac..e2927fb083cf 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/ep0.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/ep0.c
@@ -108,6 +108,13 @@ void ast_vhub_ep0_handle_setup(struct ast_vhub_ep *ep)
108 /* Check our state, cancel pending requests if needed */ 108 /* Check our state, cancel pending requests if needed */
109 if (ep->ep0.state != ep0_state_token) { 109 if (ep->ep0.state != ep0_state_token) {
110 EPDBG(ep, "wrong state\n"); 110 EPDBG(ep, "wrong state\n");
111 ast_vhub_nuke(ep, -EIO);
112
113 /*
114 * Accept the packet regardless, this seems to happen
115 * when stalling a SETUP packet that has an OUT data
116 * phase.
117 */
111 ast_vhub_nuke(ep, 0); 118 ast_vhub_nuke(ep, 0);
112 goto stall; 119 goto stall;
113 } 120 }
@@ -212,6 +219,8 @@ static void ast_vhub_ep0_do_send(struct ast_vhub_ep *ep,
212 if (chunk && req->req.buf) 219 if (chunk && req->req.buf)
213 memcpy(ep->buf, req->req.buf + req->req.actual, chunk); 220 memcpy(ep->buf, req->req.buf + req->req.actual, chunk);
214 221
222 vhub_dma_workaround(ep->buf);
223
215 /* Remember chunk size and trigger send */ 224 /* Remember chunk size and trigger send */
216 reg = VHUB_EP0_SET_TX_LEN(chunk); 225 reg = VHUB_EP0_SET_TX_LEN(chunk);
217 writel(reg, ep->ep0.ctlstat); 226 writel(reg, ep->ep0.ctlstat);
@@ -224,7 +233,7 @@ static void ast_vhub_ep0_rx_prime(struct ast_vhub_ep *ep)
224 EPVDBG(ep, "rx prime\n"); 233 EPVDBG(ep, "rx prime\n");
225 234
226 /* Prime endpoint for receiving data */ 235 /* Prime endpoint for receiving data */
227 writel(VHUB_EP0_RX_BUFF_RDY, ep->ep0.ctlstat + AST_VHUB_EP0_CTRL); 236 writel(VHUB_EP0_RX_BUFF_RDY, ep->ep0.ctlstat);
228} 237}
229 238
230static void ast_vhub_ep0_do_receive(struct ast_vhub_ep *ep, struct ast_vhub_req *req, 239static void ast_vhub_ep0_do_receive(struct ast_vhub_ep *ep, struct ast_vhub_req *req,
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/epn.c b/drivers/usb/gadget/udc/aspeed-vhub/epn.c
index 80c9feac5147..5939eb1e97f2 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/epn.c
+++ b/drivers/usb/gadget/udc/aspeed-vhub/epn.c
@@ -66,11 +66,16 @@ static void ast_vhub_epn_kick(struct ast_vhub_ep *ep, struct ast_vhub_req *req)
66 if (!req->req.dma) { 66 if (!req->req.dma) {
67 67
68 /* For IN transfers, copy data over first */ 68 /* For IN transfers, copy data over first */
69 if (ep->epn.is_in) 69 if (ep->epn.is_in) {
70 memcpy(ep->buf, req->req.buf + act, chunk); 70 memcpy(ep->buf, req->req.buf + act, chunk);
71 vhub_dma_workaround(ep->buf);
72 }
71 writel(ep->buf_dma, ep->epn.regs + AST_VHUB_EP_DESC_BASE); 73 writel(ep->buf_dma, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
72 } else 74 } else {
75 if (ep->epn.is_in)
76 vhub_dma_workaround(req->req.buf);
73 writel(req->req.dma + act, ep->epn.regs + AST_VHUB_EP_DESC_BASE); 77 writel(req->req.dma + act, ep->epn.regs + AST_VHUB_EP_DESC_BASE);
78 }
74 79
75 /* Start DMA */ 80 /* Start DMA */
76 req->active = true; 81 req->active = true;
@@ -161,6 +166,7 @@ static inline unsigned int ast_vhub_count_free_descs(struct ast_vhub_ep *ep)
161static void ast_vhub_epn_kick_desc(struct ast_vhub_ep *ep, 166static void ast_vhub_epn_kick_desc(struct ast_vhub_ep *ep,
162 struct ast_vhub_req *req) 167 struct ast_vhub_req *req)
163{ 168{
169 struct ast_vhub_desc *desc = NULL;
164 unsigned int act = req->act_count; 170 unsigned int act = req->act_count;
165 unsigned int len = req->req.length; 171 unsigned int len = req->req.length;
166 unsigned int chunk; 172 unsigned int chunk;
@@ -177,7 +183,6 @@ static void ast_vhub_epn_kick_desc(struct ast_vhub_ep *ep,
177 183
178 /* While we can create descriptors */ 184 /* While we can create descriptors */
179 while (ast_vhub_count_free_descs(ep) && req->last_desc < 0) { 185 while (ast_vhub_count_free_descs(ep) && req->last_desc < 0) {
180 struct ast_vhub_desc *desc;
181 unsigned int d_num; 186 unsigned int d_num;
182 187
183 /* Grab next free descriptor */ 188 /* Grab next free descriptor */
@@ -227,6 +232,9 @@ static void ast_vhub_epn_kick_desc(struct ast_vhub_ep *ep,
227 req->act_count = act = act + chunk; 232 req->act_count = act = act + chunk;
228 } 233 }
229 234
235 if (likely(desc))
236 vhub_dma_workaround(desc);
237
230 /* Tell HW about new descriptors */ 238 /* Tell HW about new descriptors */
231 writel(VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next), 239 writel(VHUB_EP_DMA_SET_CPU_WPTR(ep->epn.d_next),
232 ep->epn.regs + AST_VHUB_EP_DESC_STATUS); 240 ep->epn.regs + AST_VHUB_EP_DESC_STATUS);
diff --git a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
index 2b040257bc1f..4ed03d33a5a9 100644
--- a/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
+++ b/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
@@ -462,6 +462,39 @@ enum std_req_rc {
462#define DDBG(d, fmt, ...) do { } while(0) 462#define DDBG(d, fmt, ...) do { } while(0)
463#endif 463#endif
464 464
465static inline void vhub_dma_workaround(void *addr)
466{
467 /*
468 * This works around a confirmed HW issue with the Aspeed chip.
469 *
470 * The core uses a different bus to memory than the AHB going to
471 * the USB device controller. Due to the latter having a higher
472 * priority than the core for arbitration on that bus, it's
473 * possible for an MMIO to the device, followed by a DMA by the
474 * device from memory to all be performed and services before
475 * a previous store to memory gets completed.
476 *
477 * This the following scenario can happen:
478 *
479 * - Driver writes to a DMA descriptor (Mbus)
480 * - Driver writes to the MMIO register to start the DMA (AHB)
481 * - The gadget sees the second write and sends a read of the
482 * descriptor to the memory controller (Mbus)
483 * - The gadget hits memory before the descriptor write
484 * causing it to read an obsolete value.
485 *
486 * Thankfully the problem is limited to the USB gadget device, other
487 * masters in the SoC all have a lower priority than the core, thus
488 * ensuring that the store by the core arrives first.
489 *
490 * The workaround consists of using a dummy read of the memory before
491 * doing the MMIO writes. This will ensure that the previous writes
492 * have been "pushed out".
493 */
494 mb();
495 (void)__raw_readl((void __iomem *)addr);
496}
497
465/* core.c */ 498/* core.c */
466void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req, 499void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req,
467 int status); 500 int status);
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index a3ecce62662b..11e25a3f4f1f 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -832,11 +832,11 @@ static void init_controller(struct r8a66597 *r8a66597)
832 832
833 r8a66597_bset(r8a66597, XCKE, SYSCFG0); 833 r8a66597_bset(r8a66597, XCKE, SYSCFG0);
834 834
835 msleep(3); 835 mdelay(3);
836 836
837 r8a66597_bset(r8a66597, PLLC, SYSCFG0); 837 r8a66597_bset(r8a66597, PLLC, SYSCFG0);
838 838
839 msleep(1); 839 mdelay(1);
840 840
841 r8a66597_bset(r8a66597, SCKE, SYSCFG0); 841 r8a66597_bset(r8a66597, SCKE, SYSCFG0);
842 842
@@ -1190,7 +1190,7 @@ __acquires(r8a66597->lock)
1190 r8a66597->ep0_req->length = 2; 1190 r8a66597->ep0_req->length = 2;
1191 /* AV: what happens if we get called again before that gets through? */ 1191 /* AV: what happens if we get called again before that gets through? */
1192 spin_unlock(&r8a66597->lock); 1192 spin_unlock(&r8a66597->lock);
1193 r8a66597_queue(r8a66597->gadget.ep0, r8a66597->ep0_req, GFP_KERNEL); 1193 r8a66597_queue(r8a66597->gadget.ep0, r8a66597->ep0_req, GFP_ATOMIC);
1194 spin_lock(&r8a66597->lock); 1194 spin_lock(&r8a66597->lock);
1195} 1195}
1196 1196
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2f4850f25e82..68e6132aa8b2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3051,6 +3051,7 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
3051 if (!list_empty(&ep->ring->td_list)) { 3051 if (!list_empty(&ep->ring->td_list)) {
3052 dev_err(&udev->dev, "EP not empty, refuse reset\n"); 3052 dev_err(&udev->dev, "EP not empty, refuse reset\n");
3053 spin_unlock_irqrestore(&xhci->lock, flags); 3053 spin_unlock_irqrestore(&xhci->lock, flags);
3054 xhci_free_command(xhci, cfg_cmd);
3054 goto cleanup; 3055 goto cleanup;
3055 } 3056 }
3056 xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0); 3057 xhci_queue_stop_endpoint(xhci, stop_cmd, udev->slot_id, ep_index, 0);
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 900875f326d7..f7c96d209eda 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -861,6 +861,7 @@ int usb_otg_start(struct platform_device *pdev)
861 if (pdata->init && pdata->init(pdev) != 0) 861 if (pdata->init && pdata->init(pdev) != 0)
862 return -EINVAL; 862 return -EINVAL;
863 863
864#ifdef CONFIG_PPC32
864 if (pdata->big_endian_mmio) { 865 if (pdata->big_endian_mmio) {
865 _fsl_readl = _fsl_readl_be; 866 _fsl_readl = _fsl_readl_be;
866 _fsl_writel = _fsl_writel_be; 867 _fsl_writel = _fsl_writel_be;
@@ -868,6 +869,7 @@ int usb_otg_start(struct platform_device *pdev)
868 _fsl_readl = _fsl_readl_le; 869 _fsl_readl = _fsl_readl_le;
869 _fsl_writel = _fsl_writel_le; 870 _fsl_writel = _fsl_writel_le;
870 } 871 }
872#endif
871 873
872 /* request irq */ 874 /* request irq */
873 p_otg->irq = platform_get_irq(pdev, 0); 875 p_otg->irq = platform_get_irq(pdev, 0);
@@ -958,7 +960,7 @@ int usb_otg_start(struct platform_device *pdev)
958/* 960/*
959 * state file in sysfs 961 * state file in sysfs
960 */ 962 */
961static int show_fsl_usb2_otg_state(struct device *dev, 963static ssize_t show_fsl_usb2_otg_state(struct device *dev,
962 struct device_attribute *attr, char *buf) 964 struct device_attribute *attr, char *buf)
963{ 965{
964 struct otg_fsm *fsm = &fsl_otg_dev->fsm; 966 struct otg_fsm *fsm = &fsl_otg_dev->fsm;
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 150f43668bec..d1d20252bad8 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -2140,7 +2140,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
2140 * PPS APDO. Again skip the first sink PDO as this will 2140 * PPS APDO. Again skip the first sink PDO as this will
2141 * always be 5V 3A. 2141 * always be 5V 3A.
2142 */ 2142 */
2143 for (j = i; j < port->nr_snk_pdo; j++) { 2143 for (j = 1; j < port->nr_snk_pdo; j++) {
2144 pdo = port->snk_pdo[j]; 2144 pdo = port->snk_pdo[j];
2145 2145
2146 switch (pdo_type(pdo)) { 2146 switch (pdo_type(pdo)) {
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index b423a309a6e0..125b58eff936 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -28,6 +28,7 @@
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/vfio.h> 29#include <linux/vfio.h>
30#include <linux/vgaarb.h> 30#include <linux/vgaarb.h>
31#include <linux/nospec.h>
31 32
32#include "vfio_pci_private.h" 33#include "vfio_pci_private.h"
33 34
@@ -727,6 +728,9 @@ static long vfio_pci_ioctl(void *device_data,
727 if (info.index >= 728 if (info.index >=
728 VFIO_PCI_NUM_REGIONS + vdev->num_regions) 729 VFIO_PCI_NUM_REGIONS + vdev->num_regions)
729 return -EINVAL; 730 return -EINVAL;
731 info.index = array_index_nospec(info.index,
732 VFIO_PCI_NUM_REGIONS +
733 vdev->num_regions);
730 734
731 i = info.index - VFIO_PCI_NUM_REGIONS; 735 i = info.index - VFIO_PCI_NUM_REGIONS;
732 736
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index 759a5bdd40e1..7cd63b0c1a46 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -457,17 +457,17 @@ static void tce_iommu_unuse_page(struct tce_container *container,
457} 457}
458 458
459static int tce_iommu_prereg_ua_to_hpa(struct tce_container *container, 459static int tce_iommu_prereg_ua_to_hpa(struct tce_container *container,
460 unsigned long tce, unsigned long size, 460 unsigned long tce, unsigned long shift,
461 unsigned long *phpa, struct mm_iommu_table_group_mem_t **pmem) 461 unsigned long *phpa, struct mm_iommu_table_group_mem_t **pmem)
462{ 462{
463 long ret = 0; 463 long ret = 0;
464 struct mm_iommu_table_group_mem_t *mem; 464 struct mm_iommu_table_group_mem_t *mem;
465 465
466 mem = mm_iommu_lookup(container->mm, tce, size); 466 mem = mm_iommu_lookup(container->mm, tce, 1ULL << shift);
467 if (!mem) 467 if (!mem)
468 return -EINVAL; 468 return -EINVAL;
469 469
470 ret = mm_iommu_ua_to_hpa(mem, tce, phpa); 470 ret = mm_iommu_ua_to_hpa(mem, tce, shift, phpa);
471 if (ret) 471 if (ret)
472 return -EINVAL; 472 return -EINVAL;
473 473
@@ -487,7 +487,7 @@ static void tce_iommu_unuse_page_v2(struct tce_container *container,
487 if (!pua) 487 if (!pua)
488 return; 488 return;
489 489
490 ret = tce_iommu_prereg_ua_to_hpa(container, *pua, IOMMU_PAGE_SIZE(tbl), 490 ret = tce_iommu_prereg_ua_to_hpa(container, *pua, tbl->it_page_shift,
491 &hpa, &mem); 491 &hpa, &mem);
492 if (ret) 492 if (ret)
493 pr_debug("%s: tce %lx at #%lx was not cached, ret=%d\n", 493 pr_debug("%s: tce %lx at #%lx was not cached, ret=%d\n",
@@ -611,7 +611,7 @@ static long tce_iommu_build_v2(struct tce_container *container,
611 entry + i); 611 entry + i);
612 612
613 ret = tce_iommu_prereg_ua_to_hpa(container, 613 ret = tce_iommu_prereg_ua_to_hpa(container,
614 tce, IOMMU_PAGE_SIZE(tbl), &hpa, &mem); 614 tce, tbl->it_page_shift, &hpa, &mem);
615 if (ret) 615 if (ret)
616 break; 616 break;
617 617
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 6b237e3f4983..3988c0914322 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -513,7 +513,9 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
513 tell_host(vb, vb->inflate_vq); 513 tell_host(vb, vb->inflate_vq);
514 514
515 /* balloon's page migration 2nd step -- deflate "page" */ 515 /* balloon's page migration 2nd step -- deflate "page" */
516 spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
516 balloon_page_delete(page); 517 balloon_page_delete(page);
518 spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
517 vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE; 519 vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
518 set_page_pfns(vb, vb->pfns, page); 520 set_page_pfns(vb, vb->pfns, page);
519 tell_host(vb, vb->deflate_vq); 521 tell_host(vb, vb->deflate_vq);
diff --git a/fs/aio.c b/fs/aio.c
index 210df9da1283..27454594e37a 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1896,6 +1896,11 @@ SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,
1896 return ret; 1896 return ret;
1897} 1897}
1898 1898
1899struct __aio_sigset {
1900 const sigset_t __user *sigmask;
1901 size_t sigsetsize;
1902};
1903
1899SYSCALL_DEFINE6(io_pgetevents, 1904SYSCALL_DEFINE6(io_pgetevents,
1900 aio_context_t, ctx_id, 1905 aio_context_t, ctx_id,
1901 long, min_nr, 1906 long, min_nr,
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 0dd87aaeb39a..aba25414231a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -221,7 +221,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
221 221
222 ret = bio_iov_iter_get_pages(&bio, iter); 222 ret = bio_iov_iter_get_pages(&bio, iter);
223 if (unlikely(ret)) 223 if (unlikely(ret))
224 return ret; 224 goto out;
225 ret = bio.bi_iter.bi_size; 225 ret = bio.bi_iter.bi_size;
226 226
227 if (iov_iter_rw(iter) == READ) { 227 if (iov_iter_rw(iter) == READ) {
@@ -250,12 +250,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
250 put_page(bvec->bv_page); 250 put_page(bvec->bv_page);
251 } 251 }
252 252
253 if (vecs != inline_vecs)
254 kfree(vecs);
255
256 if (unlikely(bio.bi_status)) 253 if (unlikely(bio.bi_status))
257 ret = blk_status_to_errno(bio.bi_status); 254 ret = blk_status_to_errno(bio.bi_status);
258 255
256out:
257 if (vecs != inline_vecs)
258 kfree(vecs);
259
259 bio_uninit(&bio); 260 bio_uninit(&bio);
260 261
261 return ret; 262 return ret;
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e55843f536bc..b3e45714d28f 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4238,8 +4238,9 @@ int try_release_extent_mapping(struct page *page, gfp_t mask)
4238 struct extent_map *em; 4238 struct extent_map *em;
4239 u64 start = page_offset(page); 4239 u64 start = page_offset(page);
4240 u64 end = start + PAGE_SIZE - 1; 4240 u64 end = start + PAGE_SIZE - 1;
4241 struct extent_io_tree *tree = &BTRFS_I(page->mapping->host)->io_tree; 4241 struct btrfs_inode *btrfs_inode = BTRFS_I(page->mapping->host);
4242 struct extent_map_tree *map = &BTRFS_I(page->mapping->host)->extent_tree; 4242 struct extent_io_tree *tree = &btrfs_inode->io_tree;
4243 struct extent_map_tree *map = &btrfs_inode->extent_tree;
4243 4244
4244 if (gfpflags_allow_blocking(mask) && 4245 if (gfpflags_allow_blocking(mask) &&
4245 page->mapping->host->i_size > SZ_16M) { 4246 page->mapping->host->i_size > SZ_16M) {
@@ -4262,6 +4263,8 @@ int try_release_extent_mapping(struct page *page, gfp_t mask)
4262 extent_map_end(em) - 1, 4263 extent_map_end(em) - 1,
4263 EXTENT_LOCKED | EXTENT_WRITEBACK, 4264 EXTENT_LOCKED | EXTENT_WRITEBACK,
4264 0, NULL)) { 4265 0, NULL)) {
4266 set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
4267 &btrfs_inode->runtime_flags);
4265 remove_extent_mapping(map, em); 4268 remove_extent_mapping(map, em);
4266 /* once for the rb tree */ 4269 /* once for the rb tree */
4267 free_extent_map(em); 4270 free_extent_map(em);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 43ecbe620dea..b077544b5232 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3327,11 +3327,13 @@ static void btrfs_cmp_data_free(struct cmp_pages *cmp)
3327 if (pg) { 3327 if (pg) {
3328 unlock_page(pg); 3328 unlock_page(pg);
3329 put_page(pg); 3329 put_page(pg);
3330 cmp->src_pages[i] = NULL;
3330 } 3331 }
3331 pg = cmp->dst_pages[i]; 3332 pg = cmp->dst_pages[i];
3332 if (pg) { 3333 if (pg) {
3333 unlock_page(pg); 3334 unlock_page(pg);
3334 put_page(pg); 3335 put_page(pg);
3336 cmp->dst_pages[i] = NULL;
3335 } 3337 }
3336 } 3338 }
3337} 3339}
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 572306036477..6702896cdb8f 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1151,11 +1151,6 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
1151 return ret; 1151 return ret;
1152 } 1152 }
1153 1153
1154 if (sctx->is_dev_replace && !is_metadata && !have_csum) {
1155 sblocks_for_recheck = NULL;
1156 goto nodatasum_case;
1157 }
1158
1159 /* 1154 /*
1160 * read all mirrors one after the other. This includes to 1155 * read all mirrors one after the other. This includes to
1161 * re-read the extent or metadata block that failed (that was 1156 * re-read the extent or metadata block that failed (that was
@@ -1268,13 +1263,19 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
1268 goto out; 1263 goto out;
1269 } 1264 }
1270 1265
1271 if (!is_metadata && !have_csum) { 1266 /*
1267 * NOTE: Even for nodatasum case, it's still possible that it's a
1268 * compressed data extent, thus scrub_fixup_nodatasum(), which write
1269 * inode page cache onto disk, could cause serious data corruption.
1270 *
1271 * So here we could only read from disk, and hope our recovery could
1272 * reach disk before the newer write.
1273 */
1274 if (0 && !is_metadata && !have_csum) {
1272 struct scrub_fixup_nodatasum *fixup_nodatasum; 1275 struct scrub_fixup_nodatasum *fixup_nodatasum;
1273 1276
1274 WARN_ON(sctx->is_dev_replace); 1277 WARN_ON(sctx->is_dev_replace);
1275 1278
1276nodatasum_case:
1277
1278 /* 1279 /*
1279 * !is_metadata and !have_csum, this means that the data 1280 * !is_metadata and !have_csum, this means that the data
1280 * might not be COWed, that it might be modified 1281 * might not be COWed, that it might be modified
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e034ad9e23b4..1da162928d1a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1146,6 +1146,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
1146{ 1146{
1147 int ret; 1147 int ret;
1148 1148
1149 mutex_lock(&uuid_mutex);
1149 mutex_lock(&fs_devices->device_list_mutex); 1150 mutex_lock(&fs_devices->device_list_mutex);
1150 if (fs_devices->opened) { 1151 if (fs_devices->opened) {
1151 fs_devices->opened++; 1152 fs_devices->opened++;
@@ -1155,6 +1156,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
1155 ret = open_fs_devices(fs_devices, flags, holder); 1156 ret = open_fs_devices(fs_devices, flags, holder);
1156 } 1157 }
1157 mutex_unlock(&fs_devices->device_list_mutex); 1158 mutex_unlock(&fs_devices->device_list_mutex);
1159 mutex_unlock(&uuid_mutex);
1158 1160
1159 return ret; 1161 return ret;
1160} 1162}
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
index d9f001078e08..4a717d400807 100644
--- a/fs/cachefiles/bind.c
+++ b/fs/cachefiles/bind.c
@@ -218,7 +218,8 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
218 "%s", 218 "%s",
219 fsdef->dentry->d_sb->s_id); 219 fsdef->dentry->d_sb->s_id);
220 220
221 fscache_object_init(&fsdef->fscache, NULL, &cache->cache); 221 fscache_object_init(&fsdef->fscache, &fscache_fsdef_index,
222 &cache->cache);
222 223
223 ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag); 224 ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag);
224 if (ret < 0) 225 if (ret < 0)
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index ab0bbe93b398..af2b17b21b94 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -186,12 +186,12 @@ try_again:
186 * need to wait for it to be destroyed */ 186 * need to wait for it to be destroyed */
187wait_for_old_object: 187wait_for_old_object:
188 trace_cachefiles_wait_active(object, dentry, xobject); 188 trace_cachefiles_wait_active(object, dentry, xobject);
189 clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
189 190
190 if (fscache_object_is_live(&xobject->fscache)) { 191 if (fscache_object_is_live(&xobject->fscache)) {
191 pr_err("\n"); 192 pr_err("\n");
192 pr_err("Error: Unexpected object collision\n"); 193 pr_err("Error: Unexpected object collision\n");
193 cachefiles_printk_object(object, xobject); 194 cachefiles_printk_object(object, xobject);
194 BUG();
195 } 195 }
196 atomic_inc(&xobject->usage); 196 atomic_inc(&xobject->usage);
197 write_unlock(&cache->active_lock); 197 write_unlock(&cache->active_lock);
@@ -248,7 +248,6 @@ wait_for_old_object:
248 goto try_again; 248 goto try_again;
249 249
250requeue: 250requeue:
251 clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
252 cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo); 251 cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo);
253 _leave(" = -ETIMEDOUT"); 252 _leave(" = -ETIMEDOUT");
254 return -ETIMEDOUT; 253 return -ETIMEDOUT;
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
index 5082c8a49686..40f7595aad10 100644
--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -27,6 +27,7 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode,
27 struct cachefiles_one_read *monitor = 27 struct cachefiles_one_read *monitor =
28 container_of(wait, struct cachefiles_one_read, monitor); 28 container_of(wait, struct cachefiles_one_read, monitor);
29 struct cachefiles_object *object; 29 struct cachefiles_object *object;
30 struct fscache_retrieval *op = monitor->op;
30 struct wait_bit_key *key = _key; 31 struct wait_bit_key *key = _key;
31 struct page *page = wait->private; 32 struct page *page = wait->private;
32 33
@@ -51,16 +52,22 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode,
51 list_del(&wait->entry); 52 list_del(&wait->entry);
52 53
53 /* move onto the action list and queue for FS-Cache thread pool */ 54 /* move onto the action list and queue for FS-Cache thread pool */
54 ASSERT(monitor->op); 55 ASSERT(op);
55 56
56 object = container_of(monitor->op->op.object, 57 /* We need to temporarily bump the usage count as we don't own a ref
57 struct cachefiles_object, fscache); 58 * here otherwise cachefiles_read_copier() may free the op between the
59 * monitor being enqueued on the op->to_do list and the op getting
60 * enqueued on the work queue.
61 */
62 fscache_get_retrieval(op);
58 63
64 object = container_of(op->op.object, struct cachefiles_object, fscache);
59 spin_lock(&object->work_lock); 65 spin_lock(&object->work_lock);
60 list_add_tail(&monitor->op_link, &monitor->op->to_do); 66 list_add_tail(&monitor->op_link, &op->to_do);
61 spin_unlock(&object->work_lock); 67 spin_unlock(&object->work_lock);
62 68
63 fscache_enqueue_retrieval(monitor->op); 69 fscache_enqueue_retrieval(op);
70 fscache_put_retrieval(op);
64 return 0; 71 return 0;
65} 72}
66 73
diff --git a/fs/exec.c b/fs/exec.c
index 2d4e0075bd24..bdd0eacefdf5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -290,15 +290,15 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
290 struct vm_area_struct *vma = NULL; 290 struct vm_area_struct *vma = NULL;
291 struct mm_struct *mm = bprm->mm; 291 struct mm_struct *mm = bprm->mm;
292 292
293 bprm->vma = vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 293 bprm->vma = vma = vm_area_alloc(mm);
294 if (!vma) 294 if (!vma)
295 return -ENOMEM; 295 return -ENOMEM;
296 vma_set_anonymous(vma);
296 297
297 if (down_write_killable(&mm->mmap_sem)) { 298 if (down_write_killable(&mm->mmap_sem)) {
298 err = -EINTR; 299 err = -EINTR;
299 goto err_free; 300 goto err_free;
300 } 301 }
301 vma->vm_mm = mm;
302 302
303 /* 303 /*
304 * Place the stack at the largest stack address the architecture 304 * Place the stack at the largest stack address the architecture
@@ -311,7 +311,6 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
311 vma->vm_start = vma->vm_end - PAGE_SIZE; 311 vma->vm_start = vma->vm_end - PAGE_SIZE;
312 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP; 312 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
313 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); 313 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
314 INIT_LIST_HEAD(&vma->anon_vma_chain);
315 314
316 err = insert_vm_struct(mm, vma); 315 err = insert_vm_struct(mm, vma);
317 if (err) 316 if (err)
@@ -326,7 +325,7 @@ err:
326 up_write(&mm->mmap_sem); 325 up_write(&mm->mmap_sem);
327err_free: 326err_free:
328 bprm->vma = NULL; 327 bprm->vma = NULL;
329 kmem_cache_free(vm_area_cachep, vma); 328 vm_area_free(vma);
330 return err; 329 return err;
331} 330}
332 331
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index e68cefe08261..aa52d87985aa 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -368,6 +368,8 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
368 return -EFSCORRUPTED; 368 return -EFSCORRUPTED;
369 369
370 ext4_lock_group(sb, block_group); 370 ext4_lock_group(sb, block_group);
371 if (buffer_verified(bh))
372 goto verified;
371 if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, 373 if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
372 desc, bh))) { 374 desc, bh))) {
373 ext4_unlock_group(sb, block_group); 375 ext4_unlock_group(sb, block_group);
@@ -386,6 +388,7 @@ static int ext4_validate_block_bitmap(struct super_block *sb,
386 return -EFSCORRUPTED; 388 return -EFSCORRUPTED;
387 } 389 }
388 set_buffer_verified(bh); 390 set_buffer_verified(bh);
391verified:
389 ext4_unlock_group(sb, block_group); 392 ext4_unlock_group(sb, block_group);
390 return 0; 393 return 0;
391} 394}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index fb83750c1a14..f336cbc6e932 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -90,6 +90,8 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
90 return -EFSCORRUPTED; 90 return -EFSCORRUPTED;
91 91
92 ext4_lock_group(sb, block_group); 92 ext4_lock_group(sb, block_group);
93 if (buffer_verified(bh))
94 goto verified;
93 blk = ext4_inode_bitmap(sb, desc); 95 blk = ext4_inode_bitmap(sb, desc);
94 if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh, 96 if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,
95 EXT4_INODES_PER_GROUP(sb) / 8)) { 97 EXT4_INODES_PER_GROUP(sb) / 8)) {
@@ -101,6 +103,7 @@ static int ext4_validate_inode_bitmap(struct super_block *sb,
101 return -EFSBADCRC; 103 return -EFSBADCRC;
102 } 104 }
103 set_buffer_verified(bh); 105 set_buffer_verified(bh);
106verified:
104 ext4_unlock_group(sb, block_group); 107 ext4_unlock_group(sb, block_group);
105 return 0; 108 return 0;
106} 109}
@@ -1385,7 +1388,10 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
1385 ext4_itable_unused_count(sb, gdp)), 1388 ext4_itable_unused_count(sb, gdp)),
1386 sbi->s_inodes_per_block); 1389 sbi->s_inodes_per_block);
1387 1390
1388 if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group)) { 1391 if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) ||
1392 ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) -
1393 ext4_itable_unused_count(sb, gdp)) <
1394 EXT4_FIRST_INO(sb)))) {
1389 ext4_error(sb, "Something is wrong with group %u: " 1395 ext4_error(sb, "Something is wrong with group %u: "
1390 "used itable blocks: %d; " 1396 "used itable blocks: %d; "
1391 "itable unused count: %u", 1397 "itable unused count: %u",
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index e55a8bc870bd..3543fe80a3c4 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -682,6 +682,10 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
682 goto convert; 682 goto convert;
683 } 683 }
684 684
685 ret = ext4_journal_get_write_access(handle, iloc.bh);
686 if (ret)
687 goto out;
688
685 flags |= AOP_FLAG_NOFS; 689 flags |= AOP_FLAG_NOFS;
686 690
687 page = grab_cache_page_write_begin(mapping, 0, flags); 691 page = grab_cache_page_write_begin(mapping, 0, flags);
@@ -710,7 +714,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
710out_up_read: 714out_up_read:
711 up_read(&EXT4_I(inode)->xattr_sem); 715 up_read(&EXT4_I(inode)->xattr_sem);
712out: 716out:
713 if (handle) 717 if (handle && (ret != 1))
714 ext4_journal_stop(handle); 718 ext4_journal_stop(handle);
715 brelse(iloc.bh); 719 brelse(iloc.bh);
716 return ret; 720 return ret;
@@ -752,6 +756,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
752 756
753 ext4_write_unlock_xattr(inode, &no_expand); 757 ext4_write_unlock_xattr(inode, &no_expand);
754 brelse(iloc.bh); 758 brelse(iloc.bh);
759 mark_inode_dirty(inode);
755out: 760out:
756 return copied; 761 return copied;
757} 762}
@@ -898,7 +903,6 @@ retry_journal:
898 goto out; 903 goto out;
899 } 904 }
900 905
901
902 page = grab_cache_page_write_begin(mapping, 0, flags); 906 page = grab_cache_page_write_begin(mapping, 0, flags);
903 if (!page) { 907 if (!page) {
904 ret = -ENOMEM; 908 ret = -ENOMEM;
@@ -916,6 +920,9 @@ retry_journal:
916 if (ret < 0) 920 if (ret < 0)
917 goto out_release_page; 921 goto out_release_page;
918 } 922 }
923 ret = ext4_journal_get_write_access(handle, iloc.bh);
924 if (ret)
925 goto out_release_page;
919 926
920 up_read(&EXT4_I(inode)->xattr_sem); 927 up_read(&EXT4_I(inode)->xattr_sem);
921 *pagep = page; 928 *pagep = page;
@@ -936,7 +943,6 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
936 unsigned len, unsigned copied, 943 unsigned len, unsigned copied,
937 struct page *page) 944 struct page *page)
938{ 945{
939 int i_size_changed = 0;
940 int ret; 946 int ret;
941 947
942 ret = ext4_write_inline_data_end(inode, pos, len, copied, page); 948 ret = ext4_write_inline_data_end(inode, pos, len, copied, page);
@@ -954,10 +960,8 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
954 * But it's important to update i_size while still holding page lock: 960 * But it's important to update i_size while still holding page lock:
955 * page writeout could otherwise come in and zero beyond i_size. 961 * page writeout could otherwise come in and zero beyond i_size.
956 */ 962 */
957 if (pos+copied > inode->i_size) { 963 if (pos+copied > inode->i_size)
958 i_size_write(inode, pos+copied); 964 i_size_write(inode, pos+copied);
959 i_size_changed = 1;
960 }
961 unlock_page(page); 965 unlock_page(page);
962 put_page(page); 966 put_page(page);
963 967
@@ -967,8 +971,7 @@ int ext4_da_write_inline_data_end(struct inode *inode, loff_t pos,
967 * ordering of page lock and transaction start for journaling 971 * ordering of page lock and transaction start for journaling
968 * filesystems. 972 * filesystems.
969 */ 973 */
970 if (i_size_changed) 974 mark_inode_dirty(inode);
971 mark_inode_dirty(inode);
972 975
973 return copied; 976 return copied;
974} 977}
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7d6c10017bdf..4efe77286ecd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1389,9 +1389,10 @@ static int ext4_write_end(struct file *file,
1389 loff_t old_size = inode->i_size; 1389 loff_t old_size = inode->i_size;
1390 int ret = 0, ret2; 1390 int ret = 0, ret2;
1391 int i_size_changed = 0; 1391 int i_size_changed = 0;
1392 int inline_data = ext4_has_inline_data(inode);
1392 1393
1393 trace_ext4_write_end(inode, pos, len, copied); 1394 trace_ext4_write_end(inode, pos, len, copied);
1394 if (ext4_has_inline_data(inode)) { 1395 if (inline_data) {
1395 ret = ext4_write_inline_data_end(inode, pos, len, 1396 ret = ext4_write_inline_data_end(inode, pos, len,
1396 copied, page); 1397 copied, page);
1397 if (ret < 0) { 1398 if (ret < 0) {
@@ -1419,7 +1420,7 @@ static int ext4_write_end(struct file *file,
1419 * ordering of page lock and transaction start for journaling 1420 * ordering of page lock and transaction start for journaling
1420 * filesystems. 1421 * filesystems.
1421 */ 1422 */
1422 if (i_size_changed) 1423 if (i_size_changed || inline_data)
1423 ext4_mark_inode_dirty(handle, inode); 1424 ext4_mark_inode_dirty(handle, inode);
1424 1425
1425 if (pos + len > inode->i_size && ext4_can_truncate(inode)) 1426 if (pos + len > inode->i_size && ext4_can_truncate(inode))
@@ -1493,6 +1494,7 @@ static int ext4_journalled_write_end(struct file *file,
1493 int partial = 0; 1494 int partial = 0;
1494 unsigned from, to; 1495 unsigned from, to;
1495 int size_changed = 0; 1496 int size_changed = 0;
1497 int inline_data = ext4_has_inline_data(inode);
1496 1498
1497 trace_ext4_journalled_write_end(inode, pos, len, copied); 1499 trace_ext4_journalled_write_end(inode, pos, len, copied);
1498 from = pos & (PAGE_SIZE - 1); 1500 from = pos & (PAGE_SIZE - 1);
@@ -1500,7 +1502,7 @@ static int ext4_journalled_write_end(struct file *file,
1500 1502
1501 BUG_ON(!ext4_handle_valid(handle)); 1503 BUG_ON(!ext4_handle_valid(handle));
1502 1504
1503 if (ext4_has_inline_data(inode)) { 1505 if (inline_data) {
1504 ret = ext4_write_inline_data_end(inode, pos, len, 1506 ret = ext4_write_inline_data_end(inode, pos, len,
1505 copied, page); 1507 copied, page);
1506 if (ret < 0) { 1508 if (ret < 0) {
@@ -1531,7 +1533,7 @@ static int ext4_journalled_write_end(struct file *file,
1531 if (old_size < pos) 1533 if (old_size < pos)
1532 pagecache_isize_extended(inode, old_size, pos); 1534 pagecache_isize_extended(inode, old_size, pos);
1533 1535
1534 if (size_changed) { 1536 if (size_changed || inline_data) {
1535 ret2 = ext4_mark_inode_dirty(handle, inode); 1537 ret2 = ext4_mark_inode_dirty(handle, inode);
1536 if (!ret) 1538 if (!ret)
1537 ret = ret2; 1539 ret = ret2;
@@ -2028,11 +2030,7 @@ static int __ext4_journalled_writepage(struct page *page,
2028 } 2030 }
2029 2031
2030 if (inline_data) { 2032 if (inline_data) {
2031 BUFFER_TRACE(inode_bh, "get write access"); 2033 ret = ext4_mark_inode_dirty(handle, inode);
2032 ret = ext4_journal_get_write_access(handle, inode_bh);
2033
2034 err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
2035
2036 } else { 2034 } else {
2037 ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL, 2035 ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
2038 do_journal_get_write_access); 2036 do_journal_get_write_access);
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index 27b9a76a0dfa..638ad4743477 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -186,11 +186,8 @@ static int kmmpd(void *data)
186 goto exit_thread; 186 goto exit_thread;
187 } 187 }
188 188
189 if (sb_rdonly(sb)) { 189 if (sb_rdonly(sb))
190 ext4_warning(sb, "kmmpd being stopped since filesystem " 190 break;
191 "has been remounted as readonly.");
192 goto exit_thread;
193 }
194 191
195 diff = jiffies - last_update_time; 192 diff = jiffies - last_update_time;
196 if (diff < mmp_update_interval * HZ) 193 if (diff < mmp_update_interval * HZ)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ba2396a7bd04..b7f7922061be 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2342,7 +2342,7 @@ static int ext4_check_descriptors(struct super_block *sb,
2342 struct ext4_sb_info *sbi = EXT4_SB(sb); 2342 struct ext4_sb_info *sbi = EXT4_SB(sb);
2343 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); 2343 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
2344 ext4_fsblk_t last_block; 2344 ext4_fsblk_t last_block;
2345 ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0) + 1; 2345 ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0);
2346 ext4_fsblk_t block_bitmap; 2346 ext4_fsblk_t block_bitmap;
2347 ext4_fsblk_t inode_bitmap; 2347 ext4_fsblk_t inode_bitmap;
2348 ext4_fsblk_t inode_table; 2348 ext4_fsblk_t inode_table;
@@ -3141,14 +3141,8 @@ static ext4_group_t ext4_has_uninit_itable(struct super_block *sb)
3141 if (!gdp) 3141 if (!gdp)
3142 continue; 3142 continue;
3143 3143
3144 if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)) 3144 if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)))
3145 continue;
3146 if (group != 0)
3147 break; 3145 break;
3148 ext4_error(sb, "Inode table for bg 0 marked as "
3149 "needing zeroing");
3150 if (sb_rdonly(sb))
3151 return ngroups;
3152 } 3146 }
3153 3147
3154 return group; 3148 return group;
@@ -4085,14 +4079,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
4085 goto failed_mount2; 4079 goto failed_mount2;
4086 } 4080 }
4087 } 4081 }
4082 sbi->s_gdb_count = db_count;
4088 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { 4083 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
4089 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 4084 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
4090 ret = -EFSCORRUPTED; 4085 ret = -EFSCORRUPTED;
4091 goto failed_mount2; 4086 goto failed_mount2;
4092 } 4087 }
4093 4088
4094 sbi->s_gdb_count = db_count;
4095
4096 timer_setup(&sbi->s_err_report, print_daily_error_info, 0); 4089 timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
4097 4090
4098 /* Register extent status tree shrinker */ 4091 /* Register extent status tree shrinker */
@@ -5213,6 +5206,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
5213 5206
5214 if (sbi->s_journal) 5207 if (sbi->s_journal)
5215 ext4_mark_recovery_complete(sb, es); 5208 ext4_mark_recovery_complete(sb, es);
5209 if (sbi->s_mmp_tsk)
5210 kthread_stop(sbi->s_mmp_tsk);
5216 } else { 5211 } else {
5217 /* Make sure we can mount this feature set readwrite */ 5212 /* Make sure we can mount this feature set readwrite */
5218 if (ext4_has_feature_readonly(sb) || 5213 if (ext4_has_feature_readonly(sb) ||
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 065dc919a0ce..bfd589ea74c0 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -707,13 +707,21 @@ static void fat_set_state(struct super_block *sb,
707 brelse(bh); 707 brelse(bh);
708} 708}
709 709
710static void fat_reset_iocharset(struct fat_mount_options *opts)
711{
712 if (opts->iocharset != fat_default_iocharset) {
713 /* Note: opts->iocharset can be NULL here */
714 kfree(opts->iocharset);
715 opts->iocharset = fat_default_iocharset;
716 }
717}
718
710static void delayed_free(struct rcu_head *p) 719static void delayed_free(struct rcu_head *p)
711{ 720{
712 struct msdos_sb_info *sbi = container_of(p, struct msdos_sb_info, rcu); 721 struct msdos_sb_info *sbi = container_of(p, struct msdos_sb_info, rcu);
713 unload_nls(sbi->nls_disk); 722 unload_nls(sbi->nls_disk);
714 unload_nls(sbi->nls_io); 723 unload_nls(sbi->nls_io);
715 if (sbi->options.iocharset != fat_default_iocharset) 724 fat_reset_iocharset(&sbi->options);
716 kfree(sbi->options.iocharset);
717 kfree(sbi); 725 kfree(sbi);
718} 726}
719 727
@@ -1132,7 +1140,7 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
1132 opts->fs_fmask = opts->fs_dmask = current_umask(); 1140 opts->fs_fmask = opts->fs_dmask = current_umask();
1133 opts->allow_utime = -1; 1141 opts->allow_utime = -1;
1134 opts->codepage = fat_default_codepage; 1142 opts->codepage = fat_default_codepage;
1135 opts->iocharset = fat_default_iocharset; 1143 fat_reset_iocharset(opts);
1136 if (is_vfat) { 1144 if (is_vfat) {
1137 opts->shortname = VFAT_SFN_DISPLAY_WINNT|VFAT_SFN_CREATE_WIN95; 1145 opts->shortname = VFAT_SFN_DISPLAY_WINNT|VFAT_SFN_CREATE_WIN95;
1138 opts->rodir = 0; 1146 opts->rodir = 0;
@@ -1289,8 +1297,7 @@ static int parse_options(struct super_block *sb, char *options, int is_vfat,
1289 1297
1290 /* vfat specific */ 1298 /* vfat specific */
1291 case Opt_charset: 1299 case Opt_charset:
1292 if (opts->iocharset != fat_default_iocharset) 1300 fat_reset_iocharset(opts);
1293 kfree(opts->iocharset);
1294 iocharset = match_strdup(&args[0]); 1301 iocharset = match_strdup(&args[0]);
1295 if (!iocharset) 1302 if (!iocharset)
1296 return -ENOMEM; 1303 return -ENOMEM;
@@ -1881,8 +1888,7 @@ out_fail:
1881 iput(fat_inode); 1888 iput(fat_inode);
1882 unload_nls(sbi->nls_io); 1889 unload_nls(sbi->nls_io);
1883 unload_nls(sbi->nls_disk); 1890 unload_nls(sbi->nls_disk);
1884 if (sbi->options.iocharset != fat_default_iocharset) 1891 fat_reset_iocharset(&sbi->options);
1885 kfree(sbi->options.iocharset);
1886 sb->s_fs_info = NULL; 1892 sb->s_fs_info = NULL;
1887 kfree(sbi); 1893 kfree(sbi);
1888 return error; 1894 return error;
diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c
index c184c5a356ff..cdcb376ef8df 100644
--- a/fs/fscache/cache.c
+++ b/fs/fscache/cache.c
@@ -220,6 +220,7 @@ int fscache_add_cache(struct fscache_cache *cache,
220{ 220{
221 struct fscache_cache_tag *tag; 221 struct fscache_cache_tag *tag;
222 222
223 ASSERTCMP(ifsdef->cookie, ==, &fscache_fsdef_index);
223 BUG_ON(!cache->ops); 224 BUG_ON(!cache->ops);
224 BUG_ON(!ifsdef); 225 BUG_ON(!ifsdef);
225 226
@@ -248,7 +249,6 @@ int fscache_add_cache(struct fscache_cache *cache,
248 if (!cache->kobj) 249 if (!cache->kobj)
249 goto error; 250 goto error;
250 251
251 ifsdef->cookie = &fscache_fsdef_index;
252 ifsdef->cache = cache; 252 ifsdef->cache = cache;
253 cache->fsdef = ifsdef; 253 cache->fsdef = ifsdef;
254 254
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 97137d7ec5ee..83bfe04456b6 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -516,6 +516,7 @@ static int fscache_alloc_object(struct fscache_cache *cache,
516 goto error; 516 goto error;
517 } 517 }
518 518
519 ASSERTCMP(object->cookie, ==, cookie);
519 fscache_stat(&fscache_n_object_alloc); 520 fscache_stat(&fscache_n_object_alloc);
520 521
521 object->debug_id = atomic_inc_return(&fscache_object_debug_id); 522 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
@@ -571,6 +572,8 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
571 572
572 _enter("{%s},{OBJ%x}", cookie->def->name, object->debug_id); 573 _enter("{%s},{OBJ%x}", cookie->def->name, object->debug_id);
573 574
575 ASSERTCMP(object->cookie, ==, cookie);
576
574 spin_lock(&cookie->lock); 577 spin_lock(&cookie->lock);
575 578
576 /* there may be multiple initial creations of this object, but we only 579 /* there may be multiple initial creations of this object, but we only
@@ -610,9 +613,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
610 spin_unlock(&cache->object_list_lock); 613 spin_unlock(&cache->object_list_lock);
611 } 614 }
612 615
613 /* attach to the cookie */ 616 /* Attach to the cookie. The object already has a ref on it. */
614 object->cookie = cookie;
615 fscache_cookie_get(cookie, fscache_cookie_get_attach_object);
616 hlist_add_head(&object->cookie_link, &cookie->backing_objects); 617 hlist_add_head(&object->cookie_link, &cookie->backing_objects);
617 618
618 fscache_objlist_add(object); 619 fscache_objlist_add(object);
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 20e0d0a4dc8c..9edc920f651f 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -327,6 +327,7 @@ void fscache_object_init(struct fscache_object *object,
327 object->store_limit_l = 0; 327 object->store_limit_l = 0;
328 object->cache = cache; 328 object->cache = cache;
329 object->cookie = cookie; 329 object->cookie = cookie;
330 fscache_cookie_get(cookie, fscache_cookie_get_attach_object);
330 object->parent = NULL; 331 object->parent = NULL;
331#ifdef CONFIG_FSCACHE_OBJECT_LIST 332#ifdef CONFIG_FSCACHE_OBJECT_LIST
332 RB_CLEAR_NODE(&object->objlist_link); 333 RB_CLEAR_NODE(&object->objlist_link);
diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
index e30c5975ea58..8d265790374c 100644
--- a/fs/fscache/operation.c
+++ b/fs/fscache/operation.c
@@ -70,7 +70,8 @@ void fscache_enqueue_operation(struct fscache_operation *op)
70 ASSERT(op->processor != NULL); 70 ASSERT(op->processor != NULL);
71 ASSERT(fscache_object_is_available(op->object)); 71 ASSERT(fscache_object_is_available(op->object));
72 ASSERTCMP(atomic_read(&op->usage), >, 0); 72 ASSERTCMP(atomic_read(&op->usage), >, 0);
73 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS); 73 ASSERTIFCMP(op->state != FSCACHE_OP_ST_IN_PROGRESS,
74 op->state, ==, FSCACHE_OP_ST_CANCELLED);
74 75
75 fscache_stat(&fscache_n_op_enqueue); 76 fscache_stat(&fscache_n_op_enqueue);
76 switch (op->flags & FSCACHE_OP_TYPE) { 77 switch (op->flags & FSCACHE_OP_TYPE) {
@@ -499,7 +500,8 @@ void fscache_put_operation(struct fscache_operation *op)
499 struct fscache_cache *cache; 500 struct fscache_cache *cache;
500 501
501 _enter("{OBJ%x OP%x,%d}", 502 _enter("{OBJ%x OP%x,%d}",
502 op->object->debug_id, op->debug_id, atomic_read(&op->usage)); 503 op->object ? op->object->debug_id : 0,
504 op->debug_id, atomic_read(&op->usage));
503 505
504 ASSERTCMP(atomic_read(&op->usage), >, 0); 506 ASSERTCMP(atomic_read(&op->usage), >, 0);
505 507
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index d508c7844681..40d4c66c7751 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -411,6 +411,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
411 bool truncate_op = (lend == LLONG_MAX); 411 bool truncate_op = (lend == LLONG_MAX);
412 412
413 memset(&pseudo_vma, 0, sizeof(struct vm_area_struct)); 413 memset(&pseudo_vma, 0, sizeof(struct vm_area_struct));
414 vma_init(&pseudo_vma, current->mm);
414 pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED); 415 pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
415 pagevec_init(&pvec); 416 pagevec_init(&pvec);
416 next = start; 417 next = start;
@@ -595,6 +596,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
595 * as input to create an allocation policy. 596 * as input to create an allocation policy.
596 */ 597 */
597 memset(&pseudo_vma, 0, sizeof(struct vm_area_struct)); 598 memset(&pseudo_vma, 0, sizeof(struct vm_area_struct));
599 vma_init(&pseudo_vma, mm);
598 pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED); 600 pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
599 pseudo_vma.vm_file = file; 601 pseudo_vma.vm_file = file;
600 602
diff --git a/fs/internal.h b/fs/internal.h
index 980d005b21b4..5645b4ebf494 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -127,7 +127,6 @@ int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
127 127
128extern int open_check_o_direct(struct file *f); 128extern int open_check_o_direct(struct file *f);
129extern int vfs_open(const struct path *, struct file *, const struct cred *); 129extern int vfs_open(const struct path *, struct file *, const struct cred *);
130extern struct file *filp_clone_open(struct file *);
131 130
132/* 131/*
133 * inode.c 132 * inode.c
diff --git a/fs/iomap.c b/fs/iomap.c
index 77397b5a96ef..0d0bd8845586 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1443,7 +1443,7 @@ iomap_bmap(struct address_space *mapping, sector_t bno,
1443 const struct iomap_ops *ops) 1443 const struct iomap_ops *ops)
1444{ 1444{
1445 struct inode *inode = mapping->host; 1445 struct inode *inode = mapping->host;
1446 loff_t pos = bno >> inode->i_blkbits; 1446 loff_t pos = bno << inode->i_blkbits;
1447 unsigned blocksize = i_blocksize(inode); 1447 unsigned blocksize = i_blocksize(inode);
1448 1448
1449 if (filemap_write_and_wait(mapping)) 1449 if (filemap_write_and_wait(mapping))
diff --git a/fs/jfs/jfs_dinode.h b/fs/jfs/jfs_dinode.h
index 395c4c0d0f06..1682a87c00b2 100644
--- a/fs/jfs/jfs_dinode.h
+++ b/fs/jfs/jfs_dinode.h
@@ -115,6 +115,13 @@ struct dinode {
115 dxd_t _dxd; /* 16: */ 115 dxd_t _dxd; /* 16: */
116 union { 116 union {
117 __le32 _rdev; /* 4: */ 117 __le32 _rdev; /* 4: */
118 /*
119 * The fast symlink area
120 * is expected to overflow
121 * into _inlineea when
122 * needed (which will clear
123 * INLINEEA).
124 */
118 u8 _fastsymlink[128]; 125 u8 _fastsymlink[128];
119 } _u; 126 } _u;
120 u8 _inlineea[128]; 127 u8 _inlineea[128];
diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
index 1f26d1910409..9940a1e04cbf 100644
--- a/fs/jfs/jfs_incore.h
+++ b/fs/jfs/jfs_incore.h
@@ -87,6 +87,7 @@ struct jfs_inode_info {
87 struct { 87 struct {
88 unchar _unused[16]; /* 16: */ 88 unchar _unused[16]; /* 16: */
89 dxd_t _dxd; /* 16: */ 89 dxd_t _dxd; /* 16: */
90 /* _inline may overflow into _inline_ea when needed */
90 unchar _inline[128]; /* 128: inline symlink */ 91 unchar _inline[128]; /* 128: inline symlink */
91 /* _inline_ea may overlay the last part of 92 /* _inline_ea may overlay the last part of
92 * file._xtroot if maxentry = XTROOTINITSLOT 93 * file._xtroot if maxentry = XTROOTINITSLOT
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 1b9264fd54b6..f08571433aba 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -967,8 +967,7 @@ static int __init init_jfs_fs(void)
967 jfs_inode_cachep = 967 jfs_inode_cachep =
968 kmem_cache_create_usercopy("jfs_ip", sizeof(struct jfs_inode_info), 968 kmem_cache_create_usercopy("jfs_ip", sizeof(struct jfs_inode_info),
969 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_ACCOUNT, 969 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_ACCOUNT,
970 offsetof(struct jfs_inode_info, i_inline), 970 offsetof(struct jfs_inode_info, i_inline), IDATASIZE,
971 sizeof_field(struct jfs_inode_info, i_inline),
972 init_once); 971 init_once);
973 if (jfs_inode_cachep == NULL) 972 if (jfs_inode_cachep == NULL)
974 return -ENOMEM; 973 return -ENOMEM;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6dd146885da9..f6c4ccd693f4 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6466,34 +6466,34 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
6466 if (data->arg.new_lock && !data->cancelled) { 6466 if (data->arg.new_lock && !data->cancelled) {
6467 data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS); 6467 data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS);
6468 if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0) 6468 if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0)
6469 break; 6469 goto out_restart;
6470 } 6470 }
6471
6472 if (data->arg.new_lock_owner != 0) { 6471 if (data->arg.new_lock_owner != 0) {
6473 nfs_confirm_seqid(&lsp->ls_seqid, 0); 6472 nfs_confirm_seqid(&lsp->ls_seqid, 0);
6474 nfs4_stateid_copy(&lsp->ls_stateid, &data->res.stateid); 6473 nfs4_stateid_copy(&lsp->ls_stateid, &data->res.stateid);
6475 set_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags); 6474 set_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags);
6476 goto out_done; 6475 } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
6477 } else if (nfs4_update_lock_stateid(lsp, &data->res.stateid)) 6476 goto out_restart;
6478 goto out_done;
6479
6480 break; 6477 break;
6481 case -NFS4ERR_BAD_STATEID: 6478 case -NFS4ERR_BAD_STATEID:
6482 case -NFS4ERR_OLD_STATEID: 6479 case -NFS4ERR_OLD_STATEID:
6483 case -NFS4ERR_STALE_STATEID: 6480 case -NFS4ERR_STALE_STATEID:
6484 case -NFS4ERR_EXPIRED: 6481 case -NFS4ERR_EXPIRED:
6485 if (data->arg.new_lock_owner != 0) { 6482 if (data->arg.new_lock_owner != 0) {
6486 if (nfs4_stateid_match(&data->arg.open_stateid, 6483 if (!nfs4_stateid_match(&data->arg.open_stateid,
6487 &lsp->ls_state->open_stateid)) 6484 &lsp->ls_state->open_stateid))
6488 goto out_done; 6485 goto out_restart;
6489 } else if (nfs4_stateid_match(&data->arg.lock_stateid, 6486 } else if (!nfs4_stateid_match(&data->arg.lock_stateid,
6490 &lsp->ls_stateid)) 6487 &lsp->ls_stateid))
6491 goto out_done; 6488 goto out_restart;
6492 } 6489 }
6493 if (!data->cancelled)
6494 rpc_restart_call_prepare(task);
6495out_done: 6490out_done:
6496 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status); 6491 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
6492 return;
6493out_restart:
6494 if (!data->cancelled)
6495 rpc_restart_call_prepare(task);
6496 goto out_done;
6497} 6497}
6498 6498
6499static void nfs4_lock_release(void *calldata) 6499static void nfs4_lock_release(void *calldata)
@@ -6502,7 +6502,7 @@ static void nfs4_lock_release(void *calldata)
6502 6502
6503 dprintk("%s: begin!\n", __func__); 6503 dprintk("%s: begin!\n", __func__);
6504 nfs_free_seqid(data->arg.open_seqid); 6504 nfs_free_seqid(data->arg.open_seqid);
6505 if (data->cancelled) { 6505 if (data->cancelled && data->rpc_status == 0) {
6506 struct rpc_task *task; 6506 struct rpc_task *task;
6507 task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp, 6507 task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp,
6508 data->arg.lock_seqid); 6508 data->arg.lock_seqid);
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 2751476e6b6e..f098b9f1c396 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -167,6 +167,8 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
167 } 167 }
168 168
169 if (compressed) { 169 if (compressed) {
170 if (!msblk->stream)
171 goto read_failure;
170 length = squashfs_decompress(msblk, bh, b, offset, length, 172 length = squashfs_decompress(msblk, bh, b, offset, length,
171 output); 173 output);
172 if (length < 0) 174 if (length < 0)
diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
index 23813c078cc9..0839efa720b3 100644
--- a/fs/squashfs/cache.c
+++ b/fs/squashfs/cache.c
@@ -350,6 +350,9 @@ int squashfs_read_metadata(struct super_block *sb, void *buffer,
350 350
351 TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset); 351 TRACE("Entered squashfs_read_metadata [%llx:%x]\n", *block, *offset);
352 352
353 if (unlikely(length < 0))
354 return -EIO;
355
353 while (length) { 356 while (length) {
354 entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0); 357 entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0);
355 if (entry->error) { 358 if (entry->error) {
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 13d80947bf9e..f1c1430ae721 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -194,7 +194,11 @@ static long long read_indexes(struct super_block *sb, int n,
194 } 194 }
195 195
196 for (i = 0; i < blocks; i++) { 196 for (i = 0; i < blocks; i++) {
197 int size = le32_to_cpu(blist[i]); 197 int size = squashfs_block_size(blist[i]);
198 if (size < 0) {
199 err = size;
200 goto failure;
201 }
198 block += SQUASHFS_COMPRESSED_SIZE_BLOCK(size); 202 block += SQUASHFS_COMPRESSED_SIZE_BLOCK(size);
199 } 203 }
200 n -= blocks; 204 n -= blocks;
@@ -367,7 +371,24 @@ static int read_blocklist(struct inode *inode, int index, u64 *block)
367 sizeof(size)); 371 sizeof(size));
368 if (res < 0) 372 if (res < 0)
369 return res; 373 return res;
370 return le32_to_cpu(size); 374 return squashfs_block_size(size);
375}
376
377void squashfs_fill_page(struct page *page, struct squashfs_cache_entry *buffer, int offset, int avail)
378{
379 int copied;
380 void *pageaddr;
381
382 pageaddr = kmap_atomic(page);
383 copied = squashfs_copy_data(pageaddr, buffer, offset, avail);
384 memset(pageaddr + copied, 0, PAGE_SIZE - copied);
385 kunmap_atomic(pageaddr);
386
387 flush_dcache_page(page);
388 if (copied == avail)
389 SetPageUptodate(page);
390 else
391 SetPageError(page);
371} 392}
372 393
373/* Copy data into page cache */ 394/* Copy data into page cache */
@@ -376,7 +397,6 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
376{ 397{
377 struct inode *inode = page->mapping->host; 398 struct inode *inode = page->mapping->host;
378 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 399 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
379 void *pageaddr;
380 int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1; 400 int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
381 int start_index = page->index & ~mask, end_index = start_index | mask; 401 int start_index = page->index & ~mask, end_index = start_index | mask;
382 402
@@ -402,12 +422,7 @@ void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry *buffer,
402 if (PageUptodate(push_page)) 422 if (PageUptodate(push_page))
403 goto skip_page; 423 goto skip_page;
404 424
405 pageaddr = kmap_atomic(push_page); 425 squashfs_fill_page(push_page, buffer, offset, avail);
406 squashfs_copy_data(pageaddr, buffer, offset, avail);
407 memset(pageaddr + avail, 0, PAGE_SIZE - avail);
408 kunmap_atomic(pageaddr);
409 flush_dcache_page(push_page);
410 SetPageUptodate(push_page);
411skip_page: 426skip_page:
412 unlock_page(push_page); 427 unlock_page(push_page);
413 if (i != page->index) 428 if (i != page->index)
@@ -416,10 +431,9 @@ skip_page:
416} 431}
417 432
418/* Read datablock stored packed inside a fragment (tail-end packed block) */ 433/* Read datablock stored packed inside a fragment (tail-end packed block) */
419static int squashfs_readpage_fragment(struct page *page) 434static int squashfs_readpage_fragment(struct page *page, int expected)
420{ 435{
421 struct inode *inode = page->mapping->host; 436 struct inode *inode = page->mapping->host;
422 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
423 struct squashfs_cache_entry *buffer = squashfs_get_fragment(inode->i_sb, 437 struct squashfs_cache_entry *buffer = squashfs_get_fragment(inode->i_sb,
424 squashfs_i(inode)->fragment_block, 438 squashfs_i(inode)->fragment_block,
425 squashfs_i(inode)->fragment_size); 439 squashfs_i(inode)->fragment_size);
@@ -430,23 +444,16 @@ static int squashfs_readpage_fragment(struct page *page)
430 squashfs_i(inode)->fragment_block, 444 squashfs_i(inode)->fragment_block,
431 squashfs_i(inode)->fragment_size); 445 squashfs_i(inode)->fragment_size);
432 else 446 else
433 squashfs_copy_cache(page, buffer, i_size_read(inode) & 447 squashfs_copy_cache(page, buffer, expected,
434 (msblk->block_size - 1),
435 squashfs_i(inode)->fragment_offset); 448 squashfs_i(inode)->fragment_offset);
436 449
437 squashfs_cache_put(buffer); 450 squashfs_cache_put(buffer);
438 return res; 451 return res;
439} 452}
440 453
441static int squashfs_readpage_sparse(struct page *page, int index, int file_end) 454static int squashfs_readpage_sparse(struct page *page, int expected)
442{ 455{
443 struct inode *inode = page->mapping->host; 456 squashfs_copy_cache(page, NULL, expected, 0);
444 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
445 int bytes = index == file_end ?
446 (i_size_read(inode) & (msblk->block_size - 1)) :
447 msblk->block_size;
448
449 squashfs_copy_cache(page, NULL, bytes, 0);
450 return 0; 457 return 0;
451} 458}
452 459
@@ -456,6 +463,9 @@ static int squashfs_readpage(struct file *file, struct page *page)
456 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; 463 struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
457 int index = page->index >> (msblk->block_log - PAGE_SHIFT); 464 int index = page->index >> (msblk->block_log - PAGE_SHIFT);
458 int file_end = i_size_read(inode) >> msblk->block_log; 465 int file_end = i_size_read(inode) >> msblk->block_log;
466 int expected = index == file_end ?
467 (i_size_read(inode) & (msblk->block_size - 1)) :
468 msblk->block_size;
459 int res; 469 int res;
460 void *pageaddr; 470 void *pageaddr;
461 471
@@ -474,11 +484,11 @@ static int squashfs_readpage(struct file *file, struct page *page)
474 goto error_out; 484 goto error_out;
475 485
476 if (bsize == 0) 486 if (bsize == 0)
477 res = squashfs_readpage_sparse(page, index, file_end); 487 res = squashfs_readpage_sparse(page, expected);
478 else 488 else
479 res = squashfs_readpage_block(page, block, bsize); 489 res = squashfs_readpage_block(page, block, bsize, expected);
480 } else 490 } else
481 res = squashfs_readpage_fragment(page); 491 res = squashfs_readpage_fragment(page, expected);
482 492
483 if (!res) 493 if (!res)
484 return 0; 494 return 0;
diff --git a/fs/squashfs/file_cache.c b/fs/squashfs/file_cache.c
index f2310d2a2019..a9ba8d96776a 100644
--- a/fs/squashfs/file_cache.c
+++ b/fs/squashfs/file_cache.c
@@ -20,7 +20,7 @@
20#include "squashfs.h" 20#include "squashfs.h"
21 21
22/* Read separately compressed datablock and memcopy into page cache */ 22/* Read separately compressed datablock and memcopy into page cache */
23int squashfs_readpage_block(struct page *page, u64 block, int bsize) 23int squashfs_readpage_block(struct page *page, u64 block, int bsize, int expected)
24{ 24{
25 struct inode *i = page->mapping->host; 25 struct inode *i = page->mapping->host;
26 struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb, 26 struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
@@ -31,7 +31,7 @@ int squashfs_readpage_block(struct page *page, u64 block, int bsize)
31 ERROR("Unable to read page, block %llx, size %x\n", block, 31 ERROR("Unable to read page, block %llx, size %x\n", block,
32 bsize); 32 bsize);
33 else 33 else
34 squashfs_copy_cache(page, buffer, buffer->length, 0); 34 squashfs_copy_cache(page, buffer, expected, 0);
35 35
36 squashfs_cache_put(buffer); 36 squashfs_cache_put(buffer);
37 return res; 37 return res;
diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c
index cb485d8e0e91..80db1b86a27c 100644
--- a/fs/squashfs/file_direct.c
+++ b/fs/squashfs/file_direct.c
@@ -21,10 +21,11 @@
21#include "page_actor.h" 21#include "page_actor.h"
22 22
23static int squashfs_read_cache(struct page *target_page, u64 block, int bsize, 23static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
24 int pages, struct page **page); 24 int pages, struct page **page, int bytes);
25 25
26/* Read separately compressed datablock directly into page cache */ 26/* Read separately compressed datablock directly into page cache */
27int squashfs_readpage_block(struct page *target_page, u64 block, int bsize) 27int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
28 int expected)
28 29
29{ 30{
30 struct inode *inode = target_page->mapping->host; 31 struct inode *inode = target_page->mapping->host;
@@ -83,7 +84,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
83 * using an intermediate buffer. 84 * using an intermediate buffer.
84 */ 85 */
85 res = squashfs_read_cache(target_page, block, bsize, pages, 86 res = squashfs_read_cache(target_page, block, bsize, pages,
86 page); 87 page, expected);
87 if (res < 0) 88 if (res < 0)
88 goto mark_errored; 89 goto mark_errored;
89 90
@@ -95,6 +96,11 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
95 if (res < 0) 96 if (res < 0)
96 goto mark_errored; 97 goto mark_errored;
97 98
99 if (res != expected) {
100 res = -EIO;
101 goto mark_errored;
102 }
103
98 /* Last page may have trailing bytes not filled */ 104 /* Last page may have trailing bytes not filled */
99 bytes = res % PAGE_SIZE; 105 bytes = res % PAGE_SIZE;
100 if (bytes) { 106 if (bytes) {
@@ -138,13 +144,12 @@ out:
138 144
139 145
140static int squashfs_read_cache(struct page *target_page, u64 block, int bsize, 146static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
141 int pages, struct page **page) 147 int pages, struct page **page, int bytes)
142{ 148{
143 struct inode *i = target_page->mapping->host; 149 struct inode *i = target_page->mapping->host;
144 struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb, 150 struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
145 block, bsize); 151 block, bsize);
146 int bytes = buffer->length, res = buffer->error, n, offset = 0; 152 int res = buffer->error, n, offset = 0;
147 void *pageaddr;
148 153
149 if (res) { 154 if (res) {
150 ERROR("Unable to read page, block %llx, size %x\n", block, 155 ERROR("Unable to read page, block %llx, size %x\n", block,
@@ -159,12 +164,7 @@ static int squashfs_read_cache(struct page *target_page, u64 block, int bsize,
159 if (page[n] == NULL) 164 if (page[n] == NULL)
160 continue; 165 continue;
161 166
162 pageaddr = kmap_atomic(page[n]); 167 squashfs_fill_page(page[n], buffer, offset, avail);
163 squashfs_copy_data(pageaddr, buffer, offset, avail);
164 memset(pageaddr + avail, 0, PAGE_SIZE - avail);
165 kunmap_atomic(pageaddr);
166 flush_dcache_page(page[n]);
167 SetPageUptodate(page[n]);
168 unlock_page(page[n]); 168 unlock_page(page[n]);
169 if (page[n] != target_page) 169 if (page[n] != target_page)
170 put_page(page[n]); 170 put_page(page[n]);
diff --git a/fs/squashfs/fragment.c b/fs/squashfs/fragment.c
index 0ed6edbc5c71..0681feab4a84 100644
--- a/fs/squashfs/fragment.c
+++ b/fs/squashfs/fragment.c
@@ -49,11 +49,16 @@ int squashfs_frag_lookup(struct super_block *sb, unsigned int fragment,
49 u64 *fragment_block) 49 u64 *fragment_block)
50{ 50{
51 struct squashfs_sb_info *msblk = sb->s_fs_info; 51 struct squashfs_sb_info *msblk = sb->s_fs_info;
52 int block = SQUASHFS_FRAGMENT_INDEX(fragment); 52 int block, offset, size;
53 int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
54 u64 start_block = le64_to_cpu(msblk->fragment_index[block]);
55 struct squashfs_fragment_entry fragment_entry; 53 struct squashfs_fragment_entry fragment_entry;
56 int size; 54 u64 start_block;
55
56 if (fragment >= msblk->fragments)
57 return -EIO;
58 block = SQUASHFS_FRAGMENT_INDEX(fragment);
59 offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment);
60
61 start_block = le64_to_cpu(msblk->fragment_index[block]);
57 62
58 size = squashfs_read_metadata(sb, &fragment_entry, &start_block, 63 size = squashfs_read_metadata(sb, &fragment_entry, &start_block,
59 &offset, sizeof(fragment_entry)); 64 &offset, sizeof(fragment_entry));
@@ -61,9 +66,7 @@ int squashfs_frag_lookup(struct super_block *sb, unsigned int fragment,
61 return size; 66 return size;
62 67
63 *fragment_block = le64_to_cpu(fragment_entry.start_block); 68 *fragment_block = le64_to_cpu(fragment_entry.start_block);
64 size = le32_to_cpu(fragment_entry.size); 69 return squashfs_block_size(fragment_entry.size);
65
66 return size;
67} 70}
68 71
69 72
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h
index 887d6d270080..f89f8a74c6ce 100644
--- a/fs/squashfs/squashfs.h
+++ b/fs/squashfs/squashfs.h
@@ -67,11 +67,12 @@ extern __le64 *squashfs_read_fragment_index_table(struct super_block *,
67 u64, u64, unsigned int); 67 u64, u64, unsigned int);
68 68
69/* file.c */ 69/* file.c */
70void squashfs_fill_page(struct page *, struct squashfs_cache_entry *, int, int);
70void squashfs_copy_cache(struct page *, struct squashfs_cache_entry *, int, 71void squashfs_copy_cache(struct page *, struct squashfs_cache_entry *, int,
71 int); 72 int);
72 73
73/* file_xxx.c */ 74/* file_xxx.c */
74extern int squashfs_readpage_block(struct page *, u64, int); 75extern int squashfs_readpage_block(struct page *, u64, int, int);
75 76
76/* id.c */ 77/* id.c */
77extern int squashfs_get_id(struct super_block *, unsigned int, unsigned int *); 78extern int squashfs_get_id(struct super_block *, unsigned int, unsigned int *);
diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h
index 24d12fd14177..4e6853f084d0 100644
--- a/fs/squashfs/squashfs_fs.h
+++ b/fs/squashfs/squashfs_fs.h
@@ -129,6 +129,12 @@
129 129
130#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK)) 130#define SQUASHFS_COMPRESSED_BLOCK(B) (!((B) & SQUASHFS_COMPRESSED_BIT_BLOCK))
131 131
132static inline int squashfs_block_size(__le32 raw)
133{
134 u32 size = le32_to_cpu(raw);
135 return (size >> 25) ? -EIO : size;
136}
137
132/* 138/*
133 * Inode number ops. Inodes consist of a compressed block number, and an 139 * Inode number ops. Inodes consist of a compressed block number, and an
134 * uncompressed offset within that block 140 * uncompressed offset within that block
diff --git a/fs/squashfs/squashfs_fs_sb.h b/fs/squashfs/squashfs_fs_sb.h
index 1da565cb50c3..ef69c31947bf 100644
--- a/fs/squashfs/squashfs_fs_sb.h
+++ b/fs/squashfs/squashfs_fs_sb.h
@@ -75,6 +75,7 @@ struct squashfs_sb_info {
75 unsigned short block_log; 75 unsigned short block_log;
76 long long bytes_used; 76 long long bytes_used;
77 unsigned int inodes; 77 unsigned int inodes;
78 unsigned int fragments;
78 int xattr_ids; 79 int xattr_ids;
79}; 80};
80#endif 81#endif
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 8a73b97217c8..40e657386fa5 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -175,6 +175,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
175 msblk->inode_table = le64_to_cpu(sblk->inode_table_start); 175 msblk->inode_table = le64_to_cpu(sblk->inode_table_start);
176 msblk->directory_table = le64_to_cpu(sblk->directory_table_start); 176 msblk->directory_table = le64_to_cpu(sblk->directory_table_start);
177 msblk->inodes = le32_to_cpu(sblk->inodes); 177 msblk->inodes = le32_to_cpu(sblk->inodes);
178 msblk->fragments = le32_to_cpu(sblk->fragments);
178 flags = le16_to_cpu(sblk->flags); 179 flags = le16_to_cpu(sblk->flags);
179 180
180 TRACE("Found valid superblock on %pg\n", sb->s_bdev); 181 TRACE("Found valid superblock on %pg\n", sb->s_bdev);
@@ -185,7 +186,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
185 TRACE("Filesystem size %lld bytes\n", msblk->bytes_used); 186 TRACE("Filesystem size %lld bytes\n", msblk->bytes_used);
186 TRACE("Block size %d\n", msblk->block_size); 187 TRACE("Block size %d\n", msblk->block_size);
187 TRACE("Number of inodes %d\n", msblk->inodes); 188 TRACE("Number of inodes %d\n", msblk->inodes);
188 TRACE("Number of fragments %d\n", le32_to_cpu(sblk->fragments)); 189 TRACE("Number of fragments %d\n", msblk->fragments);
189 TRACE("Number of ids %d\n", le16_to_cpu(sblk->no_ids)); 190 TRACE("Number of ids %d\n", le16_to_cpu(sblk->no_ids));
190 TRACE("sblk->inode_table_start %llx\n", msblk->inode_table); 191 TRACE("sblk->inode_table_start %llx\n", msblk->inode_table);
191 TRACE("sblk->directory_table_start %llx\n", msblk->directory_table); 192 TRACE("sblk->directory_table_start %llx\n", msblk->directory_table);
@@ -272,7 +273,7 @@ allocate_id_index_table:
272 sb->s_export_op = &squashfs_export_ops; 273 sb->s_export_op = &squashfs_export_ops;
273 274
274handle_fragments: 275handle_fragments:
275 fragments = le32_to_cpu(sblk->fragments); 276 fragments = msblk->fragments;
276 if (fragments == 0) 277 if (fragments == 0)
277 goto check_directory_table; 278 goto check_directory_table;
278 279
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 594d192b2331..bad9cea37f12 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -633,8 +633,10 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
633 /* the various vma->vm_userfaultfd_ctx still points to it */ 633 /* the various vma->vm_userfaultfd_ctx still points to it */
634 down_write(&mm->mmap_sem); 634 down_write(&mm->mmap_sem);
635 for (vma = mm->mmap; vma; vma = vma->vm_next) 635 for (vma = mm->mmap; vma; vma = vma->vm_next)
636 if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx) 636 if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx) {
637 vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX; 637 vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
638 vma->vm_flags &= ~(VM_UFFD_WP | VM_UFFD_MISSING);
639 }
638 up_write(&mm->mmap_sem); 640 up_write(&mm->mmap_sem);
639 641
640 userfaultfd_ctx_put(release_new_ctx); 642 userfaultfd_ctx_put(release_new_ctx);
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index eef466260d43..75dbdc14c45f 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -223,12 +223,13 @@ xfs_alloc_get_rec(
223 error = xfs_btree_get_rec(cur, &rec, stat); 223 error = xfs_btree_get_rec(cur, &rec, stat);
224 if (error || !(*stat)) 224 if (error || !(*stat))
225 return error; 225 return error;
226 if (rec->alloc.ar_blockcount == 0)
227 goto out_bad_rec;
228 226
229 *bno = be32_to_cpu(rec->alloc.ar_startblock); 227 *bno = be32_to_cpu(rec->alloc.ar_startblock);
230 *len = be32_to_cpu(rec->alloc.ar_blockcount); 228 *len = be32_to_cpu(rec->alloc.ar_blockcount);
231 229
230 if (*len == 0)
231 goto out_bad_rec;
232
232 /* check for valid extent range, including overflow */ 233 /* check for valid extent range, including overflow */
233 if (!xfs_verify_agbno(mp, agno, *bno)) 234 if (!xfs_verify_agbno(mp, agno, *bno))
234 goto out_bad_rec; 235 goto out_bad_rec;
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 33dc34655ac3..30d1d60f1d46 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -731,7 +731,8 @@ xfs_inode_validate_extsize(
731 if ((hint_flag || inherit_flag) && extsize == 0) 731 if ((hint_flag || inherit_flag) && extsize == 0)
732 return __this_address; 732 return __this_address;
733 733
734 if (!(hint_flag || inherit_flag) && extsize != 0) 734 /* free inodes get flags set to zero but extsize remains */
735 if (mode && !(hint_flag || inherit_flag) && extsize != 0)
735 return __this_address; 736 return __this_address;
736 737
737 if (extsize_bytes % blocksize_bytes) 738 if (extsize_bytes % blocksize_bytes)
@@ -777,7 +778,8 @@ xfs_inode_validate_cowextsize(
777 if (hint_flag && cowextsize == 0) 778 if (hint_flag && cowextsize == 0)
778 return __this_address; 779 return __this_address;
779 780
780 if (!hint_flag && cowextsize != 0) 781 /* free inodes get flags set to zero but cowextsize remains */
782 if (mode && !hint_flag && cowextsize != 0)
781 return __this_address; 783 return __this_address;
782 784
783 if (hint_flag && rt_flag) 785 if (hint_flag && rt_flag)
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index e3147eb74222..ca3f2c2edd85 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -287,6 +287,20 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
287 287
288void blk_mq_quiesce_queue_nowait(struct request_queue *q); 288void blk_mq_quiesce_queue_nowait(struct request_queue *q);
289 289
290/**
291 * blk_mq_mark_complete() - Set request state to complete
292 * @rq: request to set to complete state
293 *
294 * Returns true if request state was successfully set to complete. If
295 * successful, the caller is responsibile for seeing this request is ended, as
296 * blk_mq_complete_request will not work again.
297 */
298static inline bool blk_mq_mark_complete(struct request *rq)
299{
300 return cmpxchg(&rq->state, MQ_RQ_IN_FLIGHT, MQ_RQ_COMPLETE) ==
301 MQ_RQ_IN_FLIGHT;
302}
303
290/* 304/*
291 * Driver command data is immediately after the request. So subtract request 305 * Driver command data is immediately after the request. So subtract request
292 * size to get back to the original request, add request size to get the PDU. 306 * size to get back to the original request, add request size to get the PDU.
diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 79795c5fa7c3..d50c2f0a655a 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -2,6 +2,7 @@
2#ifndef _BPF_CGROUP_H 2#ifndef _BPF_CGROUP_H
3#define _BPF_CGROUP_H 3#define _BPF_CGROUP_H
4 4
5#include <linux/errno.h>
5#include <linux/jump_label.h> 6#include <linux/jump_label.h>
6#include <uapi/linux/bpf.h> 7#include <uapi/linux/bpf.h>
7 8
diff --git a/include/linux/bpfilter.h b/include/linux/bpfilter.h
index 687b1760bb9f..f02cee0225d4 100644
--- a/include/linux/bpfilter.h
+++ b/include/linux/bpfilter.h
@@ -5,10 +5,10 @@
5#include <uapi/linux/bpfilter.h> 5#include <uapi/linux/bpfilter.h>
6 6
7struct sock; 7struct sock;
8int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char *optval, 8int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval,
9 unsigned int optlen); 9 unsigned int optlen);
10int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char *optval, 10int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval,
11 int *optlen); 11 int __user *optlen);
12extern int (*bpfilter_process_sockopt)(struct sock *sk, int optname, 12extern int (*bpfilter_process_sockopt)(struct sock *sk, int optname,
13 char __user *optval, 13 char __user *optval,
14 unsigned int optlen, bool is_set); 14 unsigned int optlen, bool is_set);
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index e6c0448ebcc7..31c865d1842e 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -124,7 +124,7 @@ static inline void delayacct_blkio_start(void)
124 124
125static inline void delayacct_blkio_end(struct task_struct *p) 125static inline void delayacct_blkio_end(struct task_struct *p)
126{ 126{
127 if (current->delays) 127 if (p->delays)
128 __delayacct_blkio_end(p); 128 __delayacct_blkio_end(p);
129 delayacct_clear_flag(DELAYACCT_PF_BLKIO); 129 delayacct_clear_flag(DELAYACCT_PF_BLKIO);
130} 130}
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
index 7094718b653b..ffcc7724ca21 100644
--- a/include/linux/eventfd.h
+++ b/include/linux/eventfd.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/fcntl.h> 12#include <linux/fcntl.h>
13#include <linux/wait.h> 13#include <linux/wait.h>
14#include <linux/err.h>
14 15
15/* 16/*
16 * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining 17 * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 300baad62c88..c73dd7396886 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -765,8 +765,8 @@ static inline bool bpf_dump_raw_ok(void)
765struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, 765struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
766 const struct bpf_insn *patch, u32 len); 766 const struct bpf_insn *patch, u32 len);
767 767
768static inline int __xdp_generic_ok_fwd_dev(struct sk_buff *skb, 768static inline int xdp_ok_fwd_dev(const struct net_device *fwd,
769 struct net_device *fwd) 769 unsigned int pktlen)
770{ 770{
771 unsigned int len; 771 unsigned int len;
772 772
@@ -774,7 +774,7 @@ static inline int __xdp_generic_ok_fwd_dev(struct sk_buff *skb,
774 return -ENETDOWN; 774 return -ENETDOWN;
775 775
776 len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN; 776 len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN;
777 if (skb->len > len) 777 if (pktlen > len)
778 return -EMSGSIZE; 778 return -EMSGSIZE;
779 779
780 return 0; 780 return 0;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d78d146a98da..805bf22898cf 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2420,6 +2420,7 @@ extern struct file *filp_open(const char *, int, umode_t);
2420extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2420extern struct file *file_open_root(struct dentry *, struct vfsmount *,
2421 const char *, int, umode_t); 2421 const char *, int, umode_t);
2422extern struct file * dentry_open(const struct path *, int, const struct cred *); 2422extern struct file * dentry_open(const struct path *, int, const struct cred *);
2423extern struct file *filp_clone_open(struct file *);
2423extern int filp_close(struct file *, fl_owner_t id); 2424extern int filp_close(struct file *, fl_owner_t id);
2424 2425
2425extern struct filename *getname_flags(const char __user *, int, int *); 2426extern struct filename *getname_flags(const char __user *, int, int *);
diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h
index 3efa3b861d44..941b11811f85 100644
--- a/include/linux/fsl/guts.h
+++ b/include/linux/fsl/guts.h
@@ -16,6 +16,7 @@
16#define __FSL_GUTS_H__ 16#define __FSL_GUTS_H__
17 17
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/io.h>
19 20
20/** 21/**
21 * Global Utility Registers. 22 * Global Utility Registers.
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index 7843b98e1c6e..c20c7e197d07 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -105,13 +105,13 @@ static inline bool br_vlan_enabled(const struct net_device *dev)
105 105
106static inline int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid) 106static inline int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
107{ 107{
108 return -1; 108 return -EINVAL;
109} 109}
110 110
111static inline int br_vlan_get_info(const struct net_device *dev, u16 vid, 111static inline int br_vlan_get_info(const struct net_device *dev, u16 vid,
112 struct bridge_vlan_info *p_vinfo) 112 struct bridge_vlan_info *p_vinfo)
113{ 113{
114 return -1; 114 return -EINVAL;
115} 115}
116#endif 116#endif
117 117
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index f8231854b5d6..119f53941c12 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -109,6 +109,8 @@ struct ip_mc_list {
109extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto); 109extern int ip_check_mc_rcu(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u8 proto);
110extern int igmp_rcv(struct sk_buff *); 110extern int igmp_rcv(struct sk_buff *);
111extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr); 111extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr);
112extern int ip_mc_join_group_ssm(struct sock *sk, struct ip_mreqn *imr,
113 unsigned int mode);
112extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr); 114extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr);
113extern void ip_mc_drop_socket(struct sock *sk); 115extern void ip_mc_drop_socket(struct sock *sk);
114extern int ip_mc_source(int add, int omode, struct sock *sk, 116extern int ip_mc_source(int add, int omode, struct sock *sk,
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 1df940196ab2..ef169d67df92 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -121,6 +121,7 @@
121#define ecap_srs(e) ((e >> 31) & 0x1) 121#define ecap_srs(e) ((e >> 31) & 0x1)
122#define ecap_ers(e) ((e >> 30) & 0x1) 122#define ecap_ers(e) ((e >> 30) & 0x1)
123#define ecap_prs(e) ((e >> 29) & 0x1) 123#define ecap_prs(e) ((e >> 29) & 0x1)
124#define ecap_broken_pasid(e) ((e >> 28) & 0x1)
124#define ecap_dis(e) ((e >> 27) & 0x1) 125#define ecap_dis(e) ((e >> 27) & 0x1)
125#define ecap_nest(e) ((e >> 26) & 0x1) 126#define ecap_nest(e) ((e >> 26) & 0x1)
126#define ecap_mts(e) ((e >> 25) & 0x1) 127#define ecap_mts(e) ((e >> 25) & 0x1)
diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h
index 4f5f8c21e283..1eb6f244588d 100644
--- a/include/linux/marvell_phy.h
+++ b/include/linux/marvell_phy.h
@@ -27,6 +27,8 @@
27 */ 27 */
28#define MARVELL_PHY_ID_88E6390 0x01410f90 28#define MARVELL_PHY_ID_88E6390 0x01410f90
29 29
30#define MARVELL_PHY_FAMILY_ID(id) ((id) >> 4)
31
30/* struct phy_device dev_flags definitions */ 32/* struct phy_device dev_flags definitions */
31#define MARVELL_PHY_M1145_FLAGS_RESISTANCE 0x00000001 33#define MARVELL_PHY_M1145_FLAGS_RESISTANCE 0x00000001
32#define MARVELL_PHY_M1118_DNS323_LEDS 0x00000002 34#define MARVELL_PHY_M1118_DNS323_LEDS 0x00000002
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 80cbb7fdce4a..83957920653a 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -358,6 +358,7 @@ struct mlx5_frag_buf_ctrl {
358 struct mlx5_frag_buf frag_buf; 358 struct mlx5_frag_buf frag_buf;
359 u32 sz_m1; 359 u32 sz_m1;
360 u32 frag_sz_m1; 360 u32 frag_sz_m1;
361 u32 strides_offset;
361 u8 log_sz; 362 u8 log_sz;
362 u8 log_stride; 363 u8 log_stride;
363 u8 log_frag_strides; 364 u8 log_frag_strides;
@@ -983,14 +984,22 @@ static inline u32 mlx5_base_mkey(const u32 key)
983 return key & 0xffffff00u; 984 return key & 0xffffff00u;
984} 985}
985 986
986static inline void mlx5_fill_fbc(u8 log_stride, u8 log_sz, 987static inline void mlx5_fill_fbc_offset(u8 log_stride, u8 log_sz,
987 struct mlx5_frag_buf_ctrl *fbc) 988 u32 strides_offset,
989 struct mlx5_frag_buf_ctrl *fbc)
988{ 990{
989 fbc->log_stride = log_stride; 991 fbc->log_stride = log_stride;
990 fbc->log_sz = log_sz; 992 fbc->log_sz = log_sz;
991 fbc->sz_m1 = (1 << fbc->log_sz) - 1; 993 fbc->sz_m1 = (1 << fbc->log_sz) - 1;
992 fbc->log_frag_strides = PAGE_SHIFT - fbc->log_stride; 994 fbc->log_frag_strides = PAGE_SHIFT - fbc->log_stride;
993 fbc->frag_sz_m1 = (1 << fbc->log_frag_strides) - 1; 995 fbc->frag_sz_m1 = (1 << fbc->log_frag_strides) - 1;
996 fbc->strides_offset = strides_offset;
997}
998
999static inline void mlx5_fill_fbc(u8 log_stride, u8 log_sz,
1000 struct mlx5_frag_buf_ctrl *fbc)
1001{
1002 mlx5_fill_fbc_offset(log_stride, log_sz, 0, fbc);
994} 1003}
995 1004
996static inline void mlx5_core_init_cq_frag_buf(struct mlx5_frag_buf_ctrl *fbc, 1005static inline void mlx5_core_init_cq_frag_buf(struct mlx5_frag_buf_ctrl *fbc,
@@ -1004,7 +1013,10 @@ static inline void mlx5_core_init_cq_frag_buf(struct mlx5_frag_buf_ctrl *fbc,
1004static inline void *mlx5_frag_buf_get_wqe(struct mlx5_frag_buf_ctrl *fbc, 1013static inline void *mlx5_frag_buf_get_wqe(struct mlx5_frag_buf_ctrl *fbc,
1005 u32 ix) 1014 u32 ix)
1006{ 1015{
1007 unsigned int frag = (ix >> fbc->log_frag_strides); 1016 unsigned int frag;
1017
1018 ix += fbc->strides_offset;
1019 frag = ix >> fbc->log_frag_strides;
1008 1020
1009 return fbc->frag_buf.frags[frag].buf + 1021 return fbc->frag_buf.frags[frag].buf +
1010 ((fbc->frag_sz_m1 & ix) << fbc->log_stride); 1022 ((fbc->frag_sz_m1 & ix) << fbc->log_stride);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index a0fbb9ffe380..68a5121694ef 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -155,7 +155,9 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
155 * mmap() functions). 155 * mmap() functions).
156 */ 156 */
157 157
158extern struct kmem_cache *vm_area_cachep; 158struct vm_area_struct *vm_area_alloc(struct mm_struct *);
159struct vm_area_struct *vm_area_dup(struct vm_area_struct *);
160void vm_area_free(struct vm_area_struct *);
159 161
160#ifndef CONFIG_MMU 162#ifndef CONFIG_MMU
161extern struct rb_root nommu_region_tree; 163extern struct rb_root nommu_region_tree;
@@ -450,6 +452,23 @@ struct vm_operations_struct {
450 unsigned long addr); 452 unsigned long addr);
451}; 453};
452 454
455static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)
456{
457 static const struct vm_operations_struct dummy_vm_ops = {};
458
459 vma->vm_mm = mm;
460 vma->vm_ops = &dummy_vm_ops;
461 INIT_LIST_HEAD(&vma->anon_vma_chain);
462}
463
464static inline void vma_set_anonymous(struct vm_area_struct *vma)
465{
466 vma->vm_ops = NULL;
467}
468
469/* flush_tlb_range() takes a vma, not a mm, and can care about flags */
470#define TLB_FLUSH_VMA(mm,flags) { .vm_mm = (mm), .vm_flags = (flags) }
471
453struct mmu_gather; 472struct mmu_gather;
454struct inode; 473struct inode;
455 474
@@ -2132,7 +2151,7 @@ extern int __meminit __early_pfn_to_nid(unsigned long pfn,
2132 struct mminit_pfnnid_cache *state); 2151 struct mminit_pfnnid_cache *state);
2133#endif 2152#endif
2134 2153
2135#ifdef CONFIG_HAVE_MEMBLOCK 2154#if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP)
2136void zero_resv_unavail(void); 2155void zero_resv_unavail(void);
2137#else 2156#else
2138static inline void zero_resv_unavail(void) {} 2157static inline void zero_resv_unavail(void) {}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 340029b2fb38..c133ccfa002e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -368,7 +368,6 @@ struct pci_dev {
368 unsigned int transparent:1; /* Subtractive decode bridge */ 368 unsigned int transparent:1; /* Subtractive decode bridge */
369 unsigned int multifunction:1; /* Multi-function device */ 369 unsigned int multifunction:1; /* Multi-function device */
370 370
371 unsigned int is_added:1;
372 unsigned int is_busmaster:1; /* Is busmaster */ 371 unsigned int is_busmaster:1; /* Is busmaster */
373 unsigned int no_msi:1; /* May not use MSI */ 372 unsigned int no_msi:1; /* May not use MSI */
374 unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */ 373 unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */
@@ -1240,6 +1239,8 @@ int pci_register_io_range(struct fwnode_handle *fwnode, phys_addr_t addr,
1240unsigned long pci_address_to_pio(phys_addr_t addr); 1239unsigned long pci_address_to_pio(phys_addr_t addr);
1241phys_addr_t pci_pio_to_address(unsigned long pio); 1240phys_addr_t pci_pio_to_address(unsigned long pio);
1242int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr); 1241int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr);
1242int devm_pci_remap_iospace(struct device *dev, const struct resource *res,
1243 phys_addr_t phys_addr);
1243void pci_unmap_iospace(struct resource *res); 1244void pci_unmap_iospace(struct resource *res);
1244void __iomem *devm_pci_remap_cfgspace(struct device *dev, 1245void __iomem *devm_pci_remap_cfgspace(struct device *dev,
1245 resource_size_t offset, 1246 resource_size_t offset,
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 1fa12887ec02..87f6db437e4a 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1130,6 +1130,7 @@ extern void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct
1130extern struct perf_callchain_entry * 1130extern struct perf_callchain_entry *
1131get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user, 1131get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
1132 u32 max_stack, bool crosstask, bool add_mark); 1132 u32 max_stack, bool crosstask, bool add_mark);
1133extern struct perf_callchain_entry *perf_callchain(struct perf_event *event, struct pt_regs *regs);
1133extern int get_callchain_buffers(int max_stack); 1134extern int get_callchain_buffers(int max_stack);
1134extern void put_callchain_buffers(void); 1135extern void put_callchain_buffers(void);
1135 1136
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index b72ebdff0b77..003d09ab308d 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -165,6 +165,7 @@ void ring_buffer_record_enable(struct ring_buffer *buffer);
165void ring_buffer_record_off(struct ring_buffer *buffer); 165void ring_buffer_record_off(struct ring_buffer *buffer);
166void ring_buffer_record_on(struct ring_buffer *buffer); 166void ring_buffer_record_on(struct ring_buffer *buffer);
167int ring_buffer_record_is_on(struct ring_buffer *buffer); 167int ring_buffer_record_is_on(struct ring_buffer *buffer);
168int ring_buffer_record_is_set_on(struct ring_buffer *buffer);
168void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu); 169void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);
169void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu); 170void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
170 171
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 1b92a28dd672..6fd615a0eea9 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -106,7 +106,14 @@ static inline int rt_mutex_is_locked(struct rt_mutex *lock)
106extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key); 106extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key);
107extern void rt_mutex_destroy(struct rt_mutex *lock); 107extern void rt_mutex_destroy(struct rt_mutex *lock);
108 108
109#ifdef CONFIG_DEBUG_LOCK_ALLOC
110extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass);
111#define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0)
112#else
109extern void rt_mutex_lock(struct rt_mutex *lock); 113extern void rt_mutex_lock(struct rt_mutex *lock);
114#define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock)
115#endif
116
110extern int rt_mutex_lock_interruptible(struct rt_mutex *lock); 117extern int rt_mutex_lock_interruptible(struct rt_mutex *lock);
111extern int rt_mutex_timed_lock(struct rt_mutex *lock, 118extern int rt_mutex_timed_lock(struct rt_mutex *lock,
112 struct hrtimer_sleeper *timeout); 119 struct hrtimer_sleeper *timeout);
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
index 5be31eb7b266..108ede99e533 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -75,7 +75,7 @@ extern long _do_fork(unsigned long, unsigned long, unsigned long, int __user *,
75extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *); 75extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, int __user *);
76struct task_struct *fork_idle(int); 76struct task_struct *fork_idle(int);
77extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 77extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
78extern long kernel_wait4(pid_t, int *, int, struct rusage *); 78extern long kernel_wait4(pid_t, int __user *, int, struct rusage *);
79 79
80extern void free_task(struct task_struct *tsk); 80extern void free_task(struct task_struct *tsk);
81 81
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 164cdedf6012..610a201126ee 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -630,6 +630,7 @@ typedef unsigned char *sk_buff_data_t;
630 * @hash: the packet hash 630 * @hash: the packet hash
631 * @queue_mapping: Queue mapping for multiqueue devices 631 * @queue_mapping: Queue mapping for multiqueue devices
632 * @xmit_more: More SKBs are pending for this queue 632 * @xmit_more: More SKBs are pending for this queue
633 * @pfmemalloc: skbuff was allocated from PFMEMALLOC reserves
633 * @ndisc_nodetype: router type (from link layer) 634 * @ndisc_nodetype: router type (from link layer)
634 * @ooo_okay: allow the mapping of a socket to a queue to be changed 635 * @ooo_okay: allow the mapping of a socket to a queue to be changed
635 * @l4_hash: indicate hash is a canonical 4-tuple hash over transport 636 * @l4_hash: indicate hash is a canonical 4-tuple hash over transport
@@ -735,7 +736,7 @@ struct sk_buff {
735 peeked:1, 736 peeked:1,
736 head_frag:1, 737 head_frag:1,
737 xmit_more:1, 738 xmit_more:1,
738 __unused:1; /* one bit hole */ 739 pfmemalloc:1;
739 740
740 /* fields enclosed in headers_start/headers_end are copied 741 /* fields enclosed in headers_start/headers_end are copied
741 * using a single memcpy() in __copy_skb_header() 742 * using a single memcpy() in __copy_skb_header()
@@ -754,31 +755,30 @@ struct sk_buff {
754 755
755 __u8 __pkt_type_offset[0]; 756 __u8 __pkt_type_offset[0];
756 __u8 pkt_type:3; 757 __u8 pkt_type:3;
757 __u8 pfmemalloc:1;
758 __u8 ignore_df:1; 758 __u8 ignore_df:1;
759
760 __u8 nf_trace:1; 759 __u8 nf_trace:1;
761 __u8 ip_summed:2; 760 __u8 ip_summed:2;
762 __u8 ooo_okay:1; 761 __u8 ooo_okay:1;
762
763 __u8 l4_hash:1; 763 __u8 l4_hash:1;
764 __u8 sw_hash:1; 764 __u8 sw_hash:1;
765 __u8 wifi_acked_valid:1; 765 __u8 wifi_acked_valid:1;
766 __u8 wifi_acked:1; 766 __u8 wifi_acked:1;
767
768 __u8 no_fcs:1; 767 __u8 no_fcs:1;
769 /* Indicates the inner headers are valid in the skbuff. */ 768 /* Indicates the inner headers are valid in the skbuff. */
770 __u8 encapsulation:1; 769 __u8 encapsulation:1;
771 __u8 encap_hdr_csum:1; 770 __u8 encap_hdr_csum:1;
772 __u8 csum_valid:1; 771 __u8 csum_valid:1;
772
773 __u8 csum_complete_sw:1; 773 __u8 csum_complete_sw:1;
774 __u8 csum_level:2; 774 __u8 csum_level:2;
775 __u8 csum_not_inet:1; 775 __u8 csum_not_inet:1;
776
777 __u8 dst_pending_confirm:1; 776 __u8 dst_pending_confirm:1;
778#ifdef CONFIG_IPV6_NDISC_NODETYPE 777#ifdef CONFIG_IPV6_NDISC_NODETYPE
779 __u8 ndisc_nodetype:2; 778 __u8 ndisc_nodetype:2;
780#endif 779#endif
781 __u8 ipvs_property:1; 780 __u8 ipvs_property:1;
781
782 __u8 inner_protocol_type:1; 782 __u8 inner_protocol_type:1;
783 __u8 remcsum_offload:1; 783 __u8 remcsum_offload:1;
784#ifdef CONFIG_NET_SWITCHDEV 784#ifdef CONFIG_NET_SWITCHDEV
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a368a68cb667..5c1a0933768e 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -11,6 +11,7 @@
11#ifndef _LINUX_SYSCALLS_H 11#ifndef _LINUX_SYSCALLS_H
12#define _LINUX_SYSCALLS_H 12#define _LINUX_SYSCALLS_H
13 13
14struct __aio_sigset;
14struct epoll_event; 15struct epoll_event;
15struct iattr; 16struct iattr;
16struct inode; 17struct inode;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5fbfe61f41c6..1beb3ead0385 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5835,10 +5835,11 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
5835/** 5835/**
5836 * cfg80211_rx_control_port - notification about a received control port frame 5836 * cfg80211_rx_control_port - notification about a received control port frame
5837 * @dev: The device the frame matched to 5837 * @dev: The device the frame matched to
5838 * @buf: control port frame 5838 * @skb: The skbuf with the control port frame. It is assumed that the skbuf
5839 * @len: length of the frame data 5839 * is 802.3 formatted (with 802.3 header). The skb can be non-linear.
5840 * @addr: The peer from which the frame was received 5840 * This function does not take ownership of the skb, so the caller is
5841 * @proto: frame protocol, typically PAE or Pre-authentication 5841 * responsible for any cleanup. The caller must also ensure that
5842 * skb->protocol is set appropriately.
5842 * @unencrypted: Whether the frame was received unencrypted 5843 * @unencrypted: Whether the frame was received unencrypted
5843 * 5844 *
5844 * This function is used to inform userspace about a received control port 5845 * This function is used to inform userspace about a received control port
@@ -5851,8 +5852,7 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
5851 * Return: %true if the frame was passed to userspace 5852 * Return: %true if the frame was passed to userspace
5852 */ 5853 */
5853bool cfg80211_rx_control_port(struct net_device *dev, 5854bool cfg80211_rx_control_port(struct net_device *dev,
5854 const u8 *buf, size_t len, 5855 struct sk_buff *skb, bool unencrypted);
5855 const u8 *addr, u16 proto, bool unencrypted);
5856 5856
5857/** 5857/**
5858 * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event 5858 * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 71b9043aa0e7..3d4930528db0 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -281,6 +281,11 @@ static inline void fib6_info_hold(struct fib6_info *f6i)
281 atomic_inc(&f6i->fib6_ref); 281 atomic_inc(&f6i->fib6_ref);
282} 282}
283 283
284static inline bool fib6_info_hold_safe(struct fib6_info *f6i)
285{
286 return atomic_inc_not_zero(&f6i->fib6_ref);
287}
288
284static inline void fib6_info_release(struct fib6_info *f6i) 289static inline void fib6_info_release(struct fib6_info *f6i)
285{ 290{
286 if (f6i && atomic_dec_and_test(&f6i->fib6_ref)) 291 if (f6i && atomic_dec_and_test(&f6i->fib6_ref))
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 59656fc580df..7b9c82de11cc 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -66,6 +66,12 @@ static inline bool rt6_need_strict(const struct in6_addr *daddr)
66 (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); 66 (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);
67} 67}
68 68
69static inline bool rt6_qualify_for_ecmp(const struct fib6_info *f6i)
70{
71 return (f6i->fib6_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) ==
72 RTF_GATEWAY;
73}
74
69void ip6_route_input(struct sk_buff *skb); 75void ip6_route_input(struct sk_buff *skb);
70struct dst_entry *ip6_route_input_lookup(struct net *net, 76struct dst_entry *ip6_route_input_lookup(struct net *net,
71 struct net_device *dev, 77 struct net_device *dev,
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 16475c269749..8f73be494503 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -355,14 +355,7 @@ struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,
355struct ipv6_txoptions *ipv6_renew_options(struct sock *sk, 355struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
356 struct ipv6_txoptions *opt, 356 struct ipv6_txoptions *opt,
357 int newtype, 357 int newtype,
358 struct ipv6_opt_hdr __user *newopt, 358 struct ipv6_opt_hdr *newopt);
359 int newoptlen);
360struct ipv6_txoptions *
361ipv6_renew_options_kern(struct sock *sk,
362 struct ipv6_txoptions *opt,
363 int newtype,
364 struct ipv6_opt_hdr *newopt,
365 int newoptlen);
366struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, 359struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
367 struct ipv6_txoptions *opt); 360 struct ipv6_txoptions *opt);
368 361
@@ -830,7 +823,7 @@ static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
830 * to minimize possbility that any useful information to an 823 * to minimize possbility that any useful information to an
831 * attacker is leaked. Only lower 20 bits are relevant. 824 * attacker is leaked. Only lower 20 bits are relevant.
832 */ 825 */
833 rol32(hash, 16); 826 hash = rol32(hash, 16);
834 827
835 flowlabel = (__force __be32)hash & IPV6_FLOWLABEL_MASK; 828 flowlabel = (__force __be32)hash & IPV6_FLOWLABEL_MASK;
836 829
@@ -1107,6 +1100,8 @@ void ipv6_sysctl_unregister(void);
1107 1100
1108int ipv6_sock_mc_join(struct sock *sk, int ifindex, 1101int ipv6_sock_mc_join(struct sock *sk, int ifindex,
1109 const struct in6_addr *addr); 1102 const struct in6_addr *addr);
1103int ipv6_sock_mc_join_ssm(struct sock *sk, int ifindex,
1104 const struct in6_addr *addr, unsigned int mode);
1110int ipv6_sock_mc_drop(struct sock *sk, int ifindex, 1105int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
1111 const struct in6_addr *addr); 1106 const struct in6_addr *addr);
1112#endif /* _NET_IPV6_H */ 1107#endif /* _NET_IPV6_H */
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 08c005ce56e9..dc417ef0a0c5 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -150,6 +150,7 @@ static inline void nft_data_debug(const struct nft_data *data)
150 * @portid: netlink portID of the original message 150 * @portid: netlink portID of the original message
151 * @seq: netlink sequence number 151 * @seq: netlink sequence number
152 * @family: protocol family 152 * @family: protocol family
153 * @level: depth of the chains
153 * @report: notify via unicast netlink message 154 * @report: notify via unicast netlink message
154 */ 155 */
155struct nft_ctx { 156struct nft_ctx {
@@ -160,6 +161,7 @@ struct nft_ctx {
160 u32 portid; 161 u32 portid;
161 u32 seq; 162 u32 seq;
162 u8 family; 163 u8 family;
164 u8 level;
163 bool report; 165 bool report;
164}; 166};
165 167
@@ -865,7 +867,6 @@ enum nft_chain_flags {
865 * @table: table that this chain belongs to 867 * @table: table that this chain belongs to
866 * @handle: chain handle 868 * @handle: chain handle
867 * @use: number of jump references to this chain 869 * @use: number of jump references to this chain
868 * @level: length of longest path to this chain
869 * @flags: bitmask of enum nft_chain_flags 870 * @flags: bitmask of enum nft_chain_flags
870 * @name: name of the chain 871 * @name: name of the chain
871 */ 872 */
@@ -878,7 +879,6 @@ struct nft_chain {
878 struct nft_table *table; 879 struct nft_table *table;
879 u64 handle; 880 u64 handle;
880 u32 use; 881 u32 use;
881 u16 level;
882 u8 flags:6, 882 u8 flags:6,
883 genmask:2; 883 genmask:2;
884 char *name; 884 char *name;
@@ -1124,7 +1124,6 @@ struct nft_flowtable {
1124 u32 genmask:2, 1124 u32 genmask:2,
1125 use:30; 1125 use:30;
1126 u64 handle; 1126 u64 handle;
1127 char *dev_name[NFT_FLOWTABLE_DEVICE_MAX];
1128 /* runtime data below here */ 1127 /* runtime data below here */
1129 struct nf_hook_ops *ops ____cacheline_aligned; 1128 struct nf_hook_ops *ops ____cacheline_aligned;
1130 struct nf_flowtable data; 1129 struct nf_flowtable data;
diff --git a/include/net/netfilter/nf_tables_core.h b/include/net/netfilter/nf_tables_core.h
index e0c0c2558ec4..a05134507e7b 100644
--- a/include/net/netfilter/nf_tables_core.h
+++ b/include/net/netfilter/nf_tables_core.h
@@ -65,4 +65,10 @@ extern const struct nft_expr_ops nft_payload_fast_ops;
65extern struct static_key_false nft_counters_enabled; 65extern struct static_key_false nft_counters_enabled;
66extern struct static_key_false nft_trace_enabled; 66extern struct static_key_false nft_trace_enabled;
67 67
68extern struct nft_set_type nft_set_rhash_type;
69extern struct nft_set_type nft_set_hash_type;
70extern struct nft_set_type nft_set_hash_fast_type;
71extern struct nft_set_type nft_set_rbtree_type;
72extern struct nft_set_type nft_set_bitmap_type;
73
68#endif /* _NET_NF_TABLES_CORE_H */ 74#endif /* _NET_NF_TABLES_CORE_H */
diff --git a/include/net/netfilter/nf_tproxy.h b/include/net/netfilter/nf_tproxy.h
index 9754a50ecde9..4cc64c8446eb 100644
--- a/include/net/netfilter/nf_tproxy.h
+++ b/include/net/netfilter/nf_tproxy.h
@@ -64,7 +64,7 @@ nf_tproxy_handle_time_wait4(struct net *net, struct sk_buff *skb,
64 * belonging to established connections going through that one. 64 * belonging to established connections going through that one.
65 */ 65 */
66struct sock * 66struct sock *
67nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp, 67nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb,
68 const u8 protocol, 68 const u8 protocol,
69 const __be32 saddr, const __be32 daddr, 69 const __be32 saddr, const __be32 daddr,
70 const __be16 sport, const __be16 dport, 70 const __be16 sport, const __be16 dport,
@@ -103,7 +103,7 @@ nf_tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
103 struct sock *sk); 103 struct sock *sk);
104 104
105struct sock * 105struct sock *
106nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp, 106nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff,
107 const u8 protocol, 107 const u8 protocol,
108 const struct in6_addr *saddr, const struct in6_addr *daddr, 108 const struct in6_addr *saddr, const struct in6_addr *daddr,
109 const __be16 sport, const __be16 dport, 109 const __be16 sport, const __be16 dport,
diff --git a/include/net/tc_act/tc_csum.h b/include/net/tc_act/tc_csum.h
index 9470fd7e4350..32d2454c0479 100644
--- a/include/net/tc_act/tc_csum.h
+++ b/include/net/tc_act/tc_csum.h
@@ -7,7 +7,6 @@
7#include <linux/tc_act/tc_csum.h> 7#include <linux/tc_act/tc_csum.h>
8 8
9struct tcf_csum_params { 9struct tcf_csum_params {
10 int action;
11 u32 update_flags; 10 u32 update_flags;
12 struct rcu_head rcu; 11 struct rcu_head rcu;
13}; 12};
diff --git a/include/net/tc_act/tc_tunnel_key.h b/include/net/tc_act/tc_tunnel_key.h
index efef0b4b1b2b..46b8c7f1c8d5 100644
--- a/include/net/tc_act/tc_tunnel_key.h
+++ b/include/net/tc_act/tc_tunnel_key.h
@@ -18,7 +18,6 @@
18struct tcf_tunnel_key_params { 18struct tcf_tunnel_key_params {
19 struct rcu_head rcu; 19 struct rcu_head rcu;
20 int tcft_action; 20 int tcft_action;
21 int action;
22 struct metadata_dst *tcft_enc_metadata; 21 struct metadata_dst *tcft_enc_metadata;
23}; 22};
24 23
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 800582b5dd54..cd3ecda9386a 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -342,6 +342,7 @@ ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
342 struct pipe_inode_info *pipe, size_t len, 342 struct pipe_inode_info *pipe, size_t len,
343 unsigned int flags); 343 unsigned int flags);
344 344
345void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks);
345static inline void tcp_dec_quickack_mode(struct sock *sk, 346static inline void tcp_dec_quickack_mode(struct sock *sk,
346 const unsigned int pkts) 347 const unsigned int pkts)
347{ 348{
@@ -539,6 +540,7 @@ void tcp_send_fin(struct sock *sk);
539void tcp_send_active_reset(struct sock *sk, gfp_t priority); 540void tcp_send_active_reset(struct sock *sk, gfp_t priority);
540int tcp_send_synack(struct sock *); 541int tcp_send_synack(struct sock *);
541void tcp_push_one(struct sock *, unsigned int mss_now); 542void tcp_push_one(struct sock *, unsigned int mss_now);
543void __tcp_send_ack(struct sock *sk, u32 rcv_nxt);
542void tcp_send_ack(struct sock *sk); 544void tcp_send_ack(struct sock *sk);
543void tcp_send_delayed_ack(struct sock *sk); 545void tcp_send_delayed_ack(struct sock *sk);
544void tcp_send_loss_probe(struct sock *sk); 546void tcp_send_loss_probe(struct sock *sk);
@@ -828,6 +830,10 @@ struct tcp_skb_cb {
828 830
829#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) 831#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
830 832
833static inline void bpf_compute_data_end_sk_skb(struct sk_buff *skb)
834{
835 TCP_SKB_CB(skb)->bpf.data_end = skb->data + skb_headlen(skb);
836}
831 837
832#if IS_ENABLED(CONFIG_IPV6) 838#if IS_ENABLED(CONFIG_IPV6)
833/* This is the variant of inet6_iif() that must be used by TCP, 839/* This is the variant of inet6_iif() that must be used by TCP,
@@ -835,6 +841,11 @@ struct tcp_skb_cb {
835 */ 841 */
836static inline int tcp_v6_iif(const struct sk_buff *skb) 842static inline int tcp_v6_iif(const struct sk_buff *skb)
837{ 843{
844 return TCP_SKB_CB(skb)->header.h6.iif;
845}
846
847static inline int tcp_v6_iif_l3_slave(const struct sk_buff *skb)
848{
838 bool l3_slave = ipv6_l3mdev_skb(TCP_SKB_CB(skb)->header.h6.flags); 849 bool l3_slave = ipv6_l3mdev_skb(TCP_SKB_CB(skb)->header.h6.flags);
839 850
840 return l3_slave ? skb->skb_iif : TCP_SKB_CB(skb)->header.h6.iif; 851 return l3_slave ? skb->skb_iif : TCP_SKB_CB(skb)->header.h6.iif;
@@ -908,8 +919,6 @@ enum tcp_ca_event {
908 CA_EVENT_LOSS, /* loss timeout */ 919 CA_EVENT_LOSS, /* loss timeout */
909 CA_EVENT_ECN_NO_CE, /* ECT set, but not CE marked */ 920 CA_EVENT_ECN_NO_CE, /* ECT set, but not CE marked */
910 CA_EVENT_ECN_IS_CE, /* received CE marked IP packet */ 921 CA_EVENT_ECN_IS_CE, /* received CE marked IP packet */
911 CA_EVENT_DELAYED_ACK, /* Delayed ack is sent */
912 CA_EVENT_NON_DELAYED_ACK,
913}; 922};
914 923
915/* Information about inbound ACK, passed to cong_ops->in_ack_event() */ 924/* Information about inbound ACK, passed to cong_ops->in_ack_event() */
diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
index 9fe472f2ac95..7161856bcf9c 100644
--- a/include/net/xdp_sock.h
+++ b/include/net/xdp_sock.h
@@ -60,6 +60,10 @@ struct xdp_sock {
60 bool zc; 60 bool zc;
61 /* Protects multiple processes in the control path */ 61 /* Protects multiple processes in the control path */
62 struct mutex mutex; 62 struct mutex mutex;
63 /* Mutual exclusion of NAPI TX thread and sendmsg error paths
64 * in the SKB destructor callback.
65 */
66 spinlock_t tx_completion_lock;
63 u64 rx_dropped; 67 u64 rx_dropped;
64}; 68};
65 69
diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h
index 3c5038b587ba..d4593a6062ef 100644
--- a/include/uapi/linux/aio_abi.h
+++ b/include/uapi/linux/aio_abi.h
@@ -29,7 +29,6 @@
29 29
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/signal.h>
33#include <asm/byteorder.h> 32#include <asm/byteorder.h>
34 33
35typedef __kernel_ulong_t aio_context_t; 34typedef __kernel_ulong_t aio_context_t;
@@ -110,10 +109,5 @@ struct iocb {
110#undef IFBIG 109#undef IFBIG
111#undef IFLITTLE 110#undef IFLITTLE
112 111
113struct __aio_sigset {
114 const sigset_t __user *sigmask;
115 size_t sigsetsize;
116};
117
118#endif /* __LINUX__AIO_ABI_H */ 112#endif /* __LINUX__AIO_ABI_H */
119 113
diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h
index 0b5ddbe135a4..972265f32871 100644
--- a/include/uapi/linux/btf.h
+++ b/include/uapi/linux/btf.h
@@ -76,7 +76,7 @@ struct btf_type {
76 */ 76 */
77#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 77#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
78#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 78#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16)
79#define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff) 79#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
80 80
81/* Attributes stored in the BTF_INT_ENCODING */ 81/* Attributes stored in the BTF_INT_ENCODING */
82#define BTF_INT_SIGNED (1 << 0) 82#define BTF_INT_SIGNED (1 << 0)
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 4ca65b56084f..7363f18e65a5 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -226,7 +226,7 @@ enum tunable_id {
226 ETHTOOL_TX_COPYBREAK, 226 ETHTOOL_TX_COPYBREAK,
227 ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */ 227 ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
228 /* 228 /*
229 * Add your fresh new tubale attribute above and remember to update 229 * Add your fresh new tunable attribute above and remember to update
230 * tunable_strings[] in net/core/ethtool.c 230 * tunable_strings[] in net/core/ethtool.c
231 */ 231 */
232 __ETHTOOL_TUNABLE_COUNT, 232 __ETHTOOL_TUNABLE_COUNT,
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index b8e288a1f740..eeb787b1c53c 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -143,6 +143,8 @@ enum perf_event_sample_format {
143 PERF_SAMPLE_PHYS_ADDR = 1U << 19, 143 PERF_SAMPLE_PHYS_ADDR = 1U << 19,
144 144
145 PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */ 145 PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
146
147 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63,
146}; 148};
147 149
148/* 150/*
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 29eb659aa77a..e3f6ed8a7064 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -127,6 +127,10 @@ enum {
127 127
128#define TCP_CM_INQ TCP_INQ 128#define TCP_CM_INQ TCP_INQ
129 129
130#define TCP_REPAIR_ON 1
131#define TCP_REPAIR_OFF 0
132#define TCP_REPAIR_OFF_NO_WP -1 /* Turn off without window probes */
133
130struct tcp_repair_opt { 134struct tcp_repair_opt {
131 __u32 opt_code; 135 __u32 opt_code;
132 __u32 opt_val; 136 __u32 opt_val;
diff --git a/ipc/sem.c b/ipc/sem.c
index 5af1943ad782..76e95e4f3aa2 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -2118,7 +2118,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
2118 } 2118 }
2119 2119
2120 do { 2120 do {
2121 queue.status = -EINTR; 2121 WRITE_ONCE(queue.status, -EINTR);
2122 queue.sleeper = current; 2122 queue.sleeper = current;
2123 2123
2124 __set_current_state(TASK_INTERRUPTIBLE); 2124 __set_current_state(TASK_INTERRUPTIBLE);
diff --git a/ipc/shm.c b/ipc/shm.c
index 051a3e1fb8df..fefa00d310fb 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -427,6 +427,17 @@ static int shm_split(struct vm_area_struct *vma, unsigned long addr)
427 return 0; 427 return 0;
428} 428}
429 429
430static unsigned long shm_pagesize(struct vm_area_struct *vma)
431{
432 struct file *file = vma->vm_file;
433 struct shm_file_data *sfd = shm_file_data(file);
434
435 if (sfd->vm_ops->pagesize)
436 return sfd->vm_ops->pagesize(vma);
437
438 return PAGE_SIZE;
439}
440
430#ifdef CONFIG_NUMA 441#ifdef CONFIG_NUMA
431static int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new) 442static int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
432{ 443{
@@ -554,6 +565,7 @@ static const struct vm_operations_struct shm_vm_ops = {
554 .close = shm_close, /* callback for when the vm-area is released */ 565 .close = shm_close, /* callback for when the vm-area is released */
555 .fault = shm_fault, 566 .fault = shm_fault,
556 .split = shm_split, 567 .split = shm_split,
568 .pagesize = shm_pagesize,
557#if defined(CONFIG_NUMA) 569#if defined(CONFIG_NUMA)
558 .set_policy = shm_set_policy, 570 .set_policy = shm_set_policy,
559 .get_policy = shm_get_policy, 571 .get_policy = shm_get_policy,
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index ceb1c4596c51..80d672a11088 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1279,8 +1279,12 @@ static void show_special(struct audit_context *context, int *call_panic)
1279 break; 1279 break;
1280 case AUDIT_KERN_MODULE: 1280 case AUDIT_KERN_MODULE:
1281 audit_log_format(ab, "name="); 1281 audit_log_format(ab, "name=");
1282 audit_log_untrustedstring(ab, context->module.name); 1282 if (context->module.name) {
1283 kfree(context->module.name); 1283 audit_log_untrustedstring(ab, context->module.name);
1284 kfree(context->module.name);
1285 } else
1286 audit_log_format(ab, "(null)");
1287
1284 break; 1288 break;
1285 } 1289 }
1286 audit_log_end(ab); 1290 audit_log_end(ab);
@@ -2411,8 +2415,9 @@ void __audit_log_kern_module(char *name)
2411{ 2415{
2412 struct audit_context *context = audit_context(); 2416 struct audit_context *context = audit_context();
2413 2417
2414 context->module.name = kmalloc(strlen(name) + 1, GFP_KERNEL); 2418 context->module.name = kstrdup(name, GFP_KERNEL);
2415 strcpy(context->module.name, name); 2419 if (!context->module.name)
2420 audit_log_lost("out of memory in __audit_log_kern_module");
2416 context->type = AUDIT_KERN_MODULE; 2421 context->type = AUDIT_KERN_MODULE;
2417} 2422}
2418 2423
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 544e58f5f642..2aa55d030c77 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -378,7 +378,7 @@ static int array_map_check_btf(const struct bpf_map *map, const struct btf *btf,
378 return -EINVAL; 378 return -EINVAL;
379 379
380 value_type = btf_type_id_size(btf, &btf_value_id, &value_size); 380 value_type = btf_type_id_size(btf, &btf_value_id, &value_size);
381 if (!value_type || value_size > map->value_size) 381 if (!value_type || value_size != map->value_size)
382 return -EINVAL; 382 return -EINVAL;
383 383
384 return 0; 384 return 0;
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 2d49d18b793a..2590700237c1 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -450,7 +450,7 @@ static const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id)
450 */ 450 */
451static bool btf_type_int_is_regular(const struct btf_type *t) 451static bool btf_type_int_is_regular(const struct btf_type *t)
452{ 452{
453 u16 nr_bits, nr_bytes; 453 u8 nr_bits, nr_bytes;
454 u32 int_data; 454 u32 int_data;
455 455
456 int_data = btf_type_int(t); 456 int_data = btf_type_int(t);
@@ -991,38 +991,38 @@ static void btf_int_bits_seq_show(const struct btf *btf,
991 void *data, u8 bits_offset, 991 void *data, u8 bits_offset,
992 struct seq_file *m) 992 struct seq_file *m)
993{ 993{
994 u16 left_shift_bits, right_shift_bits;
994 u32 int_data = btf_type_int(t); 995 u32 int_data = btf_type_int(t);
995 u16 nr_bits = BTF_INT_BITS(int_data); 996 u8 nr_bits = BTF_INT_BITS(int_data);
996 u16 total_bits_offset; 997 u8 total_bits_offset;
997 u16 nr_copy_bytes; 998 u8 nr_copy_bytes;
998 u16 nr_copy_bits; 999 u8 nr_copy_bits;
999 u8 nr_upper_bits; 1000 u64 print_num;
1000 union {
1001 u64 u64_num;
1002 u8 u8_nums[8];
1003 } print_num;
1004 1001
1002 /*
1003 * bits_offset is at most 7.
1004 * BTF_INT_OFFSET() cannot exceed 64 bits.
1005 */
1005 total_bits_offset = bits_offset + BTF_INT_OFFSET(int_data); 1006 total_bits_offset = bits_offset + BTF_INT_OFFSET(int_data);
1006 data += BITS_ROUNDDOWN_BYTES(total_bits_offset); 1007 data += BITS_ROUNDDOWN_BYTES(total_bits_offset);
1007 bits_offset = BITS_PER_BYTE_MASKED(total_bits_offset); 1008 bits_offset = BITS_PER_BYTE_MASKED(total_bits_offset);
1008 nr_copy_bits = nr_bits + bits_offset; 1009 nr_copy_bits = nr_bits + bits_offset;
1009 nr_copy_bytes = BITS_ROUNDUP_BYTES(nr_copy_bits); 1010 nr_copy_bytes = BITS_ROUNDUP_BYTES(nr_copy_bits);
1010 1011
1011 print_num.u64_num = 0; 1012 print_num = 0;
1012 memcpy(&print_num.u64_num, data, nr_copy_bytes); 1013 memcpy(&print_num, data, nr_copy_bytes);
1013
1014 /* Ditch the higher order bits */
1015 nr_upper_bits = BITS_PER_BYTE_MASKED(nr_copy_bits);
1016 if (nr_upper_bits) {
1017 /* We need to mask out some bits of the upper byte. */
1018 u8 mask = (1 << nr_upper_bits) - 1;
1019 1014
1020 print_num.u8_nums[nr_copy_bytes - 1] &= mask; 1015#ifdef __BIG_ENDIAN_BITFIELD
1021 } 1016 left_shift_bits = bits_offset;
1017#else
1018 left_shift_bits = BITS_PER_U64 - nr_copy_bits;
1019#endif
1020 right_shift_bits = BITS_PER_U64 - nr_bits;
1022 1021
1023 print_num.u64_num >>= bits_offset; 1022 print_num <<= left_shift_bits;
1023 print_num >>= right_shift_bits;
1024 1024
1025 seq_printf(m, "0x%llx", print_num.u64_num); 1025 seq_printf(m, "0x%llx", print_num);
1026} 1026}
1027 1027
1028static void btf_int_seq_show(const struct btf *btf, const struct btf_type *t, 1028static void btf_int_seq_show(const struct btf *btf, const struct btf_type *t,
@@ -1032,7 +1032,7 @@ static void btf_int_seq_show(const struct btf *btf, const struct btf_type *t,
1032 u32 int_data = btf_type_int(t); 1032 u32 int_data = btf_type_int(t);
1033 u8 encoding = BTF_INT_ENCODING(int_data); 1033 u8 encoding = BTF_INT_ENCODING(int_data);
1034 bool sign = encoding & BTF_INT_SIGNED; 1034 bool sign = encoding & BTF_INT_SIGNED;
1035 u32 nr_bits = BTF_INT_BITS(int_data); 1035 u8 nr_bits = BTF_INT_BITS(int_data);
1036 1036
1037 if (bits_offset || BTF_INT_OFFSET(int_data) || 1037 if (bits_offset || BTF_INT_OFFSET(int_data) ||
1038 BITS_PER_BYTE_MASKED(nr_bits)) { 1038 BITS_PER_BYTE_MASKED(nr_bits)) {
@@ -1519,9 +1519,9 @@ static s32 btf_struct_check_meta(struct btf_verifier_env *env,
1519{ 1519{
1520 bool is_union = BTF_INFO_KIND(t->info) == BTF_KIND_UNION; 1520 bool is_union = BTF_INFO_KIND(t->info) == BTF_KIND_UNION;
1521 const struct btf_member *member; 1521 const struct btf_member *member;
1522 u32 meta_needed, last_offset;
1522 struct btf *btf = env->btf; 1523 struct btf *btf = env->btf;
1523 u32 struct_size = t->size; 1524 u32 struct_size = t->size;
1524 u32 meta_needed;
1525 u16 i; 1525 u16 i;
1526 1526
1527 meta_needed = btf_type_vlen(t) * sizeof(*member); 1527 meta_needed = btf_type_vlen(t) * sizeof(*member);
@@ -1534,6 +1534,7 @@ static s32 btf_struct_check_meta(struct btf_verifier_env *env,
1534 1534
1535 btf_verifier_log_type(env, t, NULL); 1535 btf_verifier_log_type(env, t, NULL);
1536 1536
1537 last_offset = 0;
1537 for_each_member(i, t, member) { 1538 for_each_member(i, t, member) {
1538 if (!btf_name_offset_valid(btf, member->name_off)) { 1539 if (!btf_name_offset_valid(btf, member->name_off)) {
1539 btf_verifier_log_member(env, t, member, 1540 btf_verifier_log_member(env, t, member,
@@ -1555,6 +1556,16 @@ static s32 btf_struct_check_meta(struct btf_verifier_env *env,
1555 return -EINVAL; 1556 return -EINVAL;
1556 } 1557 }
1557 1558
1559 /*
1560 * ">" instead of ">=" because the last member could be
1561 * "char a[0];"
1562 */
1563 if (last_offset > member->offset) {
1564 btf_verifier_log_member(env, t, member,
1565 "Invalid member bits_offset");
1566 return -EINVAL;
1567 }
1568
1558 if (BITS_ROUNDUP_BYTES(member->offset) > struct_size) { 1569 if (BITS_ROUNDUP_BYTES(member->offset) > struct_size) {
1559 btf_verifier_log_member(env, t, member, 1570 btf_verifier_log_member(env, t, member,
1560 "Memmber bits_offset exceeds its struct size"); 1571 "Memmber bits_offset exceeds its struct size");
@@ -1562,6 +1573,7 @@ static s32 btf_struct_check_meta(struct btf_verifier_env *env,
1562 } 1573 }
1563 1574
1564 btf_verifier_log_member(env, t, member, NULL); 1575 btf_verifier_log_member(env, t, member, NULL);
1576 last_offset = member->offset;
1565 } 1577 }
1566 1578
1567 return meta_needed; 1579 return meta_needed;
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 642c97f6d1b8..d361fc1e3bf3 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -334,10 +334,15 @@ int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp,
334{ 334{
335 struct net_device *dev = dst->dev; 335 struct net_device *dev = dst->dev;
336 struct xdp_frame *xdpf; 336 struct xdp_frame *xdpf;
337 int err;
337 338
338 if (!dev->netdev_ops->ndo_xdp_xmit) 339 if (!dev->netdev_ops->ndo_xdp_xmit)
339 return -EOPNOTSUPP; 340 return -EOPNOTSUPP;
340 341
342 err = xdp_ok_fwd_dev(dev, xdp->data_end - xdp->data);
343 if (unlikely(err))
344 return err;
345
341 xdpf = convert_to_xdp_frame(xdp); 346 xdpf = convert_to_xdp_frame(xdp);
342 if (unlikely(!xdpf)) 347 if (unlikely(!xdpf))
343 return -EOVERFLOW; 348 return -EOVERFLOW;
@@ -350,7 +355,7 @@ int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb,
350{ 355{
351 int err; 356 int err;
352 357
353 err = __xdp_generic_ok_fwd_dev(skb, dst->dev); 358 err = xdp_ok_fwd_dev(dst->dev, skb->len);
354 if (unlikely(err)) 359 if (unlikely(err))
355 return err; 360 return err;
356 skb->dev = dst->dev; 361 skb->dev = dst->dev;
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 3ca2198a6d22..513d9dfcf4ee 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -747,13 +747,15 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
747 * old element will be freed immediately. 747 * old element will be freed immediately.
748 * Otherwise return an error 748 * Otherwise return an error
749 */ 749 */
750 atomic_dec(&htab->count); 750 l_new = ERR_PTR(-E2BIG);
751 return ERR_PTR(-E2BIG); 751 goto dec_count;
752 } 752 }
753 l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, 753 l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
754 htab->map.numa_node); 754 htab->map.numa_node);
755 if (!l_new) 755 if (!l_new) {
756 return ERR_PTR(-ENOMEM); 756 l_new = ERR_PTR(-ENOMEM);
757 goto dec_count;
758 }
757 } 759 }
758 760
759 memcpy(l_new->key, key, key_size); 761 memcpy(l_new->key, key, key_size);
@@ -766,7 +768,8 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
766 GFP_ATOMIC | __GFP_NOWARN); 768 GFP_ATOMIC | __GFP_NOWARN);
767 if (!pptr) { 769 if (!pptr) {
768 kfree(l_new); 770 kfree(l_new);
769 return ERR_PTR(-ENOMEM); 771 l_new = ERR_PTR(-ENOMEM);
772 goto dec_count;
770 } 773 }
771 } 774 }
772 775
@@ -780,6 +783,9 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
780 783
781 l_new->hash = hash; 784 l_new->hash = hash;
782 return l_new; 785 return l_new;
786dec_count:
787 atomic_dec(&htab->count);
788 return l_new;
783} 789}
784 790
785static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old, 791static int check_flags(struct bpf_htab *htab, struct htab_elem *l_old,
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index cf7b6a6dbd1f..98fb7938beea 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -312,10 +312,12 @@ static void bpf_tcp_close(struct sock *sk, long timeout)
312 struct smap_psock *psock; 312 struct smap_psock *psock;
313 struct sock *osk; 313 struct sock *osk;
314 314
315 lock_sock(sk);
315 rcu_read_lock(); 316 rcu_read_lock();
316 psock = smap_psock_sk(sk); 317 psock = smap_psock_sk(sk);
317 if (unlikely(!psock)) { 318 if (unlikely(!psock)) {
318 rcu_read_unlock(); 319 rcu_read_unlock();
320 release_sock(sk);
319 return sk->sk_prot->close(sk, timeout); 321 return sk->sk_prot->close(sk, timeout);
320 } 322 }
321 323
@@ -371,6 +373,7 @@ static void bpf_tcp_close(struct sock *sk, long timeout)
371 e = psock_map_pop(sk, psock); 373 e = psock_map_pop(sk, psock);
372 } 374 }
373 rcu_read_unlock(); 375 rcu_read_unlock();
376 release_sock(sk);
374 close_fun(sk, timeout); 377 close_fun(sk, timeout);
375} 378}
376 379
@@ -568,7 +571,8 @@ static int free_sg(struct sock *sk, int start, struct sk_msg_buff *md)
568 while (sg[i].length) { 571 while (sg[i].length) {
569 free += sg[i].length; 572 free += sg[i].length;
570 sk_mem_uncharge(sk, sg[i].length); 573 sk_mem_uncharge(sk, sg[i].length);
571 put_page(sg_page(&sg[i])); 574 if (!md->skb)
575 put_page(sg_page(&sg[i]));
572 sg[i].length = 0; 576 sg[i].length = 0;
573 sg[i].page_link = 0; 577 sg[i].page_link = 0;
574 sg[i].offset = 0; 578 sg[i].offset = 0;
@@ -577,6 +581,8 @@ static int free_sg(struct sock *sk, int start, struct sk_msg_buff *md)
577 if (i == MAX_SKB_FRAGS) 581 if (i == MAX_SKB_FRAGS)
578 i = 0; 582 i = 0;
579 } 583 }
584 if (md->skb)
585 consume_skb(md->skb);
580 586
581 return free; 587 return free;
582} 588}
@@ -1230,7 +1236,7 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb)
1230 */ 1236 */
1231 TCP_SKB_CB(skb)->bpf.sk_redir = NULL; 1237 TCP_SKB_CB(skb)->bpf.sk_redir = NULL;
1232 skb->sk = psock->sock; 1238 skb->sk = psock->sock;
1233 bpf_compute_data_pointers(skb); 1239 bpf_compute_data_end_sk_skb(skb);
1234 preempt_disable(); 1240 preempt_disable();
1235 rc = (*prog->bpf_func)(skb, prog->insnsi); 1241 rc = (*prog->bpf_func)(skb, prog->insnsi);
1236 preempt_enable(); 1242 preempt_enable();
@@ -1485,7 +1491,7 @@ static int smap_parse_func_strparser(struct strparser *strp,
1485 * any socket yet. 1491 * any socket yet.
1486 */ 1492 */
1487 skb->sk = psock->sock; 1493 skb->sk = psock->sock;
1488 bpf_compute_data_pointers(skb); 1494 bpf_compute_data_end_sk_skb(skb);
1489 rc = (*prog->bpf_func)(skb, prog->insnsi); 1495 rc = (*prog->bpf_func)(skb, prog->insnsi);
1490 skb->sk = NULL; 1496 skb->sk = NULL;
1491 rcu_read_unlock(); 1497 rcu_read_unlock();
@@ -1896,7 +1902,7 @@ static int __sock_map_ctx_update_elem(struct bpf_map *map,
1896 e = kzalloc(sizeof(*e), GFP_ATOMIC | __GFP_NOWARN); 1902 e = kzalloc(sizeof(*e), GFP_ATOMIC | __GFP_NOWARN);
1897 if (!e) { 1903 if (!e) {
1898 err = -ENOMEM; 1904 err = -ENOMEM;
1899 goto out_progs; 1905 goto out_free;
1900 } 1906 }
1901 } 1907 }
1902 1908
@@ -2069,7 +2075,13 @@ static int sock_map_update_elem(struct bpf_map *map,
2069 return -EOPNOTSUPP; 2075 return -EOPNOTSUPP;
2070 } 2076 }
2071 2077
2078 lock_sock(skops.sk);
2079 preempt_disable();
2080 rcu_read_lock();
2072 err = sock_map_ctx_update_elem(&skops, map, key, flags); 2081 err = sock_map_ctx_update_elem(&skops, map, key, flags);
2082 rcu_read_unlock();
2083 preempt_enable();
2084 release_sock(skops.sk);
2073 fput(socket->file); 2085 fput(socket->file);
2074 return err; 2086 return err;
2075} 2087}
@@ -2342,7 +2354,10 @@ static int sock_hash_ctx_update_elem(struct bpf_sock_ops_kern *skops,
2342 if (err) 2354 if (err)
2343 goto err; 2355 goto err;
2344 2356
2345 /* bpf_map_update_elem() can be called in_irq() */ 2357 /* psock is valid here because otherwise above *ctx_update_elem would
2358 * have thrown an error. It is safe to skip error check.
2359 */
2360 psock = smap_psock_sk(sock);
2346 raw_spin_lock_bh(&b->lock); 2361 raw_spin_lock_bh(&b->lock);
2347 l_old = lookup_elem_raw(head, hash, key, key_size); 2362 l_old = lookup_elem_raw(head, hash, key, key_size);
2348 if (l_old && map_flags == BPF_NOEXIST) { 2363 if (l_old && map_flags == BPF_NOEXIST) {
@@ -2360,12 +2375,6 @@ static int sock_hash_ctx_update_elem(struct bpf_sock_ops_kern *skops,
2360 goto bucket_err; 2375 goto bucket_err;
2361 } 2376 }
2362 2377
2363 psock = smap_psock_sk(sock);
2364 if (unlikely(!psock)) {
2365 err = -EINVAL;
2366 goto bucket_err;
2367 }
2368
2369 rcu_assign_pointer(e->hash_link, l_new); 2378 rcu_assign_pointer(e->hash_link, l_new);
2370 rcu_assign_pointer(e->htab, 2379 rcu_assign_pointer(e->htab,
2371 container_of(map, struct bpf_htab, map)); 2380 container_of(map, struct bpf_htab, map));
@@ -2388,12 +2397,10 @@ static int sock_hash_ctx_update_elem(struct bpf_sock_ops_kern *skops,
2388 raw_spin_unlock_bh(&b->lock); 2397 raw_spin_unlock_bh(&b->lock);
2389 return 0; 2398 return 0;
2390bucket_err: 2399bucket_err:
2400 smap_release_sock(psock, sock);
2391 raw_spin_unlock_bh(&b->lock); 2401 raw_spin_unlock_bh(&b->lock);
2392err: 2402err:
2393 kfree(e); 2403 kfree(e);
2394 psock = smap_psock_sk(sock);
2395 if (psock)
2396 smap_release_sock(psock, sock);
2397 return err; 2404 return err;
2398} 2405}
2399 2406
@@ -2415,7 +2422,13 @@ static int sock_hash_update_elem(struct bpf_map *map,
2415 return -EINVAL; 2422 return -EINVAL;
2416 } 2423 }
2417 2424
2425 lock_sock(skops.sk);
2426 preempt_disable();
2427 rcu_read_lock();
2418 err = sock_hash_ctx_update_elem(&skops, map, key, flags); 2428 err = sock_hash_ctx_update_elem(&skops, map, key, flags);
2429 rcu_read_unlock();
2430 preempt_enable();
2431 release_sock(skops.sk);
2419 fput(socket->file); 2432 fput(socket->file);
2420 return err; 2433 return err;
2421} 2434}
@@ -2472,10 +2485,8 @@ struct sock *__sock_hash_lookup_elem(struct bpf_map *map, void *key)
2472 b = __select_bucket(htab, hash); 2485 b = __select_bucket(htab, hash);
2473 head = &b->head; 2486 head = &b->head;
2474 2487
2475 raw_spin_lock_bh(&b->lock);
2476 l = lookup_elem_raw(head, hash, key, key_size); 2488 l = lookup_elem_raw(head, hash, key, key_size);
2477 sk = l ? l->sk : NULL; 2489 sk = l ? l->sk : NULL;
2478 raw_spin_unlock_bh(&b->lock);
2479 return sk; 2490 return sk;
2480} 2491}
2481 2492
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index d10ecd78105f..a31a1ba0f8ea 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -735,7 +735,9 @@ static int map_update_elem(union bpf_attr *attr)
735 if (bpf_map_is_dev_bound(map)) { 735 if (bpf_map_is_dev_bound(map)) {
736 err = bpf_map_offload_update_elem(map, key, value, attr->flags); 736 err = bpf_map_offload_update_elem(map, key, value, attr->flags);
737 goto out; 737 goto out;
738 } else if (map->map_type == BPF_MAP_TYPE_CPUMAP) { 738 } else if (map->map_type == BPF_MAP_TYPE_CPUMAP ||
739 map->map_type == BPF_MAP_TYPE_SOCKHASH ||
740 map->map_type == BPF_MAP_TYPE_SOCKMAP) {
739 err = map->ops->map_update_elem(map, key, value, attr->flags); 741 err = map->ops->map_update_elem(map, key, value, attr->flags);
740 goto out; 742 goto out;
741 } 743 }
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 9e2bf834f13a..63aaac52a265 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5430,6 +5430,10 @@ static int jit_subprogs(struct bpf_verifier_env *env)
5430 if (insn->code != (BPF_JMP | BPF_CALL) || 5430 if (insn->code != (BPF_JMP | BPF_CALL) ||
5431 insn->src_reg != BPF_PSEUDO_CALL) 5431 insn->src_reg != BPF_PSEUDO_CALL)
5432 continue; 5432 continue;
5433 /* Upon error here we cannot fall back to interpreter but
5434 * need a hard reject of the program. Thus -EFAULT is
5435 * propagated in any case.
5436 */
5433 subprog = find_subprog(env, i + insn->imm + 1); 5437 subprog = find_subprog(env, i + insn->imm + 1);
5434 if (subprog < 0) { 5438 if (subprog < 0) {
5435 WARN_ONCE(1, "verifier bug. No program starts at insn %d\n", 5439 WARN_ONCE(1, "verifier bug. No program starts at insn %d\n",
@@ -5450,7 +5454,7 @@ static int jit_subprogs(struct bpf_verifier_env *env)
5450 5454
5451 func = kcalloc(env->subprog_cnt, sizeof(prog), GFP_KERNEL); 5455 func = kcalloc(env->subprog_cnt, sizeof(prog), GFP_KERNEL);
5452 if (!func) 5456 if (!func)
5453 return -ENOMEM; 5457 goto out_undo_insn;
5454 5458
5455 for (i = 0; i < env->subprog_cnt; i++) { 5459 for (i = 0; i < env->subprog_cnt; i++) {
5456 subprog_start = subprog_end; 5460 subprog_start = subprog_end;
@@ -5515,7 +5519,7 @@ static int jit_subprogs(struct bpf_verifier_env *env)
5515 tmp = bpf_int_jit_compile(func[i]); 5519 tmp = bpf_int_jit_compile(func[i]);
5516 if (tmp != func[i] || func[i]->bpf_func != old_bpf_func) { 5520 if (tmp != func[i] || func[i]->bpf_func != old_bpf_func) {
5517 verbose(env, "JIT doesn't support bpf-to-bpf calls\n"); 5521 verbose(env, "JIT doesn't support bpf-to-bpf calls\n");
5518 err = -EFAULT; 5522 err = -ENOTSUPP;
5519 goto out_free; 5523 goto out_free;
5520 } 5524 }
5521 cond_resched(); 5525 cond_resched();
@@ -5552,6 +5556,7 @@ out_free:
5552 if (func[i]) 5556 if (func[i])
5553 bpf_jit_free(func[i]); 5557 bpf_jit_free(func[i]);
5554 kfree(func); 5558 kfree(func);
5559out_undo_insn:
5555 /* cleanup main prog to be interpreted */ 5560 /* cleanup main prog to be interpreted */
5556 prog->jit_requested = 0; 5561 prog->jit_requested = 0;
5557 for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) { 5562 for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) {
@@ -5578,6 +5583,8 @@ static int fixup_call_args(struct bpf_verifier_env *env)
5578 err = jit_subprogs(env); 5583 err = jit_subprogs(env);
5579 if (err == 0) 5584 if (err == 0)
5580 return 0; 5585 return 0;
5586 if (err == -EFAULT)
5587 return err;
5581 } 5588 }
5582#ifndef CONFIG_BPF_JIT_ALWAYS_ON 5589#ifndef CONFIG_BPF_JIT_ALWAYS_ON
5583 for (i = 0; i < prog->len; i++, insn++) { 5590 for (i = 0; i < prog->len; i++, insn++) {
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8f0434a9951a..eec2d5fb676b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6343,7 +6343,7 @@ static u64 perf_virt_to_phys(u64 virt)
6343 6343
6344static struct perf_callchain_entry __empty_callchain = { .nr = 0, }; 6344static struct perf_callchain_entry __empty_callchain = { .nr = 0, };
6345 6345
6346static struct perf_callchain_entry * 6346struct perf_callchain_entry *
6347perf_callchain(struct perf_event *event, struct pt_regs *regs) 6347perf_callchain(struct perf_event *event, struct pt_regs *regs)
6348{ 6348{
6349 bool kernel = !event->attr.exclude_callchain_kernel; 6349 bool kernel = !event->attr.exclude_callchain_kernel;
@@ -6382,7 +6382,9 @@ void perf_prepare_sample(struct perf_event_header *header,
6382 if (sample_type & PERF_SAMPLE_CALLCHAIN) { 6382 if (sample_type & PERF_SAMPLE_CALLCHAIN) {
6383 int size = 1; 6383 int size = 1;
6384 6384
6385 data->callchain = perf_callchain(event, regs); 6385 if (!(sample_type & __PERF_SAMPLE_CALLCHAIN_EARLY))
6386 data->callchain = perf_callchain(event, regs);
6387
6386 size += data->callchain->nr; 6388 size += data->callchain->nr;
6387 6389
6388 header->size += size * sizeof(u64); 6390 header->size += size * sizeof(u64);
@@ -7335,6 +7337,10 @@ static bool perf_addr_filter_match(struct perf_addr_filter *filter,
7335 struct file *file, unsigned long offset, 7337 struct file *file, unsigned long offset,
7336 unsigned long size) 7338 unsigned long size)
7337{ 7339{
7340 /* d_inode(NULL) won't be equal to any mapped user-space file */
7341 if (!filter->path.dentry)
7342 return false;
7343
7338 if (d_inode(filter->path.dentry) != file_inode(file)) 7344 if (d_inode(filter->path.dentry) != file_inode(file))
7339 return false; 7345 return false;
7340 7346
diff --git a/kernel/fork.c b/kernel/fork.c
index 9440d61b925c..1b27babc4c78 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -303,11 +303,36 @@ struct kmem_cache *files_cachep;
303struct kmem_cache *fs_cachep; 303struct kmem_cache *fs_cachep;
304 304
305/* SLAB cache for vm_area_struct structures */ 305/* SLAB cache for vm_area_struct structures */
306struct kmem_cache *vm_area_cachep; 306static struct kmem_cache *vm_area_cachep;
307 307
308/* SLAB cache for mm_struct structures (tsk->mm) */ 308/* SLAB cache for mm_struct structures (tsk->mm) */
309static struct kmem_cache *mm_cachep; 309static struct kmem_cache *mm_cachep;
310 310
311struct vm_area_struct *vm_area_alloc(struct mm_struct *mm)
312{
313 struct vm_area_struct *vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
314
315 if (vma)
316 vma_init(vma, mm);
317 return vma;
318}
319
320struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig)
321{
322 struct vm_area_struct *new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
323
324 if (new) {
325 *new = *orig;
326 INIT_LIST_HEAD(&new->anon_vma_chain);
327 }
328 return new;
329}
330
331void vm_area_free(struct vm_area_struct *vma)
332{
333 kmem_cache_free(vm_area_cachep, vma);
334}
335
311static void account_kernel_stack(struct task_struct *tsk, int account) 336static void account_kernel_stack(struct task_struct *tsk, int account)
312{ 337{
313 void *stack = task_stack_page(tsk); 338 void *stack = task_stack_page(tsk);
@@ -455,11 +480,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
455 goto fail_nomem; 480 goto fail_nomem;
456 charge = len; 481 charge = len;
457 } 482 }
458 tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); 483 tmp = vm_area_dup(mpnt);
459 if (!tmp) 484 if (!tmp)
460 goto fail_nomem; 485 goto fail_nomem;
461 *tmp = *mpnt;
462 INIT_LIST_HEAD(&tmp->anon_vma_chain);
463 retval = vma_dup_policy(mpnt, tmp); 486 retval = vma_dup_policy(mpnt, tmp);
464 if (retval) 487 if (retval)
465 goto fail_nomem_policy; 488 goto fail_nomem_policy;
@@ -539,7 +562,7 @@ fail_uprobe_end:
539fail_nomem_anon_vma_fork: 562fail_nomem_anon_vma_fork:
540 mpol_put(vma_policy(tmp)); 563 mpol_put(vma_policy(tmp));
541fail_nomem_policy: 564fail_nomem_policy:
542 kmem_cache_free(vm_area_cachep, tmp); 565 vm_area_free(tmp);
543fail_nomem: 566fail_nomem:
544 retval = -ENOMEM; 567 retval = -ENOMEM;
545 vm_unacct_memory(charge); 568 vm_unacct_memory(charge);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index daeabd791d58..9a8b7ba9aa88 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1068,6 +1068,13 @@ static int irq_setup_forced_threading(struct irqaction *new)
1068 if (new->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT)) 1068 if (new->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT))
1069 return 0; 1069 return 0;
1070 1070
1071 /*
1072 * No further action required for interrupts which are requested as
1073 * threaded interrupts already
1074 */
1075 if (new->handler == irq_default_primary_handler)
1076 return 0;
1077
1071 new->flags |= IRQF_ONESHOT; 1078 new->flags |= IRQF_ONESHOT;
1072 1079
1073 /* 1080 /*
@@ -1075,7 +1082,7 @@ static int irq_setup_forced_threading(struct irqaction *new)
1075 * thread handler. We force thread them as well by creating a 1082 * thread handler. We force thread them as well by creating a
1076 * secondary action. 1083 * secondary action.
1077 */ 1084 */
1078 if (new->handler != irq_default_primary_handler && new->thread_fn) { 1085 if (new->handler && new->thread_fn) {
1079 /* Allocate the secondary action */ 1086 /* Allocate the secondary action */
1080 new->secondary = kzalloc(sizeof(struct irqaction), GFP_KERNEL); 1087 new->secondary = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
1081 if (!new->secondary) 1088 if (!new->secondary)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 750cb8082694..486dedbd9af5 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -325,8 +325,14 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
325 task = create->result; 325 task = create->result;
326 if (!IS_ERR(task)) { 326 if (!IS_ERR(task)) {
327 static const struct sched_param param = { .sched_priority = 0 }; 327 static const struct sched_param param = { .sched_priority = 0 };
328 char name[TASK_COMM_LEN];
328 329
329 vsnprintf(task->comm, sizeof(task->comm), namefmt, args); 330 /*
331 * task is already visible to other tasks, so updating
332 * COMM must be protected.
333 */
334 vsnprintf(name, sizeof(name), namefmt, args);
335 set_task_comm(task, name);
330 /* 336 /*
331 * root may have changed our (kthreadd's) priority or CPU mask. 337 * root may have changed our (kthreadd's) priority or CPU mask.
332 * The kernel thread should not inherit these properties. 338 * The kernel thread should not inherit these properties.
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 4f014be7a4b8..2823d4163a37 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1465,6 +1465,29 @@ rt_mutex_fastunlock(struct rt_mutex *lock,
1465 rt_mutex_postunlock(&wake_q); 1465 rt_mutex_postunlock(&wake_q);
1466} 1466}
1467 1467
1468static inline void __rt_mutex_lock(struct rt_mutex *lock, unsigned int subclass)
1469{
1470 might_sleep();
1471
1472 mutex_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
1473 rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock);
1474}
1475
1476#ifdef CONFIG_DEBUG_LOCK_ALLOC
1477/**
1478 * rt_mutex_lock_nested - lock a rt_mutex
1479 *
1480 * @lock: the rt_mutex to be locked
1481 * @subclass: the lockdep subclass
1482 */
1483void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass)
1484{
1485 __rt_mutex_lock(lock, subclass);
1486}
1487EXPORT_SYMBOL_GPL(rt_mutex_lock_nested);
1488#endif
1489
1490#ifndef CONFIG_DEBUG_LOCK_ALLOC
1468/** 1491/**
1469 * rt_mutex_lock - lock a rt_mutex 1492 * rt_mutex_lock - lock a rt_mutex
1470 * 1493 *
@@ -1472,12 +1495,10 @@ rt_mutex_fastunlock(struct rt_mutex *lock,
1472 */ 1495 */
1473void __sched rt_mutex_lock(struct rt_mutex *lock) 1496void __sched rt_mutex_lock(struct rt_mutex *lock)
1474{ 1497{
1475 might_sleep(); 1498 __rt_mutex_lock(lock, 0);
1476
1477 mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_);
1478 rt_mutex_fastlock(lock, TASK_UNINTERRUPTIBLE, rt_mutex_slowlock);
1479} 1499}
1480EXPORT_SYMBOL_GPL(rt_mutex_lock); 1500EXPORT_SYMBOL_GPL(rt_mutex_lock);
1501#endif
1481 1502
1482/** 1503/**
1483 * rt_mutex_lock_interruptible - lock a rt_mutex interruptible 1504 * rt_mutex_lock_interruptible - lock a rt_mutex interruptible
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 5857267a4af5..38283363da06 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -176,10 +176,27 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
176 unsigned long pfn, pgoff, order; 176 unsigned long pfn, pgoff, order;
177 pgprot_t pgprot = PAGE_KERNEL; 177 pgprot_t pgprot = PAGE_KERNEL;
178 int error, nid, is_ram; 178 int error, nid, is_ram;
179 struct dev_pagemap *conflict_pgmap;
179 180
180 align_start = res->start & ~(SECTION_SIZE - 1); 181 align_start = res->start & ~(SECTION_SIZE - 1);
181 align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) 182 align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
182 - align_start; 183 - align_start;
184 align_end = align_start + align_size - 1;
185
186 conflict_pgmap = get_dev_pagemap(PHYS_PFN(align_start), NULL);
187 if (conflict_pgmap) {
188 dev_WARN(dev, "Conflicting mapping in same section\n");
189 put_dev_pagemap(conflict_pgmap);
190 return ERR_PTR(-ENOMEM);
191 }
192
193 conflict_pgmap = get_dev_pagemap(PHYS_PFN(align_end), NULL);
194 if (conflict_pgmap) {
195 dev_WARN(dev, "Conflicting mapping in same section\n");
196 put_dev_pagemap(conflict_pgmap);
197 return ERR_PTR(-ENOMEM);
198 }
199
183 is_ram = region_intersects(align_start, align_size, 200 is_ram = region_intersects(align_start, align_size,
184 IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE); 201 IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);
185 202
@@ -199,7 +216,6 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
199 216
200 mutex_lock(&pgmap_lock); 217 mutex_lock(&pgmap_lock);
201 error = 0; 218 error = 0;
202 align_end = align_start + align_size - 1;
203 219
204 foreach_order_pgoff(res, order, pgoff) { 220 foreach_order_pgoff(res, order, pgoff) {
205 error = __radix_tree_insert(&pgmap_radix, 221 error = __radix_tree_insert(&pgmap_radix,
@@ -305,7 +321,7 @@ EXPORT_SYMBOL_GPL(get_dev_pagemap);
305 321
306#ifdef CONFIG_DEV_PAGEMAP_OPS 322#ifdef CONFIG_DEV_PAGEMAP_OPS
307DEFINE_STATIC_KEY_FALSE(devmap_managed_key); 323DEFINE_STATIC_KEY_FALSE(devmap_managed_key);
308EXPORT_SYMBOL_GPL(devmap_managed_key); 324EXPORT_SYMBOL(devmap_managed_key);
309static atomic_t devmap_enable; 325static atomic_t devmap_enable;
310 326
311/* 327/*
@@ -346,5 +362,5 @@ void __put_devmap_managed_page(struct page *page)
346 } else if (!count) 362 } else if (!count)
347 __put_page(page); 363 __put_page(page);
348} 364}
349EXPORT_SYMBOL_GPL(__put_devmap_managed_page); 365EXPORT_SYMBOL(__put_devmap_managed_page);
350#endif /* CONFIG_DEV_PAGEMAP_OPS */ 366#endif /* CONFIG_DEV_PAGEMAP_OPS */
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index fbfc3f1d368a..b5fbdde6afa9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2090,8 +2090,14 @@ retry:
2090 sub_rq_bw(&next_task->dl, &rq->dl); 2090 sub_rq_bw(&next_task->dl, &rq->dl);
2091 set_task_cpu(next_task, later_rq->cpu); 2091 set_task_cpu(next_task, later_rq->cpu);
2092 add_rq_bw(&next_task->dl, &later_rq->dl); 2092 add_rq_bw(&next_task->dl, &later_rq->dl);
2093
2094 /*
2095 * Update the later_rq clock here, because the clock is used
2096 * by the cpufreq_update_util() inside __add_running_bw().
2097 */
2098 update_rq_clock(later_rq);
2093 add_running_bw(&next_task->dl, &later_rq->dl); 2099 add_running_bw(&next_task->dl, &later_rq->dl);
2094 activate_task(later_rq, next_task, 0); 2100 activate_task(later_rq, next_task, ENQUEUE_NOCLOCK);
2095 ret = 1; 2101 ret = 1;
2096 2102
2097 resched_curr(later_rq); 2103 resched_curr(later_rq);
@@ -2290,8 +2296,17 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
2290 if (task_on_rq_queued(p) && p->dl.dl_runtime) 2296 if (task_on_rq_queued(p) && p->dl.dl_runtime)
2291 task_non_contending(p); 2297 task_non_contending(p);
2292 2298
2293 if (!task_on_rq_queued(p)) 2299 if (!task_on_rq_queued(p)) {
2300 /*
2301 * Inactive timer is armed. However, p is leaving DEADLINE and
2302 * might migrate away from this rq while continuing to run on
2303 * some other class. We need to remove its contribution from
2304 * this rq running_bw now, or sub_rq_bw (below) will complain.
2305 */
2306 if (p->dl.dl_non_contending)
2307 sub_running_bw(&p->dl, &rq->dl);
2294 sub_rq_bw(&p->dl, &rq->dl); 2308 sub_rq_bw(&p->dl, &rq->dl);
2309 }
2295 2310
2296 /* 2311 /*
2297 * We cannot use inactive_task_timer() to invoke sub_running_bw() 2312 * We cannot use inactive_task_timer() to invoke sub_running_bw()
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 572567078b60..eaaec8364f96 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -836,6 +836,8 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
836 * can be time-consuming. Try to avoid it when possible. 836 * can be time-consuming. Try to avoid it when possible.
837 */ 837 */
838 raw_spin_lock(&rt_rq->rt_runtime_lock); 838 raw_spin_lock(&rt_rq->rt_runtime_lock);
839 if (!sched_feat(RT_RUNTIME_SHARE) && rt_rq->rt_runtime != RUNTIME_INF)
840 rt_rq->rt_runtime = rt_b->rt_runtime;
839 skip = !rt_rq->rt_time && !rt_rq->rt_nr_running; 841 skip = !rt_rq->rt_time && !rt_rq->rt_nr_running;
840 raw_spin_unlock(&rt_rq->rt_runtime_lock); 842 raw_spin_unlock(&rt_rq->rt_runtime_lock);
841 if (skip) 843 if (skip)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 05a831427bc7..56a0fed30c0a 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -47,7 +47,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
47 if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) { 47 if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) {
48 printk(KERN_ERR "ERROR: domain->span does not contain CPU%d\n", cpu); 48 printk(KERN_ERR "ERROR: domain->span does not contain CPU%d\n", cpu);
49 } 49 }
50 if (!cpumask_test_cpu(cpu, sched_group_span(group))) { 50 if (group && !cpumask_test_cpu(cpu, sched_group_span(group))) {
51 printk(KERN_ERR "ERROR: domain->groups does not contain CPU%d\n", cpu); 51 printk(KERN_ERR "ERROR: domain->groups does not contain CPU%d\n", cpu);
52 } 52 }
53 53
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 900dcfee542c..6f584861d329 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -79,12 +79,16 @@ static void wakeup_softirqd(void)
79 79
80/* 80/*
81 * If ksoftirqd is scheduled, we do not want to process pending softirqs 81 * If ksoftirqd is scheduled, we do not want to process pending softirqs
82 * right now. Let ksoftirqd handle this at its own rate, to get fairness. 82 * right now. Let ksoftirqd handle this at its own rate, to get fairness,
83 * unless we're doing some of the synchronous softirqs.
83 */ 84 */
84static bool ksoftirqd_running(void) 85#define SOFTIRQ_NOW_MASK ((1 << HI_SOFTIRQ) | (1 << TASKLET_SOFTIRQ))
86static bool ksoftirqd_running(unsigned long pending)
85{ 87{
86 struct task_struct *tsk = __this_cpu_read(ksoftirqd); 88 struct task_struct *tsk = __this_cpu_read(ksoftirqd);
87 89
90 if (pending & SOFTIRQ_NOW_MASK)
91 return false;
88 return tsk && (tsk->state == TASK_RUNNING); 92 return tsk && (tsk->state == TASK_RUNNING);
89} 93}
90 94
@@ -328,7 +332,7 @@ asmlinkage __visible void do_softirq(void)
328 332
329 pending = local_softirq_pending(); 333 pending = local_softirq_pending();
330 334
331 if (pending && !ksoftirqd_running()) 335 if (pending && !ksoftirqd_running(pending))
332 do_softirq_own_stack(); 336 do_softirq_own_stack();
333 337
334 local_irq_restore(flags); 338 local_irq_restore(flags);
@@ -355,7 +359,7 @@ void irq_enter(void)
355 359
356static inline void invoke_softirq(void) 360static inline void invoke_softirq(void)
357{ 361{
358 if (ksoftirqd_running()) 362 if (ksoftirqd_running(local_softirq_pending()))
359 return; 363 return;
360 364
361 if (!force_irqthreads) { 365 if (!force_irqthreads) {
@@ -386,7 +390,7 @@ static inline void tick_irq_exit(void)
386 390
387 /* Make sure that timer wheel updates are propagated */ 391 /* Make sure that timer wheel updates are propagated */
388 if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) { 392 if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) {
389 if (!in_interrupt()) 393 if (!in_irq())
390 tick_nohz_irq_exit(); 394 tick_nohz_irq_exit();
391 } 395 }
392#endif 396#endif
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index f89014a2c238..e190d1ef3a23 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -260,6 +260,15 @@ retry:
260 err = 0; 260 err = 0;
261 __cpu_stop_queue_work(stopper1, work1, &wakeq); 261 __cpu_stop_queue_work(stopper1, work1, &wakeq);
262 __cpu_stop_queue_work(stopper2, work2, &wakeq); 262 __cpu_stop_queue_work(stopper2, work2, &wakeq);
263 /*
264 * The waking up of stopper threads has to happen
265 * in the same scheduling context as the queueing.
266 * Otherwise, there is a possibility of one of the
267 * above stoppers being woken up by another CPU,
268 * and preempting us. This will cause us to n ot
269 * wake up the other stopper forever.
270 */
271 preempt_disable();
263unlock: 272unlock:
264 raw_spin_unlock(&stopper2->lock); 273 raw_spin_unlock(&stopper2->lock);
265 raw_spin_unlock_irq(&stopper1->lock); 274 raw_spin_unlock_irq(&stopper1->lock);
@@ -270,7 +279,10 @@ unlock:
270 goto retry; 279 goto retry;
271 } 280 }
272 281
273 wake_up_q(&wakeq); 282 if (!err) {
283 wake_up_q(&wakeq);
284 preempt_enable();
285 }
274 286
275 return err; 287 return err;
276} 288}
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index da9455a6b42b..5b33e2f5c0ed 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -642,7 +642,7 @@ static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
642 642
643static inline bool local_timer_softirq_pending(void) 643static inline bool local_timer_softirq_pending(void)
644{ 644{
645 return local_softirq_pending() & TIMER_SOFTIRQ; 645 return local_softirq_pending() & BIT(TIMER_SOFTIRQ);
646} 646}
647 647
648static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) 648static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 6a46af21765c..0b0b688ea166 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3227,6 +3227,22 @@ int ring_buffer_record_is_on(struct ring_buffer *buffer)
3227} 3227}
3228 3228
3229/** 3229/**
3230 * ring_buffer_record_is_set_on - return true if the ring buffer is set writable
3231 * @buffer: The ring buffer to see if write is set enabled
3232 *
3233 * Returns true if the ring buffer is set writable by ring_buffer_record_on().
3234 * Note that this does NOT mean it is in a writable state.
3235 *
3236 * It may return true when the ring buffer has been disabled by
3237 * ring_buffer_record_disable(), as that is a temporary disabling of
3238 * the ring buffer.
3239 */
3240int ring_buffer_record_is_set_on(struct ring_buffer *buffer)
3241{
3242 return !(atomic_read(&buffer->record_disabled) & RB_BUFFER_OFF);
3243}
3244
3245/**
3230 * ring_buffer_record_disable_cpu - stop all writes into the cpu_buffer 3246 * ring_buffer_record_disable_cpu - stop all writes into the cpu_buffer
3231 * @buffer: The ring buffer to stop writes to. 3247 * @buffer: The ring buffer to stop writes to.
3232 * @cpu: The CPU buffer to stop 3248 * @cpu: The CPU buffer to stop
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 87cf25171fb8..823687997b01 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1373,6 +1373,12 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
1373 1373
1374 arch_spin_lock(&tr->max_lock); 1374 arch_spin_lock(&tr->max_lock);
1375 1375
1376 /* Inherit the recordable setting from trace_buffer */
1377 if (ring_buffer_record_is_set_on(tr->trace_buffer.buffer))
1378 ring_buffer_record_on(tr->max_buffer.buffer);
1379 else
1380 ring_buffer_record_off(tr->max_buffer.buffer);
1381
1376 swap(tr->trace_buffer.buffer, tr->max_buffer.buffer); 1382 swap(tr->trace_buffer.buffer, tr->max_buffer.buffer);
1377 1383
1378 __update_max_tr(tr, tsk, cpu); 1384 __update_max_tr(tr, tsk, cpu);
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index d18249683682..5dea177cef53 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -679,6 +679,8 @@ event_trigger_callback(struct event_command *cmd_ops,
679 goto out_free; 679 goto out_free;
680 680
681 out_reg: 681 out_reg:
682 /* Up the trigger_data count to make sure reg doesn't free it on failure */
683 event_trigger_init(trigger_ops, trigger_data);
682 ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file); 684 ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
683 /* 685 /*
684 * The above returns on success the # of functions enabled, 686 * The above returns on success the # of functions enabled,
@@ -686,11 +688,13 @@ event_trigger_callback(struct event_command *cmd_ops,
686 * Consider no functions a failure too. 688 * Consider no functions a failure too.
687 */ 689 */
688 if (!ret) { 690 if (!ret) {
691 cmd_ops->unreg(glob, trigger_ops, trigger_data, file);
689 ret = -ENOENT; 692 ret = -ENOENT;
690 goto out_free; 693 } else if (ret > 0)
691 } else if (ret < 0) 694 ret = 0;
692 goto out_free; 695
693 ret = 0; 696 /* Down the counter of trigger_data or free it if not used anymore */
697 event_trigger_free(trigger_ops, trigger_data);
694 out: 698 out:
695 return ret; 699 return ret;
696 700
@@ -1416,6 +1420,9 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
1416 goto out; 1420 goto out;
1417 } 1421 }
1418 1422
1423 /* Up the trigger_data count to make sure nothing frees it on failure */
1424 event_trigger_init(trigger_ops, trigger_data);
1425
1419 if (trigger) { 1426 if (trigger) {
1420 number = strsep(&trigger, ":"); 1427 number = strsep(&trigger, ":");
1421 1428
@@ -1466,6 +1473,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
1466 goto out_disable; 1473 goto out_disable;
1467 /* Just return zero, not the number of enabled functions */ 1474 /* Just return zero, not the number of enabled functions */
1468 ret = 0; 1475 ret = 0;
1476 event_trigger_free(trigger_ops, trigger_data);
1469 out: 1477 out:
1470 return ret; 1478 return ret;
1471 1479
@@ -1476,7 +1484,7 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
1476 out_free: 1484 out_free:
1477 if (cmd_ops->set_filter) 1485 if (cmd_ops->set_filter)
1478 cmd_ops->set_filter(NULL, trigger_data, NULL); 1486 cmd_ops->set_filter(NULL, trigger_data, NULL);
1479 kfree(trigger_data); 1487 event_trigger_free(trigger_ops, trigger_data);
1480 kfree(enable_data); 1488 kfree(enable_data);
1481 goto out; 1489 goto out;
1482} 1490}
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 21f718472942..6b71860f3998 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -400,11 +400,10 @@ static struct trace_kprobe *find_trace_kprobe(const char *event,
400static int 400static int
401enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file) 401enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
402{ 402{
403 struct event_file_link *link = NULL;
403 int ret = 0; 404 int ret = 0;
404 405
405 if (file) { 406 if (file) {
406 struct event_file_link *link;
407
408 link = kmalloc(sizeof(*link), GFP_KERNEL); 407 link = kmalloc(sizeof(*link), GFP_KERNEL);
409 if (!link) { 408 if (!link) {
410 ret = -ENOMEM; 409 ret = -ENOMEM;
@@ -424,6 +423,18 @@ enable_trace_kprobe(struct trace_kprobe *tk, struct trace_event_file *file)
424 else 423 else
425 ret = enable_kprobe(&tk->rp.kp); 424 ret = enable_kprobe(&tk->rp.kp);
426 } 425 }
426
427 if (ret) {
428 if (file) {
429 /* Notice the if is true on not WARN() */
430 if (!WARN_ON_ONCE(!link))
431 list_del_rcu(&link->list);
432 kfree(link);
433 tk->tp.flags &= ~TP_FLAG_TRACE;
434 } else {
435 tk->tp.flags &= ~TP_FLAG_PROFILE;
436 }
437 }
427 out: 438 out:
428 return ret; 439 return ret;
429} 440}
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index c253c1b46c6b..befb127507c0 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -5,7 +5,7 @@ if HAVE_ARCH_KASAN
5 5
6config KASAN 6config KASAN
7 bool "KASan: runtime memory debugger" 7 bool "KASan: runtime memory debugger"
8 depends on SLUB || (SLAB && !DEBUG_SLAB) 8 depends on (SLUB && SYSFS) || (SLAB && !DEBUG_SLAB)
9 select SLUB_DEBUG if SLUB 9 select SLUB_DEBUG if SLUB
10 select CONSTRUCTORS 10 select CONSTRUCTORS
11 select STACKDEPOT 11 select STACKDEPOT
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 7e43cd54c84c..8be175df3075 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -596,15 +596,70 @@ static unsigned long memcpy_mcsafe_to_page(struct page *page, size_t offset,
596 return ret; 596 return ret;
597} 597}
598 598
599static size_t copy_pipe_to_iter_mcsafe(const void *addr, size_t bytes,
600 struct iov_iter *i)
601{
602 struct pipe_inode_info *pipe = i->pipe;
603 size_t n, off, xfer = 0;
604 int idx;
605
606 if (!sanity(i))
607 return 0;
608
609 bytes = n = push_pipe(i, bytes, &idx, &off);
610 if (unlikely(!n))
611 return 0;
612 for ( ; n; idx = next_idx(idx, pipe), off = 0) {
613 size_t chunk = min_t(size_t, n, PAGE_SIZE - off);
614 unsigned long rem;
615
616 rem = memcpy_mcsafe_to_page(pipe->bufs[idx].page, off, addr,
617 chunk);
618 i->idx = idx;
619 i->iov_offset = off + chunk - rem;
620 xfer += chunk - rem;
621 if (rem)
622 break;
623 n -= chunk;
624 addr += chunk;
625 }
626 i->count -= xfer;
627 return xfer;
628}
629
630/**
631 * _copy_to_iter_mcsafe - copy to user with source-read error exception handling
632 * @addr: source kernel address
633 * @bytes: total transfer length
634 * @iter: destination iterator
635 *
636 * The pmem driver arranges for filesystem-dax to use this facility via
637 * dax_copy_to_iter() for protecting read/write to persistent memory.
638 * Unless / until an architecture can guarantee identical performance
639 * between _copy_to_iter_mcsafe() and _copy_to_iter() it would be a
640 * performance regression to switch more users to the mcsafe version.
641 *
642 * Otherwise, the main differences between this and typical _copy_to_iter().
643 *
644 * * Typical tail/residue handling after a fault retries the copy
645 * byte-by-byte until the fault happens again. Re-triggering machine
646 * checks is potentially fatal so the implementation uses source
647 * alignment and poison alignment assumptions to avoid re-triggering
648 * hardware exceptions.
649 *
650 * * ITER_KVEC, ITER_PIPE, and ITER_BVEC can return short copies.
651 * Compare to copy_to_iter() where only ITER_IOVEC attempts might return
652 * a short copy.
653 *
654 * See MCSAFE_TEST for self-test.
655 */
599size_t _copy_to_iter_mcsafe(const void *addr, size_t bytes, struct iov_iter *i) 656size_t _copy_to_iter_mcsafe(const void *addr, size_t bytes, struct iov_iter *i)
600{ 657{
601 const char *from = addr; 658 const char *from = addr;
602 unsigned long rem, curr_addr, s_addr = (unsigned long) addr; 659 unsigned long rem, curr_addr, s_addr = (unsigned long) addr;
603 660
604 if (unlikely(i->type & ITER_PIPE)) { 661 if (unlikely(i->type & ITER_PIPE))
605 WARN_ON(1); 662 return copy_pipe_to_iter_mcsafe(addr, bytes, i);
606 return 0;
607 }
608 if (iter_is_iovec(i)) 663 if (iter_is_iovec(i))
609 might_fault(); 664 might_fault();
610 iterate_and_advance(i, bytes, v, 665 iterate_and_advance(i, bytes, v,
@@ -701,6 +756,20 @@ size_t _copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i)
701EXPORT_SYMBOL(_copy_from_iter_nocache); 756EXPORT_SYMBOL(_copy_from_iter_nocache);
702 757
703#ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE 758#ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
759/**
760 * _copy_from_iter_flushcache - write destination through cpu cache
761 * @addr: destination kernel address
762 * @bytes: total transfer length
763 * @iter: source iterator
764 *
765 * The pmem driver arranges for filesystem-dax to use this facility via
766 * dax_copy_from_iter() for ensuring that writes to persistent memory
767 * are flushed through the CPU cache. It is differentiated from
768 * _copy_from_iter_nocache() in that guarantees all data is flushed for
769 * all iterator types. The _copy_from_iter_nocache() only attempts to
770 * bypass the cache for the ITER_IOVEC case, and on some archs may use
771 * instructions that strand dirty-data in the cache.
772 */
704size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i) 773size_t _copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
705{ 774{
706 char *to = addr; 775 char *to = addr;
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 9427b5766134..e5c8586cf717 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -774,7 +774,7 @@ int rhashtable_walk_start_check(struct rhashtable_iter *iter)
774 skip++; 774 skip++;
775 if (list == iter->list) { 775 if (list == iter->list) {
776 iter->p = p; 776 iter->p = p;
777 skip = skip; 777 iter->skip = skip;
778 goto found; 778 goto found;
779 } 779 }
780 } 780 }
@@ -964,8 +964,16 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_stop);
964 964
965static size_t rounded_hashtable_size(const struct rhashtable_params *params) 965static size_t rounded_hashtable_size(const struct rhashtable_params *params)
966{ 966{
967 return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), 967 size_t retsize;
968 (unsigned long)params->min_size); 968
969 if (params->nelem_hint)
970 retsize = max(roundup_pow_of_two(params->nelem_hint * 4 / 3),
971 (unsigned long)params->min_size);
972 else
973 retsize = max(HASH_DEFAULT_SIZE,
974 (unsigned long)params->min_size);
975
976 return retsize;
969} 977}
970 978
971static u32 rhashtable_jhash2(const void *key, u32 length, u32 seed) 979static u32 rhashtable_jhash2(const void *key, u32 length, u32 seed)
@@ -1022,8 +1030,6 @@ int rhashtable_init(struct rhashtable *ht,
1022 struct bucket_table *tbl; 1030 struct bucket_table *tbl;
1023 size_t size; 1031 size_t size;
1024 1032
1025 size = HASH_DEFAULT_SIZE;
1026
1027 if ((!params->key_len && !params->obj_hashfn) || 1033 if ((!params->key_len && !params->obj_hashfn) ||
1028 (params->obj_hashfn && !params->obj_cmpfn)) 1034 (params->obj_hashfn && !params->obj_cmpfn))
1029 return -EINVAL; 1035 return -EINVAL;
@@ -1050,8 +1056,7 @@ int rhashtable_init(struct rhashtable *ht,
1050 1056
1051 ht->p.min_size = max_t(u16, ht->p.min_size, HASH_MIN_SIZE); 1057 ht->p.min_size = max_t(u16, ht->p.min_size, HASH_MIN_SIZE);
1052 1058
1053 if (params->nelem_hint) 1059 size = rounded_hashtable_size(&ht->p);
1054 size = rounded_hashtable_size(&ht->p);
1055 1060
1056 if (params->locks_mul) 1061 if (params->locks_mul)
1057 ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); 1062 ht->p.locks_mul = roundup_pow_of_two(params->locks_mul);
@@ -1143,13 +1148,14 @@ void rhashtable_free_and_destroy(struct rhashtable *ht,
1143 void (*free_fn)(void *ptr, void *arg), 1148 void (*free_fn)(void *ptr, void *arg),
1144 void *arg) 1149 void *arg)
1145{ 1150{
1146 struct bucket_table *tbl; 1151 struct bucket_table *tbl, *next_tbl;
1147 unsigned int i; 1152 unsigned int i;
1148 1153
1149 cancel_work_sync(&ht->run_work); 1154 cancel_work_sync(&ht->run_work);
1150 1155
1151 mutex_lock(&ht->mutex); 1156 mutex_lock(&ht->mutex);
1152 tbl = rht_dereference(ht->tbl, ht); 1157 tbl = rht_dereference(ht->tbl, ht);
1158restart:
1153 if (free_fn) { 1159 if (free_fn) {
1154 for (i = 0; i < tbl->size; i++) { 1160 for (i = 0; i < tbl->size; i++) {
1155 struct rhash_head *pos, *next; 1161 struct rhash_head *pos, *next;
@@ -1166,7 +1172,12 @@ void rhashtable_free_and_destroy(struct rhashtable *ht,
1166 } 1172 }
1167 } 1173 }
1168 1174
1175 next_tbl = rht_dereference(tbl->future_tbl, ht);
1169 bucket_table_free(tbl); 1176 bucket_table_free(tbl);
1177 if (next_tbl) {
1178 tbl = next_tbl;
1179 goto restart;
1180 }
1170 mutex_unlock(&ht->mutex); 1181 mutex_unlock(&ht->mutex);
1171} 1182}
1172EXPORT_SYMBOL_GPL(rhashtable_free_and_destroy); 1183EXPORT_SYMBOL_GPL(rhashtable_free_and_destroy);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 1cd7c1a57a14..25346bd99364 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2084,6 +2084,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
2084 if (vma_is_dax(vma)) 2084 if (vma_is_dax(vma))
2085 return; 2085 return;
2086 page = pmd_page(_pmd); 2086 page = pmd_page(_pmd);
2087 if (!PageDirty(page) && pmd_dirty(_pmd))
2088 set_page_dirty(page);
2087 if (!PageReferenced(page) && pmd_young(_pmd)) 2089 if (!PageReferenced(page) && pmd_young(_pmd))
2088 SetPageReferenced(page); 2090 SetPageReferenced(page);
2089 page_remove_rmap(page, true); 2091 page_remove_rmap(page, true);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 039ddbc574e9..3103099f64fd 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3167,6 +3167,13 @@ static vm_fault_t hugetlb_vm_op_fault(struct vm_fault *vmf)
3167 return 0; 3167 return 0;
3168} 3168}
3169 3169
3170/*
3171 * When a new function is introduced to vm_operations_struct and added
3172 * to hugetlb_vm_ops, please consider adding the function to shm_vm_ops.
3173 * This is because under System V memory model, mappings created via
3174 * shmget/shmat with "huge page" specified are backed by hugetlbfs files,
3175 * their original vm_ops are overwritten with shm_vm_ops.
3176 */
3170const struct vm_operations_struct hugetlb_vm_ops = { 3177const struct vm_operations_struct hugetlb_vm_ops = {
3171 .fault = hugetlb_vm_op_fault, 3178 .fault = hugetlb_vm_op_fault,
3172 .open = hugetlb_vm_op_open, 3179 .open = hugetlb_vm_op_open,
diff --git a/mm/memblock.c b/mm/memblock.c
index 11e46f83e1ad..4b5d245fafc1 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -20,6 +20,7 @@
20#include <linux/kmemleak.h> 20#include <linux/kmemleak.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/memblock.h> 22#include <linux/memblock.h>
23#include <linux/bootmem.h>
23 24
24#include <asm/sections.h> 25#include <asm/sections.h>
25#include <linux/io.h> 26#include <linux/io.h>
@@ -1225,6 +1226,7 @@ phys_addr_t __init memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, i
1225 return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE); 1226 return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
1226} 1227}
1227 1228
1229#if defined(CONFIG_NO_BOOTMEM)
1228/** 1230/**
1229 * memblock_virt_alloc_internal - allocate boot memory block 1231 * memblock_virt_alloc_internal - allocate boot memory block
1230 * @size: size of memory block to be allocated in bytes 1232 * @size: size of memory block to be allocated in bytes
@@ -1432,6 +1434,7 @@ void * __init memblock_virt_alloc_try_nid(
1432 (u64)max_addr); 1434 (u64)max_addr);
1433 return NULL; 1435 return NULL;
1434} 1436}
1437#endif
1435 1438
1436/** 1439/**
1437 * __memblock_free_early - free boot memory block 1440 * __memblock_free_early - free boot memory block
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e6f0d5ef320a..b2173f7e5164 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -850,7 +850,7 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)
850 int nid; 850 int nid;
851 int i; 851 int i;
852 852
853 while ((memcg = parent_mem_cgroup(memcg))) { 853 for (; memcg; memcg = parent_mem_cgroup(memcg)) {
854 for_each_node(nid) { 854 for_each_node(nid) {
855 mz = mem_cgroup_nodeinfo(memcg, nid); 855 mz = mem_cgroup_nodeinfo(memcg, nid);
856 for (i = 0; i <= DEF_PRIORITY; i++) { 856 for (i = 0; i <= DEF_PRIORITY; i++) {
@@ -4037,6 +4037,14 @@ static struct cftype mem_cgroup_legacy_files[] = {
4037 4037
4038static DEFINE_IDR(mem_cgroup_idr); 4038static DEFINE_IDR(mem_cgroup_idr);
4039 4039
4040static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
4041{
4042 if (memcg->id.id > 0) {
4043 idr_remove(&mem_cgroup_idr, memcg->id.id);
4044 memcg->id.id = 0;
4045 }
4046}
4047
4040static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n) 4048static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
4041{ 4049{
4042 VM_BUG_ON(atomic_read(&memcg->id.ref) <= 0); 4050 VM_BUG_ON(atomic_read(&memcg->id.ref) <= 0);
@@ -4047,8 +4055,7 @@ static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
4047{ 4055{
4048 VM_BUG_ON(atomic_read(&memcg->id.ref) < n); 4056 VM_BUG_ON(atomic_read(&memcg->id.ref) < n);
4049 if (atomic_sub_and_test(n, &memcg->id.ref)) { 4057 if (atomic_sub_and_test(n, &memcg->id.ref)) {
4050 idr_remove(&mem_cgroup_idr, memcg->id.id); 4058 mem_cgroup_id_remove(memcg);
4051 memcg->id.id = 0;
4052 4059
4053 /* Memcg ID pins CSS */ 4060 /* Memcg ID pins CSS */
4054 css_put(&memcg->css); 4061 css_put(&memcg->css);
@@ -4185,8 +4192,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
4185 idr_replace(&mem_cgroup_idr, memcg, memcg->id.id); 4192 idr_replace(&mem_cgroup_idr, memcg, memcg->id.id);
4186 return memcg; 4193 return memcg;
4187fail: 4194fail:
4188 if (memcg->id.id > 0) 4195 mem_cgroup_id_remove(memcg);
4189 idr_remove(&mem_cgroup_idr, memcg->id.id);
4190 __mem_cgroup_free(memcg); 4196 __mem_cgroup_free(memcg);
4191 return NULL; 4197 return NULL;
4192} 4198}
@@ -4245,6 +4251,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
4245 4251
4246 return &memcg->css; 4252 return &memcg->css;
4247fail: 4253fail:
4254 mem_cgroup_id_remove(memcg);
4248 mem_cgroup_free(memcg); 4255 mem_cgroup_free(memcg);
4249 return ERR_PTR(-ENOMEM); 4256 return ERR_PTR(-ENOMEM);
4250} 4257}
diff --git a/mm/memory.c b/mm/memory.c
index 7206a634270b..dab1511294ad 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1417,11 +1417,9 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
1417 do { 1417 do {
1418 next = pmd_addr_end(addr, end); 1418 next = pmd_addr_end(addr, end);
1419 if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) { 1419 if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
1420 if (next - addr != HPAGE_PMD_SIZE) { 1420 if (next - addr != HPAGE_PMD_SIZE)
1421 VM_BUG_ON_VMA(vma_is_anonymous(vma) &&
1422 !rwsem_is_locked(&tlb->mm->mmap_sem), vma);
1423 __split_huge_pmd(vma, pmd, addr, false, NULL); 1421 __split_huge_pmd(vma, pmd, addr, false, NULL);
1424 } else if (zap_huge_pmd(tlb, vma, pmd, addr)) 1422 else if (zap_huge_pmd(tlb, vma, pmd, addr))
1425 goto next; 1423 goto next;
1426 /* fall through */ 1424 /* fall through */
1427 } 1425 }
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 9ac49ef17b4e..01f1a14facc4 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2505,6 +2505,7 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
2505 2505
2506 /* Create pseudo-vma that contains just the policy */ 2506 /* Create pseudo-vma that contains just the policy */
2507 memset(&pvma, 0, sizeof(struct vm_area_struct)); 2507 memset(&pvma, 0, sizeof(struct vm_area_struct));
2508 vma_init(&pvma, NULL);
2508 pvma.vm_end = TASK_SIZE; /* policy covers entire file */ 2509 pvma.vm_end = TASK_SIZE; /* policy covers entire file */
2509 mpol_set_shared_policy(sp, &pvma, new); /* adds ref */ 2510 mpol_set_shared_policy(sp, &pvma, new); /* adds ref */
2510 2511
diff --git a/mm/mmap.c b/mm/mmap.c
index 5801b5f0a634..17bbf4d3e24f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -182,7 +182,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
182 if (vma->vm_file) 182 if (vma->vm_file)
183 fput(vma->vm_file); 183 fput(vma->vm_file);
184 mpol_put(vma_policy(vma)); 184 mpol_put(vma_policy(vma));
185 kmem_cache_free(vm_area_cachep, vma); 185 vm_area_free(vma);
186 return next; 186 return next;
187} 187}
188 188
@@ -911,7 +911,7 @@ again:
911 anon_vma_merge(vma, next); 911 anon_vma_merge(vma, next);
912 mm->map_count--; 912 mm->map_count--;
913 mpol_put(vma_policy(next)); 913 mpol_put(vma_policy(next));
914 kmem_cache_free(vm_area_cachep, next); 914 vm_area_free(next);
915 /* 915 /*
916 * In mprotect's case 6 (see comments on vma_merge), 916 * In mprotect's case 6 (see comments on vma_merge),
917 * we must remove another next too. It would clutter 917 * we must remove another next too. It would clutter
@@ -1729,19 +1729,17 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
1729 * specific mapper. the address has already been validated, but 1729 * specific mapper. the address has already been validated, but
1730 * not unmapped, but the maps are removed from the list. 1730 * not unmapped, but the maps are removed from the list.
1731 */ 1731 */
1732 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 1732 vma = vm_area_alloc(mm);
1733 if (!vma) { 1733 if (!vma) {
1734 error = -ENOMEM; 1734 error = -ENOMEM;
1735 goto unacct_error; 1735 goto unacct_error;
1736 } 1736 }
1737 1737
1738 vma->vm_mm = mm;
1739 vma->vm_start = addr; 1738 vma->vm_start = addr;
1740 vma->vm_end = addr + len; 1739 vma->vm_end = addr + len;
1741 vma->vm_flags = vm_flags; 1740 vma->vm_flags = vm_flags;
1742 vma->vm_page_prot = vm_get_page_prot(vm_flags); 1741 vma->vm_page_prot = vm_get_page_prot(vm_flags);
1743 vma->vm_pgoff = pgoff; 1742 vma->vm_pgoff = pgoff;
1744 INIT_LIST_HEAD(&vma->anon_vma_chain);
1745 1743
1746 if (file) { 1744 if (file) {
1747 if (vm_flags & VM_DENYWRITE) { 1745 if (vm_flags & VM_DENYWRITE) {
@@ -1780,6 +1778,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
1780 error = shmem_zero_setup(vma); 1778 error = shmem_zero_setup(vma);
1781 if (error) 1779 if (error)
1782 goto free_vma; 1780 goto free_vma;
1781 } else {
1782 vma_set_anonymous(vma);
1783 } 1783 }
1784 1784
1785 vma_link(mm, vma, prev, rb_link, rb_parent); 1785 vma_link(mm, vma, prev, rb_link, rb_parent);
@@ -1832,7 +1832,7 @@ allow_write_and_free_vma:
1832 if (vm_flags & VM_DENYWRITE) 1832 if (vm_flags & VM_DENYWRITE)
1833 allow_write_access(file); 1833 allow_write_access(file);
1834free_vma: 1834free_vma:
1835 kmem_cache_free(vm_area_cachep, vma); 1835 vm_area_free(vma);
1836unacct_error: 1836unacct_error:
1837 if (charged) 1837 if (charged)
1838 vm_unacct_memory(charged); 1838 vm_unacct_memory(charged);
@@ -2620,15 +2620,10 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
2620 return err; 2620 return err;
2621 } 2621 }
2622 2622
2623 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); 2623 new = vm_area_dup(vma);
2624 if (!new) 2624 if (!new)
2625 return -ENOMEM; 2625 return -ENOMEM;
2626 2626
2627 /* most fields are the same, copy all, and then fixup */
2628 *new = *vma;
2629
2630 INIT_LIST_HEAD(&new->anon_vma_chain);
2631
2632 if (new_below) 2627 if (new_below)
2633 new->vm_end = addr; 2628 new->vm_end = addr;
2634 else { 2629 else {
@@ -2669,7 +2664,7 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
2669 out_free_mpol: 2664 out_free_mpol:
2670 mpol_put(vma_policy(new)); 2665 mpol_put(vma_policy(new));
2671 out_free_vma: 2666 out_free_vma:
2672 kmem_cache_free(vm_area_cachep, new); 2667 vm_area_free(new);
2673 return err; 2668 return err;
2674} 2669}
2675 2670
@@ -2984,14 +2979,13 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla
2984 /* 2979 /*
2985 * create a vma struct for an anonymous mapping 2980 * create a vma struct for an anonymous mapping
2986 */ 2981 */
2987 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 2982 vma = vm_area_alloc(mm);
2988 if (!vma) { 2983 if (!vma) {
2989 vm_unacct_memory(len >> PAGE_SHIFT); 2984 vm_unacct_memory(len >> PAGE_SHIFT);
2990 return -ENOMEM; 2985 return -ENOMEM;
2991 } 2986 }
2992 2987
2993 INIT_LIST_HEAD(&vma->anon_vma_chain); 2988 vma_set_anonymous(vma);
2994 vma->vm_mm = mm;
2995 vma->vm_start = addr; 2989 vma->vm_start = addr;
2996 vma->vm_end = addr + len; 2990 vma->vm_end = addr + len;
2997 vma->vm_pgoff = pgoff; 2991 vma->vm_pgoff = pgoff;
@@ -3202,16 +3196,14 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
3202 } 3196 }
3203 *need_rmap_locks = (new_vma->vm_pgoff <= vma->vm_pgoff); 3197 *need_rmap_locks = (new_vma->vm_pgoff <= vma->vm_pgoff);
3204 } else { 3198 } else {
3205 new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); 3199 new_vma = vm_area_dup(vma);
3206 if (!new_vma) 3200 if (!new_vma)
3207 goto out; 3201 goto out;
3208 *new_vma = *vma;
3209 new_vma->vm_start = addr; 3202 new_vma->vm_start = addr;
3210 new_vma->vm_end = addr + len; 3203 new_vma->vm_end = addr + len;
3211 new_vma->vm_pgoff = pgoff; 3204 new_vma->vm_pgoff = pgoff;
3212 if (vma_dup_policy(vma, new_vma)) 3205 if (vma_dup_policy(vma, new_vma))
3213 goto out_free_vma; 3206 goto out_free_vma;
3214 INIT_LIST_HEAD(&new_vma->anon_vma_chain);
3215 if (anon_vma_clone(new_vma, vma)) 3207 if (anon_vma_clone(new_vma, vma))
3216 goto out_free_mempol; 3208 goto out_free_mempol;
3217 if (new_vma->vm_file) 3209 if (new_vma->vm_file)
@@ -3226,7 +3218,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
3226out_free_mempol: 3218out_free_mempol:
3227 mpol_put(vma_policy(new_vma)); 3219 mpol_put(vma_policy(new_vma));
3228out_free_vma: 3220out_free_vma:
3229 kmem_cache_free(vm_area_cachep, new_vma); 3221 vm_area_free(new_vma);
3230out: 3222out:
3231 return NULL; 3223 return NULL;
3232} 3224}
@@ -3350,12 +3342,10 @@ static struct vm_area_struct *__install_special_mapping(
3350 int ret; 3342 int ret;
3351 struct vm_area_struct *vma; 3343 struct vm_area_struct *vma;
3352 3344
3353 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 3345 vma = vm_area_alloc(mm);
3354 if (unlikely(vma == NULL)) 3346 if (unlikely(vma == NULL))
3355 return ERR_PTR(-ENOMEM); 3347 return ERR_PTR(-ENOMEM);
3356 3348
3357 INIT_LIST_HEAD(&vma->anon_vma_chain);
3358 vma->vm_mm = mm;
3359 vma->vm_start = addr; 3349 vma->vm_start = addr;
3360 vma->vm_end = addr + len; 3350 vma->vm_end = addr + len;
3361 3351
@@ -3376,7 +3366,7 @@ static struct vm_area_struct *__install_special_mapping(
3376 return vma; 3366 return vma;
3377 3367
3378out: 3368out:
3379 kmem_cache_free(vm_area_cachep, vma); 3369 vm_area_free(vma);
3380 return ERR_PTR(ret); 3370 return ERR_PTR(ret);
3381} 3371}
3382 3372
diff --git a/mm/nommu.c b/mm/nommu.c
index 4452d8bd9ae4..9fc9e43335b6 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -769,7 +769,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma)
769 if (vma->vm_file) 769 if (vma->vm_file)
770 fput(vma->vm_file); 770 fput(vma->vm_file);
771 put_nommu_region(vma->vm_region); 771 put_nommu_region(vma->vm_region);
772 kmem_cache_free(vm_area_cachep, vma); 772 vm_area_free(vma);
773} 773}
774 774
775/* 775/*
@@ -1145,6 +1145,8 @@ static int do_mmap_private(struct vm_area_struct *vma,
1145 if (ret < len) 1145 if (ret < len)
1146 memset(base + ret, 0, len - ret); 1146 memset(base + ret, 0, len - ret);
1147 1147
1148 } else {
1149 vma_set_anonymous(vma);
1148 } 1150 }
1149 1151
1150 return 0; 1152 return 0;
@@ -1204,7 +1206,7 @@ unsigned long do_mmap(struct file *file,
1204 if (!region) 1206 if (!region)
1205 goto error_getting_region; 1207 goto error_getting_region;
1206 1208
1207 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 1209 vma = vm_area_alloc(current->mm);
1208 if (!vma) 1210 if (!vma)
1209 goto error_getting_vma; 1211 goto error_getting_vma;
1210 1212
@@ -1212,7 +1214,6 @@ unsigned long do_mmap(struct file *file,
1212 region->vm_flags = vm_flags; 1214 region->vm_flags = vm_flags;
1213 region->vm_pgoff = pgoff; 1215 region->vm_pgoff = pgoff;
1214 1216
1215 INIT_LIST_HEAD(&vma->anon_vma_chain);
1216 vma->vm_flags = vm_flags; 1217 vma->vm_flags = vm_flags;
1217 vma->vm_pgoff = pgoff; 1218 vma->vm_pgoff = pgoff;
1218 1219
@@ -1368,7 +1369,7 @@ error:
1368 kmem_cache_free(vm_region_jar, region); 1369 kmem_cache_free(vm_region_jar, region);
1369 if (vma->vm_file) 1370 if (vma->vm_file)
1370 fput(vma->vm_file); 1371 fput(vma->vm_file);
1371 kmem_cache_free(vm_area_cachep, vma); 1372 vm_area_free(vma);
1372 return ret; 1373 return ret;
1373 1374
1374sharing_violation: 1375sharing_violation:
@@ -1469,14 +1470,13 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
1469 if (!region) 1470 if (!region)
1470 return -ENOMEM; 1471 return -ENOMEM;
1471 1472
1472 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); 1473 new = vm_area_dup(vma);
1473 if (!new) { 1474 if (!new) {
1474 kmem_cache_free(vm_region_jar, region); 1475 kmem_cache_free(vm_region_jar, region);
1475 return -ENOMEM; 1476 return -ENOMEM;
1476 } 1477 }
1477 1478
1478 /* most fields are the same, copy all, and then fixup */ 1479 /* most fields are the same, copy all, and then fixup */
1479 *new = *vma;
1480 *region = *vma->vm_region; 1480 *region = *vma->vm_region;
1481 new->vm_region = region; 1481 new->vm_region = region;
1482 1482
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5d800d61ddb7..3222193c46c6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6383,7 +6383,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
6383 free_area_init_core(pgdat); 6383 free_area_init_core(pgdat);
6384} 6384}
6385 6385
6386#ifdef CONFIG_HAVE_MEMBLOCK 6386#if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP)
6387/* 6387/*
6388 * Only struct pages that are backed by physical memory are zeroed and 6388 * Only struct pages that are backed by physical memory are zeroed and
6389 * initialized by going through __init_single_page(). But, there are some 6389 * initialized by going through __init_single_page(). But, there are some
@@ -6421,7 +6421,7 @@ void __paginginit zero_resv_unavail(void)
6421 if (pgcnt) 6421 if (pgcnt)
6422 pr_info("Reserved but unavailable: %lld pages", pgcnt); 6422 pr_info("Reserved but unavailable: %lld pages", pgcnt);
6423} 6423}
6424#endif /* CONFIG_HAVE_MEMBLOCK */ 6424#endif /* CONFIG_HAVE_MEMBLOCK && !CONFIG_FLAT_NODE_MEM_MAP */
6425 6425
6426#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP 6426#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
6427 6427
@@ -6939,9 +6939,21 @@ unsigned long free_reserved_area(void *start, void *end, int poison, char *s)
6939 start = (void *)PAGE_ALIGN((unsigned long)start); 6939 start = (void *)PAGE_ALIGN((unsigned long)start);
6940 end = (void *)((unsigned long)end & PAGE_MASK); 6940 end = (void *)((unsigned long)end & PAGE_MASK);
6941 for (pos = start; pos < end; pos += PAGE_SIZE, pages++) { 6941 for (pos = start; pos < end; pos += PAGE_SIZE, pages++) {
6942 struct page *page = virt_to_page(pos);
6943 void *direct_map_addr;
6944
6945 /*
6946 * 'direct_map_addr' might be different from 'pos'
6947 * because some architectures' virt_to_page()
6948 * work with aliases. Getting the direct map
6949 * address ensures that we get a _writeable_
6950 * alias for the memset().
6951 */
6952 direct_map_addr = page_address(page);
6942 if ((unsigned int)poison <= 0xFF) 6953 if ((unsigned int)poison <= 0xFF)
6943 memset(pos, poison, PAGE_SIZE); 6954 memset(direct_map_addr, poison, PAGE_SIZE);
6944 free_reserved_page(virt_to_page(pos)); 6955
6956 free_reserved_page(page);
6945 } 6957 }
6946 6958
6947 if (pages && s) 6959 if (pages && s)
diff --git a/mm/shmem.c b/mm/shmem.c
index 2cab84403055..41b9bbf24e16 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1421,6 +1421,7 @@ static void shmem_pseudo_vma_init(struct vm_area_struct *vma,
1421{ 1421{
1422 /* Create a pseudo vma that just contains the policy */ 1422 /* Create a pseudo vma that just contains the policy */
1423 memset(vma, 0, sizeof(*vma)); 1423 memset(vma, 0, sizeof(*vma));
1424 vma_init(vma, NULL);
1424 /* Bias interleave by inode number to distribute better across nodes */ 1425 /* Bias interleave by inode number to distribute better across nodes */
1425 vma->vm_pgoff = index + info->vfs_inode.i_ino; 1426 vma->vm_pgoff = index + info->vfs_inode.i_ino;
1426 vma->vm_policy = mpol_shared_policy_lookup(&info->policy, index); 1427 vma->vm_policy = mpol_shared_policy_lookup(&info->policy, index);
diff --git a/mm/zswap.c b/mm/zswap.c
index 7d34e69507e3..cd91fd9d96b8 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1026,6 +1026,15 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
1026 ret = -ENOMEM; 1026 ret = -ENOMEM;
1027 goto reject; 1027 goto reject;
1028 } 1028 }
1029
1030 /* A second zswap_is_full() check after
1031 * zswap_shrink() to make sure it's now
1032 * under the max_pool_percent
1033 */
1034 if (zswap_is_full()) {
1035 ret = -ENOMEM;
1036 goto reject;
1037 }
1029 } 1038 }
1030 1039
1031 /* allocate entry */ 1040 /* allocate entry */
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index be09a9883825..73bf6a93a3cf 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2732,7 +2732,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
2732{ 2732{
2733 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 2733 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
2734 struct batadv_neigh_node *router; 2734 struct batadv_neigh_node *router;
2735 struct batadv_gw_node *curr_gw; 2735 struct batadv_gw_node *curr_gw = NULL;
2736 int ret = 0; 2736 int ret = 0;
2737 void *hdr; 2737 void *hdr;
2738 2738
@@ -2780,6 +2780,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
2780 ret = 0; 2780 ret = 0;
2781 2781
2782out: 2782out:
2783 if (curr_gw)
2784 batadv_gw_node_put(curr_gw);
2783 if (router_ifinfo) 2785 if (router_ifinfo)
2784 batadv_neigh_ifinfo_put(router_ifinfo); 2786 batadv_neigh_ifinfo_put(router_ifinfo);
2785 if (router) 2787 if (router)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index ec93337ee259..6baec4e68898 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
927{ 927{
928 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 928 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
929 struct batadv_neigh_node *router; 929 struct batadv_neigh_node *router;
930 struct batadv_gw_node *curr_gw; 930 struct batadv_gw_node *curr_gw = NULL;
931 int ret = 0; 931 int ret = 0;
932 void *hdr; 932 void *hdr;
933 933
@@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
995 ret = 0; 995 ret = 0;
996 996
997out: 997out:
998 if (curr_gw)
999 batadv_gw_node_put(curr_gw);
998 if (router_ifinfo) 1000 if (router_ifinfo)
999 batadv_neigh_ifinfo_put(router_ifinfo); 1001 batadv_neigh_ifinfo_put(router_ifinfo);
1000 if (router) 1002 if (router)
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index 4229b01ac7b5..87479c60670e 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -19,6 +19,7 @@
19#include "debugfs.h" 19#include "debugfs.h"
20#include "main.h" 20#include "main.h"
21 21
22#include <linux/dcache.h>
22#include <linux/debugfs.h> 23#include <linux/debugfs.h>
23#include <linux/err.h> 24#include <linux/err.h>
24#include <linux/errno.h> 25#include <linux/errno.h>
@@ -344,6 +345,25 @@ out:
344} 345}
345 346
346/** 347/**
348 * batadv_debugfs_rename_hardif() - Fix debugfs path for renamed hardif
349 * @hard_iface: hard interface which was renamed
350 */
351void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
352{
353 const char *name = hard_iface->net_dev->name;
354 struct dentry *dir;
355 struct dentry *d;
356
357 dir = hard_iface->debug_dir;
358 if (!dir)
359 return;
360
361 d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name);
362 if (!d)
363 pr_err("Can't rename debugfs dir to %s\n", name);
364}
365
366/**
347 * batadv_debugfs_del_hardif() - delete the base directory for a hard interface 367 * batadv_debugfs_del_hardif() - delete the base directory for a hard interface
348 * in debugfs. 368 * in debugfs.
349 * @hard_iface: hard interface which is deleted. 369 * @hard_iface: hard interface which is deleted.
@@ -414,6 +434,26 @@ out:
414} 434}
415 435
416/** 436/**
437 * batadv_debugfs_rename_meshif() - Fix debugfs path for renamed softif
438 * @dev: net_device which was renamed
439 */
440void batadv_debugfs_rename_meshif(struct net_device *dev)
441{
442 struct batadv_priv *bat_priv = netdev_priv(dev);
443 const char *name = dev->name;
444 struct dentry *dir;
445 struct dentry *d;
446
447 dir = bat_priv->debug_dir;
448 if (!dir)
449 return;
450
451 d = debugfs_rename(dir->d_parent, dir, dir->d_parent, name);
452 if (!d)
453 pr_err("Can't rename debugfs dir to %s\n", name);
454}
455
456/**
417 * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries 457 * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries
418 * @dev: netdev struct of the soft interface 458 * @dev: netdev struct of the soft interface
419 */ 459 */
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h
index 37b069698b04..08a592ffbee5 100644
--- a/net/batman-adv/debugfs.h
+++ b/net/batman-adv/debugfs.h
@@ -30,8 +30,10 @@ struct net_device;
30void batadv_debugfs_init(void); 30void batadv_debugfs_init(void);
31void batadv_debugfs_destroy(void); 31void batadv_debugfs_destroy(void);
32int batadv_debugfs_add_meshif(struct net_device *dev); 32int batadv_debugfs_add_meshif(struct net_device *dev);
33void batadv_debugfs_rename_meshif(struct net_device *dev);
33void batadv_debugfs_del_meshif(struct net_device *dev); 34void batadv_debugfs_del_meshif(struct net_device *dev);
34int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface); 35int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface);
36void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface);
35void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface); 37void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface);
36 38
37#else 39#else
@@ -49,6 +51,10 @@ static inline int batadv_debugfs_add_meshif(struct net_device *dev)
49 return 0; 51 return 0;
50} 52}
51 53
54static inline void batadv_debugfs_rename_meshif(struct net_device *dev)
55{
56}
57
52static inline void batadv_debugfs_del_meshif(struct net_device *dev) 58static inline void batadv_debugfs_del_meshif(struct net_device *dev)
53{ 59{
54} 60}
@@ -60,6 +66,11 @@ int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface)
60} 66}
61 67
62static inline 68static inline
69void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface)
70{
71}
72
73static inline
63void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface) 74void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface)
64{ 75{
65} 76}
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index c405d15befd6..2f0d42f2f913 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -989,6 +989,32 @@ void batadv_hardif_remove_interfaces(void)
989 rtnl_unlock(); 989 rtnl_unlock();
990} 990}
991 991
992/**
993 * batadv_hard_if_event_softif() - Handle events for soft interfaces
994 * @event: NETDEV_* event to handle
995 * @net_dev: net_device which generated an event
996 *
997 * Return: NOTIFY_* result
998 */
999static int batadv_hard_if_event_softif(unsigned long event,
1000 struct net_device *net_dev)
1001{
1002 struct batadv_priv *bat_priv;
1003
1004 switch (event) {
1005 case NETDEV_REGISTER:
1006 batadv_sysfs_add_meshif(net_dev);
1007 bat_priv = netdev_priv(net_dev);
1008 batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS);
1009 break;
1010 case NETDEV_CHANGENAME:
1011 batadv_debugfs_rename_meshif(net_dev);
1012 break;
1013 }
1014
1015 return NOTIFY_DONE;
1016}
1017
992static int batadv_hard_if_event(struct notifier_block *this, 1018static int batadv_hard_if_event(struct notifier_block *this,
993 unsigned long event, void *ptr) 1019 unsigned long event, void *ptr)
994{ 1020{
@@ -997,12 +1023,8 @@ static int batadv_hard_if_event(struct notifier_block *this,
997 struct batadv_hard_iface *primary_if = NULL; 1023 struct batadv_hard_iface *primary_if = NULL;
998 struct batadv_priv *bat_priv; 1024 struct batadv_priv *bat_priv;
999 1025
1000 if (batadv_softif_is_valid(net_dev) && event == NETDEV_REGISTER) { 1026 if (batadv_softif_is_valid(net_dev))
1001 batadv_sysfs_add_meshif(net_dev); 1027 return batadv_hard_if_event_softif(event, net_dev);
1002 bat_priv = netdev_priv(net_dev);
1003 batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS);
1004 return NOTIFY_DONE;
1005 }
1006 1028
1007 hard_iface = batadv_hardif_get_by_netdev(net_dev); 1029 hard_iface = batadv_hardif_get_by_netdev(net_dev);
1008 if (!hard_iface && (event == NETDEV_REGISTER || 1030 if (!hard_iface && (event == NETDEV_REGISTER ||
@@ -1051,6 +1073,9 @@ static int batadv_hard_if_event(struct notifier_block *this,
1051 if (batadv_is_wifi_hardif(hard_iface)) 1073 if (batadv_is_wifi_hardif(hard_iface))
1052 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; 1074 hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
1053 break; 1075 break;
1076 case NETDEV_CHANGENAME:
1077 batadv_debugfs_rename_hardif(hard_iface);
1078 break;
1054 default: 1079 default:
1055 break; 1080 break;
1056 } 1081 }
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 3986551397ca..12a2b7d21376 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1705,7 +1705,9 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
1705 ether_addr_copy(common->addr, tt_addr); 1705 ether_addr_copy(common->addr, tt_addr);
1706 common->vid = vid; 1706 common->vid = vid;
1707 1707
1708 common->flags = flags; 1708 if (!is_multicast_ether_addr(common->addr))
1709 common->flags = flags & (~BATADV_TT_SYNC_MASK);
1710
1709 tt_global_entry->roam_at = 0; 1711 tt_global_entry->roam_at = 0;
1710 /* node must store current time in case of roaming. This is 1712 /* node must store current time in case of roaming. This is
1711 * needed to purge this entry out on timeout (if nobody claims 1713 * needed to purge this entry out on timeout (if nobody claims
@@ -1768,7 +1770,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
1768 * TT_CLIENT_TEMP, therefore they have to be copied in the 1770 * TT_CLIENT_TEMP, therefore they have to be copied in the
1769 * client entry 1771 * client entry
1770 */ 1772 */
1771 common->flags |= flags & (~BATADV_TT_SYNC_MASK); 1773 if (!is_multicast_ether_addr(common->addr))
1774 common->flags |= flags & (~BATADV_TT_SYNC_MASK);
1772 1775
1773 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only 1776 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
1774 * one originator left in the list and we previously received a 1777 * one originator left in the list and we previously received a
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 68c3578343b4..22a78eedf4b1 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -96,6 +96,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
96 u32 size = kattr->test.data_size_in; 96 u32 size = kattr->test.data_size_in;
97 u32 repeat = kattr->test.repeat; 97 u32 repeat = kattr->test.repeat;
98 u32 retval, duration; 98 u32 retval, duration;
99 int hh_len = ETH_HLEN;
99 struct sk_buff *skb; 100 struct sk_buff *skb;
100 void *data; 101 void *data;
101 int ret; 102 int ret;
@@ -131,12 +132,22 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
131 skb_reset_network_header(skb); 132 skb_reset_network_header(skb);
132 133
133 if (is_l2) 134 if (is_l2)
134 __skb_push(skb, ETH_HLEN); 135 __skb_push(skb, hh_len);
135 if (is_direct_pkt_access) 136 if (is_direct_pkt_access)
136 bpf_compute_data_pointers(skb); 137 bpf_compute_data_pointers(skb);
137 retval = bpf_test_run(prog, skb, repeat, &duration); 138 retval = bpf_test_run(prog, skb, repeat, &duration);
138 if (!is_l2) 139 if (!is_l2) {
139 __skb_push(skb, ETH_HLEN); 140 if (skb_headroom(skb) < hh_len) {
141 int nhead = HH_DATA_ALIGN(hh_len - skb_headroom(skb));
142
143 if (pskb_expand_head(skb, nhead, 0, GFP_USER)) {
144 kfree_skb(skb);
145 return -ENOMEM;
146 }
147 }
148 memset(__skb_push(skb, hh_len), 0, hh_len);
149 }
150
140 size = skb->len; 151 size = skb->len;
141 /* bpf program can never convert linear skb to non-linear */ 152 /* bpf program can never convert linear skb to non-linear */
142 if (WARN_ON_ONCE(skb_is_nonlinear(skb))) 153 if (WARN_ON_ONCE(skb_is_nonlinear(skb)))
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index e0adcd123f48..711d7156efd8 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -131,8 +131,10 @@ static void caif_flow_cb(struct sk_buff *skb)
131 caifd = caif_get(skb->dev); 131 caifd = caif_get(skb->dev);
132 132
133 WARN_ON(caifd == NULL); 133 WARN_ON(caifd == NULL);
134 if (caifd == NULL) 134 if (!caifd) {
135 rcu_read_unlock();
135 return; 136 return;
137 }
136 138
137 caifd_hold(caifd); 139 caifd_hold(caifd);
138 rcu_read_unlock(); 140 rcu_read_unlock();
diff --git a/net/core/dev.c b/net/core/dev.c
index a5aa1c7444e6..559a91271f82 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7149,16 +7149,19 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len)
7149 dev->tx_queue_len = new_len; 7149 dev->tx_queue_len = new_len;
7150 res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev); 7150 res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
7151 res = notifier_to_errno(res); 7151 res = notifier_to_errno(res);
7152 if (res) { 7152 if (res)
7153 netdev_err(dev, 7153 goto err_rollback;
7154 "refused to change device tx_queue_len\n"); 7154 res = dev_qdisc_change_tx_queue_len(dev);
7155 dev->tx_queue_len = orig_len; 7155 if (res)
7156 return res; 7156 goto err_rollback;
7157 }
7158 return dev_qdisc_change_tx_queue_len(dev);
7159 } 7157 }
7160 7158
7161 return 0; 7159 return 0;
7160
7161err_rollback:
7162 netdev_err(dev, "refused to change device tx_queue_len\n");
7163 dev->tx_queue_len = orig_len;
7164 return res;
7162} 7165}
7163 7166
7164/** 7167/**
diff --git a/net/core/filter.c b/net/core/filter.c
index 0ca6907d7efe..9dfd145eedcc 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -459,11 +459,21 @@ static bool convert_bpf_ld_abs(struct sock_filter *fp, struct bpf_insn **insnp)
459 (!unaligned_ok && offset >= 0 && 459 (!unaligned_ok && offset >= 0 &&
460 offset + ip_align >= 0 && 460 offset + ip_align >= 0 &&
461 offset + ip_align % size == 0))) { 461 offset + ip_align % size == 0))) {
462 bool ldx_off_ok = offset <= S16_MAX;
463
462 *insn++ = BPF_MOV64_REG(BPF_REG_TMP, BPF_REG_H); 464 *insn++ = BPF_MOV64_REG(BPF_REG_TMP, BPF_REG_H);
463 *insn++ = BPF_ALU64_IMM(BPF_SUB, BPF_REG_TMP, offset); 465 *insn++ = BPF_ALU64_IMM(BPF_SUB, BPF_REG_TMP, offset);
464 *insn++ = BPF_JMP_IMM(BPF_JSLT, BPF_REG_TMP, size, 2 + endian); 466 *insn++ = BPF_JMP_IMM(BPF_JSLT, BPF_REG_TMP,
465 *insn++ = BPF_LDX_MEM(BPF_SIZE(fp->code), BPF_REG_A, BPF_REG_D, 467 size, 2 + endian + (!ldx_off_ok * 2));
466 offset); 468 if (ldx_off_ok) {
469 *insn++ = BPF_LDX_MEM(BPF_SIZE(fp->code), BPF_REG_A,
470 BPF_REG_D, offset);
471 } else {
472 *insn++ = BPF_MOV64_REG(BPF_REG_TMP, BPF_REG_D);
473 *insn++ = BPF_ALU64_IMM(BPF_ADD, BPF_REG_TMP, offset);
474 *insn++ = BPF_LDX_MEM(BPF_SIZE(fp->code), BPF_REG_A,
475 BPF_REG_TMP, 0);
476 }
467 if (endian) 477 if (endian)
468 *insn++ = BPF_ENDIAN(BPF_FROM_BE, BPF_REG_A, size * 8); 478 *insn++ = BPF_ENDIAN(BPF_FROM_BE, BPF_REG_A, size * 8);
469 *insn++ = BPF_JMP_A(8); 479 *insn++ = BPF_JMP_A(8);
@@ -1702,24 +1712,26 @@ static const struct bpf_func_proto bpf_skb_load_bytes_proto = {
1702BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb, 1712BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb,
1703 u32, offset, void *, to, u32, len, u32, start_header) 1713 u32, offset, void *, to, u32, len, u32, start_header)
1704{ 1714{
1715 u8 *end = skb_tail_pointer(skb);
1716 u8 *net = skb_network_header(skb);
1717 u8 *mac = skb_mac_header(skb);
1705 u8 *ptr; 1718 u8 *ptr;
1706 1719
1707 if (unlikely(offset > 0xffff || len > skb_headlen(skb))) 1720 if (unlikely(offset > 0xffff || len > (end - mac)))
1708 goto err_clear; 1721 goto err_clear;
1709 1722
1710 switch (start_header) { 1723 switch (start_header) {
1711 case BPF_HDR_START_MAC: 1724 case BPF_HDR_START_MAC:
1712 ptr = skb_mac_header(skb) + offset; 1725 ptr = mac + offset;
1713 break; 1726 break;
1714 case BPF_HDR_START_NET: 1727 case BPF_HDR_START_NET:
1715 ptr = skb_network_header(skb) + offset; 1728 ptr = net + offset;
1716 break; 1729 break;
1717 default: 1730 default:
1718 goto err_clear; 1731 goto err_clear;
1719 } 1732 }
1720 1733
1721 if (likely(ptr >= skb_mac_header(skb) && 1734 if (likely(ptr >= mac && ptr + len <= end)) {
1722 ptr + len <= skb_tail_pointer(skb))) {
1723 memcpy(to, ptr, len); 1735 memcpy(to, ptr, len);
1724 return 0; 1736 return 0;
1725 } 1737 }
@@ -1762,6 +1774,37 @@ static const struct bpf_func_proto bpf_skb_pull_data_proto = {
1762 .arg2_type = ARG_ANYTHING, 1774 .arg2_type = ARG_ANYTHING,
1763}; 1775};
1764 1776
1777static inline int sk_skb_try_make_writable(struct sk_buff *skb,
1778 unsigned int write_len)
1779{
1780 int err = __bpf_try_make_writable(skb, write_len);
1781
1782 bpf_compute_data_end_sk_skb(skb);
1783 return err;
1784}
1785
1786BPF_CALL_2(sk_skb_pull_data, struct sk_buff *, skb, u32, len)
1787{
1788 /* Idea is the following: should the needed direct read/write
1789 * test fail during runtime, we can pull in more data and redo
1790 * again, since implicitly, we invalidate previous checks here.
1791 *
1792 * Or, since we know how much we need to make read/writeable,
1793 * this can be done once at the program beginning for direct
1794 * access case. By this we overcome limitations of only current
1795 * headroom being accessible.
1796 */
1797 return sk_skb_try_make_writable(skb, len ? : skb_headlen(skb));
1798}
1799
1800static const struct bpf_func_proto sk_skb_pull_data_proto = {
1801 .func = sk_skb_pull_data,
1802 .gpl_only = false,
1803 .ret_type = RET_INTEGER,
1804 .arg1_type = ARG_PTR_TO_CTX,
1805 .arg2_type = ARG_ANYTHING,
1806};
1807
1765BPF_CALL_5(bpf_l3_csum_replace, struct sk_buff *, skb, u32, offset, 1808BPF_CALL_5(bpf_l3_csum_replace, struct sk_buff *, skb, u32, offset,
1766 u64, from, u64, to, u64, flags) 1809 u64, from, u64, to, u64, flags)
1767{ 1810{
@@ -2779,7 +2822,8 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff)
2779 2822
2780static u32 __bpf_skb_max_len(const struct sk_buff *skb) 2823static u32 __bpf_skb_max_len(const struct sk_buff *skb)
2781{ 2824{
2782 return skb->dev->mtu + skb->dev->hard_header_len; 2825 return skb->dev ? skb->dev->mtu + skb->dev->hard_header_len :
2826 SKB_MAX_ALLOC;
2783} 2827}
2784 2828
2785static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff) 2829static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff)
@@ -2863,8 +2907,8 @@ static int bpf_skb_trim_rcsum(struct sk_buff *skb, unsigned int new_len)
2863 return __skb_trim_rcsum(skb, new_len); 2907 return __skb_trim_rcsum(skb, new_len);
2864} 2908}
2865 2909
2866BPF_CALL_3(bpf_skb_change_tail, struct sk_buff *, skb, u32, new_len, 2910static inline int __bpf_skb_change_tail(struct sk_buff *skb, u32 new_len,
2867 u64, flags) 2911 u64 flags)
2868{ 2912{
2869 u32 max_len = __bpf_skb_max_len(skb); 2913 u32 max_len = __bpf_skb_max_len(skb);
2870 u32 min_len = __bpf_skb_min_len(skb); 2914 u32 min_len = __bpf_skb_min_len(skb);
@@ -2900,6 +2944,13 @@ BPF_CALL_3(bpf_skb_change_tail, struct sk_buff *, skb, u32, new_len,
2900 if (!ret && skb_is_gso(skb)) 2944 if (!ret && skb_is_gso(skb))
2901 skb_gso_reset(skb); 2945 skb_gso_reset(skb);
2902 } 2946 }
2947 return ret;
2948}
2949
2950BPF_CALL_3(bpf_skb_change_tail, struct sk_buff *, skb, u32, new_len,
2951 u64, flags)
2952{
2953 int ret = __bpf_skb_change_tail(skb, new_len, flags);
2903 2954
2904 bpf_compute_data_pointers(skb); 2955 bpf_compute_data_pointers(skb);
2905 return ret; 2956 return ret;
@@ -2914,9 +2965,27 @@ static const struct bpf_func_proto bpf_skb_change_tail_proto = {
2914 .arg3_type = ARG_ANYTHING, 2965 .arg3_type = ARG_ANYTHING,
2915}; 2966};
2916 2967
2917BPF_CALL_3(bpf_skb_change_head, struct sk_buff *, skb, u32, head_room, 2968BPF_CALL_3(sk_skb_change_tail, struct sk_buff *, skb, u32, new_len,
2918 u64, flags) 2969 u64, flags)
2919{ 2970{
2971 int ret = __bpf_skb_change_tail(skb, new_len, flags);
2972
2973 bpf_compute_data_end_sk_skb(skb);
2974 return ret;
2975}
2976
2977static const struct bpf_func_proto sk_skb_change_tail_proto = {
2978 .func = sk_skb_change_tail,
2979 .gpl_only = false,
2980 .ret_type = RET_INTEGER,
2981 .arg1_type = ARG_PTR_TO_CTX,
2982 .arg2_type = ARG_ANYTHING,
2983 .arg3_type = ARG_ANYTHING,
2984};
2985
2986static inline int __bpf_skb_change_head(struct sk_buff *skb, u32 head_room,
2987 u64 flags)
2988{
2920 u32 max_len = __bpf_skb_max_len(skb); 2989 u32 max_len = __bpf_skb_max_len(skb);
2921 u32 new_len = skb->len + head_room; 2990 u32 new_len = skb->len + head_room;
2922 int ret; 2991 int ret;
@@ -2941,8 +3010,16 @@ BPF_CALL_3(bpf_skb_change_head, struct sk_buff *, skb, u32, head_room,
2941 skb_reset_mac_header(skb); 3010 skb_reset_mac_header(skb);
2942 } 3011 }
2943 3012
3013 return ret;
3014}
3015
3016BPF_CALL_3(bpf_skb_change_head, struct sk_buff *, skb, u32, head_room,
3017 u64, flags)
3018{
3019 int ret = __bpf_skb_change_head(skb, head_room, flags);
3020
2944 bpf_compute_data_pointers(skb); 3021 bpf_compute_data_pointers(skb);
2945 return 0; 3022 return ret;
2946} 3023}
2947 3024
2948static const struct bpf_func_proto bpf_skb_change_head_proto = { 3025static const struct bpf_func_proto bpf_skb_change_head_proto = {
@@ -2954,6 +3031,23 @@ static const struct bpf_func_proto bpf_skb_change_head_proto = {
2954 .arg3_type = ARG_ANYTHING, 3031 .arg3_type = ARG_ANYTHING,
2955}; 3032};
2956 3033
3034BPF_CALL_3(sk_skb_change_head, struct sk_buff *, skb, u32, head_room,
3035 u64, flags)
3036{
3037 int ret = __bpf_skb_change_head(skb, head_room, flags);
3038
3039 bpf_compute_data_end_sk_skb(skb);
3040 return ret;
3041}
3042
3043static const struct bpf_func_proto sk_skb_change_head_proto = {
3044 .func = sk_skb_change_head,
3045 .gpl_only = false,
3046 .ret_type = RET_INTEGER,
3047 .arg1_type = ARG_PTR_TO_CTX,
3048 .arg2_type = ARG_ANYTHING,
3049 .arg3_type = ARG_ANYTHING,
3050};
2957static unsigned long xdp_get_metalen(const struct xdp_buff *xdp) 3051static unsigned long xdp_get_metalen(const struct xdp_buff *xdp)
2958{ 3052{
2959 return xdp_data_meta_unsupported(xdp) ? 0 : 3053 return xdp_data_meta_unsupported(xdp) ? 0 :
@@ -3046,12 +3140,16 @@ static int __bpf_tx_xdp(struct net_device *dev,
3046 u32 index) 3140 u32 index)
3047{ 3141{
3048 struct xdp_frame *xdpf; 3142 struct xdp_frame *xdpf;
3049 int sent; 3143 int err, sent;
3050 3144
3051 if (!dev->netdev_ops->ndo_xdp_xmit) { 3145 if (!dev->netdev_ops->ndo_xdp_xmit) {
3052 return -EOPNOTSUPP; 3146 return -EOPNOTSUPP;
3053 } 3147 }
3054 3148
3149 err = xdp_ok_fwd_dev(dev, xdp->data_end - xdp->data);
3150 if (unlikely(err))
3151 return err;
3152
3055 xdpf = convert_to_xdp_frame(xdp); 3153 xdpf = convert_to_xdp_frame(xdp);
3056 if (unlikely(!xdpf)) 3154 if (unlikely(!xdpf))
3057 return -EOVERFLOW; 3155 return -EOVERFLOW;
@@ -3285,7 +3383,8 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
3285 goto err; 3383 goto err;
3286 } 3384 }
3287 3385
3288 if (unlikely((err = __xdp_generic_ok_fwd_dev(skb, fwd)))) 3386 err = xdp_ok_fwd_dev(fwd, skb->len);
3387 if (unlikely(err))
3289 goto err; 3388 goto err;
3290 3389
3291 skb->dev = fwd; 3390 skb->dev = fwd;
@@ -4439,10 +4538,10 @@ static const struct bpf_func_proto bpf_lwt_push_encap_proto = {
4439 .arg4_type = ARG_CONST_SIZE 4538 .arg4_type = ARG_CONST_SIZE
4440}; 4539};
4441 4540
4541#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)
4442BPF_CALL_4(bpf_lwt_seg6_store_bytes, struct sk_buff *, skb, u32, offset, 4542BPF_CALL_4(bpf_lwt_seg6_store_bytes, struct sk_buff *, skb, u32, offset,
4443 const void *, from, u32, len) 4543 const void *, from, u32, len)
4444{ 4544{
4445#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)
4446 struct seg6_bpf_srh_state *srh_state = 4545 struct seg6_bpf_srh_state *srh_state =
4447 this_cpu_ptr(&seg6_bpf_srh_states); 4546 this_cpu_ptr(&seg6_bpf_srh_states);
4448 void *srh_tlvs, *srh_end, *ptr; 4547 void *srh_tlvs, *srh_end, *ptr;
@@ -4468,9 +4567,6 @@ BPF_CALL_4(bpf_lwt_seg6_store_bytes, struct sk_buff *, skb, u32, offset,
4468 4567
4469 memcpy(skb->data + offset, from, len); 4568 memcpy(skb->data + offset, from, len);
4470 return 0; 4569 return 0;
4471#else /* CONFIG_IPV6_SEG6_BPF */
4472 return -EOPNOTSUPP;
4473#endif
4474} 4570}
4475 4571
4476static const struct bpf_func_proto bpf_lwt_seg6_store_bytes_proto = { 4572static const struct bpf_func_proto bpf_lwt_seg6_store_bytes_proto = {
@@ -4486,7 +4582,6 @@ static const struct bpf_func_proto bpf_lwt_seg6_store_bytes_proto = {
4486BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb, 4582BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,
4487 u32, action, void *, param, u32, param_len) 4583 u32, action, void *, param, u32, param_len)
4488{ 4584{
4489#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)
4490 struct seg6_bpf_srh_state *srh_state = 4585 struct seg6_bpf_srh_state *srh_state =
4491 this_cpu_ptr(&seg6_bpf_srh_states); 4586 this_cpu_ptr(&seg6_bpf_srh_states);
4492 struct ipv6_sr_hdr *srh; 4587 struct ipv6_sr_hdr *srh;
@@ -4534,9 +4629,6 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,
4534 default: 4629 default:
4535 return -EINVAL; 4630 return -EINVAL;
4536 } 4631 }
4537#else /* CONFIG_IPV6_SEG6_BPF */
4538 return -EOPNOTSUPP;
4539#endif
4540} 4632}
4541 4633
4542static const struct bpf_func_proto bpf_lwt_seg6_action_proto = { 4634static const struct bpf_func_proto bpf_lwt_seg6_action_proto = {
@@ -4552,7 +4644,6 @@ static const struct bpf_func_proto bpf_lwt_seg6_action_proto = {
4552BPF_CALL_3(bpf_lwt_seg6_adjust_srh, struct sk_buff *, skb, u32, offset, 4644BPF_CALL_3(bpf_lwt_seg6_adjust_srh, struct sk_buff *, skb, u32, offset,
4553 s32, len) 4645 s32, len)
4554{ 4646{
4555#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)
4556 struct seg6_bpf_srh_state *srh_state = 4647 struct seg6_bpf_srh_state *srh_state =
4557 this_cpu_ptr(&seg6_bpf_srh_states); 4648 this_cpu_ptr(&seg6_bpf_srh_states);
4558 void *srh_end, *srh_tlvs, *ptr; 4649 void *srh_end, *srh_tlvs, *ptr;
@@ -4596,9 +4687,6 @@ BPF_CALL_3(bpf_lwt_seg6_adjust_srh, struct sk_buff *, skb, u32, offset,
4596 srh_state->hdrlen += len; 4687 srh_state->hdrlen += len;
4597 srh_state->valid = 0; 4688 srh_state->valid = 0;
4598 return 0; 4689 return 0;
4599#else /* CONFIG_IPV6_SEG6_BPF */
4600 return -EOPNOTSUPP;
4601#endif
4602} 4690}
4603 4691
4604static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = { 4692static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = {
@@ -4609,6 +4697,7 @@ static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = {
4609 .arg2_type = ARG_ANYTHING, 4697 .arg2_type = ARG_ANYTHING,
4610 .arg3_type = ARG_ANYTHING, 4698 .arg3_type = ARG_ANYTHING,
4611}; 4699};
4700#endif /* CONFIG_IPV6_SEG6_BPF */
4612 4701
4613bool bpf_helper_changes_pkt_data(void *func) 4702bool bpf_helper_changes_pkt_data(void *func)
4614{ 4703{
@@ -4617,9 +4706,12 @@ bool bpf_helper_changes_pkt_data(void *func)
4617 func == bpf_skb_store_bytes || 4706 func == bpf_skb_store_bytes ||
4618 func == bpf_skb_change_proto || 4707 func == bpf_skb_change_proto ||
4619 func == bpf_skb_change_head || 4708 func == bpf_skb_change_head ||
4709 func == sk_skb_change_head ||
4620 func == bpf_skb_change_tail || 4710 func == bpf_skb_change_tail ||
4711 func == sk_skb_change_tail ||
4621 func == bpf_skb_adjust_room || 4712 func == bpf_skb_adjust_room ||
4622 func == bpf_skb_pull_data || 4713 func == bpf_skb_pull_data ||
4714 func == sk_skb_pull_data ||
4623 func == bpf_clone_redirect || 4715 func == bpf_clone_redirect ||
4624 func == bpf_l3_csum_replace || 4716 func == bpf_l3_csum_replace ||
4625 func == bpf_l4_csum_replace || 4717 func == bpf_l4_csum_replace ||
@@ -4627,11 +4719,12 @@ bool bpf_helper_changes_pkt_data(void *func)
4627 func == bpf_xdp_adjust_meta || 4719 func == bpf_xdp_adjust_meta ||
4628 func == bpf_msg_pull_data || 4720 func == bpf_msg_pull_data ||
4629 func == bpf_xdp_adjust_tail || 4721 func == bpf_xdp_adjust_tail ||
4630 func == bpf_lwt_push_encap || 4722#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)
4631 func == bpf_lwt_seg6_store_bytes || 4723 func == bpf_lwt_seg6_store_bytes ||
4632 func == bpf_lwt_seg6_adjust_srh || 4724 func == bpf_lwt_seg6_adjust_srh ||
4633 func == bpf_lwt_seg6_action 4725 func == bpf_lwt_seg6_action ||
4634 ) 4726#endif
4727 func == bpf_lwt_push_encap)
4635 return true; 4728 return true;
4636 4729
4637 return false; 4730 return false;
@@ -4871,11 +4964,11 @@ sk_skb_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
4871 case BPF_FUNC_skb_load_bytes: 4964 case BPF_FUNC_skb_load_bytes:
4872 return &bpf_skb_load_bytes_proto; 4965 return &bpf_skb_load_bytes_proto;
4873 case BPF_FUNC_skb_pull_data: 4966 case BPF_FUNC_skb_pull_data:
4874 return &bpf_skb_pull_data_proto; 4967 return &sk_skb_pull_data_proto;
4875 case BPF_FUNC_skb_change_tail: 4968 case BPF_FUNC_skb_change_tail:
4876 return &bpf_skb_change_tail_proto; 4969 return &sk_skb_change_tail_proto;
4877 case BPF_FUNC_skb_change_head: 4970 case BPF_FUNC_skb_change_head:
4878 return &bpf_skb_change_head_proto; 4971 return &sk_skb_change_head_proto;
4879 case BPF_FUNC_get_socket_cookie: 4972 case BPF_FUNC_get_socket_cookie:
4880 return &bpf_get_socket_cookie_proto; 4973 return &bpf_get_socket_cookie_proto;
4881 case BPF_FUNC_get_socket_uid: 4974 case BPF_FUNC_get_socket_uid:
@@ -4966,12 +5059,14 @@ static const struct bpf_func_proto *
4966lwt_seg6local_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) 5059lwt_seg6local_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
4967{ 5060{
4968 switch (func_id) { 5061 switch (func_id) {
5062#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)
4969 case BPF_FUNC_lwt_seg6_store_bytes: 5063 case BPF_FUNC_lwt_seg6_store_bytes:
4970 return &bpf_lwt_seg6_store_bytes_proto; 5064 return &bpf_lwt_seg6_store_bytes_proto;
4971 case BPF_FUNC_lwt_seg6_action: 5065 case BPF_FUNC_lwt_seg6_action:
4972 return &bpf_lwt_seg6_action_proto; 5066 return &bpf_lwt_seg6_action_proto;
4973 case BPF_FUNC_lwt_seg6_adjust_srh: 5067 case BPF_FUNC_lwt_seg6_adjust_srh:
4974 return &bpf_lwt_seg6_adjust_srh_proto; 5068 return &bpf_lwt_seg6_adjust_srh_proto;
5069#endif
4975 default: 5070 default:
4976 return lwt_out_func_proto(func_id, prog); 5071 return lwt_out_func_proto(func_id, prog);
4977 } 5072 }
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index b2b2323bdc84..188d693cb251 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -77,8 +77,20 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
77 d->lock = lock; 77 d->lock = lock;
78 spin_lock_bh(lock); 78 spin_lock_bh(lock);
79 } 79 }
80 if (d->tail) 80 if (d->tail) {
81 return gnet_stats_copy(d, type, NULL, 0, padattr); 81 int ret = gnet_stats_copy(d, type, NULL, 0, padattr);
82
83 /* The initial attribute added in gnet_stats_copy() may be
84 * preceded by a padding attribute, in which case d->tail will
85 * end up pointing at the padding instead of the real attribute.
86 * Fix this so gnet_stats_finish_copy() adjusts the length of
87 * the right attribute.
88 */
89 if (ret == 0 && d->tail->nla_type == padattr)
90 d->tail = (struct nlattr *)((char *)d->tail +
91 NLA_ALIGN(d->tail->nla_len));
92 return ret;
93 }
82 94
83 return 0; 95 return 0;
84} 96}
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index e7e626fb87bb..e45098593dc0 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -217,7 +217,7 @@ static int bpf_parse_prog(struct nlattr *attr, struct bpf_lwt_prog *prog,
217 if (!tb[LWT_BPF_PROG_FD] || !tb[LWT_BPF_PROG_NAME]) 217 if (!tb[LWT_BPF_PROG_FD] || !tb[LWT_BPF_PROG_NAME])
218 return -EINVAL; 218 return -EINVAL;
219 219
220 prog->name = nla_memdup(tb[LWT_BPF_PROG_NAME], GFP_KERNEL); 220 prog->name = nla_memdup(tb[LWT_BPF_PROG_NAME], GFP_ATOMIC);
221 if (!prog->name) 221 if (!prog->name)
222 return -ENOMEM; 222 return -ENOMEM;
223 223
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 68bf07206744..43a932cb609b 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -269,7 +269,7 @@ static void __page_pool_empty_ring(struct page_pool *pool)
269 struct page *page; 269 struct page *page;
270 270
271 /* Empty recycle ring */ 271 /* Empty recycle ring */
272 while ((page = ptr_ring_consume(&pool->ring))) { 272 while ((page = ptr_ring_consume_bh(&pool->ring))) {
273 /* Verify the refcnt invariant of cached pages */ 273 /* Verify the refcnt invariant of cached pages */
274 if (!(page_ref_count(page) == 1)) 274 if (!(page_ref_count(page) == 1))
275 pr_crit("%s() page_pool refcnt %d violation\n", 275 pr_crit("%s() page_pool refcnt %d violation\n",
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 5ef61222fdef..e3f743c141b3 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2759,9 +2759,12 @@ int rtnl_configure_link(struct net_device *dev, const struct ifinfomsg *ifm)
2759 return err; 2759 return err;
2760 } 2760 }
2761 2761
2762 dev->rtnl_link_state = RTNL_LINK_INITIALIZED; 2762 if (dev->rtnl_link_state == RTNL_LINK_INITIALIZED) {
2763 2763 __dev_notify_flags(dev, old_flags, 0U);
2764 __dev_notify_flags(dev, old_flags, ~0U); 2764 } else {
2765 dev->rtnl_link_state = RTNL_LINK_INITIALIZED;
2766 __dev_notify_flags(dev, old_flags, ~0U);
2767 }
2765 return 0; 2768 return 0;
2766} 2769}
2767EXPORT_SYMBOL(rtnl_configure_link); 2770EXPORT_SYMBOL(rtnl_configure_link);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index eba8dae22c25..fb35b62af272 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -858,6 +858,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
858 n->cloned = 1; 858 n->cloned = 1;
859 n->nohdr = 0; 859 n->nohdr = 0;
860 n->peeked = 0; 860 n->peeked = 0;
861 C(pfmemalloc);
861 n->destructor = NULL; 862 n->destructor = NULL;
862 C(tail); 863 C(tail);
863 C(end); 864 C(end);
@@ -3719,6 +3720,7 @@ normal:
3719 net_warn_ratelimited( 3720 net_warn_ratelimited(
3720 "skb_segment: too many frags: %u %u\n", 3721 "skb_segment: too many frags: %u %u\n",
3721 pos, mss); 3722 pos, mss);
3723 err = -EINVAL;
3722 goto err; 3724 goto err;
3723 } 3725 }
3724 3726
@@ -3752,11 +3754,10 @@ skip_fraglist:
3752 3754
3753perform_csum_check: 3755perform_csum_check:
3754 if (!csum) { 3756 if (!csum) {
3755 if (skb_has_shared_frag(nskb)) { 3757 if (skb_has_shared_frag(nskb) &&
3756 err = __skb_linearize(nskb); 3758 __skb_linearize(nskb))
3757 if (err) 3759 goto err;
3758 goto err; 3760
3759 }
3760 if (!nskb->remcsum_offload) 3761 if (!nskb->remcsum_offload)
3761 nskb->ip_summed = CHECKSUM_NONE; 3762 nskb->ip_summed = CHECKSUM_NONE;
3762 SKB_GSO_CB(nskb)->csum = 3763 SKB_GSO_CB(nskb)->csum =
diff --git a/net/core/sock.c b/net/core/sock.c
index 9e8f65585b81..bc2d7a37297f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2277,9 +2277,9 @@ int sk_alloc_sg(struct sock *sk, int len, struct scatterlist *sg,
2277 pfrag->offset += use; 2277 pfrag->offset += use;
2278 2278
2279 sge = sg + sg_curr - 1; 2279 sge = sg + sg_curr - 1;
2280 if (sg_curr > first_coalesce && sg_page(sg) == pfrag->page && 2280 if (sg_curr > first_coalesce && sg_page(sge) == pfrag->page &&
2281 sg->offset + sg->length == orig_offset) { 2281 sge->offset + sge->length == orig_offset) {
2282 sg->length += use; 2282 sge->length += use;
2283 } else { 2283 } else {
2284 sge = sg + sg_curr; 2284 sge = sg + sg_curr;
2285 sg_unmark_end(sge); 2285 sg_unmark_end(sge);
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 9d1f22072d5d..6771f1855b96 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -345,7 +345,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
345 rcu_read_lock(); 345 rcu_read_lock();
346 /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */ 346 /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
347 xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params); 347 xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
348 xa->zc_alloc->free(xa->zc_alloc, handle); 348 if (!WARN_ON_ONCE(!xa))
349 xa->zc_alloc->free(xa->zc_alloc, handle);
349 rcu_read_unlock(); 350 rcu_read_unlock();
350 default: 351 default:
351 /* Not possible, checked in xdp_rxq_info_reg_mem_model() */ 352 /* Not possible, checked in xdp_rxq_info_reg_mem_model() */
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 40c851693f77..0c9478b91fa5 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -86,35 +86,39 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
86 opt++; 86 opt++;
87 kdebug("options: '%s'", opt); 87 kdebug("options: '%s'", opt);
88 do { 88 do {
89 int opt_len, opt_nlen;
89 const char *eq; 90 const char *eq;
90 int opt_len, opt_nlen, opt_vlen, tmp; 91 char optval[128];
91 92
92 next_opt = memchr(opt, '#', end - opt) ?: end; 93 next_opt = memchr(opt, '#', end - opt) ?: end;
93 opt_len = next_opt - opt; 94 opt_len = next_opt - opt;
94 if (opt_len <= 0 || opt_len > 128) { 95 if (opt_len <= 0 || opt_len > sizeof(optval)) {
95 pr_warn_ratelimited("Invalid option length (%d) for dns_resolver key\n", 96 pr_warn_ratelimited("Invalid option length (%d) for dns_resolver key\n",
96 opt_len); 97 opt_len);
97 return -EINVAL; 98 return -EINVAL;
98 } 99 }
99 100
100 eq = memchr(opt, '=', opt_len) ?: end; 101 eq = memchr(opt, '=', opt_len);
101 opt_nlen = eq - opt; 102 if (eq) {
102 eq++; 103 opt_nlen = eq - opt;
103 opt_vlen = next_opt - eq; /* will be -1 if no value */ 104 eq++;
105 memcpy(optval, eq, next_opt - eq);
106 optval[next_opt - eq] = '\0';
107 } else {
108 opt_nlen = opt_len;
109 optval[0] = '\0';
110 }
104 111
105 tmp = opt_vlen >= 0 ? opt_vlen : 0; 112 kdebug("option '%*.*s' val '%s'",
106 kdebug("option '%*.*s' val '%*.*s'", 113 opt_nlen, opt_nlen, opt, optval);
107 opt_nlen, opt_nlen, opt, tmp, tmp, eq);
108 114
109 /* see if it's an error number representing a DNS error 115 /* see if it's an error number representing a DNS error
110 * that's to be recorded as the result in this key */ 116 * that's to be recorded as the result in this key */
111 if (opt_nlen == sizeof(DNS_ERRORNO_OPTION) - 1 && 117 if (opt_nlen == sizeof(DNS_ERRORNO_OPTION) - 1 &&
112 memcmp(opt, DNS_ERRORNO_OPTION, opt_nlen) == 0) { 118 memcmp(opt, DNS_ERRORNO_OPTION, opt_nlen) == 0) {
113 kdebug("dns error number option"); 119 kdebug("dns error number option");
114 if (opt_vlen <= 0)
115 goto bad_option_value;
116 120
117 ret = kstrtoul(eq, 10, &derrno); 121 ret = kstrtoul(optval, 10, &derrno);
118 if (ret < 0) 122 if (ret < 0)
119 goto bad_option_value; 123 goto bad_option_value;
120 124
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 1e3b6a6d8a40..732369c80644 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1248,6 +1248,9 @@ int dsa_slave_suspend(struct net_device *slave_dev)
1248{ 1248{
1249 struct dsa_port *dp = dsa_slave_to_port(slave_dev); 1249 struct dsa_port *dp = dsa_slave_to_port(slave_dev);
1250 1250
1251 if (!netif_running(slave_dev))
1252 return 0;
1253
1251 netif_device_detach(slave_dev); 1254 netif_device_detach(slave_dev);
1252 1255
1253 rtnl_lock(); 1256 rtnl_lock();
@@ -1261,6 +1264,9 @@ int dsa_slave_resume(struct net_device *slave_dev)
1261{ 1264{
1262 struct dsa_port *dp = dsa_slave_to_port(slave_dev); 1265 struct dsa_port *dp = dsa_slave_to_port(slave_dev);
1263 1266
1267 if (!netif_running(slave_dev))
1268 return 0;
1269
1264 netif_device_attach(slave_dev); 1270 netif_device_attach(slave_dev);
1265 1271
1266 rtnl_lock(); 1272 rtnl_lock();
diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c
index 275449b0d633..3297e7fa9945 100644
--- a/net/ieee802154/6lowpan/core.c
+++ b/net/ieee802154/6lowpan/core.c
@@ -90,12 +90,18 @@ static int lowpan_neigh_construct(struct net_device *dev, struct neighbour *n)
90 return 0; 90 return 0;
91} 91}
92 92
93static int lowpan_get_iflink(const struct net_device *dev)
94{
95 return lowpan_802154_dev(dev)->wdev->ifindex;
96}
97
93static const struct net_device_ops lowpan_netdev_ops = { 98static const struct net_device_ops lowpan_netdev_ops = {
94 .ndo_init = lowpan_dev_init, 99 .ndo_init = lowpan_dev_init,
95 .ndo_start_xmit = lowpan_xmit, 100 .ndo_start_xmit = lowpan_xmit,
96 .ndo_open = lowpan_open, 101 .ndo_open = lowpan_open,
97 .ndo_stop = lowpan_stop, 102 .ndo_stop = lowpan_stop,
98 .ndo_neigh_construct = lowpan_neigh_construct, 103 .ndo_neigh_construct = lowpan_neigh_construct,
104 .ndo_get_iflink = lowpan_get_iflink,
99}; 105};
100 106
101static void lowpan_setup(struct net_device *ldev) 107static void lowpan_setup(struct net_device *ldev)
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index b21833651394..2998b0e47d4b 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -292,18 +292,19 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
292 return ip_hdr(skb)->daddr; 292 return ip_hdr(skb)->daddr;
293 293
294 in_dev = __in_dev_get_rcu(dev); 294 in_dev = __in_dev_get_rcu(dev);
295 BUG_ON(!in_dev);
296 295
297 net = dev_net(dev); 296 net = dev_net(dev);
298 297
299 scope = RT_SCOPE_UNIVERSE; 298 scope = RT_SCOPE_UNIVERSE;
300 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) { 299 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
300 bool vmark = in_dev && IN_DEV_SRC_VMARK(in_dev);
301 struct flowi4 fl4 = { 301 struct flowi4 fl4 = {
302 .flowi4_iif = LOOPBACK_IFINDEX, 302 .flowi4_iif = LOOPBACK_IFINDEX,
303 .flowi4_oif = l3mdev_master_ifindex_rcu(dev),
303 .daddr = ip_hdr(skb)->saddr, 304 .daddr = ip_hdr(skb)->saddr,
304 .flowi4_tos = RT_TOS(ip_hdr(skb)->tos), 305 .flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
305 .flowi4_scope = scope, 306 .flowi4_scope = scope,
306 .flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0, 307 .flowi4_mark = vmark ? skb->mark : 0,
307 }; 308 };
308 if (!fib_lookup(net, &fl4, &res, 0)) 309 if (!fib_lookup(net, &fl4, &res, 0))
309 return FIB_RES_PREFSRC(net, res); 310 return FIB_RES_PREFSRC(net, res);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 85b617b655bc..75151be21413 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1200,13 +1200,13 @@ static void igmpv3_del_delrec(struct in_device *in_dev, struct ip_mc_list *im)
1200 spin_lock_bh(&im->lock); 1200 spin_lock_bh(&im->lock);
1201 if (pmc) { 1201 if (pmc) {
1202 im->interface = pmc->interface; 1202 im->interface = pmc->interface;
1203 im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1203 if (im->sfmode == MCAST_INCLUDE) {
1204 im->sfmode = pmc->sfmode;
1205 if (pmc->sfmode == MCAST_INCLUDE) {
1206 im->tomb = pmc->tomb; 1204 im->tomb = pmc->tomb;
1207 im->sources = pmc->sources; 1205 im->sources = pmc->sources;
1208 for (psf = im->sources; psf; psf = psf->sf_next) 1206 for (psf = im->sources; psf; psf = psf->sf_next)
1209 psf->sf_crcount = im->crcount; 1207 psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
1208 } else {
1209 im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
1210 } 1210 }
1211 in_dev_put(pmc->interface); 1211 in_dev_put(pmc->interface);
1212 kfree(pmc); 1212 kfree(pmc);
@@ -1288,7 +1288,7 @@ static void igmp_group_dropped(struct ip_mc_list *im)
1288#endif 1288#endif
1289} 1289}
1290 1290
1291static void igmp_group_added(struct ip_mc_list *im) 1291static void igmp_group_added(struct ip_mc_list *im, unsigned int mode)
1292{ 1292{
1293 struct in_device *in_dev = im->interface; 1293 struct in_device *in_dev = im->interface;
1294#ifdef CONFIG_IP_MULTICAST 1294#ifdef CONFIG_IP_MULTICAST
@@ -1316,7 +1316,13 @@ static void igmp_group_added(struct ip_mc_list *im)
1316 } 1316 }
1317 /* else, v3 */ 1317 /* else, v3 */
1318 1318
1319 im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; 1319 /* Based on RFC3376 5.1, for newly added INCLUDE SSM, we should
1320 * not send filter-mode change record as the mode should be from
1321 * IN() to IN(A).
1322 */
1323 if (mode == MCAST_EXCLUDE)
1324 im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv;
1325
1320 igmp_ifc_event(in_dev); 1326 igmp_ifc_event(in_dev);
1321#endif 1327#endif
1322} 1328}
@@ -1381,8 +1387,8 @@ static void ip_mc_hash_remove(struct in_device *in_dev,
1381/* 1387/*
1382 * A socket has joined a multicast group on device dev. 1388 * A socket has joined a multicast group on device dev.
1383 */ 1389 */
1384 1390static void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
1385void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) 1391 unsigned int mode)
1386{ 1392{
1387 struct ip_mc_list *im; 1393 struct ip_mc_list *im;
1388#ifdef CONFIG_IP_MULTICAST 1394#ifdef CONFIG_IP_MULTICAST
@@ -1394,7 +1400,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1394 for_each_pmc_rtnl(in_dev, im) { 1400 for_each_pmc_rtnl(in_dev, im) {
1395 if (im->multiaddr == addr) { 1401 if (im->multiaddr == addr) {
1396 im->users++; 1402 im->users++;
1397 ip_mc_add_src(in_dev, &addr, MCAST_EXCLUDE, 0, NULL, 0); 1403 ip_mc_add_src(in_dev, &addr, mode, 0, NULL, 0);
1398 goto out; 1404 goto out;
1399 } 1405 }
1400 } 1406 }
@@ -1408,8 +1414,8 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1408 in_dev_hold(in_dev); 1414 in_dev_hold(in_dev);
1409 im->multiaddr = addr; 1415 im->multiaddr = addr;
1410 /* initial mode is (EX, empty) */ 1416 /* initial mode is (EX, empty) */
1411 im->sfmode = MCAST_EXCLUDE; 1417 im->sfmode = mode;
1412 im->sfcount[MCAST_EXCLUDE] = 1; 1418 im->sfcount[mode] = 1;
1413 refcount_set(&im->refcnt, 1); 1419 refcount_set(&im->refcnt, 1);
1414 spin_lock_init(&im->lock); 1420 spin_lock_init(&im->lock);
1415#ifdef CONFIG_IP_MULTICAST 1421#ifdef CONFIG_IP_MULTICAST
@@ -1426,12 +1432,17 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1426#ifdef CONFIG_IP_MULTICAST 1432#ifdef CONFIG_IP_MULTICAST
1427 igmpv3_del_delrec(in_dev, im); 1433 igmpv3_del_delrec(in_dev, im);
1428#endif 1434#endif
1429 igmp_group_added(im); 1435 igmp_group_added(im, mode);
1430 if (!in_dev->dead) 1436 if (!in_dev->dead)
1431 ip_rt_multicast_event(in_dev); 1437 ip_rt_multicast_event(in_dev);
1432out: 1438out:
1433 return; 1439 return;
1434} 1440}
1441
1442void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1443{
1444 __ip_mc_inc_group(in_dev, addr, MCAST_EXCLUDE);
1445}
1435EXPORT_SYMBOL(ip_mc_inc_group); 1446EXPORT_SYMBOL(ip_mc_inc_group);
1436 1447
1437static int ip_mc_check_iphdr(struct sk_buff *skb) 1448static int ip_mc_check_iphdr(struct sk_buff *skb)
@@ -1688,7 +1699,7 @@ void ip_mc_remap(struct in_device *in_dev)
1688#ifdef CONFIG_IP_MULTICAST 1699#ifdef CONFIG_IP_MULTICAST
1689 igmpv3_del_delrec(in_dev, pmc); 1700 igmpv3_del_delrec(in_dev, pmc);
1690#endif 1701#endif
1691 igmp_group_added(pmc); 1702 igmp_group_added(pmc, pmc->sfmode);
1692 } 1703 }
1693} 1704}
1694 1705
@@ -1751,7 +1762,7 @@ void ip_mc_up(struct in_device *in_dev)
1751#ifdef CONFIG_IP_MULTICAST 1762#ifdef CONFIG_IP_MULTICAST
1752 igmpv3_del_delrec(in_dev, pmc); 1763 igmpv3_del_delrec(in_dev, pmc);
1753#endif 1764#endif
1754 igmp_group_added(pmc); 1765 igmp_group_added(pmc, pmc->sfmode);
1755 } 1766 }
1756} 1767}
1757 1768
@@ -2130,8 +2141,8 @@ static void ip_mc_clear_src(struct ip_mc_list *pmc)
2130 2141
2131/* Join a multicast group 2142/* Join a multicast group
2132 */ 2143 */
2133 2144static int __ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr,
2134int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr) 2145 unsigned int mode)
2135{ 2146{
2136 __be32 addr = imr->imr_multiaddr.s_addr; 2147 __be32 addr = imr->imr_multiaddr.s_addr;
2137 struct ip_mc_socklist *iml, *i; 2148 struct ip_mc_socklist *iml, *i;
@@ -2172,15 +2183,30 @@ int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr)
2172 memcpy(&iml->multi, imr, sizeof(*imr)); 2183 memcpy(&iml->multi, imr, sizeof(*imr));
2173 iml->next_rcu = inet->mc_list; 2184 iml->next_rcu = inet->mc_list;
2174 iml->sflist = NULL; 2185 iml->sflist = NULL;
2175 iml->sfmode = MCAST_EXCLUDE; 2186 iml->sfmode = mode;
2176 rcu_assign_pointer(inet->mc_list, iml); 2187 rcu_assign_pointer(inet->mc_list, iml);
2177 ip_mc_inc_group(in_dev, addr); 2188 __ip_mc_inc_group(in_dev, addr, mode);
2178 err = 0; 2189 err = 0;
2179done: 2190done:
2180 return err; 2191 return err;
2181} 2192}
2193
2194/* Join ASM (Any-Source Multicast) group
2195 */
2196int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr)
2197{
2198 return __ip_mc_join_group(sk, imr, MCAST_EXCLUDE);
2199}
2182EXPORT_SYMBOL(ip_mc_join_group); 2200EXPORT_SYMBOL(ip_mc_join_group);
2183 2201
2202/* Join SSM (Source-Specific Multicast) group
2203 */
2204int ip_mc_join_group_ssm(struct sock *sk, struct ip_mreqn *imr,
2205 unsigned int mode)
2206{
2207 return __ip_mc_join_group(sk, imr, mode);
2208}
2209
2184static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml, 2210static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
2185 struct in_device *in_dev) 2211 struct in_device *in_dev)
2186{ 2212{
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index c9e35b81d093..0d70608cc2e1 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -90,7 +90,7 @@ static void inet_frags_free_cb(void *ptr, void *arg)
90 90
91void inet_frags_exit_net(struct netns_frags *nf) 91void inet_frags_exit_net(struct netns_frags *nf)
92{ 92{
93 nf->low_thresh = 0; /* prevent creation of new frags */ 93 nf->high_thresh = 0; /* prevent creation of new frags */
94 94
95 rhashtable_free_and_destroy(&nf->rhashtable, inet_frags_free_cb, NULL); 95 rhashtable_free_and_destroy(&nf->rhashtable, inet_frags_free_cb, NULL);
96} 96}
@@ -157,9 +157,6 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
157{ 157{
158 struct inet_frag_queue *q; 158 struct inet_frag_queue *q;
159 159
160 if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh)
161 return NULL;
162
163 q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC); 160 q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC);
164 if (!q) 161 if (!q)
165 return NULL; 162 return NULL;
@@ -204,6 +201,9 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, void *key)
204{ 201{
205 struct inet_frag_queue *fq; 202 struct inet_frag_queue *fq;
206 203
204 if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh)
205 return NULL;
206
207 rcu_read_lock(); 207 rcu_read_lock();
208 208
209 fq = rhashtable_lookup(&nf->rhashtable, key, nf->f->rhash_params); 209 fq = rhashtable_lookup(&nf->rhashtable, key, nf->f->rhash_params);
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 8e9528ebaa8e..d14d741fb05e 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -383,11 +383,16 @@ found:
383 int i = end - next->ip_defrag_offset; /* overlap is 'i' bytes */ 383 int i = end - next->ip_defrag_offset; /* overlap is 'i' bytes */
384 384
385 if (i < next->len) { 385 if (i < next->len) {
386 int delta = -next->truesize;
387
386 /* Eat head of the next overlapped fragment 388 /* Eat head of the next overlapped fragment
387 * and leave the loop. The next ones cannot overlap. 389 * and leave the loop. The next ones cannot overlap.
388 */ 390 */
389 if (!pskb_pull(next, i)) 391 if (!pskb_pull(next, i))
390 goto err; 392 goto err;
393 delta += next->truesize;
394 if (delta)
395 add_frag_mem_limit(qp->q.net, delta);
391 next->ip_defrag_offset += i; 396 next->ip_defrag_offset += i;
392 qp->q.meat -= i; 397 qp->q.meat -= i;
393 if (next->ip_summed != CHECKSUM_UNNECESSARY) 398 if (next->ip_summed != CHECKSUM_UNNECESSARY)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index b3308e9d9762..0e3edd25f881 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -523,6 +523,8 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
523 to->dev = from->dev; 523 to->dev = from->dev;
524 to->mark = from->mark; 524 to->mark = from->mark;
525 525
526 skb_copy_hash(to, from);
527
526 /* Copy the flags to each fragment. */ 528 /* Copy the flags to each fragment. */
527 IPCB(to)->flags = IPCB(from)->flags; 529 IPCB(to)->flags = IPCB(from)->flags;
528 530
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index fc32fdbeefa6..c0fe5ad996f2 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -150,15 +150,18 @@ static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
150{ 150{
151 struct sockaddr_in sin; 151 struct sockaddr_in sin;
152 const struct iphdr *iph = ip_hdr(skb); 152 const struct iphdr *iph = ip_hdr(skb);
153 __be16 *ports = (__be16 *)skb_transport_header(skb); 153 __be16 *ports;
154 int end;
154 155
155 if (skb_transport_offset(skb) + 4 > (int)skb->len) 156 end = skb_transport_offset(skb) + 4;
157 if (end > 0 && !pskb_may_pull(skb, end))
156 return; 158 return;
157 159
158 /* All current transport protocols have the port numbers in the 160 /* All current transport protocols have the port numbers in the
159 * first four bytes of the transport header and this function is 161 * first four bytes of the transport header and this function is
160 * written with this assumption in mind. 162 * written with this assumption in mind.
161 */ 163 */
164 ports = (__be16 *)skb_transport_header(skb);
162 165
163 sin.sin_family = AF_INET; 166 sin.sin_family = AF_INET;
164 sin.sin_addr.s_addr = iph->daddr; 167 sin.sin_addr.s_addr = iph->daddr;
@@ -984,7 +987,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
984 mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr; 987 mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr;
985 mreq.imr_address.s_addr = mreqs.imr_interface; 988 mreq.imr_address.s_addr = mreqs.imr_interface;
986 mreq.imr_ifindex = 0; 989 mreq.imr_ifindex = 0;
987 err = ip_mc_join_group(sk, &mreq); 990 err = ip_mc_join_group_ssm(sk, &mreq, MCAST_INCLUDE);
988 if (err && err != -EADDRINUSE) 991 if (err && err != -EADDRINUSE)
989 break; 992 break;
990 omode = MCAST_INCLUDE; 993 omode = MCAST_INCLUDE;
@@ -1061,7 +1064,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
1061 mreq.imr_multiaddr = psin->sin_addr; 1064 mreq.imr_multiaddr = psin->sin_addr;
1062 mreq.imr_address.s_addr = 0; 1065 mreq.imr_address.s_addr = 0;
1063 mreq.imr_ifindex = greqs.gsr_interface; 1066 mreq.imr_ifindex = greqs.gsr_interface;
1064 err = ip_mc_join_group(sk, &mreq); 1067 err = ip_mc_join_group_ssm(sk, &mreq, MCAST_INCLUDE);
1065 if (err && err != -EADDRINUSE) 1068 if (err && err != -EADDRINUSE)
1066 break; 1069 break;
1067 greqs.gsr_interface = mreq.imr_ifindex; 1070 greqs.gsr_interface = mreq.imr_ifindex;
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index ca0dad90803a..e77872c93c20 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -1898,6 +1898,7 @@ static struct xt_match ipt_builtin_mt[] __read_mostly = {
1898 .checkentry = icmp_checkentry, 1898 .checkentry = icmp_checkentry,
1899 .proto = IPPROTO_ICMP, 1899 .proto = IPPROTO_ICMP,
1900 .family = NFPROTO_IPV4, 1900 .family = NFPROTO_IPV4,
1901 .me = THIS_MODULE,
1901 }, 1902 },
1902}; 1903};
1903 1904
diff --git a/net/ipv4/netfilter/nf_tproxy_ipv4.c b/net/ipv4/netfilter/nf_tproxy_ipv4.c
index 805e83ec3ad9..164714104965 100644
--- a/net/ipv4/netfilter/nf_tproxy_ipv4.c
+++ b/net/ipv4/netfilter/nf_tproxy_ipv4.c
@@ -37,7 +37,7 @@ nf_tproxy_handle_time_wait4(struct net *net, struct sk_buff *skb,
37 * to a listener socket if there's one */ 37 * to a listener socket if there's one */
38 struct sock *sk2; 38 struct sock *sk2;
39 39
40 sk2 = nf_tproxy_get_sock_v4(net, skb, hp, iph->protocol, 40 sk2 = nf_tproxy_get_sock_v4(net, skb, iph->protocol,
41 iph->saddr, laddr ? laddr : iph->daddr, 41 iph->saddr, laddr ? laddr : iph->daddr,
42 hp->source, lport ? lport : hp->dest, 42 hp->source, lport ? lport : hp->dest,
43 skb->dev, NF_TPROXY_LOOKUP_LISTENER); 43 skb->dev, NF_TPROXY_LOOKUP_LISTENER);
@@ -71,7 +71,7 @@ __be32 nf_tproxy_laddr4(struct sk_buff *skb, __be32 user_laddr, __be32 daddr)
71EXPORT_SYMBOL_GPL(nf_tproxy_laddr4); 71EXPORT_SYMBOL_GPL(nf_tproxy_laddr4);
72 72
73struct sock * 73struct sock *
74nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp, 74nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb,
75 const u8 protocol, 75 const u8 protocol,
76 const __be32 saddr, const __be32 daddr, 76 const __be32 saddr, const __be32 daddr,
77 const __be16 sport, const __be16 dport, 77 const __be16 sport, const __be16 dport,
@@ -79,16 +79,21 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp,
79 const enum nf_tproxy_lookup_t lookup_type) 79 const enum nf_tproxy_lookup_t lookup_type)
80{ 80{
81 struct sock *sk; 81 struct sock *sk;
82 struct tcphdr *tcph;
83 82
84 switch (protocol) { 83 switch (protocol) {
85 case IPPROTO_TCP: 84 case IPPROTO_TCP: {
85 struct tcphdr _hdr, *hp;
86
87 hp = skb_header_pointer(skb, ip_hdrlen(skb),
88 sizeof(struct tcphdr), &_hdr);
89 if (hp == NULL)
90 return NULL;
91
86 switch (lookup_type) { 92 switch (lookup_type) {
87 case NF_TPROXY_LOOKUP_LISTENER: 93 case NF_TPROXY_LOOKUP_LISTENER:
88 tcph = hp;
89 sk = inet_lookup_listener(net, &tcp_hashinfo, skb, 94 sk = inet_lookup_listener(net, &tcp_hashinfo, skb,
90 ip_hdrlen(skb) + 95 ip_hdrlen(skb) +
91 __tcp_hdrlen(tcph), 96 __tcp_hdrlen(hp),
92 saddr, sport, 97 saddr, sport,
93 daddr, dport, 98 daddr, dport,
94 in->ifindex, 0); 99 in->ifindex, 0);
@@ -110,6 +115,7 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp,
110 BUG(); 115 BUG();
111 } 116 }
112 break; 117 break;
118 }
113 case IPPROTO_UDP: 119 case IPPROTO_UDP:
114 sk = udp4_lib_lookup(net, saddr, sport, daddr, dport, 120 sk = udp4_lib_lookup(net, saddr, sport, daddr, dport,
115 in->ifindex); 121 in->ifindex);
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index af0a857d8352..5fa335fd3852 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -189,8 +189,9 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
189 if (write && ret == 0) { 189 if (write && ret == 0) {
190 low = make_kgid(user_ns, urange[0]); 190 low = make_kgid(user_ns, urange[0]);
191 high = make_kgid(user_ns, urange[1]); 191 high = make_kgid(user_ns, urange[1]);
192 if (!gid_valid(low) || !gid_valid(high) || 192 if (!gid_valid(low) || !gid_valid(high))
193 (urange[1] < urange[0]) || gid_lt(high, low)) { 193 return -EINVAL;
194 if (urange[1] < urange[0] || gid_lt(high, low)) {
194 low = make_kgid(&init_user_ns, 1); 195 low = make_kgid(&init_user_ns, 1);
195 high = make_kgid(&init_user_ns, 0); 196 high = make_kgid(&init_user_ns, 0);
196 } 197 }
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e7b53d2a971f..4491faf83f4f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1998,7 +1998,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
1998 * shouldn't happen. 1998 * shouldn't happen.
1999 */ 1999 */
2000 if (WARN(before(*seq, TCP_SKB_CB(skb)->seq), 2000 if (WARN(before(*seq, TCP_SKB_CB(skb)->seq),
2001 "recvmsg bug: copied %X seq %X rcvnxt %X fl %X\n", 2001 "TCP recvmsg seq # bug: copied %X, seq %X, rcvnxt %X, fl %X\n",
2002 *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, 2002 *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt,
2003 flags)) 2003 flags))
2004 break; 2004 break;
@@ -2013,7 +2013,7 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
2013 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) 2013 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
2014 goto found_fin_ok; 2014 goto found_fin_ok;
2015 WARN(!(flags & MSG_PEEK), 2015 WARN(!(flags & MSG_PEEK),
2016 "recvmsg bug 2: copied %X seq %X rcvnxt %X fl %X\n", 2016 "TCP recvmsg seq # bug 2: copied %X, seq %X, rcvnxt %X, fl %X\n",
2017 *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags); 2017 *seq, TCP_SKB_CB(skb)->seq, tp->rcv_nxt, flags);
2018 } 2018 }
2019 2019
@@ -2562,6 +2562,8 @@ int tcp_disconnect(struct sock *sk, int flags)
2562 2562
2563 tcp_clear_xmit_timers(sk); 2563 tcp_clear_xmit_timers(sk);
2564 __skb_queue_purge(&sk->sk_receive_queue); 2564 __skb_queue_purge(&sk->sk_receive_queue);
2565 tp->copied_seq = tp->rcv_nxt;
2566 tp->urg_data = 0;
2565 tcp_write_queue_purge(sk); 2567 tcp_write_queue_purge(sk);
2566 tcp_fastopen_active_disable_ofo_check(sk); 2568 tcp_fastopen_active_disable_ofo_check(sk);
2567 skb_rbtree_purge(&tp->out_of_order_queue); 2569 skb_rbtree_purge(&tp->out_of_order_queue);
@@ -2821,14 +2823,17 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2821 case TCP_REPAIR: 2823 case TCP_REPAIR:
2822 if (!tcp_can_repair_sock(sk)) 2824 if (!tcp_can_repair_sock(sk))
2823 err = -EPERM; 2825 err = -EPERM;
2824 else if (val == 1) { 2826 else if (val == TCP_REPAIR_ON) {
2825 tp->repair = 1; 2827 tp->repair = 1;
2826 sk->sk_reuse = SK_FORCE_REUSE; 2828 sk->sk_reuse = SK_FORCE_REUSE;
2827 tp->repair_queue = TCP_NO_QUEUE; 2829 tp->repair_queue = TCP_NO_QUEUE;
2828 } else if (val == 0) { 2830 } else if (val == TCP_REPAIR_OFF) {
2829 tp->repair = 0; 2831 tp->repair = 0;
2830 sk->sk_reuse = SK_NO_REUSE; 2832 sk->sk_reuse = SK_NO_REUSE;
2831 tcp_send_window_probe(sk); 2833 tcp_send_window_probe(sk);
2834 } else if (val == TCP_REPAIR_OFF_NO_WP) {
2835 tp->repair = 0;
2836 sk->sk_reuse = SK_NO_REUSE;
2832 } else 2837 } else
2833 err = -EINVAL; 2838 err = -EINVAL;
2834 2839
@@ -3720,8 +3725,7 @@ int tcp_abort(struct sock *sk, int err)
3720 struct request_sock *req = inet_reqsk(sk); 3725 struct request_sock *req = inet_reqsk(sk);
3721 3726
3722 local_bh_disable(); 3727 local_bh_disable();
3723 inet_csk_reqsk_queue_drop_and_put(req->rsk_listener, 3728 inet_csk_reqsk_queue_drop(req->rsk_listener, req);
3724 req);
3725 local_bh_enable(); 3729 local_bh_enable();
3726 return 0; 3730 return 0;
3727 } 3731 }
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c
index 58e2f479ffb4..4bfff3c87e8e 100644
--- a/net/ipv4/tcp_bbr.c
+++ b/net/ipv4/tcp_bbr.c
@@ -354,6 +354,10 @@ static u32 bbr_target_cwnd(struct sock *sk, u32 bw, int gain)
354 /* Reduce delayed ACKs by rounding up cwnd to the next even number. */ 354 /* Reduce delayed ACKs by rounding up cwnd to the next even number. */
355 cwnd = (cwnd + 1) & ~1U; 355 cwnd = (cwnd + 1) & ~1U;
356 356
357 /* Ensure gain cycling gets inflight above BDP even for small BDPs. */
358 if (bbr->mode == BBR_PROBE_BW && gain > BBR_UNIT)
359 cwnd += 2;
360
357 return cwnd; 361 return cwnd;
358} 362}
359 363
diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
index 5f5e5936760e..8b637f9f23a2 100644
--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -55,7 +55,6 @@ struct dctcp {
55 u32 dctcp_alpha; 55 u32 dctcp_alpha;
56 u32 next_seq; 56 u32 next_seq;
57 u32 ce_state; 57 u32 ce_state;
58 u32 delayed_ack_reserved;
59 u32 loss_cwnd; 58 u32 loss_cwnd;
60}; 59};
61 60
@@ -96,7 +95,6 @@ static void dctcp_init(struct sock *sk)
96 95
97 ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA); 96 ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
98 97
99 ca->delayed_ack_reserved = 0;
100 ca->loss_cwnd = 0; 98 ca->loss_cwnd = 0;
101 ca->ce_state = 0; 99 ca->ce_state = 0;
102 100
@@ -131,23 +129,14 @@ static void dctcp_ce_state_0_to_1(struct sock *sk)
131 struct dctcp *ca = inet_csk_ca(sk); 129 struct dctcp *ca = inet_csk_ca(sk);
132 struct tcp_sock *tp = tcp_sk(sk); 130 struct tcp_sock *tp = tcp_sk(sk);
133 131
134 /* State has changed from CE=0 to CE=1 and delayed 132 if (!ca->ce_state) {
135 * ACK has not sent yet. 133 /* State has changed from CE=0 to CE=1, force an immediate
136 */ 134 * ACK to reflect the new CE state. If an ACK was delayed,
137 if (!ca->ce_state && ca->delayed_ack_reserved) { 135 * send that first to reflect the prior CE state.
138 u32 tmp_rcv_nxt; 136 */
139 137 if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
140 /* Save current rcv_nxt. */ 138 __tcp_send_ack(sk, ca->prior_rcv_nxt);
141 tmp_rcv_nxt = tp->rcv_nxt; 139 tcp_enter_quickack_mode(sk, 1);
142
143 /* Generate previous ack with CE=0. */
144 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
145 tp->rcv_nxt = ca->prior_rcv_nxt;
146
147 tcp_send_ack(sk);
148
149 /* Recover current rcv_nxt. */
150 tp->rcv_nxt = tmp_rcv_nxt;
151 } 140 }
152 141
153 ca->prior_rcv_nxt = tp->rcv_nxt; 142 ca->prior_rcv_nxt = tp->rcv_nxt;
@@ -161,23 +150,14 @@ static void dctcp_ce_state_1_to_0(struct sock *sk)
161 struct dctcp *ca = inet_csk_ca(sk); 150 struct dctcp *ca = inet_csk_ca(sk);
162 struct tcp_sock *tp = tcp_sk(sk); 151 struct tcp_sock *tp = tcp_sk(sk);
163 152
164 /* State has changed from CE=1 to CE=0 and delayed 153 if (ca->ce_state) {
165 * ACK has not sent yet. 154 /* State has changed from CE=1 to CE=0, force an immediate
166 */ 155 * ACK to reflect the new CE state. If an ACK was delayed,
167 if (ca->ce_state && ca->delayed_ack_reserved) { 156 * send that first to reflect the prior CE state.
168 u32 tmp_rcv_nxt; 157 */
169 158 if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
170 /* Save current rcv_nxt. */ 159 __tcp_send_ack(sk, ca->prior_rcv_nxt);
171 tmp_rcv_nxt = tp->rcv_nxt; 160 tcp_enter_quickack_mode(sk, 1);
172
173 /* Generate previous ack with CE=1. */
174 tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
175 tp->rcv_nxt = ca->prior_rcv_nxt;
176
177 tcp_send_ack(sk);
178
179 /* Recover current rcv_nxt. */
180 tp->rcv_nxt = tmp_rcv_nxt;
181 } 161 }
182 162
183 ca->prior_rcv_nxt = tp->rcv_nxt; 163 ca->prior_rcv_nxt = tp->rcv_nxt;
@@ -248,25 +228,6 @@ static void dctcp_state(struct sock *sk, u8 new_state)
248 } 228 }
249} 229}
250 230
251static void dctcp_update_ack_reserved(struct sock *sk, enum tcp_ca_event ev)
252{
253 struct dctcp *ca = inet_csk_ca(sk);
254
255 switch (ev) {
256 case CA_EVENT_DELAYED_ACK:
257 if (!ca->delayed_ack_reserved)
258 ca->delayed_ack_reserved = 1;
259 break;
260 case CA_EVENT_NON_DELAYED_ACK:
261 if (ca->delayed_ack_reserved)
262 ca->delayed_ack_reserved = 0;
263 break;
264 default:
265 /* Don't care for the rest. */
266 break;
267 }
268}
269
270static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev) 231static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
271{ 232{
272 switch (ev) { 233 switch (ev) {
@@ -276,10 +237,6 @@ static void dctcp_cwnd_event(struct sock *sk, enum tcp_ca_event ev)
276 case CA_EVENT_ECN_NO_CE: 237 case CA_EVENT_ECN_NO_CE:
277 dctcp_ce_state_1_to_0(sk); 238 dctcp_ce_state_1_to_0(sk);
278 break; 239 break;
279 case CA_EVENT_DELAYED_ACK:
280 case CA_EVENT_NON_DELAYED_ACK:
281 dctcp_update_ack_reserved(sk, ev);
282 break;
283 default: 240 default:
284 /* Don't care for the rest. */ 241 /* Don't care for the rest. */
285 break; 242 break;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 8e5522c6833a..f9dcb29be12d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -215,7 +215,7 @@ static void tcp_incr_quickack(struct sock *sk, unsigned int max_quickacks)
215 icsk->icsk_ack.quick = quickacks; 215 icsk->icsk_ack.quick = quickacks;
216} 216}
217 217
218static void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks) 218void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks)
219{ 219{
220 struct inet_connection_sock *icsk = inet_csk(sk); 220 struct inet_connection_sock *icsk = inet_csk(sk);
221 221
@@ -223,6 +223,7 @@ static void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks)
223 icsk->icsk_ack.pingpong = 0; 223 icsk->icsk_ack.pingpong = 0;
224 icsk->icsk_ack.ato = TCP_ATO_MIN; 224 icsk->icsk_ack.ato = TCP_ATO_MIN;
225} 225}
226EXPORT_SYMBOL(tcp_enter_quickack_mode);
226 227
227/* Send ACKs quickly, if "quick" count is not exhausted 228/* Send ACKs quickly, if "quick" count is not exhausted
228 * and the session is not interactive. 229 * and the session is not interactive.
@@ -245,8 +246,15 @@ static void tcp_ecn_queue_cwr(struct tcp_sock *tp)
245 246
246static void tcp_ecn_accept_cwr(struct tcp_sock *tp, const struct sk_buff *skb) 247static void tcp_ecn_accept_cwr(struct tcp_sock *tp, const struct sk_buff *skb)
247{ 248{
248 if (tcp_hdr(skb)->cwr) 249 if (tcp_hdr(skb)->cwr) {
249 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; 250 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
251
252 /* If the sender is telling us it has entered CWR, then its
253 * cwnd may be very low (even just 1 packet), so we should ACK
254 * immediately.
255 */
256 tcp_enter_quickack_mode((struct sock *)tp, 2);
257 }
250} 258}
251 259
252static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp) 260static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp)
@@ -4357,6 +4365,23 @@ static bool tcp_try_coalesce(struct sock *sk,
4357 return true; 4365 return true;
4358} 4366}
4359 4367
4368static bool tcp_ooo_try_coalesce(struct sock *sk,
4369 struct sk_buff *to,
4370 struct sk_buff *from,
4371 bool *fragstolen)
4372{
4373 bool res = tcp_try_coalesce(sk, to, from, fragstolen);
4374
4375 /* In case tcp_drop() is called later, update to->gso_segs */
4376 if (res) {
4377 u32 gso_segs = max_t(u16, 1, skb_shinfo(to)->gso_segs) +
4378 max_t(u16, 1, skb_shinfo(from)->gso_segs);
4379
4380 skb_shinfo(to)->gso_segs = min_t(u32, gso_segs, 0xFFFF);
4381 }
4382 return res;
4383}
4384
4360static void tcp_drop(struct sock *sk, struct sk_buff *skb) 4385static void tcp_drop(struct sock *sk, struct sk_buff *skb)
4361{ 4386{
4362 sk_drops_add(sk, skb); 4387 sk_drops_add(sk, skb);
@@ -4480,8 +4505,8 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
4480 /* In the typical case, we are adding an skb to the end of the list. 4505 /* In the typical case, we are adding an skb to the end of the list.
4481 * Use of ooo_last_skb avoids the O(Log(N)) rbtree lookup. 4506 * Use of ooo_last_skb avoids the O(Log(N)) rbtree lookup.
4482 */ 4507 */
4483 if (tcp_try_coalesce(sk, tp->ooo_last_skb, 4508 if (tcp_ooo_try_coalesce(sk, tp->ooo_last_skb,
4484 skb, &fragstolen)) { 4509 skb, &fragstolen)) {
4485coalesce_done: 4510coalesce_done:
4486 tcp_grow_window(sk, skb); 4511 tcp_grow_window(sk, skb);
4487 kfree_skb_partial(skb, fragstolen); 4512 kfree_skb_partial(skb, fragstolen);
@@ -4509,7 +4534,7 @@ coalesce_done:
4509 /* All the bits are present. Drop. */ 4534 /* All the bits are present. Drop. */
4510 NET_INC_STATS(sock_net(sk), 4535 NET_INC_STATS(sock_net(sk),
4511 LINUX_MIB_TCPOFOMERGE); 4536 LINUX_MIB_TCPOFOMERGE);
4512 __kfree_skb(skb); 4537 tcp_drop(sk, skb);
4513 skb = NULL; 4538 skb = NULL;
4514 tcp_dsack_set(sk, seq, end_seq); 4539 tcp_dsack_set(sk, seq, end_seq);
4515 goto add_sack; 4540 goto add_sack;
@@ -4528,11 +4553,11 @@ coalesce_done:
4528 TCP_SKB_CB(skb1)->end_seq); 4553 TCP_SKB_CB(skb1)->end_seq);
4529 NET_INC_STATS(sock_net(sk), 4554 NET_INC_STATS(sock_net(sk),
4530 LINUX_MIB_TCPOFOMERGE); 4555 LINUX_MIB_TCPOFOMERGE);
4531 __kfree_skb(skb1); 4556 tcp_drop(sk, skb1);
4532 goto merge_right; 4557 goto merge_right;
4533 } 4558 }
4534 } else if (tcp_try_coalesce(sk, skb1, 4559 } else if (tcp_ooo_try_coalesce(sk, skb1,
4535 skb, &fragstolen)) { 4560 skb, &fragstolen)) {
4536 goto coalesce_done; 4561 goto coalesce_done;
4537 } 4562 }
4538 p = &parent->rb_right; 4563 p = &parent->rb_right;
@@ -4901,6 +4926,7 @@ end:
4901static void tcp_collapse_ofo_queue(struct sock *sk) 4926static void tcp_collapse_ofo_queue(struct sock *sk)
4902{ 4927{
4903 struct tcp_sock *tp = tcp_sk(sk); 4928 struct tcp_sock *tp = tcp_sk(sk);
4929 u32 range_truesize, sum_tiny = 0;
4904 struct sk_buff *skb, *head; 4930 struct sk_buff *skb, *head;
4905 u32 start, end; 4931 u32 start, end;
4906 4932
@@ -4912,6 +4938,7 @@ new_range:
4912 } 4938 }
4913 start = TCP_SKB_CB(skb)->seq; 4939 start = TCP_SKB_CB(skb)->seq;
4914 end = TCP_SKB_CB(skb)->end_seq; 4940 end = TCP_SKB_CB(skb)->end_seq;
4941 range_truesize = skb->truesize;
4915 4942
4916 for (head = skb;;) { 4943 for (head = skb;;) {
4917 skb = skb_rb_next(skb); 4944 skb = skb_rb_next(skb);
@@ -4922,11 +4949,20 @@ new_range:
4922 if (!skb || 4949 if (!skb ||
4923 after(TCP_SKB_CB(skb)->seq, end) || 4950 after(TCP_SKB_CB(skb)->seq, end) ||
4924 before(TCP_SKB_CB(skb)->end_seq, start)) { 4951 before(TCP_SKB_CB(skb)->end_seq, start)) {
4925 tcp_collapse(sk, NULL, &tp->out_of_order_queue, 4952 /* Do not attempt collapsing tiny skbs */
4926 head, skb, start, end); 4953 if (range_truesize != head->truesize ||
4954 end - start >= SKB_WITH_OVERHEAD(SK_MEM_QUANTUM)) {
4955 tcp_collapse(sk, NULL, &tp->out_of_order_queue,
4956 head, skb, start, end);
4957 } else {
4958 sum_tiny += range_truesize;
4959 if (sum_tiny > sk->sk_rcvbuf >> 3)
4960 return;
4961 }
4927 goto new_range; 4962 goto new_range;
4928 } 4963 }
4929 4964
4965 range_truesize += skb->truesize;
4930 if (unlikely(before(TCP_SKB_CB(skb)->seq, start))) 4966 if (unlikely(before(TCP_SKB_CB(skb)->seq, start)))
4931 start = TCP_SKB_CB(skb)->seq; 4967 start = TCP_SKB_CB(skb)->seq;
4932 if (after(TCP_SKB_CB(skb)->end_seq, end)) 4968 if (after(TCP_SKB_CB(skb)->end_seq, end))
@@ -4941,6 +4977,7 @@ new_range:
4941 * 2) not add too big latencies if thousands of packets sit there. 4977 * 2) not add too big latencies if thousands of packets sit there.
4942 * (But if application shrinks SO_RCVBUF, we could still end up 4978 * (But if application shrinks SO_RCVBUF, we could still end up
4943 * freeing whole queue here) 4979 * freeing whole queue here)
4980 * 3) Drop at least 12.5 % of sk_rcvbuf to avoid malicious attacks.
4944 * 4981 *
4945 * Return true if queue has shrunk. 4982 * Return true if queue has shrunk.
4946 */ 4983 */
@@ -4948,20 +4985,26 @@ static bool tcp_prune_ofo_queue(struct sock *sk)
4948{ 4985{
4949 struct tcp_sock *tp = tcp_sk(sk); 4986 struct tcp_sock *tp = tcp_sk(sk);
4950 struct rb_node *node, *prev; 4987 struct rb_node *node, *prev;
4988 int goal;
4951 4989
4952 if (RB_EMPTY_ROOT(&tp->out_of_order_queue)) 4990 if (RB_EMPTY_ROOT(&tp->out_of_order_queue))
4953 return false; 4991 return false;
4954 4992
4955 NET_INC_STATS(sock_net(sk), LINUX_MIB_OFOPRUNED); 4993 NET_INC_STATS(sock_net(sk), LINUX_MIB_OFOPRUNED);
4994 goal = sk->sk_rcvbuf >> 3;
4956 node = &tp->ooo_last_skb->rbnode; 4995 node = &tp->ooo_last_skb->rbnode;
4957 do { 4996 do {
4958 prev = rb_prev(node); 4997 prev = rb_prev(node);
4959 rb_erase(node, &tp->out_of_order_queue); 4998 rb_erase(node, &tp->out_of_order_queue);
4999 goal -= rb_to_skb(node)->truesize;
4960 tcp_drop(sk, rb_to_skb(node)); 5000 tcp_drop(sk, rb_to_skb(node));
4961 sk_mem_reclaim(sk); 5001 if (!prev || goal <= 0) {
4962 if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf && 5002 sk_mem_reclaim(sk);
4963 !tcp_under_memory_pressure(sk)) 5003 if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf &&
4964 break; 5004 !tcp_under_memory_pressure(sk))
5005 break;
5006 goal = sk->sk_rcvbuf >> 3;
5007 }
4965 node = prev; 5008 node = prev;
4966 } while (node); 5009 } while (node);
4967 tp->ooo_last_skb = rb_to_skb(prev); 5010 tp->ooo_last_skb = rb_to_skb(prev);
@@ -4996,6 +5039,9 @@ static int tcp_prune_queue(struct sock *sk)
4996 else if (tcp_under_memory_pressure(sk)) 5039 else if (tcp_under_memory_pressure(sk))
4997 tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss); 5040 tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss);
4998 5041
5042 if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf)
5043 return 0;
5044
4999 tcp_collapse_ofo_queue(sk); 5045 tcp_collapse_ofo_queue(sk);
5000 if (!skb_queue_empty(&sk->sk_receive_queue)) 5046 if (!skb_queue_empty(&sk->sk_receive_queue))
5001 tcp_collapse(sk, &sk->sk_receive_queue, NULL, 5047 tcp_collapse(sk, &sk->sk_receive_queue, NULL,
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index bea17f1e8302..3b2711e33e4c 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -156,11 +156,24 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
156 */ 156 */
157 if (tcptw->tw_ts_recent_stamp && 157 if (tcptw->tw_ts_recent_stamp &&
158 (!twp || (reuse && get_seconds() - tcptw->tw_ts_recent_stamp > 1))) { 158 (!twp || (reuse && get_seconds() - tcptw->tw_ts_recent_stamp > 1))) {
159 tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2; 159 /* In case of repair and re-using TIME-WAIT sockets we still
160 if (tp->write_seq == 0) 160 * want to be sure that it is safe as above but honor the
161 tp->write_seq = 1; 161 * sequence numbers and time stamps set as part of the repair
162 tp->rx_opt.ts_recent = tcptw->tw_ts_recent; 162 * process.
163 tp->rx_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp; 163 *
164 * Without this check re-using a TIME-WAIT socket with TCP
165 * repair would accumulate a -1 on the repair assigned
166 * sequence number. The first time it is reused the sequence
167 * is -1, the second time -2, etc. This fixes that issue
168 * without appearing to create any others.
169 */
170 if (likely(!tp->repair)) {
171 tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2;
172 if (tp->write_seq == 0)
173 tp->write_seq = 1;
174 tp->rx_opt.ts_recent = tcptw->tw_ts_recent;
175 tp->rx_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp;
176 }
164 sock_hold(sktw); 177 sock_hold(sktw);
165 return 1; 178 return 1;
166 } 179 }
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 8e08b409c71e..c4172c1fb198 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -160,7 +160,8 @@ static void tcp_event_data_sent(struct tcp_sock *tp,
160} 160}
161 161
162/* Account for an ACK we sent. */ 162/* Account for an ACK we sent. */
163static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts) 163static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts,
164 u32 rcv_nxt)
164{ 165{
165 struct tcp_sock *tp = tcp_sk(sk); 166 struct tcp_sock *tp = tcp_sk(sk);
166 167
@@ -171,6 +172,9 @@ static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts)
171 if (hrtimer_try_to_cancel(&tp->compressed_ack_timer) == 1) 172 if (hrtimer_try_to_cancel(&tp->compressed_ack_timer) == 1)
172 __sock_put(sk); 173 __sock_put(sk);
173 } 174 }
175
176 if (unlikely(rcv_nxt != tp->rcv_nxt))
177 return; /* Special ACK sent by DCTCP to reflect ECN */
174 tcp_dec_quickack_mode(sk, pkts); 178 tcp_dec_quickack_mode(sk, pkts);
175 inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); 179 inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
176} 180}
@@ -1023,8 +1027,8 @@ static void tcp_update_skb_after_send(struct tcp_sock *tp, struct sk_buff *skb)
1023 * We are working here with either a clone of the original 1027 * We are working here with either a clone of the original
1024 * SKB, or a fresh unique copy made by the retransmit engine. 1028 * SKB, or a fresh unique copy made by the retransmit engine.
1025 */ 1029 */
1026static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, 1030static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
1027 gfp_t gfp_mask) 1031 int clone_it, gfp_t gfp_mask, u32 rcv_nxt)
1028{ 1032{
1029 const struct inet_connection_sock *icsk = inet_csk(sk); 1033 const struct inet_connection_sock *icsk = inet_csk(sk);
1030 struct inet_sock *inet; 1034 struct inet_sock *inet;
@@ -1100,7 +1104,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
1100 th->source = inet->inet_sport; 1104 th->source = inet->inet_sport;
1101 th->dest = inet->inet_dport; 1105 th->dest = inet->inet_dport;
1102 th->seq = htonl(tcb->seq); 1106 th->seq = htonl(tcb->seq);
1103 th->ack_seq = htonl(tp->rcv_nxt); 1107 th->ack_seq = htonl(rcv_nxt);
1104 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | 1108 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) |
1105 tcb->tcp_flags); 1109 tcb->tcp_flags);
1106 1110
@@ -1141,7 +1145,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
1141 icsk->icsk_af_ops->send_check(sk, skb); 1145 icsk->icsk_af_ops->send_check(sk, skb);
1142 1146
1143 if (likely(tcb->tcp_flags & TCPHDR_ACK)) 1147 if (likely(tcb->tcp_flags & TCPHDR_ACK))
1144 tcp_event_ack_sent(sk, tcp_skb_pcount(skb)); 1148 tcp_event_ack_sent(sk, tcp_skb_pcount(skb), rcv_nxt);
1145 1149
1146 if (skb->len != tcp_header_size) { 1150 if (skb->len != tcp_header_size) {
1147 tcp_event_data_sent(tp, sk); 1151 tcp_event_data_sent(tp, sk);
@@ -1178,6 +1182,13 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
1178 return err; 1182 return err;
1179} 1183}
1180 1184
1185static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
1186 gfp_t gfp_mask)
1187{
1188 return __tcp_transmit_skb(sk, skb, clone_it, gfp_mask,
1189 tcp_sk(sk)->rcv_nxt);
1190}
1191
1181/* This routine just queues the buffer for sending. 1192/* This routine just queues the buffer for sending.
1182 * 1193 *
1183 * NOTE: probe0 timer is not checked, do not forget tcp_push_pending_frames, 1194 * NOTE: probe0 timer is not checked, do not forget tcp_push_pending_frames,
@@ -3523,8 +3534,6 @@ void tcp_send_delayed_ack(struct sock *sk)
3523 int ato = icsk->icsk_ack.ato; 3534 int ato = icsk->icsk_ack.ato;
3524 unsigned long timeout; 3535 unsigned long timeout;
3525 3536
3526 tcp_ca_event(sk, CA_EVENT_DELAYED_ACK);
3527
3528 if (ato > TCP_DELACK_MIN) { 3537 if (ato > TCP_DELACK_MIN) {
3529 const struct tcp_sock *tp = tcp_sk(sk); 3538 const struct tcp_sock *tp = tcp_sk(sk);
3530 int max_ato = HZ / 2; 3539 int max_ato = HZ / 2;
@@ -3573,7 +3582,7 @@ void tcp_send_delayed_ack(struct sock *sk)
3573} 3582}
3574 3583
3575/* This routine sends an ack and also updates the window. */ 3584/* This routine sends an ack and also updates the window. */
3576void tcp_send_ack(struct sock *sk) 3585void __tcp_send_ack(struct sock *sk, u32 rcv_nxt)
3577{ 3586{
3578 struct sk_buff *buff; 3587 struct sk_buff *buff;
3579 3588
@@ -3581,8 +3590,6 @@ void tcp_send_ack(struct sock *sk)
3581 if (sk->sk_state == TCP_CLOSE) 3590 if (sk->sk_state == TCP_CLOSE)
3582 return; 3591 return;
3583 3592
3584 tcp_ca_event(sk, CA_EVENT_NON_DELAYED_ACK);
3585
3586 /* We are not putting this on the write queue, so 3593 /* We are not putting this on the write queue, so
3587 * tcp_transmit_skb() will set the ownership to this 3594 * tcp_transmit_skb() will set the ownership to this
3588 * sock. 3595 * sock.
@@ -3608,9 +3615,14 @@ void tcp_send_ack(struct sock *sk)
3608 skb_set_tcp_pure_ack(buff); 3615 skb_set_tcp_pure_ack(buff);
3609 3616
3610 /* Send it off, this clears delayed acks for us. */ 3617 /* Send it off, this clears delayed acks for us. */
3611 tcp_transmit_skb(sk, buff, 0, (__force gfp_t)0); 3618 __tcp_transmit_skb(sk, buff, 0, (__force gfp_t)0, rcv_nxt);
3619}
3620EXPORT_SYMBOL_GPL(__tcp_send_ack);
3621
3622void tcp_send_ack(struct sock *sk)
3623{
3624 __tcp_send_ack(sk, tcp_sk(sk)->rcv_nxt);
3612} 3625}
3613EXPORT_SYMBOL_GPL(tcp_send_ack);
3614 3626
3615/* This routine sends a packet with an out of date sequence 3627/* This routine sends a packet with an out of date sequence
3616 * number. It assumes the other end will try to ack it. 3628 * number. It assumes the other end will try to ack it.
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index 0eff75525da1..b3885ca22d6f 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -108,6 +108,7 @@ config IPV6_MIP6
108config IPV6_ILA 108config IPV6_ILA
109 tristate "IPv6: Identifier Locator Addressing (ILA)" 109 tristate "IPv6: Identifier Locator Addressing (ILA)"
110 depends on NETFILTER 110 depends on NETFILTER
111 select DST_CACHE
111 select LWTUNNEL 112 select LWTUNNEL
112 ---help--- 113 ---help---
113 Support for IPv6 Identifier Locator Addressing (ILA). 114 Support for IPv6 Identifier Locator Addressing (ILA).
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 91580c62bb86..f66a1cae3366 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2374,7 +2374,8 @@ static struct fib6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
2374 continue; 2374 continue;
2375 if ((rt->fib6_flags & noflags) != 0) 2375 if ((rt->fib6_flags & noflags) != 0)
2376 continue; 2376 continue;
2377 fib6_info_hold(rt); 2377 if (!fib6_info_hold_safe(rt))
2378 continue;
2378 break; 2379 break;
2379 } 2380 }
2380out: 2381out:
diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 1323b9679cf7..1c0bb9fb76e6 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -799,8 +799,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop)
799{ 799{
800 struct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts; 800 struct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts;
801 801
802 txopts = ipv6_renew_options_kern(sk, old, IPV6_HOPOPTS, 802 txopts = ipv6_renew_options(sk, old, IPV6_HOPOPTS, hop);
803 hop, hop ? ipv6_optlen(hop) : 0);
804 txopt_put(old); 803 txopt_put(old);
805 if (IS_ERR(txopts)) 804 if (IS_ERR(txopts))
806 return PTR_ERR(txopts); 805 return PTR_ERR(txopts);
@@ -1222,8 +1221,7 @@ static int calipso_req_setattr(struct request_sock *req,
1222 if (IS_ERR(new)) 1221 if (IS_ERR(new))
1223 return PTR_ERR(new); 1222 return PTR_ERR(new);
1224 1223
1225 txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, 1224 txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
1226 new, new ? ipv6_optlen(new) : 0);
1227 1225
1228 kfree(new); 1226 kfree(new);
1229 1227
@@ -1260,8 +1258,7 @@ static void calipso_req_delattr(struct request_sock *req)
1260 if (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new)) 1258 if (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new))
1261 return; /* Nothing to do */ 1259 return; /* Nothing to do */
1262 1260
1263 txopts = ipv6_renew_options_kern(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, 1261 txopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);
1264 new, new ? ipv6_optlen(new) : 0);
1265 1262
1266 if (!IS_ERR(txopts)) { 1263 if (!IS_ERR(txopts)) {
1267 txopts = xchg(&req_inet->ipv6_opt, txopts); 1264 txopts = xchg(&req_inet->ipv6_opt, txopts);
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 2ee08b6a86a4..1a1f876f8e28 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -700,13 +700,16 @@ void ip6_datagram_recv_specific_ctl(struct sock *sk, struct msghdr *msg,
700 } 700 }
701 if (np->rxopt.bits.rxorigdstaddr) { 701 if (np->rxopt.bits.rxorigdstaddr) {
702 struct sockaddr_in6 sin6; 702 struct sockaddr_in6 sin6;
703 __be16 *ports = (__be16 *) skb_transport_header(skb); 703 __be16 *ports;
704 int end;
704 705
705 if (skb_transport_offset(skb) + 4 <= (int)skb->len) { 706 end = skb_transport_offset(skb) + 4;
707 if (end <= 0 || pskb_may_pull(skb, end)) {
706 /* All current transport protocols have the port numbers in the 708 /* All current transport protocols have the port numbers in the
707 * first four bytes of the transport header and this function is 709 * first four bytes of the transport header and this function is
708 * written with this assumption in mind. 710 * written with this assumption in mind.
709 */ 711 */
712 ports = (__be16 *)skb_transport_header(skb);
710 713
711 sin6.sin6_family = AF_INET6; 714 sin6.sin6_family = AF_INET6;
712 sin6.sin6_addr = ipv6_hdr(skb)->daddr; 715 sin6.sin6_addr = ipv6_hdr(skb)->daddr;
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 97513f35bcc5..88a7579c23bd 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -669,8 +669,10 @@ skip_cow:
669 669
670 sg_init_table(sg, nfrags); 670 sg_init_table(sg, nfrags);
671 ret = skb_to_sgvec(skb, sg, 0, skb->len); 671 ret = skb_to_sgvec(skb, sg, 0, skb->len);
672 if (unlikely(ret < 0)) 672 if (unlikely(ret < 0)) {
673 kfree(tmp);
673 goto out; 674 goto out;
675 }
674 676
675 skb->ip_summed = CHECKSUM_NONE; 677 skb->ip_summed = CHECKSUM_NONE;
676 678
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 5bc2bf3733ab..20291c2036fc 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -1015,29 +1015,21 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
1015} 1015}
1016EXPORT_SYMBOL_GPL(ipv6_dup_options); 1016EXPORT_SYMBOL_GPL(ipv6_dup_options);
1017 1017
1018static int ipv6_renew_option(void *ohdr, 1018static void ipv6_renew_option(int renewtype,
1019 struct ipv6_opt_hdr __user *newopt, int newoptlen, 1019 struct ipv6_opt_hdr **dest,
1020 int inherit, 1020 struct ipv6_opt_hdr *old,
1021 struct ipv6_opt_hdr **hdr, 1021 struct ipv6_opt_hdr *new,
1022 char **p) 1022 int newtype, char **p)
1023{ 1023{
1024 if (inherit) { 1024 struct ipv6_opt_hdr *src;
1025 if (ohdr) { 1025
1026 memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr)); 1026 src = (renewtype == newtype ? new : old);
1027 *hdr = (struct ipv6_opt_hdr *)*p; 1027 if (!src)
1028 *p += CMSG_ALIGN(ipv6_optlen(*hdr)); 1028 return;
1029 } 1029
1030 } else { 1030 memcpy(*p, src, ipv6_optlen(src));
1031 if (newopt) { 1031 *dest = (struct ipv6_opt_hdr *)*p;
1032 if (copy_from_user(*p, newopt, newoptlen)) 1032 *p += CMSG_ALIGN(ipv6_optlen(*dest));
1033 return -EFAULT;
1034 *hdr = (struct ipv6_opt_hdr *)*p;
1035 if (ipv6_optlen(*hdr) > newoptlen)
1036 return -EINVAL;
1037 *p += CMSG_ALIGN(newoptlen);
1038 }
1039 }
1040 return 0;
1041} 1033}
1042 1034
1043/** 1035/**
@@ -1063,13 +1055,11 @@ static int ipv6_renew_option(void *ohdr,
1063 */ 1055 */
1064struct ipv6_txoptions * 1056struct ipv6_txoptions *
1065ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt, 1057ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
1066 int newtype, 1058 int newtype, struct ipv6_opt_hdr *newopt)
1067 struct ipv6_opt_hdr __user *newopt, int newoptlen)
1068{ 1059{
1069 int tot_len = 0; 1060 int tot_len = 0;
1070 char *p; 1061 char *p;
1071 struct ipv6_txoptions *opt2; 1062 struct ipv6_txoptions *opt2;
1072 int err;
1073 1063
1074 if (opt) { 1064 if (opt) {
1075 if (newtype != IPV6_HOPOPTS && opt->hopopt) 1065 if (newtype != IPV6_HOPOPTS && opt->hopopt)
@@ -1082,8 +1072,8 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
1082 tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt)); 1072 tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));
1083 } 1073 }
1084 1074
1085 if (newopt && newoptlen) 1075 if (newopt)
1086 tot_len += CMSG_ALIGN(newoptlen); 1076 tot_len += CMSG_ALIGN(ipv6_optlen(newopt));
1087 1077
1088 if (!tot_len) 1078 if (!tot_len)
1089 return NULL; 1079 return NULL;
@@ -1098,29 +1088,19 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
1098 opt2->tot_len = tot_len; 1088 opt2->tot_len = tot_len;
1099 p = (char *)(opt2 + 1); 1089 p = (char *)(opt2 + 1);
1100 1090
1101 err = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen, 1091 ipv6_renew_option(IPV6_HOPOPTS, &opt2->hopopt,
1102 newtype != IPV6_HOPOPTS, 1092 (opt ? opt->hopopt : NULL),
1103 &opt2->hopopt, &p); 1093 newopt, newtype, &p);
1104 if (err) 1094 ipv6_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt,
1105 goto out; 1095 (opt ? opt->dst0opt : NULL),
1106 1096 newopt, newtype, &p);
1107 err = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen, 1097 ipv6_renew_option(IPV6_RTHDR,
1108 newtype != IPV6_RTHDRDSTOPTS, 1098 (struct ipv6_opt_hdr **)&opt2->srcrt,
1109 &opt2->dst0opt, &p); 1099 (opt ? (struct ipv6_opt_hdr *)opt->srcrt : NULL),
1110 if (err) 1100 newopt, newtype, &p);
1111 goto out; 1101 ipv6_renew_option(IPV6_DSTOPTS, &opt2->dst1opt,
1112 1102 (opt ? opt->dst1opt : NULL),
1113 err = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen, 1103 newopt, newtype, &p);
1114 newtype != IPV6_RTHDR,
1115 (struct ipv6_opt_hdr **)&opt2->srcrt, &p);
1116 if (err)
1117 goto out;
1118
1119 err = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,
1120 newtype != IPV6_DSTOPTS,
1121 &opt2->dst1opt, &p);
1122 if (err)
1123 goto out;
1124 1104
1125 opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) + 1105 opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +
1126 (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) + 1106 (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +
@@ -1128,37 +1108,6 @@ ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
1128 opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0); 1108 opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);
1129 1109
1130 return opt2; 1110 return opt2;
1131out:
1132 sock_kfree_s(sk, opt2, opt2->tot_len);
1133 return ERR_PTR(err);
1134}
1135
1136/**
1137 * ipv6_renew_options_kern - replace a specific ext hdr with a new one.
1138 *
1139 * @sk: sock from which to allocate memory
1140 * @opt: original options
1141 * @newtype: option type to replace in @opt
1142 * @newopt: new option of type @newtype to replace (kernel-mem)
1143 * @newoptlen: length of @newopt
1144 *
1145 * See ipv6_renew_options(). The difference is that @newopt is
1146 * kernel memory, rather than user memory.
1147 */
1148struct ipv6_txoptions *
1149ipv6_renew_options_kern(struct sock *sk, struct ipv6_txoptions *opt,
1150 int newtype, struct ipv6_opt_hdr *newopt,
1151 int newoptlen)
1152{
1153 struct ipv6_txoptions *ret_val;
1154 const mm_segment_t old_fs = get_fs();
1155
1156 set_fs(KERNEL_DS);
1157 ret_val = ipv6_renew_options(sk, opt, newtype,
1158 (struct ipv6_opt_hdr __user *)newopt,
1159 newoptlen);
1160 set_fs(old_fs);
1161 return ret_val;
1162} 1111}
1163 1112
1164struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, 1113struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index be491bf6ab6e..ef2505aefc15 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -402,9 +402,10 @@ static int icmp6_iif(const struct sk_buff *skb)
402 402
403 /* for local traffic to local address, skb dev is the loopback 403 /* for local traffic to local address, skb dev is the loopback
404 * device. Check if there is a dst attached to the skb and if so 404 * device. Check if there is a dst attached to the skb and if so
405 * get the real device index. 405 * get the real device index. Same is needed for replies to a link
406 * local address on a device enslaved to an L3 master device
406 */ 407 */
407 if (unlikely(iif == LOOPBACK_IFINDEX)) { 408 if (unlikely(iif == LOOPBACK_IFINDEX || netif_is_l3_master(skb->dev))) {
408 const struct rt6_info *rt6 = skb_rt6_info(skb); 409 const struct rt6_info *rt6 = skb_rt6_info(skb);
409 410
410 if (rt6) 411 if (rt6)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 1fb2f3118d60..d212738e9d10 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -935,20 +935,19 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
935{ 935{
936 struct fib6_info *leaf = rcu_dereference_protected(fn->leaf, 936 struct fib6_info *leaf = rcu_dereference_protected(fn->leaf,
937 lockdep_is_held(&rt->fib6_table->tb6_lock)); 937 lockdep_is_held(&rt->fib6_table->tb6_lock));
938 enum fib_event_type event = FIB_EVENT_ENTRY_ADD; 938 struct fib6_info *iter = NULL;
939 struct fib6_info *iter = NULL, *match = NULL;
940 struct fib6_info __rcu **ins; 939 struct fib6_info __rcu **ins;
940 struct fib6_info __rcu **fallback_ins = NULL;
941 int replace = (info->nlh && 941 int replace = (info->nlh &&
942 (info->nlh->nlmsg_flags & NLM_F_REPLACE)); 942 (info->nlh->nlmsg_flags & NLM_F_REPLACE));
943 int append = (info->nlh &&
944 (info->nlh->nlmsg_flags & NLM_F_APPEND));
945 int add = (!info->nlh || 943 int add = (!info->nlh ||
946 (info->nlh->nlmsg_flags & NLM_F_CREATE)); 944 (info->nlh->nlmsg_flags & NLM_F_CREATE));
947 int found = 0; 945 int found = 0;
946 bool rt_can_ecmp = rt6_qualify_for_ecmp(rt);
948 u16 nlflags = NLM_F_EXCL; 947 u16 nlflags = NLM_F_EXCL;
949 int err; 948 int err;
950 949
951 if (append) 950 if (info->nlh && (info->nlh->nlmsg_flags & NLM_F_APPEND))
952 nlflags |= NLM_F_APPEND; 951 nlflags |= NLM_F_APPEND;
953 952
954 ins = &fn->leaf; 953 ins = &fn->leaf;
@@ -970,8 +969,13 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
970 969
971 nlflags &= ~NLM_F_EXCL; 970 nlflags &= ~NLM_F_EXCL;
972 if (replace) { 971 if (replace) {
973 found++; 972 if (rt_can_ecmp == rt6_qualify_for_ecmp(iter)) {
974 break; 973 found++;
974 break;
975 }
976 if (rt_can_ecmp)
977 fallback_ins = fallback_ins ?: ins;
978 goto next_iter;
975 } 979 }
976 980
977 if (rt6_duplicate_nexthop(iter, rt)) { 981 if (rt6_duplicate_nexthop(iter, rt)) {
@@ -986,51 +990,71 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
986 fib6_metric_set(iter, RTAX_MTU, rt->fib6_pmtu); 990 fib6_metric_set(iter, RTAX_MTU, rt->fib6_pmtu);
987 return -EEXIST; 991 return -EEXIST;
988 } 992 }
989 993 /* If we have the same destination and the same metric,
990 /* first route that matches */ 994 * but not the same gateway, then the route we try to
991 if (!match) 995 * add is sibling to this route, increment our counter
992 match = iter; 996 * of siblings, and later we will add our route to the
997 * list.
998 * Only static routes (which don't have flag
999 * RTF_EXPIRES) are used for ECMPv6.
1000 *
1001 * To avoid long list, we only had siblings if the
1002 * route have a gateway.
1003 */
1004 if (rt_can_ecmp &&
1005 rt6_qualify_for_ecmp(iter))
1006 rt->fib6_nsiblings++;
993 } 1007 }
994 1008
995 if (iter->fib6_metric > rt->fib6_metric) 1009 if (iter->fib6_metric > rt->fib6_metric)
996 break; 1010 break;
997 1011
1012next_iter:
998 ins = &iter->fib6_next; 1013 ins = &iter->fib6_next;
999 } 1014 }
1000 1015
1016 if (fallback_ins && !found) {
1017 /* No ECMP-able route found, replace first non-ECMP one */
1018 ins = fallback_ins;
1019 iter = rcu_dereference_protected(*ins,
1020 lockdep_is_held(&rt->fib6_table->tb6_lock));
1021 found++;
1022 }
1023
1001 /* Reset round-robin state, if necessary */ 1024 /* Reset round-robin state, if necessary */
1002 if (ins == &fn->leaf) 1025 if (ins == &fn->leaf)
1003 fn->rr_ptr = NULL; 1026 fn->rr_ptr = NULL;
1004 1027
1005 /* Link this route to others same route. */ 1028 /* Link this route to others same route. */
1006 if (append && match) { 1029 if (rt->fib6_nsiblings) {
1030 unsigned int fib6_nsiblings;
1007 struct fib6_info *sibling, *temp_sibling; 1031 struct fib6_info *sibling, *temp_sibling;
1008 1032
1009 if (rt->fib6_flags & RTF_REJECT) { 1033 /* Find the first route that have the same metric */
1010 NL_SET_ERR_MSG(extack, 1034 sibling = leaf;
1011 "Can not append a REJECT route"); 1035 while (sibling) {
1012 return -EINVAL; 1036 if (sibling->fib6_metric == rt->fib6_metric &&
1013 } else if (match->fib6_flags & RTF_REJECT) { 1037 rt6_qualify_for_ecmp(sibling)) {
1014 NL_SET_ERR_MSG(extack, 1038 list_add_tail(&rt->fib6_siblings,
1015 "Can not append to a REJECT route"); 1039 &sibling->fib6_siblings);
1016 return -EINVAL; 1040 break;
1041 }
1042 sibling = rcu_dereference_protected(sibling->fib6_next,
1043 lockdep_is_held(&rt->fib6_table->tb6_lock));
1017 } 1044 }
1018 event = FIB_EVENT_ENTRY_APPEND;
1019 rt->fib6_nsiblings = match->fib6_nsiblings;
1020 list_add_tail(&rt->fib6_siblings, &match->fib6_siblings);
1021 match->fib6_nsiblings++;
1022
1023 /* For each sibling in the list, increment the counter of 1045 /* For each sibling in the list, increment the counter of
1024 * siblings. BUG() if counters does not match, list of siblings 1046 * siblings. BUG() if counters does not match, list of siblings
1025 * is broken! 1047 * is broken!
1026 */ 1048 */
1049 fib6_nsiblings = 0;
1027 list_for_each_entry_safe(sibling, temp_sibling, 1050 list_for_each_entry_safe(sibling, temp_sibling,
1028 &match->fib6_siblings, fib6_siblings) { 1051 &rt->fib6_siblings, fib6_siblings) {
1029 sibling->fib6_nsiblings++; 1052 sibling->fib6_nsiblings++;
1030 BUG_ON(sibling->fib6_nsiblings != match->fib6_nsiblings); 1053 BUG_ON(sibling->fib6_nsiblings != rt->fib6_nsiblings);
1054 fib6_nsiblings++;
1031 } 1055 }
1032 1056 BUG_ON(fib6_nsiblings != rt->fib6_nsiblings);
1033 rt6_multipath_rebalance(match); 1057 rt6_multipath_rebalance(temp_sibling);
1034 } 1058 }
1035 1059
1036 /* 1060 /*
@@ -1043,8 +1067,9 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
1043add: 1067add:
1044 nlflags |= NLM_F_CREATE; 1068 nlflags |= NLM_F_CREATE;
1045 1069
1046 err = call_fib6_entry_notifiers(info->nl_net, event, rt, 1070 err = call_fib6_entry_notifiers(info->nl_net,
1047 extack); 1071 FIB_EVENT_ENTRY_ADD,
1072 rt, extack);
1048 if (err) 1073 if (err)
1049 return err; 1074 return err;
1050 1075
@@ -1062,7 +1087,7 @@ add:
1062 } 1087 }
1063 1088
1064 } else { 1089 } else {
1065 struct fib6_info *tmp; 1090 int nsiblings;
1066 1091
1067 if (!found) { 1092 if (!found) {
1068 if (add) 1093 if (add)
@@ -1077,57 +1102,48 @@ add:
1077 if (err) 1102 if (err)
1078 return err; 1103 return err;
1079 1104
1080 /* if route being replaced has siblings, set tmp to
1081 * last one, otherwise tmp is current route. this is
1082 * used to set fib6_next for new route
1083 */
1084 if (iter->fib6_nsiblings)
1085 tmp = list_last_entry(&iter->fib6_siblings,
1086 struct fib6_info,
1087 fib6_siblings);
1088 else
1089 tmp = iter;
1090
1091 /* insert new route */
1092 atomic_inc(&rt->fib6_ref); 1105 atomic_inc(&rt->fib6_ref);
1093 rcu_assign_pointer(rt->fib6_node, fn); 1106 rcu_assign_pointer(rt->fib6_node, fn);
1094 rt->fib6_next = tmp->fib6_next; 1107 rt->fib6_next = iter->fib6_next;
1095 rcu_assign_pointer(*ins, rt); 1108 rcu_assign_pointer(*ins, rt);
1096
1097 if (!info->skip_notify) 1109 if (!info->skip_notify)
1098 inet6_rt_notify(RTM_NEWROUTE, rt, info, NLM_F_REPLACE); 1110 inet6_rt_notify(RTM_NEWROUTE, rt, info, NLM_F_REPLACE);
1099 if (!(fn->fn_flags & RTN_RTINFO)) { 1111 if (!(fn->fn_flags & RTN_RTINFO)) {
1100 info->nl_net->ipv6.rt6_stats->fib_route_nodes++; 1112 info->nl_net->ipv6.rt6_stats->fib_route_nodes++;
1101 fn->fn_flags |= RTN_RTINFO; 1113 fn->fn_flags |= RTN_RTINFO;
1102 } 1114 }
1115 nsiblings = iter->fib6_nsiblings;
1116 iter->fib6_node = NULL;
1117 fib6_purge_rt(iter, fn, info->nl_net);
1118 if (rcu_access_pointer(fn->rr_ptr) == iter)
1119 fn->rr_ptr = NULL;
1120 fib6_info_release(iter);
1103 1121
1104 /* delete old route */ 1122 if (nsiblings) {
1105 rt = iter;
1106
1107 if (rt->fib6_nsiblings) {
1108 struct fib6_info *tmp;
1109
1110 /* Replacing an ECMP route, remove all siblings */ 1123 /* Replacing an ECMP route, remove all siblings */
1111 list_for_each_entry_safe(iter, tmp, &rt->fib6_siblings, 1124 ins = &rt->fib6_next;
1112 fib6_siblings) { 1125 iter = rcu_dereference_protected(*ins,
1113 iter->fib6_node = NULL; 1126 lockdep_is_held(&rt->fib6_table->tb6_lock));
1114 fib6_purge_rt(iter, fn, info->nl_net); 1127 while (iter) {
1115 if (rcu_access_pointer(fn->rr_ptr) == iter) 1128 if (iter->fib6_metric > rt->fib6_metric)
1116 fn->rr_ptr = NULL; 1129 break;
1117 fib6_info_release(iter); 1130 if (rt6_qualify_for_ecmp(iter)) {
1118 1131 *ins = iter->fib6_next;
1119 rt->fib6_nsiblings--; 1132 iter->fib6_node = NULL;
1120 info->nl_net->ipv6.rt6_stats->fib_rt_entries--; 1133 fib6_purge_rt(iter, fn, info->nl_net);
1134 if (rcu_access_pointer(fn->rr_ptr) == iter)
1135 fn->rr_ptr = NULL;
1136 fib6_info_release(iter);
1137 nsiblings--;
1138 info->nl_net->ipv6.rt6_stats->fib_rt_entries--;
1139 } else {
1140 ins = &iter->fib6_next;
1141 }
1142 iter = rcu_dereference_protected(*ins,
1143 lockdep_is_held(&rt->fib6_table->tb6_lock));
1121 } 1144 }
1145 WARN_ON(nsiblings != 0);
1122 } 1146 }
1123
1124 WARN_ON(rt->fib6_nsiblings != 0);
1125
1126 rt->fib6_node = NULL;
1127 fib6_purge_rt(rt, fn, info->nl_net);
1128 if (rcu_access_pointer(fn->rr_ptr) == rt)
1129 fn->rr_ptr = NULL;
1130 fib6_info_release(rt);
1131 } 1147 }
1132 1148
1133 return 0; 1149 return 0;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c8cf2fdbb13b..cd2cfb04e5d8 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -927,7 +927,6 @@ tx_err:
927static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, 927static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
928 struct net_device *dev) 928 struct net_device *dev)
929{ 929{
930 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
931 struct ip6_tnl *t = netdev_priv(dev); 930 struct ip6_tnl *t = netdev_priv(dev);
932 struct dst_entry *dst = skb_dst(skb); 931 struct dst_entry *dst = skb_dst(skb);
933 struct net_device_stats *stats; 932 struct net_device_stats *stats;
@@ -1010,6 +1009,8 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
1010 goto tx_err; 1009 goto tx_err;
1011 } 1010 }
1012 } else { 1011 } else {
1012 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
1013
1013 switch (skb->protocol) { 1014 switch (skb->protocol) {
1014 case htons(ETH_P_IP): 1015 case htons(ETH_P_IP):
1015 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 1016 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index a14fb4fcdf18..3168847c30d1 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -570,6 +570,8 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
570 to->dev = from->dev; 570 to->dev = from->dev;
571 to->mark = from->mark; 571 to->mark = from->mark;
572 572
573 skb_copy_hash(to, from);
574
573#ifdef CONFIG_NET_SCHED 575#ifdef CONFIG_NET_SCHED
574 to->tc_index = from->tc_index; 576 to->tc_index = from->tc_index;
575#endif 577#endif
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index b7f28deddaea..c72ae3a4fe09 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -480,10 +480,6 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
480 goto tx_err_dst_release; 480 goto tx_err_dst_release;
481 } 481 }
482 482
483 skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
484 skb_dst_set(skb, dst);
485 skb->dev = skb_dst(skb)->dev;
486
487 mtu = dst_mtu(dst); 483 mtu = dst_mtu(dst);
488 if (!skb->ignore_df && skb->len > mtu) { 484 if (!skb->ignore_df && skb->len > mtu) {
489 skb_dst_update_pmtu(skb, mtu); 485 skb_dst_update_pmtu(skb, mtu);
@@ -498,9 +494,14 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
498 htonl(mtu)); 494 htonl(mtu));
499 } 495 }
500 496
501 return -EMSGSIZE; 497 err = -EMSGSIZE;
498 goto tx_err_dst_release;
502 } 499 }
503 500
501 skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
502 skb_dst_set(skb, dst);
503 skb->dev = skb_dst(skb)->dev;
504
504 err = dst_output(t->net, skb->sk, skb); 505 err = dst_output(t->net, skb->sk, skb);
505 if (net_xmit_eval(err) == 0) { 506 if (net_xmit_eval(err) == 0) {
506 struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); 507 struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4d780c7f0130..568ca4187cd1 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -398,6 +398,12 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
398 case IPV6_DSTOPTS: 398 case IPV6_DSTOPTS:
399 { 399 {
400 struct ipv6_txoptions *opt; 400 struct ipv6_txoptions *opt;
401 struct ipv6_opt_hdr *new = NULL;
402
403 /* hop-by-hop / destination options are privileged option */
404 retv = -EPERM;
405 if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW))
406 break;
401 407
402 /* remove any sticky options header with a zero option 408 /* remove any sticky options header with a zero option
403 * length, per RFC3542. 409 * length, per RFC3542.
@@ -409,17 +415,22 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
409 else if (optlen < sizeof(struct ipv6_opt_hdr) || 415 else if (optlen < sizeof(struct ipv6_opt_hdr) ||
410 optlen & 0x7 || optlen > 8 * 255) 416 optlen & 0x7 || optlen > 8 * 255)
411 goto e_inval; 417 goto e_inval;
412 418 else {
413 /* hop-by-hop / destination options are privileged option */ 419 new = memdup_user(optval, optlen);
414 retv = -EPERM; 420 if (IS_ERR(new)) {
415 if (optname != IPV6_RTHDR && !ns_capable(net->user_ns, CAP_NET_RAW)) 421 retv = PTR_ERR(new);
416 break; 422 break;
423 }
424 if (unlikely(ipv6_optlen(new) > optlen)) {
425 kfree(new);
426 goto e_inval;
427 }
428 }
417 429
418 opt = rcu_dereference_protected(np->opt, 430 opt = rcu_dereference_protected(np->opt,
419 lockdep_sock_is_held(sk)); 431 lockdep_sock_is_held(sk));
420 opt = ipv6_renew_options(sk, opt, optname, 432 opt = ipv6_renew_options(sk, opt, optname, new);
421 (struct ipv6_opt_hdr __user *)optval, 433 kfree(new);
422 optlen);
423 if (IS_ERR(opt)) { 434 if (IS_ERR(opt)) {
424 retv = PTR_ERR(opt); 435 retv = PTR_ERR(opt);
425 break; 436 break;
@@ -718,8 +729,9 @@ done:
718 struct sockaddr_in6 *psin6; 729 struct sockaddr_in6 *psin6;
719 730
720 psin6 = (struct sockaddr_in6 *)&greqs.gsr_group; 731 psin6 = (struct sockaddr_in6 *)&greqs.gsr_group;
721 retv = ipv6_sock_mc_join(sk, greqs.gsr_interface, 732 retv = ipv6_sock_mc_join_ssm(sk, greqs.gsr_interface,
722 &psin6->sin6_addr); 733 &psin6->sin6_addr,
734 MCAST_INCLUDE);
723 /* prior join w/ different source is ok */ 735 /* prior join w/ different source is ok */
724 if (retv && retv != -EADDRINUSE) 736 if (retv && retv != -EADDRINUSE)
725 break; 737 break;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index c0c74088f2af..f60f310785fd 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -95,6 +95,8 @@ static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,
95 int delta); 95 int delta);
96static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml, 96static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
97 struct inet6_dev *idev); 97 struct inet6_dev *idev);
98static int __ipv6_dev_mc_inc(struct net_device *dev,
99 const struct in6_addr *addr, unsigned int mode);
98 100
99#define MLD_QRV_DEFAULT 2 101#define MLD_QRV_DEFAULT 2
100/* RFC3810, 9.2. Query Interval */ 102/* RFC3810, 9.2. Query Interval */
@@ -132,7 +134,8 @@ static int unsolicited_report_interval(struct inet6_dev *idev)
132 return iv > 0 ? iv : 1; 134 return iv > 0 ? iv : 1;
133} 135}
134 136
135int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr) 137static int __ipv6_sock_mc_join(struct sock *sk, int ifindex,
138 const struct in6_addr *addr, unsigned int mode)
136{ 139{
137 struct net_device *dev = NULL; 140 struct net_device *dev = NULL;
138 struct ipv6_mc_socklist *mc_lst; 141 struct ipv6_mc_socklist *mc_lst;
@@ -179,7 +182,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
179 } 182 }
180 183
181 mc_lst->ifindex = dev->ifindex; 184 mc_lst->ifindex = dev->ifindex;
182 mc_lst->sfmode = MCAST_EXCLUDE; 185 mc_lst->sfmode = mode;
183 rwlock_init(&mc_lst->sflock); 186 rwlock_init(&mc_lst->sflock);
184 mc_lst->sflist = NULL; 187 mc_lst->sflist = NULL;
185 188
@@ -187,7 +190,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
187 * now add/increase the group membership on the device 190 * now add/increase the group membership on the device
188 */ 191 */
189 192
190 err = ipv6_dev_mc_inc(dev, addr); 193 err = __ipv6_dev_mc_inc(dev, addr, mode);
191 194
192 if (err) { 195 if (err) {
193 sock_kfree_s(sk, mc_lst, sizeof(*mc_lst)); 196 sock_kfree_s(sk, mc_lst, sizeof(*mc_lst));
@@ -199,8 +202,19 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
199 202
200 return 0; 203 return 0;
201} 204}
205
206int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
207{
208 return __ipv6_sock_mc_join(sk, ifindex, addr, MCAST_EXCLUDE);
209}
202EXPORT_SYMBOL(ipv6_sock_mc_join); 210EXPORT_SYMBOL(ipv6_sock_mc_join);
203 211
212int ipv6_sock_mc_join_ssm(struct sock *sk, int ifindex,
213 const struct in6_addr *addr, unsigned int mode)
214{
215 return __ipv6_sock_mc_join(sk, ifindex, addr, mode);
216}
217
204/* 218/*
205 * socket leave on multicast group 219 * socket leave on multicast group
206 */ 220 */
@@ -646,7 +660,7 @@ bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
646 return rv; 660 return rv;
647} 661}
648 662
649static void igmp6_group_added(struct ifmcaddr6 *mc) 663static void igmp6_group_added(struct ifmcaddr6 *mc, unsigned int mode)
650{ 664{
651 struct net_device *dev = mc->idev->dev; 665 struct net_device *dev = mc->idev->dev;
652 char buf[MAX_ADDR_LEN]; 666 char buf[MAX_ADDR_LEN];
@@ -672,7 +686,13 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
672 } 686 }
673 /* else v2 */ 687 /* else v2 */
674 688
675 mc->mca_crcount = mc->idev->mc_qrv; 689 /* Based on RFC3810 6.1, for newly added INCLUDE SSM, we
690 * should not send filter-mode change record as the mode
691 * should be from IN() to IN(A).
692 */
693 if (mode == MCAST_EXCLUDE)
694 mc->mca_crcount = mc->idev->mc_qrv;
695
676 mld_ifc_event(mc->idev); 696 mld_ifc_event(mc->idev);
677} 697}
678 698
@@ -770,13 +790,13 @@ static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
770 spin_lock_bh(&im->mca_lock); 790 spin_lock_bh(&im->mca_lock);
771 if (pmc) { 791 if (pmc) {
772 im->idev = pmc->idev; 792 im->idev = pmc->idev;
773 im->mca_crcount = idev->mc_qrv; 793 if (im->mca_sfmode == MCAST_INCLUDE) {
774 im->mca_sfmode = pmc->mca_sfmode;
775 if (pmc->mca_sfmode == MCAST_INCLUDE) {
776 im->mca_tomb = pmc->mca_tomb; 794 im->mca_tomb = pmc->mca_tomb;
777 im->mca_sources = pmc->mca_sources; 795 im->mca_sources = pmc->mca_sources;
778 for (psf = im->mca_sources; psf; psf = psf->sf_next) 796 for (psf = im->mca_sources; psf; psf = psf->sf_next)
779 psf->sf_crcount = im->mca_crcount; 797 psf->sf_crcount = idev->mc_qrv;
798 } else {
799 im->mca_crcount = idev->mc_qrv;
780 } 800 }
781 in6_dev_put(pmc->idev); 801 in6_dev_put(pmc->idev);
782 kfree(pmc); 802 kfree(pmc);
@@ -831,7 +851,8 @@ static void ma_put(struct ifmcaddr6 *mc)
831} 851}
832 852
833static struct ifmcaddr6 *mca_alloc(struct inet6_dev *idev, 853static struct ifmcaddr6 *mca_alloc(struct inet6_dev *idev,
834 const struct in6_addr *addr) 854 const struct in6_addr *addr,
855 unsigned int mode)
835{ 856{
836 struct ifmcaddr6 *mc; 857 struct ifmcaddr6 *mc;
837 858
@@ -849,9 +870,8 @@ static struct ifmcaddr6 *mca_alloc(struct inet6_dev *idev,
849 refcount_set(&mc->mca_refcnt, 1); 870 refcount_set(&mc->mca_refcnt, 1);
850 spin_lock_init(&mc->mca_lock); 871 spin_lock_init(&mc->mca_lock);
851 872
852 /* initial mode is (EX, empty) */ 873 mc->mca_sfmode = mode;
853 mc->mca_sfmode = MCAST_EXCLUDE; 874 mc->mca_sfcount[mode] = 1;
854 mc->mca_sfcount[MCAST_EXCLUDE] = 1;
855 875
856 if (ipv6_addr_is_ll_all_nodes(&mc->mca_addr) || 876 if (ipv6_addr_is_ll_all_nodes(&mc->mca_addr) ||
857 IPV6_ADDR_MC_SCOPE(&mc->mca_addr) < IPV6_ADDR_SCOPE_LINKLOCAL) 877 IPV6_ADDR_MC_SCOPE(&mc->mca_addr) < IPV6_ADDR_SCOPE_LINKLOCAL)
@@ -863,7 +883,8 @@ static struct ifmcaddr6 *mca_alloc(struct inet6_dev *idev,
863/* 883/*
864 * device multicast group inc (add if not found) 884 * device multicast group inc (add if not found)
865 */ 885 */
866int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr) 886static int __ipv6_dev_mc_inc(struct net_device *dev,
887 const struct in6_addr *addr, unsigned int mode)
867{ 888{
868 struct ifmcaddr6 *mc; 889 struct ifmcaddr6 *mc;
869 struct inet6_dev *idev; 890 struct inet6_dev *idev;
@@ -887,14 +908,13 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
887 if (ipv6_addr_equal(&mc->mca_addr, addr)) { 908 if (ipv6_addr_equal(&mc->mca_addr, addr)) {
888 mc->mca_users++; 909 mc->mca_users++;
889 write_unlock_bh(&idev->lock); 910 write_unlock_bh(&idev->lock);
890 ip6_mc_add_src(idev, &mc->mca_addr, MCAST_EXCLUDE, 0, 911 ip6_mc_add_src(idev, &mc->mca_addr, mode, 0, NULL, 0);
891 NULL, 0);
892 in6_dev_put(idev); 912 in6_dev_put(idev);
893 return 0; 913 return 0;
894 } 914 }
895 } 915 }
896 916
897 mc = mca_alloc(idev, addr); 917 mc = mca_alloc(idev, addr, mode);
898 if (!mc) { 918 if (!mc) {
899 write_unlock_bh(&idev->lock); 919 write_unlock_bh(&idev->lock);
900 in6_dev_put(idev); 920 in6_dev_put(idev);
@@ -911,11 +931,16 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
911 write_unlock_bh(&idev->lock); 931 write_unlock_bh(&idev->lock);
912 932
913 mld_del_delrec(idev, mc); 933 mld_del_delrec(idev, mc);
914 igmp6_group_added(mc); 934 igmp6_group_added(mc, mode);
915 ma_put(mc); 935 ma_put(mc);
916 return 0; 936 return 0;
917} 937}
918 938
939int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr)
940{
941 return __ipv6_dev_mc_inc(dev, addr, MCAST_EXCLUDE);
942}
943
919/* 944/*
920 * device multicast group del 945 * device multicast group del
921 */ 946 */
@@ -1751,7 +1776,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
1751 1776
1752 psf_next = psf->sf_next; 1777 psf_next = psf->sf_next;
1753 1778
1754 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) { 1779 if (!is_in(pmc, psf, type, gdeleted, sdeleted) && !crsend) {
1755 psf_prev = psf; 1780 psf_prev = psf;
1756 continue; 1781 continue;
1757 } 1782 }
@@ -2066,7 +2091,7 @@ static void mld_send_initial_cr(struct inet6_dev *idev)
2066 if (pmc->mca_sfcount[MCAST_EXCLUDE]) 2091 if (pmc->mca_sfcount[MCAST_EXCLUDE])
2067 type = MLD2_CHANGE_TO_EXCLUDE; 2092 type = MLD2_CHANGE_TO_EXCLUDE;
2068 else 2093 else
2069 type = MLD2_CHANGE_TO_INCLUDE; 2094 type = MLD2_ALLOW_NEW_SOURCES;
2070 skb = add_grec(skb, pmc, type, 0, 0, 1); 2095 skb = add_grec(skb, pmc, type, 0, 0, 1);
2071 spin_unlock_bh(&pmc->mca_lock); 2096 spin_unlock_bh(&pmc->mca_lock);
2072 } 2097 }
@@ -2546,7 +2571,7 @@ void ipv6_mc_up(struct inet6_dev *idev)
2546 ipv6_mc_reset(idev); 2571 ipv6_mc_reset(idev);
2547 for (i = idev->mc_list; i; i = i->next) { 2572 for (i = idev->mc_list; i; i = i->next) {
2548 mld_del_delrec(idev, i); 2573 mld_del_delrec(idev, i);
2549 igmp6_group_added(i); 2574 igmp6_group_added(i, i->mca_sfmode);
2550 } 2575 }
2551 read_unlock_bh(&idev->lock); 2576 read_unlock_bh(&idev->lock);
2552} 2577}
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index e640d2f3c55c..0ec273997d1d 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -811,7 +811,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
811 return; 811 return;
812 } 812 }
813 } 813 }
814 if (ndopts.nd_opts_nonce) 814 if (ndopts.nd_opts_nonce && ndopts.nd_opts_nonce->nd_opt_len == 1)
815 memcpy(&nonce, (u8 *)(ndopts.nd_opts_nonce + 1), 6); 815 memcpy(&nonce, (u8 *)(ndopts.nd_opts_nonce + 1), 6);
816 816
817 inc = ipv6_addr_is_multicast(daddr); 817 inc = ipv6_addr_is_multicast(daddr);
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 7eab959734bc..daf2e9e9193d 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1909,6 +1909,7 @@ static struct xt_match ip6t_builtin_mt[] __read_mostly = {
1909 .checkentry = icmp6_checkentry, 1909 .checkentry = icmp6_checkentry,
1910 .proto = IPPROTO_ICMPV6, 1910 .proto = IPPROTO_ICMPV6,
1911 .family = NFPROTO_IPV6, 1911 .family = NFPROTO_IPV6,
1912 .me = THIS_MODULE,
1912 }, 1913 },
1913}; 1914};
1914 1915
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index a452d99c9f52..e4d9e6976d3c 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -585,6 +585,8 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
585 fq->q.meat == fq->q.len && 585 fq->q.meat == fq->q.len &&
586 nf_ct_frag6_reasm(fq, skb, dev)) 586 nf_ct_frag6_reasm(fq, skb, dev))
587 ret = 0; 587 ret = 0;
588 else
589 skb_dst_drop(skb);
588 590
589out_unlock: 591out_unlock:
590 spin_unlock_bh(&fq->q.lock); 592 spin_unlock_bh(&fq->q.lock);
diff --git a/net/ipv6/netfilter/nf_tproxy_ipv6.c b/net/ipv6/netfilter/nf_tproxy_ipv6.c
index bf1d6c421e3b..5dfd33af6451 100644
--- a/net/ipv6/netfilter/nf_tproxy_ipv6.c
+++ b/net/ipv6/netfilter/nf_tproxy_ipv6.c
@@ -55,7 +55,7 @@ nf_tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
55 * to a listener socket if there's one */ 55 * to a listener socket if there's one */
56 struct sock *sk2; 56 struct sock *sk2;
57 57
58 sk2 = nf_tproxy_get_sock_v6(net, skb, thoff, hp, tproto, 58 sk2 = nf_tproxy_get_sock_v6(net, skb, thoff, tproto,
59 &iph->saddr, 59 &iph->saddr,
60 nf_tproxy_laddr6(skb, laddr, &iph->daddr), 60 nf_tproxy_laddr6(skb, laddr, &iph->daddr),
61 hp->source, 61 hp->source,
@@ -72,7 +72,7 @@ nf_tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
72EXPORT_SYMBOL_GPL(nf_tproxy_handle_time_wait6); 72EXPORT_SYMBOL_GPL(nf_tproxy_handle_time_wait6);
73 73
74struct sock * 74struct sock *
75nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp, 75nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff,
76 const u8 protocol, 76 const u8 protocol,
77 const struct in6_addr *saddr, const struct in6_addr *daddr, 77 const struct in6_addr *saddr, const struct in6_addr *daddr,
78 const __be16 sport, const __be16 dport, 78 const __be16 sport, const __be16 dport,
@@ -80,15 +80,20 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp,
80 const enum nf_tproxy_lookup_t lookup_type) 80 const enum nf_tproxy_lookup_t lookup_type)
81{ 81{
82 struct sock *sk; 82 struct sock *sk;
83 struct tcphdr *tcph;
84 83
85 switch (protocol) { 84 switch (protocol) {
86 case IPPROTO_TCP: 85 case IPPROTO_TCP: {
86 struct tcphdr _hdr, *hp;
87
88 hp = skb_header_pointer(skb, thoff,
89 sizeof(struct tcphdr), &_hdr);
90 if (hp == NULL)
91 return NULL;
92
87 switch (lookup_type) { 93 switch (lookup_type) {
88 case NF_TPROXY_LOOKUP_LISTENER: 94 case NF_TPROXY_LOOKUP_LISTENER:
89 tcph = hp;
90 sk = inet6_lookup_listener(net, &tcp_hashinfo, skb, 95 sk = inet6_lookup_listener(net, &tcp_hashinfo, skb,
91 thoff + __tcp_hdrlen(tcph), 96 thoff + __tcp_hdrlen(hp),
92 saddr, sport, 97 saddr, sport,
93 daddr, ntohs(dport), 98 daddr, ntohs(dport),
94 in->ifindex, 0); 99 in->ifindex, 0);
@@ -110,6 +115,7 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp,
110 BUG(); 115 BUG();
111 } 116 }
112 break; 117 break;
118 }
113 case IPPROTO_UDP: 119 case IPPROTO_UDP:
114 sk = udp6_lib_lookup(net, saddr, sport, daddr, dport, 120 sk = udp6_lib_lookup(net, saddr, sport, daddr, dport,
115 in->ifindex); 121 in->ifindex);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 86a0e4333d42..ec18b3ce8b6d 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -972,10 +972,10 @@ static void ip6_rt_init_dst(struct rt6_info *rt, struct fib6_info *ort)
972 rt->dst.lastuse = jiffies; 972 rt->dst.lastuse = jiffies;
973} 973}
974 974
975/* Caller must already hold reference to @from */
975static void rt6_set_from(struct rt6_info *rt, struct fib6_info *from) 976static void rt6_set_from(struct rt6_info *rt, struct fib6_info *from)
976{ 977{
977 rt->rt6i_flags &= ~RTF_EXPIRES; 978 rt->rt6i_flags &= ~RTF_EXPIRES;
978 fib6_info_hold(from);
979 rcu_assign_pointer(rt->from, from); 979 rcu_assign_pointer(rt->from, from);
980 dst_init_metrics(&rt->dst, from->fib6_metrics->metrics, true); 980 dst_init_metrics(&rt->dst, from->fib6_metrics->metrics, true);
981 if (from->fib6_metrics != &dst_default_metrics) { 981 if (from->fib6_metrics != &dst_default_metrics) {
@@ -984,6 +984,7 @@ static void rt6_set_from(struct rt6_info *rt, struct fib6_info *from)
984 } 984 }
985} 985}
986 986
987/* Caller must already hold reference to @ort */
987static void ip6_rt_copy_init(struct rt6_info *rt, struct fib6_info *ort) 988static void ip6_rt_copy_init(struct rt6_info *rt, struct fib6_info *ort)
988{ 989{
989 struct net_device *dev = fib6_info_nh_dev(ort); 990 struct net_device *dev = fib6_info_nh_dev(ort);
@@ -1044,9 +1045,14 @@ static struct rt6_info *ip6_create_rt_rcu(struct fib6_info *rt)
1044 struct net_device *dev = rt->fib6_nh.nh_dev; 1045 struct net_device *dev = rt->fib6_nh.nh_dev;
1045 struct rt6_info *nrt; 1046 struct rt6_info *nrt;
1046 1047
1048 if (!fib6_info_hold_safe(rt))
1049 return NULL;
1050
1047 nrt = ip6_dst_alloc(dev_net(dev), dev, flags); 1051 nrt = ip6_dst_alloc(dev_net(dev), dev, flags);
1048 if (nrt) 1052 if (nrt)
1049 ip6_rt_copy_init(nrt, rt); 1053 ip6_rt_copy_init(nrt, rt);
1054 else
1055 fib6_info_release(rt);
1050 1056
1051 return nrt; 1057 return nrt;
1052} 1058}
@@ -1178,10 +1184,15 @@ static struct rt6_info *ip6_rt_cache_alloc(struct fib6_info *ort,
1178 * Clone the route. 1184 * Clone the route.
1179 */ 1185 */
1180 1186
1187 if (!fib6_info_hold_safe(ort))
1188 return NULL;
1189
1181 dev = ip6_rt_get_dev_rcu(ort); 1190 dev = ip6_rt_get_dev_rcu(ort);
1182 rt = ip6_dst_alloc(dev_net(dev), dev, 0); 1191 rt = ip6_dst_alloc(dev_net(dev), dev, 0);
1183 if (!rt) 1192 if (!rt) {
1193 fib6_info_release(ort);
1184 return NULL; 1194 return NULL;
1195 }
1185 1196
1186 ip6_rt_copy_init(rt, ort); 1197 ip6_rt_copy_init(rt, ort);
1187 rt->rt6i_flags |= RTF_CACHE; 1198 rt->rt6i_flags |= RTF_CACHE;
@@ -1210,12 +1221,17 @@ static struct rt6_info *ip6_rt_pcpu_alloc(struct fib6_info *rt)
1210 struct net_device *dev; 1221 struct net_device *dev;
1211 struct rt6_info *pcpu_rt; 1222 struct rt6_info *pcpu_rt;
1212 1223
1224 if (!fib6_info_hold_safe(rt))
1225 return NULL;
1226
1213 rcu_read_lock(); 1227 rcu_read_lock();
1214 dev = ip6_rt_get_dev_rcu(rt); 1228 dev = ip6_rt_get_dev_rcu(rt);
1215 pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags); 1229 pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags);
1216 rcu_read_unlock(); 1230 rcu_read_unlock();
1217 if (!pcpu_rt) 1231 if (!pcpu_rt) {
1232 fib6_info_release(rt);
1218 return NULL; 1233 return NULL;
1234 }
1219 ip6_rt_copy_init(pcpu_rt, rt); 1235 ip6_rt_copy_init(pcpu_rt, rt);
1220 pcpu_rt->rt6i_flags |= RTF_PCPU; 1236 pcpu_rt->rt6i_flags |= RTF_PCPU;
1221 return pcpu_rt; 1237 return pcpu_rt;
@@ -2486,7 +2502,7 @@ restart:
2486 2502
2487out: 2503out:
2488 if (ret) 2504 if (ret)
2489 dst_hold(&ret->dst); 2505 ip6_hold_safe(net, &ret, true);
2490 else 2506 else
2491 ret = ip6_create_rt_rcu(rt); 2507 ret = ip6_create_rt_rcu(rt);
2492 2508
@@ -3303,7 +3319,8 @@ static int ip6_route_del(struct fib6_config *cfg,
3303 continue; 3319 continue;
3304 if (cfg->fc_protocol && cfg->fc_protocol != rt->fib6_protocol) 3320 if (cfg->fc_protocol && cfg->fc_protocol != rt->fib6_protocol)
3305 continue; 3321 continue;
3306 fib6_info_hold(rt); 3322 if (!fib6_info_hold_safe(rt))
3323 continue;
3307 rcu_read_unlock(); 3324 rcu_read_unlock();
3308 3325
3309 /* if gateway was specified only delete the one hop */ 3326 /* if gateway was specified only delete the one hop */
@@ -3409,6 +3426,9 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
3409 3426
3410 rcu_read_lock(); 3427 rcu_read_lock();
3411 from = rcu_dereference(rt->from); 3428 from = rcu_dereference(rt->from);
3429 /* This fib6_info_hold() is safe here because we hold reference to rt
3430 * and rt already holds reference to fib6_info.
3431 */
3412 fib6_info_hold(from); 3432 fib6_info_hold(from);
3413 rcu_read_unlock(); 3433 rcu_read_unlock();
3414 3434
@@ -3470,7 +3490,8 @@ static struct fib6_info *rt6_get_route_info(struct net *net,
3470 continue; 3490 continue;
3471 if (!ipv6_addr_equal(&rt->fib6_nh.nh_gw, gwaddr)) 3491 if (!ipv6_addr_equal(&rt->fib6_nh.nh_gw, gwaddr))
3472 continue; 3492 continue;
3473 fib6_info_hold(rt); 3493 if (!fib6_info_hold_safe(rt))
3494 continue;
3474 break; 3495 break;
3475 } 3496 }
3476out: 3497out:
@@ -3530,8 +3551,8 @@ struct fib6_info *rt6_get_dflt_router(struct net *net,
3530 ipv6_addr_equal(&rt->fib6_nh.nh_gw, addr)) 3551 ipv6_addr_equal(&rt->fib6_nh.nh_gw, addr))
3531 break; 3552 break;
3532 } 3553 }
3533 if (rt) 3554 if (rt && !fib6_info_hold_safe(rt))
3534 fib6_info_hold(rt); 3555 rt = NULL;
3535 rcu_read_unlock(); 3556 rcu_read_unlock();
3536 return rt; 3557 return rt;
3537} 3558}
@@ -3579,8 +3600,8 @@ restart:
3579 struct inet6_dev *idev = dev ? __in6_dev_get(dev) : NULL; 3600 struct inet6_dev *idev = dev ? __in6_dev_get(dev) : NULL;
3580 3601
3581 if (rt->fib6_flags & (RTF_DEFAULT | RTF_ADDRCONF) && 3602 if (rt->fib6_flags & (RTF_DEFAULT | RTF_ADDRCONF) &&
3582 (!idev || idev->cnf.accept_ra != 2)) { 3603 (!idev || idev->cnf.accept_ra != 2) &&
3583 fib6_info_hold(rt); 3604 fib6_info_hold_safe(rt)) {
3584 rcu_read_unlock(); 3605 rcu_read_unlock();
3585 ip6_del_rt(net, rt); 3606 ip6_del_rt(net, rt);
3586 goto restart; 3607 goto restart;
@@ -3842,7 +3863,7 @@ static struct fib6_info *rt6_multipath_first_sibling(const struct fib6_info *rt)
3842 lockdep_is_held(&rt->fib6_table->tb6_lock)); 3863 lockdep_is_held(&rt->fib6_table->tb6_lock));
3843 while (iter) { 3864 while (iter) {
3844 if (iter->fib6_metric == rt->fib6_metric && 3865 if (iter->fib6_metric == rt->fib6_metric &&
3845 iter->fib6_nsiblings) 3866 rt6_qualify_for_ecmp(iter))
3846 return iter; 3867 return iter;
3847 iter = rcu_dereference_protected(iter->fib6_next, 3868 iter = rcu_dereference_protected(iter->fib6_next,
3848 lockdep_is_held(&rt->fib6_table->tb6_lock)); 3869 lockdep_is_held(&rt->fib6_table->tb6_lock));
@@ -4388,6 +4409,13 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
4388 rt = NULL; 4409 rt = NULL;
4389 goto cleanup; 4410 goto cleanup;
4390 } 4411 }
4412 if (!rt6_qualify_for_ecmp(rt)) {
4413 err = -EINVAL;
4414 NL_SET_ERR_MSG(extack,
4415 "Device only routes can not be added for IPv6 using the multipath API.");
4416 fib6_info_release(rt);
4417 goto cleanup;
4418 }
4391 4419
4392 rt->fib6_nh.nh_weight = rtnh->rtnh_hops + 1; 4420 rt->fib6_nh.nh_weight = rtnh->rtnh_hops + 1;
4393 4421
@@ -4439,7 +4467,6 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
4439 */ 4467 */
4440 cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL | 4468 cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
4441 NLM_F_REPLACE); 4469 NLM_F_REPLACE);
4442 cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_APPEND;
4443 nhn++; 4470 nhn++;
4444 } 4471 }
4445 4472
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 19ccf0dc996c..a8854dd3e9c5 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -101,7 +101,7 @@ static __be32 seg6_make_flowlabel(struct net *net, struct sk_buff *skb,
101 101
102 if (do_flowlabel > 0) { 102 if (do_flowlabel > 0) {
103 hash = skb_get_hash(skb); 103 hash = skb_get_hash(skb);
104 rol32(hash, 16); 104 hash = rol32(hash, 16);
105 flowlabel = (__force __be32)hash & IPV6_FLOWLABEL_MASK; 105 flowlabel = (__force __be32)hash & IPV6_FLOWLABEL_MASK;
106 } else if (!do_flowlabel && skb->protocol == htons(ETH_P_IPV6)) { 106 } else if (!do_flowlabel && skb->protocol == htons(ETH_P_IPV6)) {
107 flowlabel = ip6_flowlabel(inner_hdr); 107 flowlabel = ip6_flowlabel(inner_hdr);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 7efa9fd7e109..03e6b7a2bc53 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -938,7 +938,8 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)
938 &tcp_hashinfo, NULL, 0, 938 &tcp_hashinfo, NULL, 0,
939 &ipv6h->saddr, 939 &ipv6h->saddr,
940 th->source, &ipv6h->daddr, 940 th->source, &ipv6h->daddr,
941 ntohs(th->source), tcp_v6_iif(skb), 941 ntohs(th->source),
942 tcp_v6_iif_l3_slave(skb),
942 tcp_v6_sdif(skb)); 943 tcp_v6_sdif(skb));
943 if (!sk1) 944 if (!sk1)
944 goto out; 945 goto out;
@@ -1609,7 +1610,8 @@ do_time_wait:
1609 skb, __tcp_hdrlen(th), 1610 skb, __tcp_hdrlen(th),
1610 &ipv6_hdr(skb)->saddr, th->source, 1611 &ipv6_hdr(skb)->saddr, th->source,
1611 &ipv6_hdr(skb)->daddr, 1612 &ipv6_hdr(skb)->daddr,
1612 ntohs(th->dest), tcp_v6_iif(skb), 1613 ntohs(th->dest),
1614 tcp_v6_iif_l3_slave(skb),
1613 sdif); 1615 sdif);
1614 if (sk2) { 1616 if (sk2) {
1615 struct inet_timewait_sock *tw = inet_twsk(sk); 1617 struct inet_timewait_sock *tw = inet_twsk(sk);
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index e398797878a9..cf6cca260e7b 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1201,13 +1201,18 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
1201 l2tp_session_get(sock_net(sk), tunnel, 1201 l2tp_session_get(sock_net(sk), tunnel,
1202 stats.session_id); 1202 stats.session_id);
1203 1203
1204 if (session && session->pwtype == L2TP_PWTYPE_PPP) { 1204 if (!session) {
1205 err = pppol2tp_session_ioctl(session, cmd, 1205 err = -EBADR;
1206 arg); 1206 break;
1207 }
1208 if (session->pwtype != L2TP_PWTYPE_PPP) {
1207 l2tp_session_dec_refcount(session); 1209 l2tp_session_dec_refcount(session);
1208 } else {
1209 err = -EBADR; 1210 err = -EBADR;
1211 break;
1210 } 1212 }
1213
1214 err = pppol2tp_session_ioctl(session, cmd, arg);
1215 l2tp_session_dec_refcount(session);
1211 break; 1216 break;
1212 } 1217 }
1213#ifdef CONFIG_XFRM 1218#ifdef CONFIG_XFRM
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 0a38cc1cbebc..932985ca4e66 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2254,11 +2254,8 @@ static void ieee80211_deliver_skb_to_local_stack(struct sk_buff *skb,
2254 sdata->control_port_over_nl80211)) { 2254 sdata->control_port_over_nl80211)) {
2255 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 2255 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2256 bool noencrypt = status->flag & RX_FLAG_DECRYPTED; 2256 bool noencrypt = status->flag & RX_FLAG_DECRYPTED;
2257 struct ethhdr *ehdr = eth_hdr(skb);
2258 2257
2259 cfg80211_rx_control_port(dev, skb->data, skb->len, 2258 cfg80211_rx_control_port(dev, skb, noencrypt);
2260 ehdr->h_source,
2261 be16_to_cpu(skb->protocol), noencrypt);
2262 dev_kfree_skb(skb); 2259 dev_kfree_skb(skb);
2263 } else { 2260 } else {
2264 /* deliver to local stack */ 2261 /* deliver to local stack */
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 5e2e511c4a6f..d02fbfec3783 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2111,7 +2111,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
2111 if (!sta->uploaded) 2111 if (!sta->uploaded)
2112 continue; 2112 continue;
2113 2113
2114 if (sta->sdata->vif.type != NL80211_IFTYPE_AP) 2114 if (sta->sdata->vif.type != NL80211_IFTYPE_AP &&
2115 sta->sdata->vif.type != NL80211_IFTYPE_AP_VLAN)
2115 continue; 2116 continue;
2116 2117
2117 for (state = IEEE80211_STA_NOTEXIST; 2118 for (state = IEEE80211_STA_NOTEXIST;
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index dbd7d1fad277..f0a1c536ef15 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -460,6 +460,13 @@ config NF_TABLES
460 460
461if NF_TABLES 461if NF_TABLES
462 462
463config NF_TABLES_SET
464 tristate "Netfilter nf_tables set infrastructure"
465 help
466 This option enables the nf_tables set infrastructure that allows to
467 look up for elements in a set and to build one-way mappings between
468 matchings and actions.
469
463config NF_TABLES_INET 470config NF_TABLES_INET
464 depends on IPV6 471 depends on IPV6
465 select NF_TABLES_IPV4 472 select NF_TABLES_IPV4
@@ -493,24 +500,6 @@ config NFT_FLOW_OFFLOAD
493 This option adds the "flow_offload" expression that you can use to 500 This option adds the "flow_offload" expression that you can use to
494 choose what flows are placed into the hardware. 501 choose what flows are placed into the hardware.
495 502
496config NFT_SET_RBTREE
497 tristate "Netfilter nf_tables rbtree set module"
498 help
499 This option adds the "rbtree" set type (Red Black tree) that is used
500 to build interval-based sets.
501
502config NFT_SET_HASH
503 tristate "Netfilter nf_tables hash set module"
504 help
505 This option adds the "hash" set type that is used to build one-way
506 mappings between matchings and actions.
507
508config NFT_SET_BITMAP
509 tristate "Netfilter nf_tables bitmap set module"
510 help
511 This option adds the "bitmap" set type that is used to build sets
512 whose keys are smaller or equal to 16 bits.
513
514config NFT_COUNTER 503config NFT_COUNTER
515 tristate "Netfilter nf_tables counter module" 504 tristate "Netfilter nf_tables counter module"
516 help 505 help
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index 44449389e527..8a76dced974d 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -78,7 +78,11 @@ nf_tables-objs := nf_tables_core.o nf_tables_api.o nft_chain_filter.o \
78 nft_bitwise.o nft_byteorder.o nft_payload.o nft_lookup.o \ 78 nft_bitwise.o nft_byteorder.o nft_payload.o nft_lookup.o \
79 nft_dynset.o nft_meta.o nft_rt.o nft_exthdr.o 79 nft_dynset.o nft_meta.o nft_rt.o nft_exthdr.o
80 80
81nf_tables_set-objs := nf_tables_set_core.o \
82 nft_set_hash.o nft_set_bitmap.o nft_set_rbtree.o
83
81obj-$(CONFIG_NF_TABLES) += nf_tables.o 84obj-$(CONFIG_NF_TABLES) += nf_tables.o
85obj-$(CONFIG_NF_TABLES_SET) += nf_tables_set.o
82obj-$(CONFIG_NFT_COMPAT) += nft_compat.o 86obj-$(CONFIG_NFT_COMPAT) += nft_compat.o
83obj-$(CONFIG_NFT_CONNLIMIT) += nft_connlimit.o 87obj-$(CONFIG_NFT_CONNLIMIT) += nft_connlimit.o
84obj-$(CONFIG_NFT_NUMGEN) += nft_numgen.o 88obj-$(CONFIG_NFT_NUMGEN) += nft_numgen.o
@@ -91,9 +95,6 @@ obj-$(CONFIG_NFT_QUEUE) += nft_queue.o
91obj-$(CONFIG_NFT_QUOTA) += nft_quota.o 95obj-$(CONFIG_NFT_QUOTA) += nft_quota.o
92obj-$(CONFIG_NFT_REJECT) += nft_reject.o 96obj-$(CONFIG_NFT_REJECT) += nft_reject.o
93obj-$(CONFIG_NFT_REJECT_INET) += nft_reject_inet.o 97obj-$(CONFIG_NFT_REJECT_INET) += nft_reject_inet.o
94obj-$(CONFIG_NFT_SET_RBTREE) += nft_set_rbtree.o
95obj-$(CONFIG_NFT_SET_HASH) += nft_set_hash.o
96obj-$(CONFIG_NFT_SET_BITMAP) += nft_set_bitmap.o
97obj-$(CONFIG_NFT_COUNTER) += nft_counter.o 98obj-$(CONFIG_NFT_COUNTER) += nft_counter.o
98obj-$(CONFIG_NFT_LOG) += nft_log.o 99obj-$(CONFIG_NFT_LOG) += nft_log.o
99obj-$(CONFIG_NFT_MASQ) += nft_masq.o 100obj-$(CONFIG_NFT_MASQ) += nft_masq.o
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 3465da2a98bd..3d5280425027 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -2043,7 +2043,7 @@ int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp)
2043 return -EOPNOTSUPP; 2043 return -EOPNOTSUPP;
2044 2044
2045 /* On boot, we can set this without any fancy locking. */ 2045 /* On boot, we can set this without any fancy locking. */
2046 if (!nf_conntrack_htable_size) 2046 if (!nf_conntrack_hash)
2047 return param_set_uint(val, kp); 2047 return param_set_uint(val, kp);
2048 2048
2049 rc = kstrtouint(val, 0, &hashsize); 2049 rc = kstrtouint(val, 0, &hashsize);
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index abe647d5b8c6..9ce6336d1e55 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -243,14 +243,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
243 * We currently ignore Sync packets 243 * We currently ignore Sync packets
244 * 244 *
245 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ 245 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
246 sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, 246 sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
247 }, 247 },
248 [DCCP_PKT_SYNCACK] = { 248 [DCCP_PKT_SYNCACK] = {
249 /* 249 /*
250 * We currently ignore SyncAck packets 250 * We currently ignore SyncAck packets
251 * 251 *
252 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ 252 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
253 sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, 253 sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
254 }, 254 },
255 }, 255 },
256 [CT_DCCP_ROLE_SERVER] = { 256 [CT_DCCP_ROLE_SERVER] = {
@@ -371,14 +371,14 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][DCCP_PKT_SYNCACK + 1][CT_DCCP_MAX + 1] =
371 * We currently ignore Sync packets 371 * We currently ignore Sync packets
372 * 372 *
373 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ 373 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
374 sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, 374 sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
375 }, 375 },
376 [DCCP_PKT_SYNCACK] = { 376 [DCCP_PKT_SYNCACK] = {
377 /* 377 /*
378 * We currently ignore SyncAck packets 378 * We currently ignore SyncAck packets
379 * 379 *
380 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */ 380 * sNO, sRQ, sRS, sPO, sOP, sCR, sCG, sTW */
381 sIG, sIG, sIG, sIG, sIG, sIG, sIG, sIG, 381 sIV, sIG, sIG, sIG, sIG, sIG, sIG, sIG,
382 }, 382 },
383 }, 383 },
384}; 384};
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 896d4a36081d..f5745e4c6513 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -75,6 +75,7 @@ static void nft_ctx_init(struct nft_ctx *ctx,
75{ 75{
76 ctx->net = net; 76 ctx->net = net;
77 ctx->family = family; 77 ctx->family = family;
78 ctx->level = 0;
78 ctx->table = table; 79 ctx->table = table;
79 ctx->chain = chain; 80 ctx->chain = chain;
80 ctx->nla = nla; 81 ctx->nla = nla;
@@ -1597,7 +1598,6 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
1597 struct nft_base_chain *basechain; 1598 struct nft_base_chain *basechain;
1598 struct nft_stats *stats = NULL; 1599 struct nft_stats *stats = NULL;
1599 struct nft_chain_hook hook; 1600 struct nft_chain_hook hook;
1600 const struct nlattr *name;
1601 struct nf_hook_ops *ops; 1601 struct nf_hook_ops *ops;
1602 struct nft_trans *trans; 1602 struct nft_trans *trans;
1603 int err; 1603 int err;
@@ -1645,12 +1645,11 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
1645 return PTR_ERR(stats); 1645 return PTR_ERR(stats);
1646 } 1646 }
1647 1647
1648 err = -ENOMEM;
1648 trans = nft_trans_alloc(ctx, NFT_MSG_NEWCHAIN, 1649 trans = nft_trans_alloc(ctx, NFT_MSG_NEWCHAIN,
1649 sizeof(struct nft_trans_chain)); 1650 sizeof(struct nft_trans_chain));
1650 if (trans == NULL) { 1651 if (trans == NULL)
1651 free_percpu(stats); 1652 goto err;
1652 return -ENOMEM;
1653 }
1654 1653
1655 nft_trans_chain_stats(trans) = stats; 1654 nft_trans_chain_stats(trans) = stats;
1656 nft_trans_chain_update(trans) = true; 1655 nft_trans_chain_update(trans) = true;
@@ -1660,19 +1659,37 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
1660 else 1659 else
1661 nft_trans_chain_policy(trans) = -1; 1660 nft_trans_chain_policy(trans) = -1;
1662 1661
1663 name = nla[NFTA_CHAIN_NAME]; 1662 if (nla[NFTA_CHAIN_HANDLE] &&
1664 if (nla[NFTA_CHAIN_HANDLE] && name) { 1663 nla[NFTA_CHAIN_NAME]) {
1665 nft_trans_chain_name(trans) = 1664 struct nft_trans *tmp;
1666 nla_strdup(name, GFP_KERNEL); 1665 char *name;
1667 if (!nft_trans_chain_name(trans)) { 1666
1668 kfree(trans); 1667 err = -ENOMEM;
1669 free_percpu(stats); 1668 name = nla_strdup(nla[NFTA_CHAIN_NAME], GFP_KERNEL);
1670 return -ENOMEM; 1669 if (!name)
1670 goto err;
1671
1672 err = -EEXIST;
1673 list_for_each_entry(tmp, &ctx->net->nft.commit_list, list) {
1674 if (tmp->msg_type == NFT_MSG_NEWCHAIN &&
1675 tmp->ctx.table == table &&
1676 nft_trans_chain_update(tmp) &&
1677 nft_trans_chain_name(tmp) &&
1678 strcmp(name, nft_trans_chain_name(tmp)) == 0) {
1679 kfree(name);
1680 goto err;
1681 }
1671 } 1682 }
1683
1684 nft_trans_chain_name(trans) = name;
1672 } 1685 }
1673 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 1686 list_add_tail(&trans->list, &ctx->net->nft.commit_list);
1674 1687
1675 return 0; 1688 return 0;
1689err:
1690 free_percpu(stats);
1691 kfree(trans);
1692 return err;
1676} 1693}
1677 1694
1678static int nf_tables_newchain(struct net *net, struct sock *nlsk, 1695static int nf_tables_newchain(struct net *net, struct sock *nlsk,
@@ -2254,6 +2271,39 @@ done:
2254 return skb->len; 2271 return skb->len;
2255} 2272}
2256 2273
2274static int nf_tables_dump_rules_start(struct netlink_callback *cb)
2275{
2276 const struct nlattr * const *nla = cb->data;
2277 struct nft_rule_dump_ctx *ctx = NULL;
2278
2279 if (nla[NFTA_RULE_TABLE] || nla[NFTA_RULE_CHAIN]) {
2280 ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
2281 if (!ctx)
2282 return -ENOMEM;
2283
2284 if (nla[NFTA_RULE_TABLE]) {
2285 ctx->table = nla_strdup(nla[NFTA_RULE_TABLE],
2286 GFP_ATOMIC);
2287 if (!ctx->table) {
2288 kfree(ctx);
2289 return -ENOMEM;
2290 }
2291 }
2292 if (nla[NFTA_RULE_CHAIN]) {
2293 ctx->chain = nla_strdup(nla[NFTA_RULE_CHAIN],
2294 GFP_ATOMIC);
2295 if (!ctx->chain) {
2296 kfree(ctx->table);
2297 kfree(ctx);
2298 return -ENOMEM;
2299 }
2300 }
2301 }
2302
2303 cb->data = ctx;
2304 return 0;
2305}
2306
2257static int nf_tables_dump_rules_done(struct netlink_callback *cb) 2307static int nf_tables_dump_rules_done(struct netlink_callback *cb)
2258{ 2308{
2259 struct nft_rule_dump_ctx *ctx = cb->data; 2309 struct nft_rule_dump_ctx *ctx = cb->data;
@@ -2283,38 +2333,13 @@ static int nf_tables_getrule(struct net *net, struct sock *nlsk,
2283 2333
2284 if (nlh->nlmsg_flags & NLM_F_DUMP) { 2334 if (nlh->nlmsg_flags & NLM_F_DUMP) {
2285 struct netlink_dump_control c = { 2335 struct netlink_dump_control c = {
2336 .start= nf_tables_dump_rules_start,
2286 .dump = nf_tables_dump_rules, 2337 .dump = nf_tables_dump_rules,
2287 .done = nf_tables_dump_rules_done, 2338 .done = nf_tables_dump_rules_done,
2288 .module = THIS_MODULE, 2339 .module = THIS_MODULE,
2340 .data = (void *)nla,
2289 }; 2341 };
2290 2342
2291 if (nla[NFTA_RULE_TABLE] || nla[NFTA_RULE_CHAIN]) {
2292 struct nft_rule_dump_ctx *ctx;
2293
2294 ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
2295 if (!ctx)
2296 return -ENOMEM;
2297
2298 if (nla[NFTA_RULE_TABLE]) {
2299 ctx->table = nla_strdup(nla[NFTA_RULE_TABLE],
2300 GFP_ATOMIC);
2301 if (!ctx->table) {
2302 kfree(ctx);
2303 return -ENOMEM;
2304 }
2305 }
2306 if (nla[NFTA_RULE_CHAIN]) {
2307 ctx->chain = nla_strdup(nla[NFTA_RULE_CHAIN],
2308 GFP_ATOMIC);
2309 if (!ctx->chain) {
2310 kfree(ctx->table);
2311 kfree(ctx);
2312 return -ENOMEM;
2313 }
2314 }
2315 c.data = ctx;
2316 }
2317
2318 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c); 2343 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c);
2319 } 2344 }
2320 2345
@@ -2384,6 +2409,9 @@ int nft_chain_validate(const struct nft_ctx *ctx, const struct nft_chain *chain)
2384 struct nft_rule *rule; 2409 struct nft_rule *rule;
2385 int err; 2410 int err;
2386 2411
2412 if (ctx->level == NFT_JUMP_STACK_SIZE)
2413 return -EMLINK;
2414
2387 list_for_each_entry(rule, &chain->rules, list) { 2415 list_for_each_entry(rule, &chain->rules, list) {
2388 if (!nft_is_active_next(ctx->net, rule)) 2416 if (!nft_is_active_next(ctx->net, rule))
2389 continue; 2417 continue;
@@ -3161,6 +3189,18 @@ done:
3161 return skb->len; 3189 return skb->len;
3162} 3190}
3163 3191
3192static int nf_tables_dump_sets_start(struct netlink_callback *cb)
3193{
3194 struct nft_ctx *ctx_dump = NULL;
3195
3196 ctx_dump = kmemdup(cb->data, sizeof(*ctx_dump), GFP_ATOMIC);
3197 if (ctx_dump == NULL)
3198 return -ENOMEM;
3199
3200 cb->data = ctx_dump;
3201 return 0;
3202}
3203
3164static int nf_tables_dump_sets_done(struct netlink_callback *cb) 3204static int nf_tables_dump_sets_done(struct netlink_callback *cb)
3165{ 3205{
3166 kfree(cb->data); 3206 kfree(cb->data);
@@ -3188,18 +3228,12 @@ static int nf_tables_getset(struct net *net, struct sock *nlsk,
3188 3228
3189 if (nlh->nlmsg_flags & NLM_F_DUMP) { 3229 if (nlh->nlmsg_flags & NLM_F_DUMP) {
3190 struct netlink_dump_control c = { 3230 struct netlink_dump_control c = {
3231 .start = nf_tables_dump_sets_start,
3191 .dump = nf_tables_dump_sets, 3232 .dump = nf_tables_dump_sets,
3192 .done = nf_tables_dump_sets_done, 3233 .done = nf_tables_dump_sets_done,
3234 .data = &ctx,
3193 .module = THIS_MODULE, 3235 .module = THIS_MODULE,
3194 }; 3236 };
3195 struct nft_ctx *ctx_dump;
3196
3197 ctx_dump = kmalloc(sizeof(*ctx_dump), GFP_ATOMIC);
3198 if (ctx_dump == NULL)
3199 return -ENOMEM;
3200
3201 *ctx_dump = ctx;
3202 c.data = ctx_dump;
3203 3237
3204 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c); 3238 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c);
3205 } 3239 }
@@ -3849,6 +3883,15 @@ nla_put_failure:
3849 return -ENOSPC; 3883 return -ENOSPC;
3850} 3884}
3851 3885
3886static int nf_tables_dump_set_start(struct netlink_callback *cb)
3887{
3888 struct nft_set_dump_ctx *dump_ctx = cb->data;
3889
3890 cb->data = kmemdup(dump_ctx, sizeof(*dump_ctx), GFP_ATOMIC);
3891
3892 return cb->data ? 0 : -ENOMEM;
3893}
3894
3852static int nf_tables_dump_set_done(struct netlink_callback *cb) 3895static int nf_tables_dump_set_done(struct netlink_callback *cb)
3853{ 3896{
3854 kfree(cb->data); 3897 kfree(cb->data);
@@ -4002,20 +4045,17 @@ static int nf_tables_getsetelem(struct net *net, struct sock *nlsk,
4002 4045
4003 if (nlh->nlmsg_flags & NLM_F_DUMP) { 4046 if (nlh->nlmsg_flags & NLM_F_DUMP) {
4004 struct netlink_dump_control c = { 4047 struct netlink_dump_control c = {
4048 .start = nf_tables_dump_set_start,
4005 .dump = nf_tables_dump_set, 4049 .dump = nf_tables_dump_set,
4006 .done = nf_tables_dump_set_done, 4050 .done = nf_tables_dump_set_done,
4007 .module = THIS_MODULE, 4051 .module = THIS_MODULE,
4008 }; 4052 };
4009 struct nft_set_dump_ctx *dump_ctx; 4053 struct nft_set_dump_ctx dump_ctx = {
4010 4054 .set = set,
4011 dump_ctx = kmalloc(sizeof(*dump_ctx), GFP_ATOMIC); 4055 .ctx = ctx,
4012 if (!dump_ctx) 4056 };
4013 return -ENOMEM;
4014
4015 dump_ctx->set = set;
4016 dump_ctx->ctx = ctx;
4017 4057
4018 c.data = dump_ctx; 4058 c.data = &dump_ctx;
4019 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c); 4059 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c);
4020 } 4060 }
4021 4061
@@ -4975,38 +5015,42 @@ done:
4975 return skb->len; 5015 return skb->len;
4976} 5016}
4977 5017
4978static int nf_tables_dump_obj_done(struct netlink_callback *cb) 5018static int nf_tables_dump_obj_start(struct netlink_callback *cb)
4979{ 5019{
4980 struct nft_obj_filter *filter = cb->data; 5020 const struct nlattr * const *nla = cb->data;
5021 struct nft_obj_filter *filter = NULL;
4981 5022
4982 if (filter) { 5023 if (nla[NFTA_OBJ_TABLE] || nla[NFTA_OBJ_TYPE]) {
4983 kfree(filter->table); 5024 filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
4984 kfree(filter); 5025 if (!filter)
5026 return -ENOMEM;
5027
5028 if (nla[NFTA_OBJ_TABLE]) {
5029 filter->table = nla_strdup(nla[NFTA_OBJ_TABLE], GFP_ATOMIC);
5030 if (!filter->table) {
5031 kfree(filter);
5032 return -ENOMEM;
5033 }
5034 }
5035
5036 if (nla[NFTA_OBJ_TYPE])
5037 filter->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
4985 } 5038 }
4986 5039
5040 cb->data = filter;
4987 return 0; 5041 return 0;
4988} 5042}
4989 5043
4990static struct nft_obj_filter * 5044static int nf_tables_dump_obj_done(struct netlink_callback *cb)
4991nft_obj_filter_alloc(const struct nlattr * const nla[])
4992{ 5045{
4993 struct nft_obj_filter *filter; 5046 struct nft_obj_filter *filter = cb->data;
4994
4995 filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
4996 if (!filter)
4997 return ERR_PTR(-ENOMEM);
4998 5047
4999 if (nla[NFTA_OBJ_TABLE]) { 5048 if (filter) {
5000 filter->table = nla_strdup(nla[NFTA_OBJ_TABLE], GFP_ATOMIC); 5049 kfree(filter->table);
5001 if (!filter->table) { 5050 kfree(filter);
5002 kfree(filter);
5003 return ERR_PTR(-ENOMEM);
5004 }
5005 } 5051 }
5006 if (nla[NFTA_OBJ_TYPE])
5007 filter->type = ntohl(nla_get_be32(nla[NFTA_OBJ_TYPE]));
5008 5052
5009 return filter; 5053 return 0;
5010} 5054}
5011 5055
5012/* called with rcu_read_lock held */ 5056/* called with rcu_read_lock held */
@@ -5027,21 +5071,13 @@ static int nf_tables_getobj(struct net *net, struct sock *nlsk,
5027 5071
5028 if (nlh->nlmsg_flags & NLM_F_DUMP) { 5072 if (nlh->nlmsg_flags & NLM_F_DUMP) {
5029 struct netlink_dump_control c = { 5073 struct netlink_dump_control c = {
5074 .start = nf_tables_dump_obj_start,
5030 .dump = nf_tables_dump_obj, 5075 .dump = nf_tables_dump_obj,
5031 .done = nf_tables_dump_obj_done, 5076 .done = nf_tables_dump_obj_done,
5032 .module = THIS_MODULE, 5077 .module = THIS_MODULE,
5078 .data = (void *)nla,
5033 }; 5079 };
5034 5080
5035 if (nla[NFTA_OBJ_TABLE] ||
5036 nla[NFTA_OBJ_TYPE]) {
5037 struct nft_obj_filter *filter;
5038
5039 filter = nft_obj_filter_alloc(nla);
5040 if (IS_ERR(filter))
5041 return -ENOMEM;
5042
5043 c.data = filter;
5044 }
5045 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c); 5081 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c);
5046 } 5082 }
5047 5083
@@ -5320,8 +5356,6 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx,
5320 flowtable->ops[i].priv = &flowtable->data; 5356 flowtable->ops[i].priv = &flowtable->data;
5321 flowtable->ops[i].hook = flowtable->data.type->hook; 5357 flowtable->ops[i].hook = flowtable->data.type->hook;
5322 flowtable->ops[i].dev = dev_array[i]; 5358 flowtable->ops[i].dev = dev_array[i];
5323 flowtable->dev_name[i] = kstrdup(dev_array[i]->name,
5324 GFP_KERNEL);
5325 } 5359 }
5326 5360
5327 return err; 5361 return err;
@@ -5479,10 +5513,8 @@ static int nf_tables_newflowtable(struct net *net, struct sock *nlsk,
5479err6: 5513err6:
5480 i = flowtable->ops_len; 5514 i = flowtable->ops_len;
5481err5: 5515err5:
5482 for (k = i - 1; k >= 0; k--) { 5516 for (k = i - 1; k >= 0; k--)
5483 kfree(flowtable->dev_name[k]);
5484 nf_unregister_net_hook(net, &flowtable->ops[k]); 5517 nf_unregister_net_hook(net, &flowtable->ops[k]);
5485 }
5486 5518
5487 kfree(flowtable->ops); 5519 kfree(flowtable->ops);
5488err4: 5520err4:
@@ -5581,9 +5613,10 @@ static int nf_tables_fill_flowtable_info(struct sk_buff *skb, struct net *net,
5581 goto nla_put_failure; 5613 goto nla_put_failure;
5582 5614
5583 for (i = 0; i < flowtable->ops_len; i++) { 5615 for (i = 0; i < flowtable->ops_len; i++) {
5584 if (flowtable->dev_name[i][0] && 5616 const struct net_device *dev = READ_ONCE(flowtable->ops[i].dev);
5585 nla_put_string(skb, NFTA_DEVICE_NAME, 5617
5586 flowtable->dev_name[i])) 5618 if (dev &&
5619 nla_put_string(skb, NFTA_DEVICE_NAME, dev->name))
5587 goto nla_put_failure; 5620 goto nla_put_failure;
5588 } 5621 }
5589 nla_nest_end(skb, nest_devs); 5622 nla_nest_end(skb, nest_devs);
@@ -5650,37 +5683,39 @@ done:
5650 return skb->len; 5683 return skb->len;
5651} 5684}
5652 5685
5653static int nf_tables_dump_flowtable_done(struct netlink_callback *cb) 5686static int nf_tables_dump_flowtable_start(struct netlink_callback *cb)
5654{ 5687{
5655 struct nft_flowtable_filter *filter = cb->data; 5688 const struct nlattr * const *nla = cb->data;
5689 struct nft_flowtable_filter *filter = NULL;
5656 5690
5657 if (!filter) 5691 if (nla[NFTA_FLOWTABLE_TABLE]) {
5658 return 0; 5692 filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
5693 if (!filter)
5694 return -ENOMEM;
5659 5695
5660 kfree(filter->table); 5696 filter->table = nla_strdup(nla[NFTA_FLOWTABLE_TABLE],
5661 kfree(filter); 5697 GFP_ATOMIC);
5698 if (!filter->table) {
5699 kfree(filter);
5700 return -ENOMEM;
5701 }
5702 }
5662 5703
5704 cb->data = filter;
5663 return 0; 5705 return 0;
5664} 5706}
5665 5707
5666static struct nft_flowtable_filter * 5708static int nf_tables_dump_flowtable_done(struct netlink_callback *cb)
5667nft_flowtable_filter_alloc(const struct nlattr * const nla[])
5668{ 5709{
5669 struct nft_flowtable_filter *filter; 5710 struct nft_flowtable_filter *filter = cb->data;
5670 5711
5671 filter = kzalloc(sizeof(*filter), GFP_ATOMIC);
5672 if (!filter) 5712 if (!filter)
5673 return ERR_PTR(-ENOMEM); 5713 return 0;
5674 5714
5675 if (nla[NFTA_FLOWTABLE_TABLE]) { 5715 kfree(filter->table);
5676 filter->table = nla_strdup(nla[NFTA_FLOWTABLE_TABLE], 5716 kfree(filter);
5677 GFP_ATOMIC); 5717
5678 if (!filter->table) { 5718 return 0;
5679 kfree(filter);
5680 return ERR_PTR(-ENOMEM);
5681 }
5682 }
5683 return filter;
5684} 5719}
5685 5720
5686/* called with rcu_read_lock held */ 5721/* called with rcu_read_lock held */
@@ -5700,20 +5735,13 @@ static int nf_tables_getflowtable(struct net *net, struct sock *nlsk,
5700 5735
5701 if (nlh->nlmsg_flags & NLM_F_DUMP) { 5736 if (nlh->nlmsg_flags & NLM_F_DUMP) {
5702 struct netlink_dump_control c = { 5737 struct netlink_dump_control c = {
5738 .start = nf_tables_dump_flowtable_start,
5703 .dump = nf_tables_dump_flowtable, 5739 .dump = nf_tables_dump_flowtable,
5704 .done = nf_tables_dump_flowtable_done, 5740 .done = nf_tables_dump_flowtable_done,
5705 .module = THIS_MODULE, 5741 .module = THIS_MODULE,
5742 .data = (void *)nla,
5706 }; 5743 };
5707 5744
5708 if (nla[NFTA_FLOWTABLE_TABLE]) {
5709 struct nft_flowtable_filter *filter;
5710
5711 filter = nft_flowtable_filter_alloc(nla);
5712 if (IS_ERR(filter))
5713 return -ENOMEM;
5714
5715 c.data = filter;
5716 }
5717 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c); 5745 return nft_netlink_dump_start_rcu(nlsk, skb, nlh, &c);
5718 } 5746 }
5719 5747
@@ -5783,6 +5811,7 @@ static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable)
5783 kfree(flowtable->name); 5811 kfree(flowtable->name);
5784 flowtable->data.type->free(&flowtable->data); 5812 flowtable->data.type->free(&flowtable->data);
5785 module_put(flowtable->data.type->owner); 5813 module_put(flowtable->data.type->owner);
5814 kfree(flowtable);
5786} 5815}
5787 5816
5788static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net, 5817static int nf_tables_fill_gen_info(struct sk_buff *skb, struct net *net,
@@ -5825,7 +5854,6 @@ static void nft_flowtable_event(unsigned long event, struct net_device *dev,
5825 continue; 5854 continue;
5826 5855
5827 nf_unregister_net_hook(dev_net(dev), &flowtable->ops[i]); 5856 nf_unregister_net_hook(dev_net(dev), &flowtable->ops[i]);
5828 flowtable->dev_name[i][0] = '\0';
5829 flowtable->ops[i].dev = NULL; 5857 flowtable->ops[i].dev = NULL;
5830 break; 5858 break;
5831 } 5859 }
@@ -6086,6 +6114,9 @@ static void nft_commit_release(struct nft_trans *trans)
6086 case NFT_MSG_DELTABLE: 6114 case NFT_MSG_DELTABLE:
6087 nf_tables_table_destroy(&trans->ctx); 6115 nf_tables_table_destroy(&trans->ctx);
6088 break; 6116 break;
6117 case NFT_MSG_NEWCHAIN:
6118 kfree(nft_trans_chain_name(trans));
6119 break;
6089 case NFT_MSG_DELCHAIN: 6120 case NFT_MSG_DELCHAIN:
6090 nf_tables_chain_destroy(&trans->ctx); 6121 nf_tables_chain_destroy(&trans->ctx);
6091 break; 6122 break;
@@ -6315,13 +6346,15 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
6315 nf_tables_table_notify(&trans->ctx, NFT_MSG_DELTABLE); 6346 nf_tables_table_notify(&trans->ctx, NFT_MSG_DELTABLE);
6316 break; 6347 break;
6317 case NFT_MSG_NEWCHAIN: 6348 case NFT_MSG_NEWCHAIN:
6318 if (nft_trans_chain_update(trans)) 6349 if (nft_trans_chain_update(trans)) {
6319 nft_chain_commit_update(trans); 6350 nft_chain_commit_update(trans);
6320 else 6351 nf_tables_chain_notify(&trans->ctx, NFT_MSG_NEWCHAIN);
6352 /* trans destroyed after rcu grace period */
6353 } else {
6321 nft_clear(net, trans->ctx.chain); 6354 nft_clear(net, trans->ctx.chain);
6322 6355 nf_tables_chain_notify(&trans->ctx, NFT_MSG_NEWCHAIN);
6323 nf_tables_chain_notify(&trans->ctx, NFT_MSG_NEWCHAIN); 6356 nft_trans_destroy(trans);
6324 nft_trans_destroy(trans); 6357 }
6325 break; 6358 break;
6326 case NFT_MSG_DELCHAIN: 6359 case NFT_MSG_DELCHAIN:
6327 nft_chain_del(trans->ctx.chain); 6360 nft_chain_del(trans->ctx.chain);
@@ -6471,7 +6504,7 @@ static int __nf_tables_abort(struct net *net)
6471 case NFT_MSG_NEWCHAIN: 6504 case NFT_MSG_NEWCHAIN:
6472 if (nft_trans_chain_update(trans)) { 6505 if (nft_trans_chain_update(trans)) {
6473 free_percpu(nft_trans_chain_stats(trans)); 6506 free_percpu(nft_trans_chain_stats(trans));
6474 6507 kfree(nft_trans_chain_name(trans));
6475 nft_trans_destroy(trans); 6508 nft_trans_destroy(trans);
6476 } else { 6509 } else {
6477 trans->ctx.table->use--; 6510 trans->ctx.table->use--;
@@ -6837,13 +6870,6 @@ int nft_validate_register_store(const struct nft_ctx *ctx,
6837 err = nf_tables_check_loops(ctx, data->verdict.chain); 6870 err = nf_tables_check_loops(ctx, data->verdict.chain);
6838 if (err < 0) 6871 if (err < 0)
6839 return err; 6872 return err;
6840
6841 if (ctx->chain->level + 1 >
6842 data->verdict.chain->level) {
6843 if (ctx->chain->level + 1 == NFT_JUMP_STACK_SIZE)
6844 return -EMLINK;
6845 data->verdict.chain->level = ctx->chain->level + 1;
6846 }
6847 } 6873 }
6848 6874
6849 return 0; 6875 return 0;
diff --git a/net/netfilter/nf_tables_set_core.c b/net/netfilter/nf_tables_set_core.c
new file mode 100644
index 000000000000..814789644bd3
--- /dev/null
+++ b/net/netfilter/nf_tables_set_core.c
@@ -0,0 +1,28 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#include <net/netfilter/nf_tables_core.h>
3
4static int __init nf_tables_set_module_init(void)
5{
6 nft_register_set(&nft_set_hash_fast_type);
7 nft_register_set(&nft_set_hash_type);
8 nft_register_set(&nft_set_rhash_type);
9 nft_register_set(&nft_set_bitmap_type);
10 nft_register_set(&nft_set_rbtree_type);
11
12 return 0;
13}
14
15static void __exit nf_tables_set_module_exit(void)
16{
17 nft_unregister_set(&nft_set_rbtree_type);
18 nft_unregister_set(&nft_set_bitmap_type);
19 nft_unregister_set(&nft_set_rhash_type);
20 nft_unregister_set(&nft_set_hash_type);
21 nft_unregister_set(&nft_set_hash_fast_type);
22}
23
24module_init(nf_tables_set_module_init);
25module_exit(nf_tables_set_module_exit);
26
27MODULE_LICENSE("GPL");
28MODULE_ALIAS_NFT_SET();
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 8d1ff654e5af..32535eea51b2 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -832,10 +832,18 @@ nft_target_select_ops(const struct nft_ctx *ctx,
832 rev = ntohl(nla_get_be32(tb[NFTA_TARGET_REV])); 832 rev = ntohl(nla_get_be32(tb[NFTA_TARGET_REV]));
833 family = ctx->family; 833 family = ctx->family;
834 834
835 if (strcmp(tg_name, XT_ERROR_TARGET) == 0 ||
836 strcmp(tg_name, XT_STANDARD_TARGET) == 0 ||
837 strcmp(tg_name, "standard") == 0)
838 return ERR_PTR(-EINVAL);
839
835 /* Re-use the existing target if it's already loaded. */ 840 /* Re-use the existing target if it's already loaded. */
836 list_for_each_entry(nft_target, &nft_target_list, head) { 841 list_for_each_entry(nft_target, &nft_target_list, head) {
837 struct xt_target *target = nft_target->ops.data; 842 struct xt_target *target = nft_target->ops.data;
838 843
844 if (!target->target)
845 continue;
846
839 if (nft_target_cmp(target, tg_name, rev, family)) 847 if (nft_target_cmp(target, tg_name, rev, family))
840 return &nft_target->ops; 848 return &nft_target->ops;
841 } 849 }
@@ -844,6 +852,11 @@ nft_target_select_ops(const struct nft_ctx *ctx,
844 if (IS_ERR(target)) 852 if (IS_ERR(target))
845 return ERR_PTR(-ENOENT); 853 return ERR_PTR(-ENOENT);
846 854
855 if (!target->target) {
856 err = -EINVAL;
857 goto err;
858 }
859
847 if (target->targetsize > nla_len(tb[NFTA_TARGET_INFO])) { 860 if (target->targetsize > nla_len(tb[NFTA_TARGET_INFO])) {
848 err = -EINVAL; 861 err = -EINVAL;
849 goto err; 862 goto err;
diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c
index 15adf8ca82c3..0777a93211e2 100644
--- a/net/netfilter/nft_immediate.c
+++ b/net/netfilter/nft_immediate.c
@@ -98,6 +98,7 @@ static int nft_immediate_validate(const struct nft_ctx *ctx,
98 const struct nft_data **d) 98 const struct nft_data **d)
99{ 99{
100 const struct nft_immediate_expr *priv = nft_expr_priv(expr); 100 const struct nft_immediate_expr *priv = nft_expr_priv(expr);
101 struct nft_ctx *pctx = (struct nft_ctx *)ctx;
101 const struct nft_data *data; 102 const struct nft_data *data;
102 int err; 103 int err;
103 104
@@ -109,9 +110,11 @@ static int nft_immediate_validate(const struct nft_ctx *ctx,
109 switch (data->verdict.code) { 110 switch (data->verdict.code) {
110 case NFT_JUMP: 111 case NFT_JUMP:
111 case NFT_GOTO: 112 case NFT_GOTO:
113 pctx->level++;
112 err = nft_chain_validate(ctx, data->verdict.chain); 114 err = nft_chain_validate(ctx, data->verdict.chain);
113 if (err < 0) 115 if (err < 0)
114 return err; 116 return err;
117 pctx->level--;
115 break; 118 break;
116 default: 119 default:
117 break; 120 break;
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index 42e6fadf1417..c2a1d84cdfc4 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -155,7 +155,9 @@ static int nft_lookup_validate_setelem(const struct nft_ctx *ctx,
155 struct nft_set_elem *elem) 155 struct nft_set_elem *elem)
156{ 156{
157 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv); 157 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv);
158 struct nft_ctx *pctx = (struct nft_ctx *)ctx;
158 const struct nft_data *data; 159 const struct nft_data *data;
160 int err;
159 161
160 if (nft_set_ext_exists(ext, NFT_SET_EXT_FLAGS) && 162 if (nft_set_ext_exists(ext, NFT_SET_EXT_FLAGS) &&
161 *nft_set_ext_flags(ext) & NFT_SET_ELEM_INTERVAL_END) 163 *nft_set_ext_flags(ext) & NFT_SET_ELEM_INTERVAL_END)
@@ -165,10 +167,17 @@ static int nft_lookup_validate_setelem(const struct nft_ctx *ctx,
165 switch (data->verdict.code) { 167 switch (data->verdict.code) {
166 case NFT_JUMP: 168 case NFT_JUMP:
167 case NFT_GOTO: 169 case NFT_GOTO:
168 return nft_chain_validate(ctx, data->verdict.chain); 170 pctx->level++;
171 err = nft_chain_validate(ctx, data->verdict.chain);
172 if (err < 0)
173 return err;
174 pctx->level--;
175 break;
169 default: 176 default:
170 return 0; 177 break;
171 } 178 }
179
180 return 0;
172} 181}
173 182
174static int nft_lookup_validate(const struct nft_ctx *ctx, 183static int nft_lookup_validate(const struct nft_ctx *ctx,
diff --git a/net/netfilter/nft_set_bitmap.c b/net/netfilter/nft_set_bitmap.c
index d6626e01c7ee..128bc16f52dd 100644
--- a/net/netfilter/nft_set_bitmap.c
+++ b/net/netfilter/nft_set_bitmap.c
@@ -296,7 +296,7 @@ static bool nft_bitmap_estimate(const struct nft_set_desc *desc, u32 features,
296 return true; 296 return true;
297} 297}
298 298
299static struct nft_set_type nft_bitmap_type __read_mostly = { 299struct nft_set_type nft_set_bitmap_type __read_mostly = {
300 .owner = THIS_MODULE, 300 .owner = THIS_MODULE,
301 .ops = { 301 .ops = {
302 .privsize = nft_bitmap_privsize, 302 .privsize = nft_bitmap_privsize,
@@ -314,20 +314,3 @@ static struct nft_set_type nft_bitmap_type __read_mostly = {
314 .get = nft_bitmap_get, 314 .get = nft_bitmap_get,
315 }, 315 },
316}; 316};
317
318static int __init nft_bitmap_module_init(void)
319{
320 return nft_register_set(&nft_bitmap_type);
321}
322
323static void __exit nft_bitmap_module_exit(void)
324{
325 nft_unregister_set(&nft_bitmap_type);
326}
327
328module_init(nft_bitmap_module_init);
329module_exit(nft_bitmap_module_exit);
330
331MODULE_LICENSE("GPL");
332MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
333MODULE_ALIAS_NFT_SET();
diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c
index 6f9a1365a09f..90c3e7e6cacb 100644
--- a/net/netfilter/nft_set_hash.c
+++ b/net/netfilter/nft_set_hash.c
@@ -387,6 +387,7 @@ static void nft_rhash_destroy(const struct nft_set *set)
387 struct nft_rhash *priv = nft_set_priv(set); 387 struct nft_rhash *priv = nft_set_priv(set);
388 388
389 cancel_delayed_work_sync(&priv->gc_work); 389 cancel_delayed_work_sync(&priv->gc_work);
390 rcu_barrier();
390 rhashtable_free_and_destroy(&priv->ht, nft_rhash_elem_destroy, 391 rhashtable_free_and_destroy(&priv->ht, nft_rhash_elem_destroy,
391 (void *)set); 392 (void *)set);
392} 393}
@@ -654,7 +655,7 @@ static bool nft_hash_fast_estimate(const struct nft_set_desc *desc, u32 features
654 return true; 655 return true;
655} 656}
656 657
657static struct nft_set_type nft_rhash_type __read_mostly = { 658struct nft_set_type nft_set_rhash_type __read_mostly = {
658 .owner = THIS_MODULE, 659 .owner = THIS_MODULE,
659 .features = NFT_SET_MAP | NFT_SET_OBJECT | 660 .features = NFT_SET_MAP | NFT_SET_OBJECT |
660 NFT_SET_TIMEOUT | NFT_SET_EVAL, 661 NFT_SET_TIMEOUT | NFT_SET_EVAL,
@@ -677,7 +678,7 @@ static struct nft_set_type nft_rhash_type __read_mostly = {
677 }, 678 },
678}; 679};
679 680
680static struct nft_set_type nft_hash_type __read_mostly = { 681struct nft_set_type nft_set_hash_type __read_mostly = {
681 .owner = THIS_MODULE, 682 .owner = THIS_MODULE,
682 .features = NFT_SET_MAP | NFT_SET_OBJECT, 683 .features = NFT_SET_MAP | NFT_SET_OBJECT,
683 .ops = { 684 .ops = {
@@ -697,7 +698,7 @@ static struct nft_set_type nft_hash_type __read_mostly = {
697 }, 698 },
698}; 699};
699 700
700static struct nft_set_type nft_hash_fast_type __read_mostly = { 701struct nft_set_type nft_set_hash_fast_type __read_mostly = {
701 .owner = THIS_MODULE, 702 .owner = THIS_MODULE,
702 .features = NFT_SET_MAP | NFT_SET_OBJECT, 703 .features = NFT_SET_MAP | NFT_SET_OBJECT,
703 .ops = { 704 .ops = {
@@ -716,26 +717,3 @@ static struct nft_set_type nft_hash_fast_type __read_mostly = {
716 .get = nft_hash_get, 717 .get = nft_hash_get,
717 }, 718 },
718}; 719};
719
720static int __init nft_hash_module_init(void)
721{
722 if (nft_register_set(&nft_hash_fast_type) ||
723 nft_register_set(&nft_hash_type) ||
724 nft_register_set(&nft_rhash_type))
725 return 1;
726 return 0;
727}
728
729static void __exit nft_hash_module_exit(void)
730{
731 nft_unregister_set(&nft_rhash_type);
732 nft_unregister_set(&nft_hash_type);
733 nft_unregister_set(&nft_hash_fast_type);
734}
735
736module_init(nft_hash_module_init);
737module_exit(nft_hash_module_exit);
738
739MODULE_LICENSE("GPL");
740MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
741MODULE_ALIAS_NFT_SET();
diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
index 7f3a9a211034..9873d734b494 100644
--- a/net/netfilter/nft_set_rbtree.c
+++ b/net/netfilter/nft_set_rbtree.c
@@ -381,7 +381,7 @@ static void nft_rbtree_gc(struct work_struct *work)
381 381
382 gcb = nft_set_gc_batch_check(set, gcb, GFP_ATOMIC); 382 gcb = nft_set_gc_batch_check(set, gcb, GFP_ATOMIC);
383 if (!gcb) 383 if (!gcb)
384 goto out; 384 break;
385 385
386 atomic_dec(&set->nelems); 386 atomic_dec(&set->nelems);
387 nft_set_gc_batch_add(gcb, rbe); 387 nft_set_gc_batch_add(gcb, rbe);
@@ -390,10 +390,12 @@ static void nft_rbtree_gc(struct work_struct *work)
390 rbe = rb_entry(prev, struct nft_rbtree_elem, node); 390 rbe = rb_entry(prev, struct nft_rbtree_elem, node);
391 atomic_dec(&set->nelems); 391 atomic_dec(&set->nelems);
392 nft_set_gc_batch_add(gcb, rbe); 392 nft_set_gc_batch_add(gcb, rbe);
393 prev = NULL;
393 } 394 }
394 node = rb_next(node); 395 node = rb_next(node);
396 if (!node)
397 break;
395 } 398 }
396out:
397 if (gcb) { 399 if (gcb) {
398 for (i = 0; i < gcb->head.cnt; i++) { 400 for (i = 0; i < gcb->head.cnt; i++) {
399 rbe = gcb->elems[i]; 401 rbe = gcb->elems[i];
@@ -440,6 +442,7 @@ static void nft_rbtree_destroy(const struct nft_set *set)
440 struct rb_node *node; 442 struct rb_node *node;
441 443
442 cancel_delayed_work_sync(&priv->gc_work); 444 cancel_delayed_work_sync(&priv->gc_work);
445 rcu_barrier();
443 while ((node = priv->root.rb_node) != NULL) { 446 while ((node = priv->root.rb_node) != NULL) {
444 rb_erase(node, &priv->root); 447 rb_erase(node, &priv->root);
445 rbe = rb_entry(node, struct nft_rbtree_elem, node); 448 rbe = rb_entry(node, struct nft_rbtree_elem, node);
@@ -462,7 +465,7 @@ static bool nft_rbtree_estimate(const struct nft_set_desc *desc, u32 features,
462 return true; 465 return true;
463} 466}
464 467
465static struct nft_set_type nft_rbtree_type __read_mostly = { 468struct nft_set_type nft_set_rbtree_type __read_mostly = {
466 .owner = THIS_MODULE, 469 .owner = THIS_MODULE,
467 .features = NFT_SET_INTERVAL | NFT_SET_MAP | NFT_SET_OBJECT | NFT_SET_TIMEOUT, 470 .features = NFT_SET_INTERVAL | NFT_SET_MAP | NFT_SET_OBJECT | NFT_SET_TIMEOUT,
468 .ops = { 471 .ops = {
@@ -481,20 +484,3 @@ static struct nft_set_type nft_rbtree_type __read_mostly = {
481 .get = nft_rbtree_get, 484 .get = nft_rbtree_get,
482 }, 485 },
483}; 486};
484
485static int __init nft_rbtree_module_init(void)
486{
487 return nft_register_set(&nft_rbtree_type);
488}
489
490static void __exit nft_rbtree_module_exit(void)
491{
492 nft_unregister_set(&nft_rbtree_type);
493}
494
495module_init(nft_rbtree_module_init);
496module_exit(nft_rbtree_module_exit);
497
498MODULE_LICENSE("GPL");
499MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
500MODULE_ALIAS_NFT_SET();
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c
index 58fce4e749a9..d76550a8b642 100644
--- a/net/netfilter/xt_TPROXY.c
+++ b/net/netfilter/xt_TPROXY.c
@@ -61,7 +61,7 @@ tproxy_tg4(struct net *net, struct sk_buff *skb, __be32 laddr, __be16 lport,
61 * addresses, this happens if the redirect already happened 61 * addresses, this happens if the redirect already happened
62 * and the current packet belongs to an already established 62 * and the current packet belongs to an already established
63 * connection */ 63 * connection */
64 sk = nf_tproxy_get_sock_v4(net, skb, hp, iph->protocol, 64 sk = nf_tproxy_get_sock_v4(net, skb, iph->protocol,
65 iph->saddr, iph->daddr, 65 iph->saddr, iph->daddr,
66 hp->source, hp->dest, 66 hp->source, hp->dest,
67 skb->dev, NF_TPROXY_LOOKUP_ESTABLISHED); 67 skb->dev, NF_TPROXY_LOOKUP_ESTABLISHED);
@@ -77,7 +77,7 @@ tproxy_tg4(struct net *net, struct sk_buff *skb, __be32 laddr, __be16 lport,
77 else if (!sk) 77 else if (!sk)
78 /* no, there's no established connection, check if 78 /* no, there's no established connection, check if
79 * there's a listener on the redirected addr/port */ 79 * there's a listener on the redirected addr/port */
80 sk = nf_tproxy_get_sock_v4(net, skb, hp, iph->protocol, 80 sk = nf_tproxy_get_sock_v4(net, skb, iph->protocol,
81 iph->saddr, laddr, 81 iph->saddr, laddr,
82 hp->source, lport, 82 hp->source, lport,
83 skb->dev, NF_TPROXY_LOOKUP_LISTENER); 83 skb->dev, NF_TPROXY_LOOKUP_LISTENER);
@@ -150,7 +150,7 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
150 * addresses, this happens if the redirect already happened 150 * addresses, this happens if the redirect already happened
151 * and the current packet belongs to an already established 151 * and the current packet belongs to an already established
152 * connection */ 152 * connection */
153 sk = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff, hp, tproto, 153 sk = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff, tproto,
154 &iph->saddr, &iph->daddr, 154 &iph->saddr, &iph->daddr,
155 hp->source, hp->dest, 155 hp->source, hp->dest,
156 xt_in(par), NF_TPROXY_LOOKUP_ESTABLISHED); 156 xt_in(par), NF_TPROXY_LOOKUP_ESTABLISHED);
@@ -171,7 +171,7 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
171 else if (!sk) 171 else if (!sk)
172 /* no there's no established connection, check if 172 /* no there's no established connection, check if
173 * there's a listener on the redirected addr/port */ 173 * there's a listener on the redirected addr/port */
174 sk = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff, hp, 174 sk = nf_tproxy_get_sock_v6(xt_net(par), skb, thoff,
175 tproto, &iph->saddr, laddr, 175 tproto, &iph->saddr, laddr,
176 hp->source, lport, 176 hp->source, lport,
177 xt_in(par), NF_TPROXY_LOOKUP_LISTENER); 177 xt_in(par), NF_TPROXY_LOOKUP_LISTENER);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 393573a99a5a..56704d95f82d 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -63,6 +63,7 @@
63#include <linux/hash.h> 63#include <linux/hash.h>
64#include <linux/genetlink.h> 64#include <linux/genetlink.h>
65#include <linux/net_namespace.h> 65#include <linux/net_namespace.h>
66#include <linux/nospec.h>
66 67
67#include <net/net_namespace.h> 68#include <net/net_namespace.h>
68#include <net/netns/generic.h> 69#include <net/netns/generic.h>
@@ -679,6 +680,7 @@ static int netlink_create(struct net *net, struct socket *sock, int protocol,
679 680
680 if (protocol < 0 || protocol >= MAX_LINKS) 681 if (protocol < 0 || protocol >= MAX_LINKS)
681 return -EPROTONOSUPPORT; 682 return -EPROTONOSUPPORT;
683 protocol = array_index_nospec(protocol, MAX_LINKS);
682 684
683 netlink_lock_table(); 685 netlink_lock_table();
684#ifdef CONFIG_MODULES 686#ifdef CONFIG_MODULES
@@ -1009,6 +1011,11 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1009 return err; 1011 return err;
1010 } 1012 }
1011 1013
1014 if (nlk->ngroups == 0)
1015 groups = 0;
1016 else if (nlk->ngroups < 8*sizeof(groups))
1017 groups &= (1UL << nlk->ngroups) - 1;
1018
1012 bound = nlk->bound; 1019 bound = nlk->bound;
1013 if (bound) { 1020 if (bound) {
1014 /* Ensure nlk->portid is up-to-date. */ 1021 /* Ensure nlk->portid is up-to-date. */
diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c
index 2ceefa183cee..6a196e438b6c 100644
--- a/net/nfc/llcp_commands.c
+++ b/net/nfc/llcp_commands.c
@@ -752,11 +752,14 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
752 pr_debug("Fragment %zd bytes remaining %zd", 752 pr_debug("Fragment %zd bytes remaining %zd",
753 frag_len, remaining_len); 753 frag_len, remaining_len);
754 754
755 pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT, 755 pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, 0,
756 frag_len + LLCP_HEADER_SIZE, &err); 756 frag_len + LLCP_HEADER_SIZE, &err);
757 if (pdu == NULL) { 757 if (pdu == NULL) {
758 pr_err("Could not allocate PDU\n"); 758 pr_err("Could not allocate PDU (error=%d)\n", err);
759 continue; 759 len -= remaining_len;
760 if (len == 0)
761 len = err;
762 break;
760 } 763 }
761 764
762 pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI); 765 pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
diff --git a/net/nsh/nsh.c b/net/nsh/nsh.c
index 9696ef96b719..1a30e165eeb4 100644
--- a/net/nsh/nsh.c
+++ b/net/nsh/nsh.c
@@ -104,7 +104,7 @@ static struct sk_buff *nsh_gso_segment(struct sk_buff *skb,
104 __skb_pull(skb, nsh_len); 104 __skb_pull(skb, nsh_len);
105 105
106 skb_reset_mac_header(skb); 106 skb_reset_mac_header(skb);
107 skb_reset_mac_len(skb); 107 skb->mac_len = proto == htons(ETH_P_TEB) ? ETH_HLEN : 0;
108 skb->protocol = proto; 108 skb->protocol = proto;
109 109
110 features &= NETIF_F_SG; 110 features &= NETIF_F_SG;
diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index b891a91577f8..c038e021a591 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -211,6 +211,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
211 if (!meter) 211 if (!meter)
212 return ERR_PTR(-ENOMEM); 212 return ERR_PTR(-ENOMEM);
213 213
214 meter->id = nla_get_u32(a[OVS_METER_ATTR_ID]);
214 meter->used = div_u64(ktime_get_ns(), 1000 * 1000); 215 meter->used = div_u64(ktime_get_ns(), 1000 * 1000);
215 meter->kbps = a[OVS_METER_ATTR_KBPS] ? 1 : 0; 216 meter->kbps = a[OVS_METER_ATTR_KBPS] ? 1 : 0;
216 meter->keep_stats = !a[OVS_METER_ATTR_CLEAR]; 217 meter->keep_stats = !a[OVS_METER_ATTR_CLEAR];
@@ -280,6 +281,10 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
280 u32 meter_id; 281 u32 meter_id;
281 bool failed; 282 bool failed;
282 283
284 if (!a[OVS_METER_ATTR_ID]) {
285 return -ENODEV;
286 }
287
283 meter = dp_meter_create(a); 288 meter = dp_meter_create(a);
284 if (IS_ERR_OR_NULL(meter)) 289 if (IS_ERR_OR_NULL(meter))
285 return PTR_ERR(meter); 290 return PTR_ERR(meter);
@@ -298,11 +303,6 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
298 goto exit_unlock; 303 goto exit_unlock;
299 } 304 }
300 305
301 if (!a[OVS_METER_ATTR_ID]) {
302 err = -ENODEV;
303 goto exit_unlock;
304 }
305
306 meter_id = nla_get_u32(a[OVS_METER_ATTR_ID]); 306 meter_id = nla_get_u32(a[OVS_METER_ATTR_ID]);
307 307
308 /* Cannot fail after this. */ 308 /* Cannot fail after this. */
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 57634bc3da74..9b27d0cd766d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2878,6 +2878,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2878 goto out_free; 2878 goto out_free;
2879 } else if (reserve) { 2879 } else if (reserve) {
2880 skb_reserve(skb, -reserve); 2880 skb_reserve(skb, -reserve);
2881 if (len < reserve)
2882 skb_reset_network_header(skb);
2881 } 2883 }
2882 2884
2883 /* Returns -EFAULT on error */ 2885 /* Returns -EFAULT on error */
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 2aa07b547b16..86e1e37eb4e8 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -191,8 +191,13 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
191 hdr->type = cpu_to_le32(type); 191 hdr->type = cpu_to_le32(type);
192 hdr->src_node_id = cpu_to_le32(from->sq_node); 192 hdr->src_node_id = cpu_to_le32(from->sq_node);
193 hdr->src_port_id = cpu_to_le32(from->sq_port); 193 hdr->src_port_id = cpu_to_le32(from->sq_port);
194 hdr->dst_node_id = cpu_to_le32(to->sq_node); 194 if (to->sq_port == QRTR_PORT_CTRL) {
195 hdr->dst_port_id = cpu_to_le32(to->sq_port); 195 hdr->dst_node_id = cpu_to_le32(node->nid);
196 hdr->dst_port_id = cpu_to_le32(QRTR_NODE_BCAST);
197 } else {
198 hdr->dst_node_id = cpu_to_le32(to->sq_node);
199 hdr->dst_port_id = cpu_to_le32(to->sq_port);
200 }
196 201
197 hdr->size = cpu_to_le32(len); 202 hdr->size = cpu_to_le32(len);
198 hdr->confirm_rx = 0; 203 hdr->confirm_rx = 0;
@@ -764,6 +769,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
764 node = NULL; 769 node = NULL;
765 if (addr->sq_node == QRTR_NODE_BCAST) { 770 if (addr->sq_node == QRTR_NODE_BCAST) {
766 enqueue_fn = qrtr_bcast_enqueue; 771 enqueue_fn = qrtr_bcast_enqueue;
772 if (addr->sq_port != QRTR_PORT_CTRL) {
773 release_sock(sk);
774 return -ENOTCONN;
775 }
767 } else if (addr->sq_node == ipc->us.sq_node) { 776 } else if (addr->sq_node == ipc->us.sq_node) {
768 enqueue_fn = qrtr_local_enqueue; 777 enqueue_fn = qrtr_local_enqueue;
769 } else { 778 } else {
diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index 48332a6ed738..d152e48ea371 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -344,6 +344,11 @@ struct rds_ib_mr *rds_ib_reg_frmr(struct rds_ib_device *rds_ibdev,
344 struct rds_ib_frmr *frmr; 344 struct rds_ib_frmr *frmr;
345 int ret; 345 int ret;
346 346
347 if (!ic) {
348 /* TODO: Add FRWR support for RDS_GET_MR using proxy qp*/
349 return ERR_PTR(-EOPNOTSUPP);
350 }
351
347 do { 352 do {
348 if (ibmr) 353 if (ibmr)
349 rds_ib_free_frmr(ibmr, true); 354 rds_ib_free_frmr(ibmr, true);
diff --git a/net/rds/ib_mr.h b/net/rds/ib_mr.h
index 0ea4ab017a8c..655f01d427fe 100644
--- a/net/rds/ib_mr.h
+++ b/net/rds/ib_mr.h
@@ -115,7 +115,8 @@ void rds_ib_get_mr_info(struct rds_ib_device *rds_ibdev,
115 struct rds_info_rdma_connection *iinfo); 115 struct rds_info_rdma_connection *iinfo);
116void rds_ib_destroy_mr_pool(struct rds_ib_mr_pool *); 116void rds_ib_destroy_mr_pool(struct rds_ib_mr_pool *);
117void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents, 117void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
118 struct rds_sock *rs, u32 *key_ret); 118 struct rds_sock *rs, u32 *key_ret,
119 struct rds_connection *conn);
119void rds_ib_sync_mr(void *trans_private, int dir); 120void rds_ib_sync_mr(void *trans_private, int dir);
120void rds_ib_free_mr(void *trans_private, int invalidate); 121void rds_ib_free_mr(void *trans_private, int invalidate);
121void rds_ib_flush_mrs(void); 122void rds_ib_flush_mrs(void);
diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c
index e678699268a2..2e49a40a5e11 100644
--- a/net/rds/ib_rdma.c
+++ b/net/rds/ib_rdma.c
@@ -537,11 +537,12 @@ void rds_ib_flush_mrs(void)
537} 537}
538 538
539void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents, 539void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
540 struct rds_sock *rs, u32 *key_ret) 540 struct rds_sock *rs, u32 *key_ret,
541 struct rds_connection *conn)
541{ 542{
542 struct rds_ib_device *rds_ibdev; 543 struct rds_ib_device *rds_ibdev;
543 struct rds_ib_mr *ibmr = NULL; 544 struct rds_ib_mr *ibmr = NULL;
544 struct rds_ib_connection *ic = rs->rs_conn->c_transport_data; 545 struct rds_ib_connection *ic = NULL;
545 int ret; 546 int ret;
546 547
547 rds_ibdev = rds_ib_get_device(rs->rs_bound_addr); 548 rds_ibdev = rds_ib_get_device(rs->rs_bound_addr);
@@ -550,6 +551,9 @@ void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
550 goto out; 551 goto out;
551 } 552 }
552 553
554 if (conn)
555 ic = conn->c_transport_data;
556
553 if (!rds_ibdev->mr_8k_pool || !rds_ibdev->mr_1m_pool) { 557 if (!rds_ibdev->mr_8k_pool || !rds_ibdev->mr_1m_pool) {
554 ret = -ENODEV; 558 ret = -ENODEV;
555 goto out; 559 goto out;
@@ -559,17 +563,18 @@ void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
559 ibmr = rds_ib_reg_frmr(rds_ibdev, ic, sg, nents, key_ret); 563 ibmr = rds_ib_reg_frmr(rds_ibdev, ic, sg, nents, key_ret);
560 else 564 else
561 ibmr = rds_ib_reg_fmr(rds_ibdev, sg, nents, key_ret); 565 ibmr = rds_ib_reg_fmr(rds_ibdev, sg, nents, key_ret);
562 if (ibmr) 566 if (IS_ERR(ibmr)) {
563 rds_ibdev = NULL; 567 ret = PTR_ERR(ibmr);
564
565 out:
566 if (!ibmr)
567 pr_warn("RDS/IB: rds_ib_get_mr failed (errno=%d)\n", ret); 568 pr_warn("RDS/IB: rds_ib_get_mr failed (errno=%d)\n", ret);
569 } else {
570 return ibmr;
571 }
568 572
573 out:
569 if (rds_ibdev) 574 if (rds_ibdev)
570 rds_ib_dev_put(rds_ibdev); 575 rds_ib_dev_put(rds_ibdev);
571 576
572 return ibmr; 577 return ERR_PTR(ret);
573} 578}
574 579
575void rds_ib_destroy_mr_pool(struct rds_ib_mr_pool *pool) 580void rds_ib_destroy_mr_pool(struct rds_ib_mr_pool *pool)
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 634cfcb7bba6..80920e47f2c7 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -170,7 +170,8 @@ static int rds_pin_pages(unsigned long user_addr, unsigned int nr_pages,
170} 170}
171 171
172static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args, 172static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
173 u64 *cookie_ret, struct rds_mr **mr_ret) 173 u64 *cookie_ret, struct rds_mr **mr_ret,
174 struct rds_conn_path *cp)
174{ 175{
175 struct rds_mr *mr = NULL, *found; 176 struct rds_mr *mr = NULL, *found;
176 unsigned int nr_pages; 177 unsigned int nr_pages;
@@ -269,7 +270,8 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,
269 * Note that dma_map() implies that pending writes are 270 * Note that dma_map() implies that pending writes are
270 * flushed to RAM, so no dma_sync is needed here. */ 271 * flushed to RAM, so no dma_sync is needed here. */
271 trans_private = rs->rs_transport->get_mr(sg, nents, rs, 272 trans_private = rs->rs_transport->get_mr(sg, nents, rs,
272 &mr->r_key); 273 &mr->r_key,
274 cp ? cp->cp_conn : NULL);
273 275
274 if (IS_ERR(trans_private)) { 276 if (IS_ERR(trans_private)) {
275 for (i = 0 ; i < nents; i++) 277 for (i = 0 ; i < nents; i++)
@@ -330,7 +332,7 @@ int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen)
330 sizeof(struct rds_get_mr_args))) 332 sizeof(struct rds_get_mr_args)))
331 return -EFAULT; 333 return -EFAULT;
332 334
333 return __rds_rdma_map(rs, &args, NULL, NULL); 335 return __rds_rdma_map(rs, &args, NULL, NULL, NULL);
334} 336}
335 337
336int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen) 338int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen)
@@ -354,7 +356,7 @@ int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen)
354 new_args.cookie_addr = args.cookie_addr; 356 new_args.cookie_addr = args.cookie_addr;
355 new_args.flags = args.flags; 357 new_args.flags = args.flags;
356 358
357 return __rds_rdma_map(rs, &new_args, NULL, NULL); 359 return __rds_rdma_map(rs, &new_args, NULL, NULL, NULL);
358} 360}
359 361
360/* 362/*
@@ -782,7 +784,8 @@ int rds_cmsg_rdma_map(struct rds_sock *rs, struct rds_message *rm,
782 rm->m_rdma_cookie != 0) 784 rm->m_rdma_cookie != 0)
783 return -EINVAL; 785 return -EINVAL;
784 786
785 return __rds_rdma_map(rs, CMSG_DATA(cmsg), &rm->m_rdma_cookie, &rm->rdma.op_rdma_mr); 787 return __rds_rdma_map(rs, CMSG_DATA(cmsg), &rm->m_rdma_cookie,
788 &rm->rdma.op_rdma_mr, rm->m_conn_path);
786} 789}
787 790
788/* 791/*
diff --git a/net/rds/rds.h b/net/rds/rds.h
index f2272fb8cd45..60b3b787fbdb 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -464,6 +464,8 @@ struct rds_message {
464 struct scatterlist *op_sg; 464 struct scatterlist *op_sg;
465 } data; 465 } data;
466 }; 466 };
467
468 struct rds_conn_path *m_conn_path;
467}; 469};
468 470
469/* 471/*
@@ -544,7 +546,8 @@ struct rds_transport {
544 unsigned int avail); 546 unsigned int avail);
545 void (*exit)(void); 547 void (*exit)(void);
546 void *(*get_mr)(struct scatterlist *sg, unsigned long nr_sg, 548 void *(*get_mr)(struct scatterlist *sg, unsigned long nr_sg,
547 struct rds_sock *rs, u32 *key_ret); 549 struct rds_sock *rs, u32 *key_ret,
550 struct rds_connection *conn);
548 void (*sync_mr)(void *trans_private, int direction); 551 void (*sync_mr)(void *trans_private, int direction);
549 void (*free_mr)(void *trans_private, int invalidate); 552 void (*free_mr)(void *trans_private, int invalidate);
550 void (*flush_mrs)(void); 553 void (*flush_mrs)(void);
diff --git a/net/rds/send.c b/net/rds/send.c
index 94c7f74909be..59f17a2335f4 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -1169,6 +1169,13 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
1169 rs->rs_conn = conn; 1169 rs->rs_conn = conn;
1170 } 1170 }
1171 1171
1172 if (conn->c_trans->t_mp_capable)
1173 cpath = &conn->c_path[rds_send_mprds_hash(rs, conn)];
1174 else
1175 cpath = &conn->c_path[0];
1176
1177 rm->m_conn_path = cpath;
1178
1172 /* Parse any control messages the user may have included. */ 1179 /* Parse any control messages the user may have included. */
1173 ret = rds_cmsg_send(rs, rm, msg, &allocated_mr); 1180 ret = rds_cmsg_send(rs, rm, msg, &allocated_mr);
1174 if (ret) { 1181 if (ret) {
@@ -1192,11 +1199,6 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
1192 goto out; 1199 goto out;
1193 } 1200 }
1194 1201
1195 if (conn->c_trans->t_mp_capable)
1196 cpath = &conn->c_path[rds_send_mprds_hash(rs, conn)];
1197 else
1198 cpath = &conn->c_path[0];
1199
1200 if (rds_destroy_pending(conn)) { 1202 if (rds_destroy_pending(conn)) {
1201 ret = -EAGAIN; 1203 ret = -EAGAIN;
1202 goto out; 1204 goto out;
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index a9a9be5519b9..9d1e298b784c 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -116,9 +116,9 @@ static int rxrpc_service_prealloc_one(struct rxrpc_sock *rx,
116 while (*pp) { 116 while (*pp) {
117 parent = *pp; 117 parent = *pp;
118 xcall = rb_entry(parent, struct rxrpc_call, sock_node); 118 xcall = rb_entry(parent, struct rxrpc_call, sock_node);
119 if (user_call_ID < call->user_call_ID) 119 if (user_call_ID < xcall->user_call_ID)
120 pp = &(*pp)->rb_left; 120 pp = &(*pp)->rb_left;
121 else if (user_call_ID > call->user_call_ID) 121 else if (user_call_ID > xcall->user_call_ID)
122 pp = &(*pp)->rb_right; 122 pp = &(*pp)->rb_right;
123 else 123 else
124 goto id_in_use; 124 goto id_in_use;
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
index 526a8e491626..6e7124e57918 100644
--- a/net/sched/act_csum.c
+++ b/net/sched/act_csum.c
@@ -91,7 +91,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
91 } 91 }
92 params_old = rtnl_dereference(p->params); 92 params_old = rtnl_dereference(p->params);
93 93
94 params_new->action = parm->action; 94 p->tcf_action = parm->action;
95 params_new->update_flags = parm->update_flags; 95 params_new->update_flags = parm->update_flags;
96 rcu_assign_pointer(p->params, params_new); 96 rcu_assign_pointer(p->params, params_new);
97 if (params_old) 97 if (params_old)
@@ -561,7 +561,7 @@ static int tcf_csum(struct sk_buff *skb, const struct tc_action *a,
561 tcf_lastuse_update(&p->tcf_tm); 561 tcf_lastuse_update(&p->tcf_tm);
562 bstats_cpu_update(this_cpu_ptr(p->common.cpu_bstats), skb); 562 bstats_cpu_update(this_cpu_ptr(p->common.cpu_bstats), skb);
563 563
564 action = params->action; 564 action = READ_ONCE(p->tcf_action);
565 if (unlikely(action == TC_ACT_SHOT)) 565 if (unlikely(action == TC_ACT_SHOT))
566 goto drop_stats; 566 goto drop_stats;
567 567
@@ -599,11 +599,11 @@ static int tcf_csum_dump(struct sk_buff *skb, struct tc_action *a, int bind,
599 .index = p->tcf_index, 599 .index = p->tcf_index,
600 .refcnt = p->tcf_refcnt - ref, 600 .refcnt = p->tcf_refcnt - ref,
601 .bindcnt = p->tcf_bindcnt - bind, 601 .bindcnt = p->tcf_bindcnt - bind,
602 .action = p->tcf_action,
602 }; 603 };
603 struct tcf_t t; 604 struct tcf_t t;
604 605
605 params = rtnl_dereference(p->params); 606 params = rtnl_dereference(p->params);
606 opt.action = params->action;
607 opt.update_flags = params->update_flags; 607 opt.update_flags = params->update_flags;
608 608
609 if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt)) 609 if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
index 626dac81a48a..9bc6c2ae98a5 100644
--- a/net/sched/act_tunnel_key.c
+++ b/net/sched/act_tunnel_key.c
@@ -36,7 +36,7 @@ static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
36 36
37 tcf_lastuse_update(&t->tcf_tm); 37 tcf_lastuse_update(&t->tcf_tm);
38 bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb); 38 bstats_cpu_update(this_cpu_ptr(t->common.cpu_bstats), skb);
39 action = params->action; 39 action = READ_ONCE(t->tcf_action);
40 40
41 switch (params->tcft_action) { 41 switch (params->tcft_action) {
42 case TCA_TUNNEL_KEY_ACT_RELEASE: 42 case TCA_TUNNEL_KEY_ACT_RELEASE:
@@ -182,7 +182,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
182 182
183 params_old = rtnl_dereference(t->params); 183 params_old = rtnl_dereference(t->params);
184 184
185 params_new->action = parm->action; 185 t->tcf_action = parm->action;
186 params_new->tcft_action = parm->t_action; 186 params_new->tcft_action = parm->t_action;
187 params_new->tcft_enc_metadata = metadata; 187 params_new->tcft_enc_metadata = metadata;
188 188
@@ -254,13 +254,13 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
254 .index = t->tcf_index, 254 .index = t->tcf_index,
255 .refcnt = t->tcf_refcnt - ref, 255 .refcnt = t->tcf_refcnt - ref,
256 .bindcnt = t->tcf_bindcnt - bind, 256 .bindcnt = t->tcf_bindcnt - bind,
257 .action = t->tcf_action,
257 }; 258 };
258 struct tcf_t tm; 259 struct tcf_t tm;
259 260
260 params = rtnl_dereference(t->params); 261 params = rtnl_dereference(t->params);
261 262
262 opt.t_action = params->tcft_action; 263 opt.t_action = params->tcft_action;
263 opt.action = params->action;
264 264
265 if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt)) 265 if (nla_put(skb, TCA_TUNNEL_KEY_PARMS, sizeof(opt), &opt))
266 goto nla_put_failure; 266 goto nla_put_failure;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index cdc3c87c53e6..f74513a7c7a8 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -1053,7 +1053,7 @@ static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,
1053 for (tp = rtnl_dereference(chain->filter_chain); 1053 for (tp = rtnl_dereference(chain->filter_chain);
1054 tp; tp = rtnl_dereference(tp->next)) 1054 tp; tp = rtnl_dereference(tp->next))
1055 tfilter_notify(net, oskb, n, tp, block, 1055 tfilter_notify(net, oskb, n, tp, block,
1056 q, parent, 0, event, false); 1056 q, parent, NULL, event, false);
1057} 1057}
1058 1058
1059static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, 1059static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
@@ -1444,7 +1444,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent,
1444 memset(&cb->args[1], 0, 1444 memset(&cb->args[1], 0,
1445 sizeof(cb->args) - sizeof(cb->args[0])); 1445 sizeof(cb->args) - sizeof(cb->args[0]));
1446 if (cb->args[1] == 0) { 1446 if (cb->args[1] == 0) {
1447 if (tcf_fill_node(net, skb, tp, block, q, parent, 0, 1447 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL,
1448 NETLINK_CB(cb->skb).portid, 1448 NETLINK_CB(cb->skb).portid,
1449 cb->nlh->nlmsg_seq, NLM_F_MULTI, 1449 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1450 RTM_NEWTFILTER) <= 0) 1450 RTM_NEWTFILTER) <= 0)
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index cd2e0e342fb6..6c0a9d5dbf94 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -479,24 +479,28 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
479 q->cparams.mtu = psched_mtu(qdisc_dev(sch)); 479 q->cparams.mtu = psched_mtu(qdisc_dev(sch));
480 480
481 if (opt) { 481 if (opt) {
482 int err = fq_codel_change(sch, opt, extack); 482 err = fq_codel_change(sch, opt, extack);
483 if (err) 483 if (err)
484 return err; 484 goto init_failure;
485 } 485 }
486 486
487 err = tcf_block_get(&q->block, &q->filter_list, sch, extack); 487 err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
488 if (err) 488 if (err)
489 return err; 489 goto init_failure;
490 490
491 if (!q->flows) { 491 if (!q->flows) {
492 q->flows = kvcalloc(q->flows_cnt, 492 q->flows = kvcalloc(q->flows_cnt,
493 sizeof(struct fq_codel_flow), 493 sizeof(struct fq_codel_flow),
494 GFP_KERNEL); 494 GFP_KERNEL);
495 if (!q->flows) 495 if (!q->flows) {
496 return -ENOMEM; 496 err = -ENOMEM;
497 goto init_failure;
498 }
497 q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL); 499 q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL);
498 if (!q->backlogs) 500 if (!q->backlogs) {
499 return -ENOMEM; 501 err = -ENOMEM;
502 goto alloc_failure;
503 }
500 for (i = 0; i < q->flows_cnt; i++) { 504 for (i = 0; i < q->flows_cnt; i++) {
501 struct fq_codel_flow *flow = q->flows + i; 505 struct fq_codel_flow *flow = q->flows + i;
502 506
@@ -509,6 +513,13 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
509 else 513 else
510 sch->flags &= ~TCQ_F_CAN_BYPASS; 514 sch->flags &= ~TCQ_F_CAN_BYPASS;
511 return 0; 515 return 0;
516
517alloc_failure:
518 kvfree(q->flows);
519 q->flows = NULL;
520init_failure:
521 q->flows_cnt = 0;
522 return err;
512} 523}
513 524
514static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) 525static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb)
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 445b7ef61677..12cac85da994 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -282,7 +282,7 @@ bool sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
282 282
283 if (dst) { 283 if (dst) {
284 /* Re-fetch, as under layers may have a higher minimum size */ 284 /* Re-fetch, as under layers may have a higher minimum size */
285 pmtu = SCTP_TRUNC4(dst_mtu(dst)); 285 pmtu = sctp_dst_mtu(dst);
286 change = t->pathmtu != pmtu; 286 change = t->pathmtu != pmtu;
287 } 287 }
288 t->pathmtu = pmtu; 288 t->pathmtu = pmtu;
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 3c1405df936c..05e4ffe5aabd 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -147,7 +147,8 @@ static int smc_release(struct socket *sock)
147 smc->clcsock = NULL; 147 smc->clcsock = NULL;
148 } 148 }
149 if (smc->use_fallback) { 149 if (smc->use_fallback) {
150 sock_put(sk); /* passive closing */ 150 if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT)
151 sock_put(sk); /* passive closing */
151 sk->sk_state = SMC_CLOSED; 152 sk->sk_state = SMC_CLOSED;
152 sk->sk_state_change(sk); 153 sk->sk_state_change(sk);
153 } 154 }
@@ -417,12 +418,18 @@ static int smc_connect_decline_fallback(struct smc_sock *smc, int reason_code)
417{ 418{
418 int rc; 419 int rc;
419 420
420 if (reason_code < 0) /* error, fallback is not possible */ 421 if (reason_code < 0) { /* error, fallback is not possible */
422 if (smc->sk.sk_state == SMC_INIT)
423 sock_put(&smc->sk); /* passive closing */
421 return reason_code; 424 return reason_code;
425 }
422 if (reason_code != SMC_CLC_DECL_REPLY) { 426 if (reason_code != SMC_CLC_DECL_REPLY) {
423 rc = smc_clc_send_decline(smc, reason_code); 427 rc = smc_clc_send_decline(smc, reason_code);
424 if (rc < 0) 428 if (rc < 0) {
429 if (smc->sk.sk_state == SMC_INIT)
430 sock_put(&smc->sk); /* passive closing */
425 return rc; 431 return rc;
432 }
426 } 433 }
427 return smc_connect_fallback(smc); 434 return smc_connect_fallback(smc);
428} 435}
@@ -435,8 +442,6 @@ static int smc_connect_abort(struct smc_sock *smc, int reason_code,
435 smc_lgr_forget(smc->conn.lgr); 442 smc_lgr_forget(smc->conn.lgr);
436 mutex_unlock(&smc_create_lgr_pending); 443 mutex_unlock(&smc_create_lgr_pending);
437 smc_conn_free(&smc->conn); 444 smc_conn_free(&smc->conn);
438 if (reason_code < 0 && smc->sk.sk_state == SMC_INIT)
439 sock_put(&smc->sk); /* passive closing */
440 return reason_code; 445 return reason_code;
441} 446}
442 447
@@ -1452,7 +1457,8 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
1452 1457
1453 if (optlen < sizeof(int)) 1458 if (optlen < sizeof(int))
1454 return -EINVAL; 1459 return -EINVAL;
1455 get_user(val, (int __user *)optval); 1460 if (get_user(val, (int __user *)optval))
1461 return -EFAULT;
1456 1462
1457 lock_sock(sk); 1463 lock_sock(sk);
1458 switch (optname) { 1464 switch (optname) {
@@ -1520,10 +1526,13 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
1520 return -EBADF; 1526 return -EBADF;
1521 return smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg); 1527 return smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg);
1522 } 1528 }
1529 lock_sock(&smc->sk);
1523 switch (cmd) { 1530 switch (cmd) {
1524 case SIOCINQ: /* same as FIONREAD */ 1531 case SIOCINQ: /* same as FIONREAD */
1525 if (smc->sk.sk_state == SMC_LISTEN) 1532 if (smc->sk.sk_state == SMC_LISTEN) {
1533 release_sock(&smc->sk);
1526 return -EINVAL; 1534 return -EINVAL;
1535 }
1527 if (smc->sk.sk_state == SMC_INIT || 1536 if (smc->sk.sk_state == SMC_INIT ||
1528 smc->sk.sk_state == SMC_CLOSED) 1537 smc->sk.sk_state == SMC_CLOSED)
1529 answ = 0; 1538 answ = 0;
@@ -1532,8 +1541,10 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
1532 break; 1541 break;
1533 case SIOCOUTQ: 1542 case SIOCOUTQ:
1534 /* output queue size (not send + not acked) */ 1543 /* output queue size (not send + not acked) */
1535 if (smc->sk.sk_state == SMC_LISTEN) 1544 if (smc->sk.sk_state == SMC_LISTEN) {
1545 release_sock(&smc->sk);
1536 return -EINVAL; 1546 return -EINVAL;
1547 }
1537 if (smc->sk.sk_state == SMC_INIT || 1548 if (smc->sk.sk_state == SMC_INIT ||
1538 smc->sk.sk_state == SMC_CLOSED) 1549 smc->sk.sk_state == SMC_CLOSED)
1539 answ = 0; 1550 answ = 0;
@@ -1543,8 +1554,10 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
1543 break; 1554 break;
1544 case SIOCOUTQNSD: 1555 case SIOCOUTQNSD:
1545 /* output queue size (not send only) */ 1556 /* output queue size (not send only) */
1546 if (smc->sk.sk_state == SMC_LISTEN) 1557 if (smc->sk.sk_state == SMC_LISTEN) {
1558 release_sock(&smc->sk);
1547 return -EINVAL; 1559 return -EINVAL;
1560 }
1548 if (smc->sk.sk_state == SMC_INIT || 1561 if (smc->sk.sk_state == SMC_INIT ||
1549 smc->sk.sk_state == SMC_CLOSED) 1562 smc->sk.sk_state == SMC_CLOSED)
1550 answ = 0; 1563 answ = 0;
@@ -1552,8 +1565,10 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
1552 answ = smc_tx_prepared_sends(&smc->conn); 1565 answ = smc_tx_prepared_sends(&smc->conn);
1553 break; 1566 break;
1554 case SIOCATMARK: 1567 case SIOCATMARK:
1555 if (smc->sk.sk_state == SMC_LISTEN) 1568 if (smc->sk.sk_state == SMC_LISTEN) {
1569 release_sock(&smc->sk);
1556 return -EINVAL; 1570 return -EINVAL;
1571 }
1557 if (smc->sk.sk_state == SMC_INIT || 1572 if (smc->sk.sk_state == SMC_INIT ||
1558 smc->sk.sk_state == SMC_CLOSED) { 1573 smc->sk.sk_state == SMC_CLOSED) {
1559 answ = 0; 1574 answ = 0;
@@ -1569,8 +1584,10 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,
1569 } 1584 }
1570 break; 1585 break;
1571 default: 1586 default:
1587 release_sock(&smc->sk);
1572 return -ENOIOCTLCMD; 1588 return -ENOIOCTLCMD;
1573 } 1589 }
1590 release_sock(&smc->sk);
1574 1591
1575 return put_user(answ, (int __user *)arg); 1592 return put_user(answ, (int __user *)arg);
1576} 1593}
diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
index a7e8d63fc8ae..9bde1e4ca288 100644
--- a/net/smc/smc_cdc.c
+++ b/net/smc/smc_cdc.c
@@ -233,7 +233,8 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
233 /* force immediate tx of current consumer cursor, but 233 /* force immediate tx of current consumer cursor, but
234 * under send_lock to guarantee arrival in seqno-order 234 * under send_lock to guarantee arrival in seqno-order
235 */ 235 */
236 smc_tx_sndbuf_nonempty(conn); 236 if (smc->sk.sk_state != SMC_INIT)
237 smc_tx_sndbuf_nonempty(conn);
237 } 238 }
238 } 239 }
239 240
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index 717449b1da0b..ae5d168653ce 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -250,6 +250,7 @@ out:
250int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, 250int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
251 u8 expected_type) 251 u8 expected_type)
252{ 252{
253 long rcvtimeo = smc->clcsock->sk->sk_rcvtimeo;
253 struct sock *clc_sk = smc->clcsock->sk; 254 struct sock *clc_sk = smc->clcsock->sk;
254 struct smc_clc_msg_hdr *clcm = buf; 255 struct smc_clc_msg_hdr *clcm = buf;
255 struct msghdr msg = {NULL, 0}; 256 struct msghdr msg = {NULL, 0};
@@ -306,7 +307,6 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
306 memset(&msg, 0, sizeof(struct msghdr)); 307 memset(&msg, 0, sizeof(struct msghdr));
307 iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, datlen); 308 iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, datlen);
308 krflags = MSG_WAITALL; 309 krflags = MSG_WAITALL;
309 smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME;
310 len = sock_recvmsg(smc->clcsock, &msg, krflags); 310 len = sock_recvmsg(smc->clcsock, &msg, krflags);
311 if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) { 311 if (len < datlen || !smc_clc_msg_hdr_valid(clcm)) {
312 smc->sk.sk_err = EPROTO; 312 smc->sk.sk_err = EPROTO;
@@ -322,6 +322,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
322 } 322 }
323 323
324out: 324out:
325 smc->clcsock->sk->sk_rcvtimeo = rcvtimeo;
325 return reason_code; 326 return reason_code;
326} 327}
327 328
diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c
index fa41d9881741..ac961dfb1ea1 100644
--- a/net/smc/smc_close.c
+++ b/net/smc/smc_close.c
@@ -107,6 +107,8 @@ static void smc_close_active_abort(struct smc_sock *smc)
107 } 107 }
108 switch (sk->sk_state) { 108 switch (sk->sk_state) {
109 case SMC_INIT: 109 case SMC_INIT:
110 sk->sk_state = SMC_PEERABORTWAIT;
111 break;
110 case SMC_ACTIVE: 112 case SMC_ACTIVE:
111 sk->sk_state = SMC_PEERABORTWAIT; 113 sk->sk_state = SMC_PEERABORTWAIT;
112 release_sock(sk); 114 release_sock(sk);
diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index cee666400752..f82886b7d1d8 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -495,7 +495,8 @@ out:
495 495
496void smc_tx_consumer_update(struct smc_connection *conn, bool force) 496void smc_tx_consumer_update(struct smc_connection *conn, bool force)
497{ 497{
498 union smc_host_cursor cfed, cons; 498 union smc_host_cursor cfed, cons, prod;
499 int sender_free = conn->rmb_desc->len;
499 int to_confirm; 500 int to_confirm;
500 501
501 smc_curs_write(&cons, 502 smc_curs_write(&cons,
@@ -505,11 +506,18 @@ void smc_tx_consumer_update(struct smc_connection *conn, bool force)
505 smc_curs_read(&conn->rx_curs_confirmed, conn), 506 smc_curs_read(&conn->rx_curs_confirmed, conn),
506 conn); 507 conn);
507 to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons); 508 to_confirm = smc_curs_diff(conn->rmb_desc->len, &cfed, &cons);
509 if (to_confirm > conn->rmbe_update_limit) {
510 smc_curs_write(&prod,
511 smc_curs_read(&conn->local_rx_ctrl.prod, conn),
512 conn);
513 sender_free = conn->rmb_desc->len -
514 smc_curs_diff(conn->rmb_desc->len, &prod, &cfed);
515 }
508 516
509 if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req || 517 if (conn->local_rx_ctrl.prod_flags.cons_curs_upd_req ||
510 force || 518 force ||
511 ((to_confirm > conn->rmbe_update_limit) && 519 ((to_confirm > conn->rmbe_update_limit) &&
512 ((to_confirm > (conn->rmb_desc->len / 2)) || 520 ((sender_free <= (conn->rmb_desc->len / 2)) ||
513 conn->local_rx_ctrl.prod_flags.write_blocked))) { 521 conn->local_rx_ctrl.prod_flags.write_blocked))) {
514 if ((smc_cdc_get_slot_and_msg_send(conn) < 0) && 522 if ((smc_cdc_get_slot_and_msg_send(conn) < 0) &&
515 conn->alert_token_local) { /* connection healthy */ 523 conn->alert_token_local) { /* connection healthy */
diff --git a/net/socket.c b/net/socket.c
index 85633622c94d..8c24d5dc4bc8 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -89,6 +89,7 @@
89#include <linux/magic.h> 89#include <linux/magic.h>
90#include <linux/slab.h> 90#include <linux/slab.h>
91#include <linux/xattr.h> 91#include <linux/xattr.h>
92#include <linux/nospec.h>
92 93
93#include <linux/uaccess.h> 94#include <linux/uaccess.h>
94#include <asm/unistd.h> 95#include <asm/unistd.h>
@@ -2522,6 +2523,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
2522 2523
2523 if (call < 1 || call > SYS_SENDMMSG) 2524 if (call < 1 || call > SYS_SENDMMSG)
2524 return -EINVAL; 2525 return -EINVAL;
2526 call = array_index_nospec(call, SYS_SENDMMSG + 1);
2525 2527
2526 len = nargs[call]; 2528 len = nargs[call];
2527 if (len > sizeof(a)) 2529 if (len > sizeof(a))
@@ -2688,7 +2690,8 @@ EXPORT_SYMBOL(sock_unregister);
2688 2690
2689bool sock_is_registered(int family) 2691bool sock_is_registered(int family)
2690{ 2692{
2691 return family < NPROTO && rcu_access_pointer(net_families[family]); 2693 return family < NPROTO &&
2694 rcu_access_pointer(net_families[array_index_nospec(family, NPROTO)]);
2692} 2695}
2693 2696
2694static int __init sock_init(void) 2697static int __init sock_init(void)
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 9f666e0650e2..2830709957bd 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -133,6 +133,8 @@ static void disc_dupl_alert(struct tipc_bearer *b, u32 node_addr,
133} 133}
134 134
135/* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer 135/* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer
136 * Returns true if message should be dropped by caller, i.e., if it is a
137 * trial message or we are inside trial period. Otherwise false.
136 */ 138 */
137static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, 139static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
138 struct tipc_media_addr *maddr, 140 struct tipc_media_addr *maddr,
@@ -168,8 +170,9 @@ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
168 msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); 170 msg_set_type(buf_msg(d->skb), DSC_REQ_MSG);
169 } 171 }
170 172
173 /* Accept regular link requests/responses only after trial period */
171 if (mtyp != DSC_TRIAL_MSG) 174 if (mtyp != DSC_TRIAL_MSG)
172 return false; 175 return trial;
173 176
174 sugg_addr = tipc_node_try_addr(net, peer_id, src); 177 sugg_addr = tipc_node_try_addr(net, peer_id, src);
175 if (sugg_addr) 178 if (sugg_addr)
@@ -284,7 +287,6 @@ static void tipc_disc_timeout(struct timer_list *t)
284{ 287{
285 struct tipc_discoverer *d = from_timer(d, t, timer); 288 struct tipc_discoverer *d = from_timer(d, t, timer);
286 struct tipc_net *tn = tipc_net(d->net); 289 struct tipc_net *tn = tipc_net(d->net);
287 u32 self = tipc_own_addr(d->net);
288 struct tipc_media_addr maddr; 290 struct tipc_media_addr maddr;
289 struct sk_buff *skb = NULL; 291 struct sk_buff *skb = NULL;
290 struct net *net = d->net; 292 struct net *net = d->net;
@@ -298,12 +300,14 @@ static void tipc_disc_timeout(struct timer_list *t)
298 goto exit; 300 goto exit;
299 } 301 }
300 302
301 /* Did we just leave the address trial period ? */ 303 /* Trial period over ? */
302 if (!self && !time_before(jiffies, tn->addr_trial_end)) { 304 if (!time_before(jiffies, tn->addr_trial_end)) {
303 self = tn->trial_addr; 305 /* Did we just leave it ? */
304 tipc_net_finalize(net, self); 306 if (!tipc_own_addr(net))
305 msg_set_prevnode(buf_msg(d->skb), self); 307 tipc_net_finalize(net, tn->trial_addr);
308
306 msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); 309 msg_set_type(buf_msg(d->skb), DSC_REQ_MSG);
310 msg_set_prevnode(buf_msg(d->skb), tipc_own_addr(net));
307 } 311 }
308 312
309 /* Adjust timeout interval according to discovery phase */ 313 /* Adjust timeout interval according to discovery phase */
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 4fbaa0464405..a7f6964c3a4b 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr)
121 121
122void tipc_net_finalize(struct net *net, u32 addr) 122void tipc_net_finalize(struct net *net, u32 addr)
123{ 123{
124 tipc_set_node_addr(net, addr); 124 struct tipc_net *tn = tipc_net(net);
125 smp_mb(); 125
126 tipc_named_reinit(net); 126 spin_lock_bh(&tn->node_list_lock);
127 tipc_sk_reinit(net); 127 if (!tipc_own_addr(net)) {
128 tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, 128 tipc_set_node_addr(net, addr);
129 TIPC_CLUSTER_SCOPE, 0, addr); 129 tipc_named_reinit(net);
130 tipc_sk_reinit(net);
131 tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
132 TIPC_CLUSTER_SCOPE, 0, addr);
133 }
134 spin_unlock_bh(&tn->node_list_lock);
130} 135}
131 136
132void tipc_net_stop(struct net *net) 137void tipc_net_stop(struct net *net)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 6a44eb812baf..0453bd451ce8 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -797,6 +797,7 @@ static u32 tipc_node_suggest_addr(struct net *net, u32 addr)
797} 797}
798 798
799/* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not 799/* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not
800 * Returns suggested address if any, otherwise 0
800 */ 801 */
801u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr) 802u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr)
802{ 803{
@@ -819,12 +820,14 @@ u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr)
819 if (n) { 820 if (n) {
820 addr = n->addr; 821 addr = n->addr;
821 tipc_node_put(n); 822 tipc_node_put(n);
823 return addr;
822 } 824 }
823 /* Even this node may be in trial phase */ 825
826 /* Even this node may be in conflict */
824 if (tn->trial_addr == addr) 827 if (tn->trial_addr == addr)
825 return tipc_node_suggest_addr(net, addr); 828 return tipc_node_suggest_addr(net, addr);
826 829
827 return addr; 830 return 0;
828} 831}
829 832
830void tipc_node_check_dest(struct net *net, u32 addr, 833void tipc_node_check_dest(struct net *net, u32 addr,
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index d2380548f8f6..1f3d9789af30 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -440,7 +440,7 @@ alloc_encrypted:
440 ret = tls_push_record(sk, msg->msg_flags, record_type); 440 ret = tls_push_record(sk, msg->msg_flags, record_type);
441 if (!ret) 441 if (!ret)
442 continue; 442 continue;
443 if (ret == -EAGAIN) 443 if (ret < 0)
444 goto send_end; 444 goto send_end;
445 445
446 copied -= try_to_copy; 446 copied -= try_to_copy;
@@ -646,6 +646,9 @@ static struct sk_buff *tls_wait_data(struct sock *sk, int flags,
646 return NULL; 646 return NULL;
647 } 647 }
648 648
649 if (sk->sk_shutdown & RCV_SHUTDOWN)
650 return NULL;
651
649 if (sock_flag(sk, SOCK_DONE)) 652 if (sock_flag(sk, SOCK_DONE))
650 return NULL; 653 return NULL;
651 654
@@ -701,6 +704,10 @@ static int decrypt_skb(struct sock *sk, struct sk_buff *skb,
701 nsg = skb_to_sgvec(skb, &sgin[1], 704 nsg = skb_to_sgvec(skb, &sgin[1],
702 rxm->offset + tls_ctx->rx.prepend_size, 705 rxm->offset + tls_ctx->rx.prepend_size,
703 rxm->full_len - tls_ctx->rx.prepend_size); 706 rxm->full_len - tls_ctx->rx.prepend_size);
707 if (nsg < 0) {
708 ret = nsg;
709 goto out;
710 }
704 711
705 tls_make_aad(ctx->rx_aad_ciphertext, 712 tls_make_aad(ctx->rx_aad_ciphertext,
706 rxm->full_len - tls_ctx->rx.overhead_size, 713 rxm->full_len - tls_ctx->rx.overhead_size,
@@ -712,6 +719,7 @@ static int decrypt_skb(struct sock *sk, struct sk_buff *skb,
712 rxm->full_len - tls_ctx->rx.overhead_size, 719 rxm->full_len - tls_ctx->rx.overhead_size,
713 skb, sk->sk_allocation); 720 skb, sk->sk_allocation);
714 721
722out:
715 if (sgin != &sgin_arr[0]) 723 if (sgin != &sgin_arr[0])
716 kfree(sgin); 724 kfree(sgin);
717 725
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 4eece06be1e7..80bc986c79e5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4409,6 +4409,7 @@ static int parse_station_flags(struct genl_info *info,
4409 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHENTICATED) | 4409 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHENTICATED) |
4410 BIT(NL80211_STA_FLAG_MFP) | 4410 BIT(NL80211_STA_FLAG_MFP) |
4411 BIT(NL80211_STA_FLAG_AUTHORIZED); 4411 BIT(NL80211_STA_FLAG_AUTHORIZED);
4412 break;
4412 default: 4413 default:
4413 return -EINVAL; 4414 return -EINVAL;
4414 } 4415 }
@@ -14923,20 +14924,24 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
14923EXPORT_SYMBOL(cfg80211_mgmt_tx_status); 14924EXPORT_SYMBOL(cfg80211_mgmt_tx_status);
14924 14925
14925static int __nl80211_rx_control_port(struct net_device *dev, 14926static int __nl80211_rx_control_port(struct net_device *dev,
14926 const u8 *buf, size_t len, 14927 struct sk_buff *skb,
14927 const u8 *addr, u16 proto,
14928 bool unencrypted, gfp_t gfp) 14928 bool unencrypted, gfp_t gfp)
14929{ 14929{
14930 struct wireless_dev *wdev = dev->ieee80211_ptr; 14930 struct wireless_dev *wdev = dev->ieee80211_ptr;
14931 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 14931 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
14932 struct ethhdr *ehdr = eth_hdr(skb);
14933 const u8 *addr = ehdr->h_source;
14934 u16 proto = be16_to_cpu(skb->protocol);
14932 struct sk_buff *msg; 14935 struct sk_buff *msg;
14933 void *hdr; 14936 void *hdr;
14937 struct nlattr *frame;
14938
14934 u32 nlportid = READ_ONCE(wdev->conn_owner_nlportid); 14939 u32 nlportid = READ_ONCE(wdev->conn_owner_nlportid);
14935 14940
14936 if (!nlportid) 14941 if (!nlportid)
14937 return -ENOENT; 14942 return -ENOENT;
14938 14943
14939 msg = nlmsg_new(100 + len, gfp); 14944 msg = nlmsg_new(100 + skb->len, gfp);
14940 if (!msg) 14945 if (!msg)
14941 return -ENOMEM; 14946 return -ENOMEM;
14942 14947
@@ -14950,13 +14955,17 @@ static int __nl80211_rx_control_port(struct net_device *dev,
14950 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 14955 nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
14951 nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev), 14956 nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
14952 NL80211_ATTR_PAD) || 14957 NL80211_ATTR_PAD) ||
14953 nla_put(msg, NL80211_ATTR_FRAME, len, buf) ||
14954 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) || 14958 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) ||
14955 nla_put_u16(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE, proto) || 14959 nla_put_u16(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE, proto) ||
14956 (unencrypted && nla_put_flag(msg, 14960 (unencrypted && nla_put_flag(msg,
14957 NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT))) 14961 NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT)))
14958 goto nla_put_failure; 14962 goto nla_put_failure;
14959 14963
14964 frame = nla_reserve(msg, NL80211_ATTR_FRAME, skb->len);
14965 if (!frame)
14966 goto nla_put_failure;
14967
14968 skb_copy_bits(skb, 0, nla_data(frame), skb->len);
14960 genlmsg_end(msg, hdr); 14969 genlmsg_end(msg, hdr);
14961 14970
14962 return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); 14971 return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
@@ -14967,14 +14976,12 @@ static int __nl80211_rx_control_port(struct net_device *dev,
14967} 14976}
14968 14977
14969bool cfg80211_rx_control_port(struct net_device *dev, 14978bool cfg80211_rx_control_port(struct net_device *dev,
14970 const u8 *buf, size_t len, 14979 struct sk_buff *skb, bool unencrypted)
14971 const u8 *addr, u16 proto, bool unencrypted)
14972{ 14980{
14973 int ret; 14981 int ret;
14974 14982
14975 trace_cfg80211_rx_control_port(dev, buf, len, addr, proto, unencrypted); 14983 trace_cfg80211_rx_control_port(dev, skb, unencrypted);
14976 ret = __nl80211_rx_control_port(dev, buf, len, addr, proto, 14984 ret = __nl80211_rx_control_port(dev, skb, unencrypted, GFP_ATOMIC);
14977 unencrypted, GFP_ATOMIC);
14978 trace_cfg80211_return_bool(ret == 0); 14985 trace_cfg80211_return_bool(ret == 0);
14979 return ret == 0; 14986 return ret == 0;
14980} 14987}
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index bbe6298e4bb9..4fc66a117b7d 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2240,7 +2240,9 @@ static void wiphy_update_regulatory(struct wiphy *wiphy,
2240 * as some drivers used this to restore its orig_* reg domain. 2240 * as some drivers used this to restore its orig_* reg domain.
2241 */ 2241 */
2242 if (initiator == NL80211_REGDOM_SET_BY_CORE && 2242 if (initiator == NL80211_REGDOM_SET_BY_CORE &&
2243 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) 2243 wiphy->regulatory_flags & REGULATORY_CUSTOM_REG &&
2244 !(wiphy->regulatory_flags &
2245 REGULATORY_WIPHY_SELF_MANAGED))
2244 reg_call_notifier(wiphy, lr); 2246 reg_call_notifier(wiphy, lr);
2245 return; 2247 return;
2246 } 2248 }
@@ -2787,26 +2789,6 @@ static void notify_self_managed_wiphys(struct regulatory_request *request)
2787 } 2789 }
2788} 2790}
2789 2791
2790static bool reg_only_self_managed_wiphys(void)
2791{
2792 struct cfg80211_registered_device *rdev;
2793 struct wiphy *wiphy;
2794 bool self_managed_found = false;
2795
2796 ASSERT_RTNL();
2797
2798 list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
2799 wiphy = &rdev->wiphy;
2800 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
2801 self_managed_found = true;
2802 else
2803 return false;
2804 }
2805
2806 /* make sure at least one self-managed wiphy exists */
2807 return self_managed_found;
2808}
2809
2810/* 2792/*
2811 * Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_* 2793 * Processes regulatory hints, this is all the NL80211_REGDOM_SET_BY_*
2812 * Regulatory hints come on a first come first serve basis and we 2794 * Regulatory hints come on a first come first serve basis and we
@@ -2839,10 +2821,6 @@ static void reg_process_pending_hints(void)
2839 spin_unlock(&reg_requests_lock); 2821 spin_unlock(&reg_requests_lock);
2840 2822
2841 notify_self_managed_wiphys(reg_request); 2823 notify_self_managed_wiphys(reg_request);
2842 if (reg_only_self_managed_wiphys()) {
2843 reg_free_request(reg_request);
2844 return;
2845 }
2846 2824
2847 reg_process_hint(reg_request); 2825 reg_process_hint(reg_request);
2848 2826
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 2b417a2fe63f..7c73510b161f 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2627,23 +2627,25 @@ TRACE_EVENT(cfg80211_mgmt_tx_status,
2627); 2627);
2628 2628
2629TRACE_EVENT(cfg80211_rx_control_port, 2629TRACE_EVENT(cfg80211_rx_control_port,
2630 TP_PROTO(struct net_device *netdev, const u8 *buf, size_t len, 2630 TP_PROTO(struct net_device *netdev, struct sk_buff *skb,
2631 const u8 *addr, u16 proto, bool unencrypted), 2631 bool unencrypted),
2632 TP_ARGS(netdev, buf, len, addr, proto, unencrypted), 2632 TP_ARGS(netdev, skb, unencrypted),
2633 TP_STRUCT__entry( 2633 TP_STRUCT__entry(
2634 NETDEV_ENTRY 2634 NETDEV_ENTRY
2635 MAC_ENTRY(addr) 2635 __field(int, len)
2636 MAC_ENTRY(from)
2636 __field(u16, proto) 2637 __field(u16, proto)
2637 __field(bool, unencrypted) 2638 __field(bool, unencrypted)
2638 ), 2639 ),
2639 TP_fast_assign( 2640 TP_fast_assign(
2640 NETDEV_ASSIGN; 2641 NETDEV_ASSIGN;
2641 MAC_ASSIGN(addr, addr); 2642 __entry->len = skb->len;
2642 __entry->proto = proto; 2643 MAC_ASSIGN(from, eth_hdr(skb)->h_source);
2644 __entry->proto = be16_to_cpu(skb->protocol);
2643 __entry->unencrypted = unencrypted; 2645 __entry->unencrypted = unencrypted;
2644 ), 2646 ),
2645 TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT " proto: 0x%x, unencrypted: %s", 2647 TP_printk(NETDEV_PR_FMT ", len=%d, " MAC_PR_FMT ", proto: 0x%x, unencrypted: %s",
2646 NETDEV_PR_ARG, MAC_PR_ARG(addr), 2648 NETDEV_PR_ARG, __entry->len, MAC_PR_ARG(from),
2647 __entry->proto, BOOL_TO_STR(__entry->unencrypted)) 2649 __entry->proto, BOOL_TO_STR(__entry->unencrypted))
2648); 2650);
2649 2651
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 59fb7d3c36a3..4e937cd7c17d 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -84,10 +84,8 @@ static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
84{ 84{
85 int err = xskq_produce_batch_desc(xs->rx, (u64)xdp->handle, len); 85 int err = xskq_produce_batch_desc(xs->rx, (u64)xdp->handle, len);
86 86
87 if (err) { 87 if (err)
88 xdp_return_buff(xdp);
89 xs->rx_dropped++; 88 xs->rx_dropped++;
90 }
91 89
92 return err; 90 return err;
93} 91}
@@ -199,8 +197,11 @@ static void xsk_destruct_skb(struct sk_buff *skb)
199{ 197{
200 u64 addr = (u64)(long)skb_shinfo(skb)->destructor_arg; 198 u64 addr = (u64)(long)skb_shinfo(skb)->destructor_arg;
201 struct xdp_sock *xs = xdp_sk(skb->sk); 199 struct xdp_sock *xs = xdp_sk(skb->sk);
200 unsigned long flags;
202 201
202 spin_lock_irqsave(&xs->tx_completion_lock, flags);
203 WARN_ON_ONCE(xskq_produce_addr(xs->umem->cq, addr)); 203 WARN_ON_ONCE(xskq_produce_addr(xs->umem->cq, addr));
204 spin_unlock_irqrestore(&xs->tx_completion_lock, flags);
204 205
205 sock_wfree(skb); 206 sock_wfree(skb);
206} 207}
@@ -215,9 +216,6 @@ static int xsk_generic_xmit(struct sock *sk, struct msghdr *m,
215 struct sk_buff *skb; 216 struct sk_buff *skb;
216 int err = 0; 217 int err = 0;
217 218
218 if (unlikely(!xs->tx))
219 return -ENOBUFS;
220
221 mutex_lock(&xs->mutex); 219 mutex_lock(&xs->mutex);
222 220
223 while (xskq_peek_desc(xs->tx, &desc)) { 221 while (xskq_peek_desc(xs->tx, &desc)) {
@@ -230,22 +228,13 @@ static int xsk_generic_xmit(struct sock *sk, struct msghdr *m,
230 goto out; 228 goto out;
231 } 229 }
232 230
233 if (xskq_reserve_addr(xs->umem->cq)) { 231 if (xskq_reserve_addr(xs->umem->cq))
234 err = -EAGAIN;
235 goto out; 232 goto out;
236 }
237 233
238 len = desc.len; 234 if (xs->queue_id >= xs->dev->real_num_tx_queues)
239 if (unlikely(len > xs->dev->mtu)) {
240 err = -EMSGSIZE;
241 goto out; 235 goto out;
242 }
243
244 if (xs->queue_id >= xs->dev->real_num_tx_queues) {
245 err = -ENXIO;
246 goto out;
247 }
248 236
237 len = desc.len;
249 skb = sock_alloc_send_skb(sk, len, 1, &err); 238 skb = sock_alloc_send_skb(sk, len, 1, &err);
250 if (unlikely(!skb)) { 239 if (unlikely(!skb)) {
251 err = -EAGAIN; 240 err = -EAGAIN;
@@ -268,15 +257,15 @@ static int xsk_generic_xmit(struct sock *sk, struct msghdr *m,
268 skb->destructor = xsk_destruct_skb; 257 skb->destructor = xsk_destruct_skb;
269 258
270 err = dev_direct_xmit(skb, xs->queue_id); 259 err = dev_direct_xmit(skb, xs->queue_id);
260 xskq_discard_desc(xs->tx);
271 /* Ignore NET_XMIT_CN as packet might have been sent */ 261 /* Ignore NET_XMIT_CN as packet might have been sent */
272 if (err == NET_XMIT_DROP || err == NETDEV_TX_BUSY) { 262 if (err == NET_XMIT_DROP || err == NETDEV_TX_BUSY) {
273 err = -EAGAIN; 263 /* SKB completed but not sent */
274 /* SKB consumed by dev_direct_xmit() */ 264 err = -EBUSY;
275 goto out; 265 goto out;
276 } 266 }
277 267
278 sent_frame = true; 268 sent_frame = true;
279 xskq_discard_desc(xs->tx);
280 } 269 }
281 270
282out: 271out:
@@ -297,6 +286,8 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)
297 return -ENXIO; 286 return -ENXIO;
298 if (unlikely(!(xs->dev->flags & IFF_UP))) 287 if (unlikely(!(xs->dev->flags & IFF_UP)))
299 return -ENETDOWN; 288 return -ENETDOWN;
289 if (unlikely(!xs->tx))
290 return -ENOBUFS;
300 if (need_wait) 291 if (need_wait)
301 return -EOPNOTSUPP; 292 return -EOPNOTSUPP;
302 293
@@ -755,6 +746,7 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol,
755 746
756 xs = xdp_sk(sk); 747 xs = xdp_sk(sk);
757 mutex_init(&xs->mutex); 748 mutex_init(&xs->mutex);
749 spin_lock_init(&xs->tx_completion_lock);
758 750
759 local_bh_disable(); 751 local_bh_disable();
760 sock_prot_inuse_add(net, &xsk_proto, 1); 752 sock_prot_inuse_add(net, &xsk_proto, 1);
diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h
index ef6a6f0ec949..8a64b150be54 100644
--- a/net/xdp/xsk_queue.h
+++ b/net/xdp/xsk_queue.h
@@ -62,14 +62,9 @@ static inline u32 xskq_nb_avail(struct xsk_queue *q, u32 dcnt)
62 return (entries > dcnt) ? dcnt : entries; 62 return (entries > dcnt) ? dcnt : entries;
63} 63}
64 64
65static inline u32 xskq_nb_free_lazy(struct xsk_queue *q, u32 producer)
66{
67 return q->nentries - (producer - q->cons_tail);
68}
69
70static inline u32 xskq_nb_free(struct xsk_queue *q, u32 producer, u32 dcnt) 65static inline u32 xskq_nb_free(struct xsk_queue *q, u32 producer, u32 dcnt)
71{ 66{
72 u32 free_entries = xskq_nb_free_lazy(q, producer); 67 u32 free_entries = q->nentries - (producer - q->cons_tail);
73 68
74 if (free_entries >= dcnt) 69 if (free_entries >= dcnt)
75 return free_entries; 70 return free_entries;
@@ -129,7 +124,7 @@ static inline int xskq_produce_addr(struct xsk_queue *q, u64 addr)
129{ 124{
130 struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring; 125 struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring;
131 126
132 if (xskq_nb_free(q, q->prod_tail, LAZY_UPDATE_THRESHOLD) == 0) 127 if (xskq_nb_free(q, q->prod_tail, 1) == 0)
133 return -ENOSPC; 128 return -ENOSPC;
134 129
135 ring->desc[q->prod_tail++ & q->ring_mask] = addr; 130 ring->desc[q->prod_tail++ & q->ring_mask] = addr;
@@ -255,7 +250,7 @@ static inline bool xskq_full_desc(struct xsk_queue *q)
255 250
256static inline bool xskq_empty_desc(struct xsk_queue *q) 251static inline bool xskq_empty_desc(struct xsk_queue *q)
257{ 252{
258 return xskq_nb_free(q, q->prod_tail, 1) == q->nentries; 253 return xskq_nb_free(q, q->prod_tail, q->nentries) == q->nentries;
259} 254}
260 255
261void xskq_set_umem(struct xsk_queue *q, struct xdp_umem_props *umem_props); 256void xskq_set_umem(struct xsk_queue *q, struct xdp_umem_props *umem_props);
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5f48251c1319..7c5e8978aeaa 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2286,6 +2286,9 @@ struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
2286 if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE) 2286 if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE)
2287 return make_blackhole(net, dst_orig->ops->family, dst_orig); 2287 return make_blackhole(net, dst_orig->ops->family, dst_orig);
2288 2288
2289 if (IS_ERR(dst))
2290 dst_release(dst_orig);
2291
2289 return dst; 2292 return dst;
2290} 2293}
2291EXPORT_SYMBOL(xfrm_lookup_route); 2294EXPORT_SYMBOL(xfrm_lookup_route);
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 080035f056d9..33878e6e0d0a 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1025,10 +1025,12 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb,
1025{ 1025{
1026 struct sock *nlsk = rcu_dereference(net->xfrm.nlsk); 1026 struct sock *nlsk = rcu_dereference(net->xfrm.nlsk);
1027 1027
1028 if (nlsk) 1028 if (!nlsk) {
1029 return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC); 1029 kfree_skb(skb);
1030 else 1030 return -EPIPE;
1031 return -1; 1031 }
1032
1033 return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
1032} 1034}
1033 1035
1034static inline unsigned int xfrm_spdinfo_msgsize(void) 1036static inline unsigned int xfrm_spdinfo_msgsize(void)
@@ -1671,9 +1673,11 @@ static inline unsigned int userpolicy_type_attrsize(void)
1671#ifdef CONFIG_XFRM_SUB_POLICY 1673#ifdef CONFIG_XFRM_SUB_POLICY
1672static int copy_to_user_policy_type(u8 type, struct sk_buff *skb) 1674static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
1673{ 1675{
1674 struct xfrm_userpolicy_type upt = { 1676 struct xfrm_userpolicy_type upt;
1675 .type = type, 1677
1676 }; 1678 /* Sadly there are two holes in struct xfrm_userpolicy_type */
1679 memset(&upt, 0, sizeof(upt));
1680 upt.type = type;
1677 1681
1678 return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt); 1682 return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
1679} 1683}
diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore
new file mode 100644
index 000000000000..8ae4940025f8
--- /dev/null
+++ b/samples/bpf/.gitignore
@@ -0,0 +1,49 @@
1cpustat
2fds_example
3lathist
4load_sock_ops
5lwt_len_hist
6map_perf_test
7offwaketime
8per_socket_stats_example
9sampleip
10sock_example
11sockex1
12sockex2
13sockex3
14spintest
15syscall_nrs.h
16syscall_tp
17task_fd_query
18tc_l2_redirect
19test_cgrp2_array_pin
20test_cgrp2_attach
21test_cgrp2_attach2
22test_cgrp2_sock
23test_cgrp2_sock2
24test_current_task_under_cgroup
25test_lru_dist
26test_map_in_map
27test_overhead
28test_probe_write_user
29trace_event
30trace_output
31tracex1
32tracex2
33tracex3
34tracex4
35tracex5
36tracex6
37tracex7
38xdp1
39xdp2
40xdp_adjust_tail
41xdp_fwd
42xdp_monitor
43xdp_redirect
44xdp_redirect_cpu
45xdp_redirect_map
46xdp_router_ipv4
47xdp_rxq_info
48xdp_tx_iptunnel
49xdpsock
diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
index 95c16324760c..0b6f22feb2c9 100644
--- a/samples/bpf/parse_varlen.c
+++ b/samples/bpf/parse_varlen.c
@@ -6,6 +6,7 @@
6 */ 6 */
7#define KBUILD_MODNAME "foo" 7#define KBUILD_MODNAME "foo"
8#include <linux/if_ether.h> 8#include <linux/if_ether.h>
9#include <linux/if_vlan.h>
9#include <linux/ip.h> 10#include <linux/ip.h>
10#include <linux/ipv6.h> 11#include <linux/ipv6.h>
11#include <linux/in.h> 12#include <linux/in.h>
@@ -108,11 +109,6 @@ static int parse_ipv6(void *data, uint64_t nh_off, void *data_end)
108 return 0; 109 return 0;
109} 110}
110 111
111struct vlan_hdr {
112 uint16_t h_vlan_TCI;
113 uint16_t h_vlan_encapsulated_proto;
114};
115
116SEC("varlen") 112SEC("varlen")
117int handle_ingress(struct __sk_buff *skb) 113int handle_ingress(struct __sk_buff *skb)
118{ 114{
diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
index 6caf47afa635..9d6dcaa9db92 100644
--- a/samples/bpf/test_overhead_user.c
+++ b/samples/bpf/test_overhead_user.c
@@ -6,6 +6,7 @@
6 */ 6 */
7#define _GNU_SOURCE 7#define _GNU_SOURCE
8#include <sched.h> 8#include <sched.h>
9#include <errno.h>
9#include <stdio.h> 10#include <stdio.h>
10#include <sys/types.h> 11#include <sys/types.h>
11#include <asm/unistd.h> 12#include <asm/unistd.h>
@@ -44,8 +45,13 @@ static void test_task_rename(int cpu)
44 exit(1); 45 exit(1);
45 } 46 }
46 start_time = time_get_ns(); 47 start_time = time_get_ns();
47 for (i = 0; i < MAX_CNT; i++) 48 for (i = 0; i < MAX_CNT; i++) {
48 write(fd, buf, sizeof(buf)); 49 if (write(fd, buf, sizeof(buf)) < 0) {
50 printf("task rename failed: %s\n", strerror(errno));
51 close(fd);
52 return;
53 }
54 }
49 printf("task_rename:%d: %lld events per sec\n", 55 printf("task_rename:%d: %lld events per sec\n",
50 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time)); 56 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
51 close(fd); 57 close(fd);
@@ -63,8 +69,13 @@ static void test_urandom_read(int cpu)
63 exit(1); 69 exit(1);
64 } 70 }
65 start_time = time_get_ns(); 71 start_time = time_get_ns();
66 for (i = 0; i < MAX_CNT; i++) 72 for (i = 0; i < MAX_CNT; i++) {
67 read(fd, buf, sizeof(buf)); 73 if (read(fd, buf, sizeof(buf)) < 0) {
74 printf("failed to read from /dev/urandom: %s\n", strerror(errno));
75 close(fd);
76 return;
77 }
78 }
68 printf("urandom_read:%d: %lld events per sec\n", 79 printf("urandom_read:%d: %lld events per sec\n",
69 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time)); 80 cpu, MAX_CNT * 1000000000ll / (time_get_ns() - start_time));
70 close(fd); 81 close(fd);
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index 1fa1becfa641..d08046ab81f0 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -122,6 +122,16 @@ static void print_stacks(void)
122 } 122 }
123} 123}
124 124
125static inline int generate_load(void)
126{
127 if (system("dd if=/dev/zero of=/dev/null count=5000k status=none") < 0) {
128 printf("failed to generate some load with dd: %s\n", strerror(errno));
129 return -1;
130 }
131
132 return 0;
133}
134
125static void test_perf_event_all_cpu(struct perf_event_attr *attr) 135static void test_perf_event_all_cpu(struct perf_event_attr *attr)
126{ 136{
127 int nr_cpus = sysconf(_SC_NPROCESSORS_CONF); 137 int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
@@ -142,7 +152,11 @@ static void test_perf_event_all_cpu(struct perf_event_attr *attr)
142 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0); 152 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
143 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0); 153 assert(ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE) == 0);
144 } 154 }
145 system("dd if=/dev/zero of=/dev/null count=5000k status=none"); 155
156 if (generate_load() < 0) {
157 error = 1;
158 goto all_cpu_err;
159 }
146 print_stacks(); 160 print_stacks();
147all_cpu_err: 161all_cpu_err:
148 for (i--; i >= 0; i--) { 162 for (i--; i >= 0; i--) {
@@ -156,7 +170,7 @@ all_cpu_err:
156 170
157static void test_perf_event_task(struct perf_event_attr *attr) 171static void test_perf_event_task(struct perf_event_attr *attr)
158{ 172{
159 int pmu_fd; 173 int pmu_fd, error = 0;
160 174
161 /* per task perf event, enable inherit so the "dd ..." command can be traced properly. 175 /* per task perf event, enable inherit so the "dd ..." command can be traced properly.
162 * Enabling inherit will cause bpf_perf_prog_read_time helper failure. 176 * Enabling inherit will cause bpf_perf_prog_read_time helper failure.
@@ -171,10 +185,17 @@ static void test_perf_event_task(struct perf_event_attr *attr)
171 } 185 }
172 assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0); 186 assert(ioctl(pmu_fd, PERF_EVENT_IOC_SET_BPF, prog_fd[0]) == 0);
173 assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0); 187 assert(ioctl(pmu_fd, PERF_EVENT_IOC_ENABLE) == 0);
174 system("dd if=/dev/zero of=/dev/null count=5000k status=none"); 188
189 if (generate_load() < 0) {
190 error = 1;
191 goto err;
192 }
175 print_stacks(); 193 print_stacks();
194err:
176 ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE); 195 ioctl(pmu_fd, PERF_EVENT_IOC_DISABLE);
177 close(pmu_fd); 196 close(pmu_fd);
197 if (error)
198 int_exit(0);
178} 199}
179 200
180static void test_bpf_perf_event(void) 201static void test_bpf_perf_event(void)
diff --git a/samples/bpf/xdp2skb_meta.sh b/samples/bpf/xdp2skb_meta.sh
index b9c9549c4c27..4bde9d066c46 100755
--- a/samples/bpf/xdp2skb_meta.sh
+++ b/samples/bpf/xdp2skb_meta.sh
@@ -16,8 +16,8 @@
16BPF_FILE=xdp2skb_meta_kern.o 16BPF_FILE=xdp2skb_meta_kern.o
17DIR=$(dirname $0) 17DIR=$(dirname $0)
18 18
19export TC=/usr/sbin/tc 19[ -z "$TC" ] && TC=tc
20export IP=/usr/sbin/ip 20[ -z "$IP" ] && IP=ip
21 21
22function usage() { 22function usage() {
23 echo "" 23 echo ""
@@ -53,7 +53,7 @@ function _call_cmd() {
53 local allow_fail="$2" 53 local allow_fail="$2"
54 shift 2 54 shift 2
55 if [[ -n "$VERBOSE" ]]; then 55 if [[ -n "$VERBOSE" ]]; then
56 echo "$(basename $cmd) $@" 56 echo "$cmd $@"
57 fi 57 fi
58 if [[ -n "$DRYRUN" ]]; then 58 if [[ -n "$DRYRUN" ]]; then
59 return 59 return
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index d69c8d78d3fd..5904b1543831 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -729,7 +729,7 @@ static void kick_tx(int fd)
729 int ret; 729 int ret;
730 730
731 ret = sendto(fd, NULL, 0, MSG_DONTWAIT, NULL, 0); 731 ret = sendto(fd, NULL, 0, MSG_DONTWAIT, NULL, 0);
732 if (ret >= 0 || errno == ENOBUFS || errno == EAGAIN) 732 if (ret >= 0 || errno == ENOBUFS || errno == EAGAIN || errno == EBUSY)
733 return; 733 return;
734 lassert(0); 734 lassert(0);
735} 735}
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 412a70cce558..26de7d5aa5c8 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -152,6 +152,7 @@ regex_asm=(
152) 152)
153regex_c=( 153regex_c=(
154 '/^SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/sys_\1/' 154 '/^SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/sys_\1/'
155 '/^BPF_CALL_[0-9](\([[:alnum:]_]*\).*/\1/'
155 '/^COMPAT_SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/compat_sys_\1/' 156 '/^COMPAT_SYSCALL_DEFINE[0-9](\([[:alnum:]_]*\).*/compat_sys_\1/'
156 '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1/' 157 '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1/'
157 '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1_rcuidle/' 158 '/^TRACE_EVENT(\([[:alnum:]_]*\).*/trace_\1_rcuidle/'
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 69616d00481c..b53026a72e73 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -635,7 +635,7 @@ static int snd_rawmidi_info_select_user(struct snd_card *card,
635int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, 635int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
636 struct snd_rawmidi_params * params) 636 struct snd_rawmidi_params * params)
637{ 637{
638 char *newbuf; 638 char *newbuf, *oldbuf;
639 struct snd_rawmidi_runtime *runtime = substream->runtime; 639 struct snd_rawmidi_runtime *runtime = substream->runtime;
640 640
641 if (substream->append && substream->use_count > 1) 641 if (substream->append && substream->use_count > 1)
@@ -648,13 +648,17 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
648 return -EINVAL; 648 return -EINVAL;
649 } 649 }
650 if (params->buffer_size != runtime->buffer_size) { 650 if (params->buffer_size != runtime->buffer_size) {
651 newbuf = krealloc(runtime->buffer, params->buffer_size, 651 newbuf = kmalloc(params->buffer_size, GFP_KERNEL);
652 GFP_KERNEL);
653 if (!newbuf) 652 if (!newbuf)
654 return -ENOMEM; 653 return -ENOMEM;
654 spin_lock_irq(&runtime->lock);
655 oldbuf = runtime->buffer;
655 runtime->buffer = newbuf; 656 runtime->buffer = newbuf;
656 runtime->buffer_size = params->buffer_size; 657 runtime->buffer_size = params->buffer_size;
657 runtime->avail = runtime->buffer_size; 658 runtime->avail = runtime->buffer_size;
659 runtime->appl_ptr = runtime->hw_ptr = 0;
660 spin_unlock_irq(&runtime->lock);
661 kfree(oldbuf);
658 } 662 }
659 runtime->avail_min = params->avail_min; 663 runtime->avail_min = params->avail_min;
660 substream->active_sensing = !params->no_active_sensing; 664 substream->active_sensing = !params->no_active_sensing;
@@ -665,7 +669,7 @@ EXPORT_SYMBOL(snd_rawmidi_output_params);
665int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, 669int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
666 struct snd_rawmidi_params * params) 670 struct snd_rawmidi_params * params)
667{ 671{
668 char *newbuf; 672 char *newbuf, *oldbuf;
669 struct snd_rawmidi_runtime *runtime = substream->runtime; 673 struct snd_rawmidi_runtime *runtime = substream->runtime;
670 674
671 snd_rawmidi_drain_input(substream); 675 snd_rawmidi_drain_input(substream);
@@ -676,12 +680,16 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
676 return -EINVAL; 680 return -EINVAL;
677 } 681 }
678 if (params->buffer_size != runtime->buffer_size) { 682 if (params->buffer_size != runtime->buffer_size) {
679 newbuf = krealloc(runtime->buffer, params->buffer_size, 683 newbuf = kmalloc(params->buffer_size, GFP_KERNEL);
680 GFP_KERNEL);
681 if (!newbuf) 684 if (!newbuf)
682 return -ENOMEM; 685 return -ENOMEM;
686 spin_lock_irq(&runtime->lock);
687 oldbuf = runtime->buffer;
683 runtime->buffer = newbuf; 688 runtime->buffer = newbuf;
684 runtime->buffer_size = params->buffer_size; 689 runtime->buffer_size = params->buffer_size;
690 runtime->appl_ptr = runtime->hw_ptr = 0;
691 spin_unlock_irq(&runtime->lock);
692 kfree(oldbuf);
685 } 693 }
686 runtime->avail_min = params->avail_min; 694 runtime->avail_min = params->avail_min;
687 return 0; 695 return 0;
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index e7fcfc3b8885..f641c20095f7 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -964,6 +964,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
964 SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC), 964 SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
965 SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO), 965 SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),
966 SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO), 966 SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO),
967 SND_PCI_QUIRK(0x103c, 0x836e, "HP ProBook 455 G5", CXT_FIXUP_MUTE_LED_GPIO),
967 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE), 968 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE),
968 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE), 969 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
969 SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE), 970 SND_PCI_QUIRK(0x103c, 0x8455, "HP Z2 G4", CXT_FIXUP_HP_MIC_NO_PRESENCE),
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 7496be4491b1..f6af3e1c2b93 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2366,6 +2366,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2366 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), 2366 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2367 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), 2367 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2368 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950), 2368 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2369 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2369 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950), 2370 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2370 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), 2371 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2371 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), 2372 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
@@ -6569,6 +6570,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6569 SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC), 6570 SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
6570 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), 6571 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
6571 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), 6572 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
6573 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
6572 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), 6574 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
6573 SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8), 6575 SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
6574 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC), 6576 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
diff --git a/tools/arch/powerpc/include/uapi/asm/unistd.h b/tools/arch/powerpc/include/uapi/asm/unistd.h
index ac5ba55066dd..985534d0b448 100644
--- a/tools/arch/powerpc/include/uapi/asm/unistd.h
+++ b/tools/arch/powerpc/include/uapi/asm/unistd.h
@@ -399,5 +399,6 @@
399#define __NR_pkey_free 385 399#define __NR_pkey_free 385
400#define __NR_pkey_mprotect 386 400#define __NR_pkey_mprotect 386
401#define __NR_rseq 387 401#define __NR_rseq 387
402#define __NR_io_pgetevents 388
402 403
403#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ 404#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/tools/arch/x86/include/asm/mcsafe_test.h b/tools/arch/x86/include/asm/mcsafe_test.h
new file mode 100644
index 000000000000..2ccd588fbad4
--- /dev/null
+++ b/tools/arch/x86/include/asm/mcsafe_test.h
@@ -0,0 +1,13 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _MCSAFE_TEST_H_
3#define _MCSAFE_TEST_H_
4
5.macro MCSAFE_TEST_CTL
6.endm
7
8.macro MCSAFE_TEST_SRC reg count target
9.endm
10
11.macro MCSAFE_TEST_DST reg count target
12.endm
13#endif /* _MCSAFE_TEST_H_ */
diff --git a/tools/arch/x86/lib/memcpy_64.S b/tools/arch/x86/lib/memcpy_64.S
index 9a53a06e5a3e..298ef1479240 100644
--- a/tools/arch/x86/lib/memcpy_64.S
+++ b/tools/arch/x86/lib/memcpy_64.S
@@ -3,6 +3,7 @@
3#include <linux/linkage.h> 3#include <linux/linkage.h>
4#include <asm/errno.h> 4#include <asm/errno.h>
5#include <asm/cpufeatures.h> 5#include <asm/cpufeatures.h>
6#include <asm/mcsafe_test.h>
6#include <asm/alternative-asm.h> 7#include <asm/alternative-asm.h>
7#include <asm/export.h> 8#include <asm/export.h>
8 9
@@ -183,12 +184,15 @@ ENTRY(memcpy_orig)
183ENDPROC(memcpy_orig) 184ENDPROC(memcpy_orig)
184 185
185#ifndef CONFIG_UML 186#ifndef CONFIG_UML
187
188MCSAFE_TEST_CTL
189
186/* 190/*
187 * memcpy_mcsafe_unrolled - memory copy with machine check exception handling 191 * __memcpy_mcsafe - memory copy with machine check exception handling
188 * Note that we only catch machine checks when reading the source addresses. 192 * Note that we only catch machine checks when reading the source addresses.
189 * Writes to target are posted and don't generate machine checks. 193 * Writes to target are posted and don't generate machine checks.
190 */ 194 */
191ENTRY(memcpy_mcsafe_unrolled) 195ENTRY(__memcpy_mcsafe)
192 cmpl $8, %edx 196 cmpl $8, %edx
193 /* Less than 8 bytes? Go to byte copy loop */ 197 /* Less than 8 bytes? Go to byte copy loop */
194 jb .L_no_whole_words 198 jb .L_no_whole_words
@@ -204,58 +208,33 @@ ENTRY(memcpy_mcsafe_unrolled)
204 subl $8, %ecx 208 subl $8, %ecx
205 negl %ecx 209 negl %ecx
206 subl %ecx, %edx 210 subl %ecx, %edx
207.L_copy_leading_bytes: 211.L_read_leading_bytes:
208 movb (%rsi), %al 212 movb (%rsi), %al
213 MCSAFE_TEST_SRC %rsi 1 .E_leading_bytes
214 MCSAFE_TEST_DST %rdi 1 .E_leading_bytes
215.L_write_leading_bytes:
209 movb %al, (%rdi) 216 movb %al, (%rdi)
210 incq %rsi 217 incq %rsi
211 incq %rdi 218 incq %rdi
212 decl %ecx 219 decl %ecx
213 jnz .L_copy_leading_bytes 220 jnz .L_read_leading_bytes
214 221
215.L_8byte_aligned: 222.L_8byte_aligned:
216 /* Figure out how many whole cache lines (64-bytes) to copy */
217 movl %edx, %ecx
218 andl $63, %edx
219 shrl $6, %ecx
220 jz .L_no_whole_cache_lines
221
222 /* Loop copying whole cache lines */
223.L_cache_w0: movq (%rsi), %r8
224.L_cache_w1: movq 1*8(%rsi), %r9
225.L_cache_w2: movq 2*8(%rsi), %r10
226.L_cache_w3: movq 3*8(%rsi), %r11
227 movq %r8, (%rdi)
228 movq %r9, 1*8(%rdi)
229 movq %r10, 2*8(%rdi)
230 movq %r11, 3*8(%rdi)
231.L_cache_w4: movq 4*8(%rsi), %r8
232.L_cache_w5: movq 5*8(%rsi), %r9
233.L_cache_w6: movq 6*8(%rsi), %r10
234.L_cache_w7: movq 7*8(%rsi), %r11
235 movq %r8, 4*8(%rdi)
236 movq %r9, 5*8(%rdi)
237 movq %r10, 6*8(%rdi)
238 movq %r11, 7*8(%rdi)
239 leaq 64(%rsi), %rsi
240 leaq 64(%rdi), %rdi
241 decl %ecx
242 jnz .L_cache_w0
243
244 /* Are there any trailing 8-byte words? */
245.L_no_whole_cache_lines:
246 movl %edx, %ecx 223 movl %edx, %ecx
247 andl $7, %edx 224 andl $7, %edx
248 shrl $3, %ecx 225 shrl $3, %ecx
249 jz .L_no_whole_words 226 jz .L_no_whole_words
250 227
251 /* Copy trailing words */ 228.L_read_words:
252.L_copy_trailing_words:
253 movq (%rsi), %r8 229 movq (%rsi), %r8
254 mov %r8, (%rdi) 230 MCSAFE_TEST_SRC %rsi 8 .E_read_words
255 leaq 8(%rsi), %rsi 231 MCSAFE_TEST_DST %rdi 8 .E_write_words
256 leaq 8(%rdi), %rdi 232.L_write_words:
233 movq %r8, (%rdi)
234 addq $8, %rsi
235 addq $8, %rdi
257 decl %ecx 236 decl %ecx
258 jnz .L_copy_trailing_words 237 jnz .L_read_words
259 238
260 /* Any trailing bytes? */ 239 /* Any trailing bytes? */
261.L_no_whole_words: 240.L_no_whole_words:
@@ -264,38 +243,55 @@ ENTRY(memcpy_mcsafe_unrolled)
264 243
265 /* Copy trailing bytes */ 244 /* Copy trailing bytes */
266 movl %edx, %ecx 245 movl %edx, %ecx
267.L_copy_trailing_bytes: 246.L_read_trailing_bytes:
268 movb (%rsi), %al 247 movb (%rsi), %al
248 MCSAFE_TEST_SRC %rsi 1 .E_trailing_bytes
249 MCSAFE_TEST_DST %rdi 1 .E_trailing_bytes
250.L_write_trailing_bytes:
269 movb %al, (%rdi) 251 movb %al, (%rdi)
270 incq %rsi 252 incq %rsi
271 incq %rdi 253 incq %rdi
272 decl %ecx 254 decl %ecx
273 jnz .L_copy_trailing_bytes 255 jnz .L_read_trailing_bytes
274 256
275 /* Copy successful. Return zero */ 257 /* Copy successful. Return zero */
276.L_done_memcpy_trap: 258.L_done_memcpy_trap:
277 xorq %rax, %rax 259 xorq %rax, %rax
278 ret 260 ret
279ENDPROC(memcpy_mcsafe_unrolled) 261ENDPROC(__memcpy_mcsafe)
280EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) 262EXPORT_SYMBOL_GPL(__memcpy_mcsafe)
281 263
282 .section .fixup, "ax" 264 .section .fixup, "ax"
283 /* Return -EFAULT for any failure */ 265 /*
284.L_memcpy_mcsafe_fail: 266 * Return number of bytes not copied for any failure. Note that
285 mov $-EFAULT, %rax 267 * there is no "tail" handling since the source buffer is 8-byte
268 * aligned and poison is cacheline aligned.
269 */
270.E_read_words:
271 shll $3, %ecx
272.E_leading_bytes:
273 addl %edx, %ecx
274.E_trailing_bytes:
275 mov %ecx, %eax
286 ret 276 ret
287 277
278 /*
279 * For write fault handling, given the destination is unaligned,
280 * we handle faults on multi-byte writes with a byte-by-byte
281 * copy up to the write-protected page.
282 */
283.E_write_words:
284 shll $3, %ecx
285 addl %edx, %ecx
286 movl %ecx, %edx
287 jmp mcsafe_handle_tail
288
288 .previous 289 .previous
289 290
290 _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) 291 _ASM_EXTABLE_FAULT(.L_read_leading_bytes, .E_leading_bytes)
291 _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) 292 _ASM_EXTABLE_FAULT(.L_read_words, .E_read_words)
292 _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) 293 _ASM_EXTABLE_FAULT(.L_read_trailing_bytes, .E_trailing_bytes)
293 _ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) 294 _ASM_EXTABLE(.L_write_leading_bytes, .E_leading_bytes)
294 _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) 295 _ASM_EXTABLE(.L_write_words, .E_write_words)
295 _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) 296 _ASM_EXTABLE(.L_write_trailing_bytes, .E_trailing_bytes)
296 _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail)
297 _ASM_EXTABLE_FAULT(.L_cache_w6, .L_memcpy_mcsafe_fail)
298 _ASM_EXTABLE_FAULT(.L_cache_w7, .L_memcpy_mcsafe_fail)
299 _ASM_EXTABLE_FAULT(.L_copy_trailing_words, .L_memcpy_mcsafe_fail)
300 _ASM_EXTABLE_FAULT(.L_copy_trailing_bytes, .L_memcpy_mcsafe_fail)
301#endif 297#endif
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 32f9e397a6c0..3f140eff039f 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -217,6 +217,14 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))
217 int err; 217 int err;
218 int fd; 218 int fd;
219 219
220 if (argc < 3) {
221 p_err("too few arguments, id ID and FILE path is required");
222 return -1;
223 } else if (argc > 3) {
224 p_err("too many arguments");
225 return -1;
226 }
227
220 if (!is_prefix(*argv, "id")) { 228 if (!is_prefix(*argv, "id")) {
221 p_err("expected 'id' got %s", *argv); 229 p_err("expected 'id' got %s", *argv);
222 return -1; 230 return -1;
@@ -230,9 +238,6 @@ int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(__u32))
230 } 238 }
231 NEXT_ARG(); 239 NEXT_ARG();
232 240
233 if (argc != 1)
234 usage();
235
236 fd = get_fd_by_id(id); 241 fd = get_fd_by_id(id);
237 if (fd < 0) { 242 if (fd < 0) {
238 p_err("can't get prog by id (%u): %s", id, strerror(errno)); 243 p_err("can't get prog by id (%u): %s", id, strerror(errno));
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 097b1a5e046b..f74a8bcbda87 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -36,6 +36,7 @@
36#include <assert.h> 36#include <assert.h>
37#include <errno.h> 37#include <errno.h>
38#include <fcntl.h> 38#include <fcntl.h>
39#include <linux/kernel.h>
39#include <stdbool.h> 40#include <stdbool.h>
40#include <stdio.h> 41#include <stdio.h>
41#include <stdlib.h> 42#include <stdlib.h>
@@ -90,7 +91,8 @@ static bool map_is_map_of_progs(__u32 type)
90static void *alloc_value(struct bpf_map_info *info) 91static void *alloc_value(struct bpf_map_info *info)
91{ 92{
92 if (map_is_per_cpu(info->type)) 93 if (map_is_per_cpu(info->type))
93 return malloc(info->value_size * get_possible_cpus()); 94 return malloc(round_up(info->value_size, 8) *
95 get_possible_cpus());
94 else 96 else
95 return malloc(info->value_size); 97 return malloc(info->value_size);
96} 98}
@@ -161,9 +163,10 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
161 jsonw_name(json_wtr, "value"); 163 jsonw_name(json_wtr, "value");
162 print_hex_data_json(value, info->value_size); 164 print_hex_data_json(value, info->value_size);
163 } else { 165 } else {
164 unsigned int i, n; 166 unsigned int i, n, step;
165 167
166 n = get_possible_cpus(); 168 n = get_possible_cpus();
169 step = round_up(info->value_size, 8);
167 170
168 jsonw_name(json_wtr, "key"); 171 jsonw_name(json_wtr, "key");
169 print_hex_data_json(key, info->key_size); 172 print_hex_data_json(key, info->key_size);
@@ -176,7 +179,7 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
176 jsonw_int_field(json_wtr, "cpu", i); 179 jsonw_int_field(json_wtr, "cpu", i);
177 180
178 jsonw_name(json_wtr, "value"); 181 jsonw_name(json_wtr, "value");
179 print_hex_data_json(value + i * info->value_size, 182 print_hex_data_json(value + i * step,
180 info->value_size); 183 info->value_size);
181 184
182 jsonw_end_object(json_wtr); 185 jsonw_end_object(json_wtr);
@@ -207,9 +210,10 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
207 210
208 printf("\n"); 211 printf("\n");
209 } else { 212 } else {
210 unsigned int i, n; 213 unsigned int i, n, step;
211 214
212 n = get_possible_cpus(); 215 n = get_possible_cpus();
216 step = round_up(info->value_size, 8);
213 217
214 printf("key:\n"); 218 printf("key:\n");
215 fprint_hex(stdout, key, info->key_size, " "); 219 fprint_hex(stdout, key, info->key_size, " ");
@@ -217,7 +221,7 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
217 for (i = 0; i < n; i++) { 221 for (i = 0; i < n; i++) {
218 printf("value (CPU %02d):%c", 222 printf("value (CPU %02d):%c",
219 i, info->value_size > 16 ? '\n' : ' '); 223 i, info->value_size > 16 ? '\n' : ' ');
220 fprint_hex(stdout, value + i * info->value_size, 224 fprint_hex(stdout, value + i * step,
221 info->value_size, " "); 225 info->value_size, " ");
222 printf("\n"); 226 printf("\n");
223 } 227 }
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 59b19b6a40d7..b7db3261c62d 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -1857,7 +1857,8 @@ union bpf_attr {
1857 * is resolved), the nexthop address is returned in ipv4_dst 1857 * is resolved), the nexthop address is returned in ipv4_dst
1858 * or ipv6_dst based on family, smac is set to mac address of 1858 * or ipv6_dst based on family, smac is set to mac address of
1859 * egress device, dmac is set to nexthop mac address, rt_metric 1859 * egress device, dmac is set to nexthop mac address, rt_metric
1860 * is set to metric from route (IPv4/IPv6 only). 1860 * is set to metric from route (IPv4/IPv6 only), and ifindex
1861 * is set to the device index of the nexthop from the FIB lookup.
1861 * 1862 *
1862 * *plen* argument is the size of the passed in struct. 1863 * *plen* argument is the size of the passed in struct.
1863 * *flags* argument can be a combination of one or more of the 1864 * *flags* argument can be a combination of one or more of the
@@ -1873,9 +1874,10 @@ union bpf_attr {
1873 * *ctx* is either **struct xdp_md** for XDP programs or 1874 * *ctx* is either **struct xdp_md** for XDP programs or
1874 * **struct sk_buff** tc cls_act programs. 1875 * **struct sk_buff** tc cls_act programs.
1875 * Return 1876 * Return
1876 * Egress device index on success, 0 if packet needs to continue 1877 * * < 0 if any input argument is invalid
1877 * up the stack for further processing or a negative error in case 1878 * * 0 on success (packet is forwarded, nexthop neighbor exists)
1878 * of failure. 1879 * * > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the
1880 * * packet is not forwarded or needs assist from full stack
1879 * 1881 *
1880 * int bpf_sock_hash_update(struct bpf_sock_ops_kern *skops, struct bpf_map *map, void *key, u64 flags) 1882 * int bpf_sock_hash_update(struct bpf_sock_ops_kern *skops, struct bpf_map *map, void *key, u64 flags)
1881 * Description 1883 * Description
@@ -2612,6 +2614,18 @@ struct bpf_raw_tracepoint_args {
2612#define BPF_FIB_LOOKUP_DIRECT BIT(0) 2614#define BPF_FIB_LOOKUP_DIRECT BIT(0)
2613#define BPF_FIB_LOOKUP_OUTPUT BIT(1) 2615#define BPF_FIB_LOOKUP_OUTPUT BIT(1)
2614 2616
2617enum {
2618 BPF_FIB_LKUP_RET_SUCCESS, /* lookup successful */
2619 BPF_FIB_LKUP_RET_BLACKHOLE, /* dest is blackholed; can be dropped */
2620 BPF_FIB_LKUP_RET_UNREACHABLE, /* dest is unreachable; can be dropped */
2621 BPF_FIB_LKUP_RET_PROHIBIT, /* dest not allowed; can be dropped */
2622 BPF_FIB_LKUP_RET_NOT_FWDED, /* packet is not forwarded */
2623 BPF_FIB_LKUP_RET_FWD_DISABLED, /* fwding is not enabled on ingress */
2624 BPF_FIB_LKUP_RET_UNSUPP_LWT, /* fwd requires encapsulation */
2625 BPF_FIB_LKUP_RET_NO_NEIGH, /* no neighbor entry for nh */
2626 BPF_FIB_LKUP_RET_FRAG_NEEDED, /* fragmentation required to fwd */
2627};
2628
2615struct bpf_fib_lookup { 2629struct bpf_fib_lookup {
2616 /* input: network family for lookup (AF_INET, AF_INET6) 2630 /* input: network family for lookup (AF_INET, AF_INET6)
2617 * output: network family of egress nexthop 2631 * output: network family of egress nexthop
@@ -2625,7 +2639,11 @@ struct bpf_fib_lookup {
2625 2639
2626 /* total length of packet from network header - used for MTU check */ 2640 /* total length of packet from network header - used for MTU check */
2627 __u16 tot_len; 2641 __u16 tot_len;
2628 __u32 ifindex; /* L3 device index for lookup */ 2642
2643 /* input: L3 device index for lookup
2644 * output: device index from FIB lookup
2645 */
2646 __u32 ifindex;
2629 2647
2630 union { 2648 union {
2631 /* inputs to lookup */ 2649 /* inputs to lookup */
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h
index 0b5ddbe135a4..972265f32871 100644
--- a/tools/include/uapi/linux/btf.h
+++ b/tools/include/uapi/linux/btf.h
@@ -76,7 +76,7 @@ struct btf_type {
76 */ 76 */
77#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24) 77#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
78#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 78#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16)
79#define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff) 79#define BTF_INT_BITS(VAL) ((VAL) & 0x000000ff)
80 80
81/* Attributes stored in the BTF_INT_ENCODING */ 81/* Attributes stored in the BTF_INT_ENCODING */
82#define BTF_INT_SIGNED (1 << 0) 82#define BTF_INT_SIGNED (1 << 0)
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index b8e288a1f740..eeb787b1c53c 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -143,6 +143,8 @@ enum perf_event_sample_format {
143 PERF_SAMPLE_PHYS_ADDR = 1U << 19, 143 PERF_SAMPLE_PHYS_ADDR = 1U << 19,
144 144
145 PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */ 145 PERF_SAMPLE_MAX = 1U << 20, /* non-ABI */
146
147 __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63,
146}; 148};
147 149
148/* 150/*
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 8c54a4b6f187..2d270c560df3 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -2,7 +2,6 @@
2/* Copyright (c) 2018 Facebook */ 2/* Copyright (c) 2018 Facebook */
3 3
4#include <stdlib.h> 4#include <stdlib.h>
5#include <stdint.h>
6#include <string.h> 5#include <string.h>
7#include <unistd.h> 6#include <unistd.h>
8#include <errno.h> 7#include <errno.h>
@@ -27,13 +26,13 @@ struct btf {
27 struct btf_type **types; 26 struct btf_type **types;
28 const char *strings; 27 const char *strings;
29 void *nohdr_data; 28 void *nohdr_data;
30 uint32_t nr_types; 29 __u32 nr_types;
31 uint32_t types_size; 30 __u32 types_size;
32 uint32_t data_size; 31 __u32 data_size;
33 int fd; 32 int fd;
34}; 33};
35 34
36static const char *btf_name_by_offset(const struct btf *btf, uint32_t offset) 35static const char *btf_name_by_offset(const struct btf *btf, __u32 offset)
37{ 36{
38 if (offset < btf->hdr->str_len) 37 if (offset < btf->hdr->str_len)
39 return &btf->strings[offset]; 38 return &btf->strings[offset];
@@ -45,7 +44,7 @@ static int btf_add_type(struct btf *btf, struct btf_type *t)
45{ 44{
46 if (btf->types_size - btf->nr_types < 2) { 45 if (btf->types_size - btf->nr_types < 2) {
47 struct btf_type **new_types; 46 struct btf_type **new_types;
48 u32 expand_by, new_size; 47 __u32 expand_by, new_size;
49 48
50 if (btf->types_size == BTF_MAX_NR_TYPES) 49 if (btf->types_size == BTF_MAX_NR_TYPES)
51 return -E2BIG; 50 return -E2BIG;
@@ -72,7 +71,7 @@ static int btf_add_type(struct btf *btf, struct btf_type *t)
72static int btf_parse_hdr(struct btf *btf, btf_print_fn_t err_log) 71static int btf_parse_hdr(struct btf *btf, btf_print_fn_t err_log)
73{ 72{
74 const struct btf_header *hdr = btf->hdr; 73 const struct btf_header *hdr = btf->hdr;
75 u32 meta_left; 74 __u32 meta_left;
76 75
77 if (btf->data_size < sizeof(struct btf_header)) { 76 if (btf->data_size < sizeof(struct btf_header)) {
78 elog("BTF header not found\n"); 77 elog("BTF header not found\n");
@@ -151,7 +150,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
151 150
152 while (next_type < end_type) { 151 while (next_type < end_type) {
153 struct btf_type *t = next_type; 152 struct btf_type *t = next_type;
154 uint16_t vlen = BTF_INFO_VLEN(t->info); 153 __u16 vlen = BTF_INFO_VLEN(t->info);
155 int err; 154 int err;
156 155
157 next_type += sizeof(*t); 156 next_type += sizeof(*t);
@@ -190,8 +189,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
190 return 0; 189 return 0;
191} 190}
192 191
193static const struct btf_type *btf_type_by_id(const struct btf *btf, 192const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
194 uint32_t type_id)
195{ 193{
196 if (type_id > btf->nr_types) 194 if (type_id > btf->nr_types)
197 return NULL; 195 return NULL;
@@ -209,7 +207,7 @@ static bool btf_type_is_void_or_null(const struct btf_type *t)
209 return !t || btf_type_is_void(t); 207 return !t || btf_type_is_void(t);
210} 208}
211 209
212static int64_t btf_type_size(const struct btf_type *t) 210static __s64 btf_type_size(const struct btf_type *t)
213{ 211{
214 switch (BTF_INFO_KIND(t->info)) { 212 switch (BTF_INFO_KIND(t->info)) {
215 case BTF_KIND_INT: 213 case BTF_KIND_INT:
@@ -226,15 +224,15 @@ static int64_t btf_type_size(const struct btf_type *t)
226 224
227#define MAX_RESOLVE_DEPTH 32 225#define MAX_RESOLVE_DEPTH 32
228 226
229int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id) 227__s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
230{ 228{
231 const struct btf_array *array; 229 const struct btf_array *array;
232 const struct btf_type *t; 230 const struct btf_type *t;
233 uint32_t nelems = 1; 231 __u32 nelems = 1;
234 int64_t size = -1; 232 __s64 size = -1;
235 int i; 233 int i;
236 234
237 t = btf_type_by_id(btf, type_id); 235 t = btf__type_by_id(btf, type_id);
238 for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t); 236 for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t);
239 i++) { 237 i++) {
240 size = btf_type_size(t); 238 size = btf_type_size(t);
@@ -259,7 +257,7 @@ int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
259 return -EINVAL; 257 return -EINVAL;
260 } 258 }
261 259
262 t = btf_type_by_id(btf, type_id); 260 t = btf__type_by_id(btf, type_id);
263 } 261 }
264 262
265 if (size < 0) 263 if (size < 0)
@@ -271,9 +269,9 @@ int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
271 return nelems * size; 269 return nelems * size;
272} 270}
273 271
274int32_t btf__find_by_name(const struct btf *btf, const char *type_name) 272__s32 btf__find_by_name(const struct btf *btf, const char *type_name)
275{ 273{
276 uint32_t i; 274 __u32 i;
277 275
278 if (!strcmp(type_name, "void")) 276 if (!strcmp(type_name, "void"))
279 return 0; 277 return 0;
@@ -302,10 +300,9 @@ void btf__free(struct btf *btf)
302 free(btf); 300 free(btf);
303} 301}
304 302
305struct btf *btf__new(uint8_t *data, uint32_t size, 303struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
306 btf_print_fn_t err_log)
307{ 304{
308 uint32_t log_buf_size = 0; 305 __u32 log_buf_size = 0;
309 char *log_buf = NULL; 306 char *log_buf = NULL;
310 struct btf *btf; 307 struct btf *btf;
311 int err; 308 int err;
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index 74bb344035bb..e2a09a155f84 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -4,19 +4,21 @@
4#ifndef __BPF_BTF_H 4#ifndef __BPF_BTF_H
5#define __BPF_BTF_H 5#define __BPF_BTF_H
6 6
7#include <stdint.h> 7#include <linux/types.h>
8 8
9#define BTF_ELF_SEC ".BTF" 9#define BTF_ELF_SEC ".BTF"
10 10
11struct btf; 11struct btf;
12struct btf_type;
12 13
13typedef int (*btf_print_fn_t)(const char *, ...) 14typedef int (*btf_print_fn_t)(const char *, ...)
14 __attribute__((format(printf, 1, 2))); 15 __attribute__((format(printf, 1, 2)));
15 16
16void btf__free(struct btf *btf); 17void btf__free(struct btf *btf);
17struct btf *btf__new(uint8_t *data, uint32_t size, btf_print_fn_t err_log); 18struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
18int32_t btf__find_by_name(const struct btf *btf, const char *type_name); 19__s32 btf__find_by_name(const struct btf *btf, const char *type_name);
19int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id); 20const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 id);
21__s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
20int btf__fd(const struct btf *btf); 22int btf__fd(const struct btf *btf);
21 23
22#endif 24#endif
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index a1e96b5de5ff..1aafdbe827fe 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -36,6 +36,7 @@
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/bpf.h> 38#include <linux/bpf.h>
39#include <linux/btf.h>
39#include <linux/list.h> 40#include <linux/list.h>
40#include <linux/limits.h> 41#include <linux/limits.h>
41#include <sys/stat.h> 42#include <sys/stat.h>
@@ -216,8 +217,8 @@ struct bpf_map {
216 size_t offset; 217 size_t offset;
217 int map_ifindex; 218 int map_ifindex;
218 struct bpf_map_def def; 219 struct bpf_map_def def;
219 uint32_t btf_key_type_id; 220 __u32 btf_key_type_id;
220 uint32_t btf_value_type_id; 221 __u32 btf_value_type_id;
221 void *priv; 222 void *priv;
222 bpf_map_clear_priv_t clear_priv; 223 bpf_map_clear_priv_t clear_priv;
223}; 224};
@@ -1014,68 +1015,72 @@ bpf_program__collect_reloc(struct bpf_program *prog, GElf_Shdr *shdr,
1014 1015
1015static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf) 1016static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
1016{ 1017{
1018 const struct btf_type *container_type;
1019 const struct btf_member *key, *value;
1017 struct bpf_map_def *def = &map->def; 1020 struct bpf_map_def *def = &map->def;
1018 const size_t max_name = 256; 1021 const size_t max_name = 256;
1019 int64_t key_size, value_size; 1022 char container_name[max_name];
1020 int32_t key_id, value_id; 1023 __s64 key_size, value_size;
1021 char name[max_name]; 1024 __s32 container_id;
1022 1025
1023 /* Find key type by name from BTF */ 1026 if (snprintf(container_name, max_name, "____btf_map_%s", map->name) ==
1024 if (snprintf(name, max_name, "%s_key", map->name) == max_name) { 1027 max_name) {
1025 pr_warning("map:%s length of BTF key_type:%s_key is too long\n", 1028 pr_warning("map:%s length of '____btf_map_%s' is too long\n",
1026 map->name, map->name); 1029 map->name, map->name);
1027 return -EINVAL; 1030 return -EINVAL;
1028 } 1031 }
1029 1032
1030 key_id = btf__find_by_name(btf, name); 1033 container_id = btf__find_by_name(btf, container_name);
1031 if (key_id < 0) { 1034 if (container_id < 0) {
1032 pr_debug("map:%s key_type:%s cannot be found in BTF\n", 1035 pr_debug("map:%s container_name:%s cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?\n",
1033 map->name, name); 1036 map->name, container_name);
1034 return key_id; 1037 return container_id;
1035 } 1038 }
1036 1039
1037 key_size = btf__resolve_size(btf, key_id); 1040 container_type = btf__type_by_id(btf, container_id);
1038 if (key_size < 0) { 1041 if (!container_type) {
1039 pr_warning("map:%s key_type:%s cannot get the BTF type_size\n", 1042 pr_warning("map:%s cannot find BTF type for container_id:%u\n",
1040 map->name, name); 1043 map->name, container_id);
1041 return key_size; 1044 return -EINVAL;
1042 } 1045 }
1043 1046
1044 if (def->key_size != key_size) { 1047 if (BTF_INFO_KIND(container_type->info) != BTF_KIND_STRUCT ||
1045 pr_warning("map:%s key_type:%s has BTF type_size:%u != key_size:%u\n", 1048 BTF_INFO_VLEN(container_type->info) < 2) {
1046 map->name, name, (unsigned int)key_size, def->key_size); 1049 pr_warning("map:%s container_name:%s is an invalid container struct\n",
1050 map->name, container_name);
1047 return -EINVAL; 1051 return -EINVAL;
1048 } 1052 }
1049 1053
1050 /* Find value type from BTF */ 1054 key = (struct btf_member *)(container_type + 1);
1051 if (snprintf(name, max_name, "%s_value", map->name) == max_name) { 1055 value = key + 1;
1052 pr_warning("map:%s length of BTF value_type:%s_value is too long\n", 1056
1053 map->name, map->name); 1057 key_size = btf__resolve_size(btf, key->type);
1054 return -EINVAL; 1058 if (key_size < 0) {
1059 pr_warning("map:%s invalid BTF key_type_size\n",
1060 map->name);
1061 return key_size;
1055 } 1062 }
1056 1063
1057 value_id = btf__find_by_name(btf, name); 1064 if (def->key_size != key_size) {
1058 if (value_id < 0) { 1065 pr_warning("map:%s btf_key_type_size:%u != map_def_key_size:%u\n",
1059 pr_debug("map:%s value_type:%s cannot be found in BTF\n", 1066 map->name, (__u32)key_size, def->key_size);
1060 map->name, name); 1067 return -EINVAL;
1061 return value_id;
1062 } 1068 }
1063 1069
1064 value_size = btf__resolve_size(btf, value_id); 1070 value_size = btf__resolve_size(btf, value->type);
1065 if (value_size < 0) { 1071 if (value_size < 0) {
1066 pr_warning("map:%s value_type:%s cannot get the BTF type_size\n", 1072 pr_warning("map:%s invalid BTF value_type_size\n", map->name);
1067 map->name, name);
1068 return value_size; 1073 return value_size;
1069 } 1074 }
1070 1075
1071 if (def->value_size != value_size) { 1076 if (def->value_size != value_size) {
1072 pr_warning("map:%s value_type:%s has BTF type_size:%u != value_size:%u\n", 1077 pr_warning("map:%s btf_value_type_size:%u != map_def_value_size:%u\n",
1073 map->name, name, (unsigned int)value_size, def->value_size); 1078 map->name, (__u32)value_size, def->value_size);
1074 return -EINVAL; 1079 return -EINVAL;
1075 } 1080 }
1076 1081
1077 map->btf_key_type_id = key_id; 1082 map->btf_key_type_id = key->type;
1078 map->btf_value_type_id = value_id; 1083 map->btf_value_type_id = value->type;
1079 1084
1080 return 0; 1085 return 0;
1081} 1086}
@@ -2089,12 +2094,12 @@ const char *bpf_map__name(struct bpf_map *map)
2089 return map ? map->name : NULL; 2094 return map ? map->name : NULL;
2090} 2095}
2091 2096
2092uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map) 2097__u32 bpf_map__btf_key_type_id(const struct bpf_map *map)
2093{ 2098{
2094 return map ? map->btf_key_type_id : 0; 2099 return map ? map->btf_key_type_id : 0;
2095} 2100}
2096 2101
2097uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map) 2102__u32 bpf_map__btf_value_type_id(const struct bpf_map *map)
2098{ 2103{
2099 return map ? map->btf_value_type_id : 0; 2104 return map ? map->btf_value_type_id : 0;
2100} 2105}
@@ -2268,8 +2273,8 @@ bpf_perf_event_read_simple(void *mem, unsigned long size,
2268 volatile struct perf_event_mmap_page *header = mem; 2273 volatile struct perf_event_mmap_page *header = mem;
2269 __u64 data_tail = header->data_tail; 2274 __u64 data_tail = header->data_tail;
2270 __u64 data_head = header->data_head; 2275 __u64 data_head = header->data_head;
2276 int ret = LIBBPF_PERF_EVENT_ERROR;
2271 void *base, *begin, *end; 2277 void *base, *begin, *end;
2272 int ret;
2273 2278
2274 asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */ 2279 asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */
2275 if (data_head == data_tail) 2280 if (data_head == data_tail)
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 09976531aa74..b33ae02f7d0e 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -244,8 +244,8 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
244int bpf_map__fd(struct bpf_map *map); 244int bpf_map__fd(struct bpf_map *map);
245const struct bpf_map_def *bpf_map__def(struct bpf_map *map); 245const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
246const char *bpf_map__name(struct bpf_map *map); 246const char *bpf_map__name(struct bpf_map *map);
247uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map); 247__u32 bpf_map__btf_key_type_id(const struct bpf_map *map);
248uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map); 248__u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
249 249
250typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *); 250typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
251int bpf_map__set_priv(struct bpf_map *map, void *priv, 251int bpf_map__set_priv(struct bpf_map *map, void *priv,
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 0d1acb704f64..7ec85d567598 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -519,10 +519,12 @@ struct section *elf_create_section(struct elf *elf, const char *name,
519 sec->sh.sh_flags = SHF_ALLOC; 519 sec->sh.sh_flags = SHF_ALLOC;
520 520
521 521
522 /* Add section name to .shstrtab */ 522 /* Add section name to .shstrtab (or .strtab for Clang) */
523 shstrtab = find_section_by_name(elf, ".shstrtab"); 523 shstrtab = find_section_by_name(elf, ".shstrtab");
524 if (!shstrtab)
525 shstrtab = find_section_by_name(elf, ".strtab");
524 if (!shstrtab) { 526 if (!shstrtab) {
525 WARN("can't find .shstrtab section"); 527 WARN("can't find .shstrtab or .strtab section");
526 return NULL; 528 return NULL;
527 } 529 }
528 530
diff --git a/tools/perf/arch/x86/util/pmu.c b/tools/perf/arch/x86/util/pmu.c
index 63a74c32ddc5..e33ef5bc31c5 100644
--- a/tools/perf/arch/x86/util/pmu.c
+++ b/tools/perf/arch/x86/util/pmu.c
@@ -1,6 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2#include <string.h> 2#include <string.h>
3 3
4#include <linux/stddef.h>
4#include <linux/perf_event.h> 5#include <linux/perf_event.h>
5 6
6#include "../../util/intel-pt.h" 7#include "../../util/intel-pt.h"
diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c
index 06bae7023a51..950539f9a4f7 100644
--- a/tools/perf/arch/x86/util/tsc.c
+++ b/tools/perf/arch/x86/util/tsc.c
@@ -2,6 +2,7 @@
2#include <stdbool.h> 2#include <stdbool.h>
3#include <errno.h> 3#include <errno.h>
4 4
5#include <linux/stddef.h>
5#include <linux/perf_event.h> 6#include <linux/perf_event.h>
6 7
7#include "../../perf.h" 8#include "../../perf.h"
diff --git a/tools/perf/bench/Build b/tools/perf/bench/Build
index 60bf11943047..eafce1a130a1 100644
--- a/tools/perf/bench/Build
+++ b/tools/perf/bench/Build
@@ -7,6 +7,7 @@ perf-y += futex-wake-parallel.o
7perf-y += futex-requeue.o 7perf-y += futex-requeue.o
8perf-y += futex-lock-pi.o 8perf-y += futex-lock-pi.o
9 9
10perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-lib.o
10perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o 11perf-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o
11perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o 12perf-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o
12 13
diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index b43f8d2a34ec..9ad015a1e202 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -6,6 +6,7 @@
6#define altinstr_replacement text 6#define altinstr_replacement text
7#define globl p2align 4; .globl 7#define globl p2align 4; .globl
8#define _ASM_EXTABLE_FAULT(x, y) 8#define _ASM_EXTABLE_FAULT(x, y)
9#define _ASM_EXTABLE(x, y)
9 10
10#include "../../arch/x86/lib/memcpy_64.S" 11#include "../../arch/x86/lib/memcpy_64.S"
11/* 12/*
diff --git a/tools/perf/bench/mem-memcpy-x86-64-lib.c b/tools/perf/bench/mem-memcpy-x86-64-lib.c
new file mode 100644
index 000000000000..4130734dde84
--- /dev/null
+++ b/tools/perf/bench/mem-memcpy-x86-64-lib.c
@@ -0,0 +1,24 @@
1/*
2 * From code in arch/x86/lib/usercopy_64.c, copied to keep tools/ copy
3 * of the kernel's arch/x86/lib/memcpy_64.s used in 'perf bench mem memcpy'
4 * happy.
5 */
6#include <linux/types.h>
7
8unsigned long __memcpy_mcsafe(void *dst, const void *src, size_t cnt);
9unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len);
10
11unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len)
12{
13 for (; len; --len, to++, from++) {
14 /*
15 * Call the assembly routine back directly since
16 * memcpy_mcsafe() may silently fallback to memcpy.
17 */
18 unsigned long rem = __memcpy_mcsafe(to, from, 1);
19
20 if (rem)
21 break;
22 }
23 return len;
24}
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index a1a97956136f..d215714f48df 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -5,6 +5,7 @@
5#include <time.h> 5#include <time.h>
6#include <stdbool.h> 6#include <stdbool.h>
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/stddef.h>
8#include <linux/perf_event.h> 9#include <linux/perf_event.h>
9 10
10extern bool test_attr__enabled; 11extern bool test_attr__enabled;
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 90d4577a92dc..6d7fe44aadc0 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -2,6 +2,7 @@
2#ifndef __PERF_HEADER_H 2#ifndef __PERF_HEADER_H
3#define __PERF_HEADER_H 3#define __PERF_HEADER_H
4 4
5#include <linux/stddef.h>
5#include <linux/perf_event.h> 6#include <linux/perf_event.h>
6#include <sys/types.h> 7#include <sys/types.h>
7#include <stdbool.h> 8#include <stdbool.h>
diff --git a/tools/perf/util/namespaces.h b/tools/perf/util/namespaces.h
index 760558dcfd18..cae1a9a39722 100644
--- a/tools/perf/util/namespaces.h
+++ b/tools/perf/util/namespaces.h
@@ -10,6 +10,7 @@
10#define __PERF_NAMESPACES_H 10#define __PERF_NAMESPACES_H
11 11
12#include <sys/types.h> 12#include <sys/types.h>
13#include <linux/stddef.h>
13#include <linux/perf_event.h> 14#include <linux/perf_event.h>
14#include <linux/refcount.h> 15#include <linux/refcount.h>
15#include <linux/types.h> 16#include <linux/types.h>
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index d39e4ff7d0bf..a6db83a88e85 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -106,7 +106,7 @@ The system configuration dump (if --quiet is not used) is followed by statistics
106\fBC1%, C2%, C3%\fP The residency percentage that Linux requested C1, C2, C3.... The system summary is the average of all CPUs in the system. Note that these are software, reflecting what was requested. The hardware counters reflect what was actually achieved. 106\fBC1%, C2%, C3%\fP The residency percentage that Linux requested C1, C2, C3.... The system summary is the average of all CPUs in the system. Note that these are software, reflecting what was requested. The hardware counters reflect what was actually achieved.
107\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. These numbers are from hardware residency counters. 107\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. These numbers are from hardware residency counters.
108\fBCoreTmp\fP Degrees Celsius reported by the per-core Digital Thermal Sensor. 108\fBCoreTmp\fP Degrees Celsius reported by the per-core Digital Thermal Sensor.
109\fBPkgTtmp\fP Degrees Celsius reported by the per-package Package Thermal Monitor. 109\fBPkgTmp\fP Degrees Celsius reported by the per-package Package Thermal Monitor.
110\fBGFX%rc6\fP The percentage of time the GPU is in the "render C6" state, rc6, during the measurement interval. From /sys/class/drm/card0/power/rc6_residency_ms. 110\fBGFX%rc6\fP The percentage of time the GPU is in the "render C6" state, rc6, during the measurement interval. From /sys/class/drm/card0/power/rc6_residency_ms.
111\fBGFXMHz\fP Instantaneous snapshot of what sysfs presents at the end of the measurement interval. From /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz. 111\fBGFXMHz\fP Instantaneous snapshot of what sysfs presents at the end of the measurement interval. From /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz.
112\fBPkg%pc2, Pkg%pc3, Pkg%pc6, Pkg%pc7\fP percentage residency in hardware package idle states. These numbers are from hardware residency counters. 112\fBPkg%pc2, Pkg%pc3, Pkg%pc6, Pkg%pc7\fP percentage residency in hardware package idle states. These numbers are from hardware residency counters.
@@ -114,7 +114,7 @@ The system configuration dump (if --quiet is not used) is followed by statistics
114\fBCorWatt\fP Watts consumed by the core part of the package. 114\fBCorWatt\fP Watts consumed by the core part of the package.
115\fBGFXWatt\fP Watts consumed by the Graphics part of the package -- available only on client processors. 115\fBGFXWatt\fP Watts consumed by the Graphics part of the package -- available only on client processors.
116\fBRAMWatt\fP Watts consumed by the DRAM DIMMS -- available only on server processors. 116\fBRAMWatt\fP Watts consumed by the DRAM DIMMS -- available only on server processors.
117\fBPKG_%\fP percent of the interval that RAPL throttling was active on the Package. 117\fBPKG_%\fP percent of the interval that RAPL throttling was active on the Package. Note that the system summary is the sum of the package throttling time, and thus may be higher than 100% on a multi-package system. Note that the meaning of this field is model specific. For example, some hardware increments this counter when RAPL responds to thermal limits, but does not increment this counter when RAPL responds to power limits. Comparing PkgWatt and PkgTmp to system limits is necessary.
118\fBRAM_%\fP percent of the interval that RAPL throttling was active on DRAM. 118\fBRAM_%\fP percent of the interval that RAPL throttling was active on DRAM.
119.fi 119.fi
120.SH TOO MUCH INFORMATION EXAMPLE 120.SH TOO MUCH INFORMATION EXAMPLE
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 4d14bbbf9b63..980bd9d20646 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1163,9 +1163,7 @@ void format_all_counters(struct thread_data *t, struct core_data *c, struct pkg_
1163 if (!printed || !summary_only) 1163 if (!printed || !summary_only)
1164 print_header("\t"); 1164 print_header("\t");
1165 1165
1166 if (topo.num_cpus > 1) 1166 format_counters(&average.threads, &average.cores, &average.packages);
1167 format_counters(&average.threads, &average.cores,
1168 &average.packages);
1169 1167
1170 printed = 1; 1168 printed = 1;
1171 1169
@@ -1692,7 +1690,7 @@ void get_apic_id(struct thread_data *t)
1692 t->x2apic_id = edx; 1690 t->x2apic_id = edx;
1693 1691
1694 if (debug && (t->apic_id != t->x2apic_id)) 1692 if (debug && (t->apic_id != t->x2apic_id))
1695 fprintf(stderr, "cpu%d: apic 0x%x x2apic 0x%x\n", t->cpu_id, t->apic_id, t->x2apic_id); 1693 fprintf(outf, "cpu%d: apic 0x%x x2apic 0x%x\n", t->cpu_id, t->apic_id, t->x2apic_id);
1696} 1694}
1697 1695
1698/* 1696/*
@@ -2473,55 +2471,43 @@ int get_core_id(int cpu)
2473 2471
2474void set_node_data(void) 2472void set_node_data(void)
2475{ 2473{
2476 char path[80]; 2474 int pkg, node, lnode, cpu, cpux;
2477 FILE *filep; 2475 int cpu_count;
2478 int pkg, node, cpu; 2476
2479 2477 /* initialize logical_node_id */
2480 struct pkg_node_info { 2478 for (cpu = 0; cpu <= topo.max_cpu_num; ++cpu)
2481 int count; 2479 cpus[cpu].logical_node_id = -1;
2482 int min; 2480
2483 } *pni; 2481 cpu_count = 0;
2484 2482 for (pkg = 0; pkg < topo.num_packages; pkg++) {
2485 pni = calloc(topo.num_packages, sizeof(struct pkg_node_info)); 2483 lnode = 0;
2486 if (!pni) 2484 for (cpu = 0; cpu <= topo.max_cpu_num; ++cpu) {
2487 err(1, "calloc pkg_node_count"); 2485 if (cpus[cpu].physical_package_id != pkg)
2488 2486 continue;
2489 for (pkg = 0; pkg < topo.num_packages; pkg++) 2487 /* find a cpu with an unset logical_node_id */
2490 pni[pkg].min = topo.num_cpus; 2488 if (cpus[cpu].logical_node_id != -1)
2491 2489 continue;
2492 for (node = 0; node <= topo.max_node_num; node++) { 2490 cpus[cpu].logical_node_id = lnode;
2493 /* find the "first" cpu in the node */ 2491 node = cpus[cpu].physical_node_id;
2494 sprintf(path, "/sys/bus/node/devices/node%d/cpulist", node); 2492 cpu_count++;
2495 filep = fopen(path, "r"); 2493 /*
2496 if (!filep) 2494 * find all matching cpus on this pkg and set
2497 continue; 2495 * the logical_node_id
2498 fscanf(filep, "%d", &cpu); 2496 */
2499 fclose(filep); 2497 for (cpux = cpu; cpux <= topo.max_cpu_num; cpux++) {
2500 2498 if ((cpus[cpux].physical_package_id == pkg) &&
2501 pkg = cpus[cpu].physical_package_id; 2499 (cpus[cpux].physical_node_id == node)) {
2502 pni[pkg].count++; 2500 cpus[cpux].logical_node_id = lnode;
2503 2501 cpu_count++;
2504 if (node < pni[pkg].min) 2502 }
2505 pni[pkg].min = node; 2503 }
2506 } 2504 lnode++;
2507 2505 if (lnode > topo.nodes_per_pkg)
2508 for (pkg = 0; pkg < topo.num_packages; pkg++) 2506 topo.nodes_per_pkg = lnode;
2509 if (pni[pkg].count > topo.nodes_per_pkg) 2507 }
2510 topo.nodes_per_pkg = pni[0].count; 2508 if (cpu_count >= topo.max_cpu_num)
2511 2509 break;
2512 /* Fake 1 node per pkg for machines that don't
2513 * expose nodes and thus avoid -nan results
2514 */
2515 if (topo.nodes_per_pkg == 0)
2516 topo.nodes_per_pkg = 1;
2517
2518 for (cpu = 0; cpu < topo.num_cpus; cpu++) {
2519 pkg = cpus[cpu].physical_package_id;
2520 node = cpus[cpu].physical_node_id;
2521 cpus[cpu].logical_node_id = node - pni[pkg].min;
2522 } 2510 }
2523 free(pni);
2524
2525} 2511}
2526 2512
2527int get_physical_node_id(struct cpu_topology *thiscpu) 2513int get_physical_node_id(struct cpu_topology *thiscpu)
@@ -4471,7 +4457,9 @@ void process_cpuid()
4471 family = (fms >> 8) & 0xf; 4457 family = (fms >> 8) & 0xf;
4472 model = (fms >> 4) & 0xf; 4458 model = (fms >> 4) & 0xf;
4473 stepping = fms & 0xf; 4459 stepping = fms & 0xf;
4474 if (family == 6 || family == 0xf) 4460 if (family == 0xf)
4461 family += (fms >> 20) & 0xff;
4462 if (family >= 6)
4475 model += ((fms >> 16) & 0xf) << 4; 4463 model += ((fms >> 16) & 0xf) << 4;
4476 4464
4477 if (!quiet) { 4465 if (!quiet) {
@@ -4840,16 +4828,8 @@ void topology_probe()
4840 siblings = get_thread_siblings(&cpus[i]); 4828 siblings = get_thread_siblings(&cpus[i]);
4841 if (siblings > max_siblings) 4829 if (siblings > max_siblings)
4842 max_siblings = siblings; 4830 max_siblings = siblings;
4843 if (cpus[i].thread_id != -1) 4831 if (cpus[i].thread_id == 0)
4844 topo.num_cores++; 4832 topo.num_cores++;
4845
4846 if (debug > 1)
4847 fprintf(outf,
4848 "cpu %d pkg %d node %d core %d thread %d\n",
4849 i, cpus[i].physical_package_id,
4850 cpus[i].physical_node_id,
4851 cpus[i].physical_core_id,
4852 cpus[i].thread_id);
4853 } 4833 }
4854 4834
4855 topo.cores_per_node = max_core_id + 1; 4835 topo.cores_per_node = max_core_id + 1;
@@ -4875,6 +4855,20 @@ void topology_probe()
4875 topo.threads_per_core = max_siblings; 4855 topo.threads_per_core = max_siblings;
4876 if (debug > 1) 4856 if (debug > 1)
4877 fprintf(outf, "max_siblings %d\n", max_siblings); 4857 fprintf(outf, "max_siblings %d\n", max_siblings);
4858
4859 if (debug < 1)
4860 return;
4861
4862 for (i = 0; i <= topo.max_cpu_num; ++i) {
4863 fprintf(outf,
4864 "cpu %d pkg %d node %d lnode %d core %d thread %d\n",
4865 i, cpus[i].physical_package_id,
4866 cpus[i].physical_node_id,
4867 cpus[i].logical_node_id,
4868 cpus[i].physical_core_id,
4869 cpus[i].thread_id);
4870 }
4871
4878} 4872}
4879 4873
4880void 4874void
@@ -5102,7 +5096,7 @@ int get_and_dump_counters(void)
5102} 5096}
5103 5097
5104void print_version() { 5098void print_version() {
5105 fprintf(outf, "turbostat version 18.06.20" 5099 fprintf(outf, "turbostat version 18.07.27"
5106 " - Len Brown <lenb@kernel.org>\n"); 5100 " - Len Brown <lenb@kernel.org>\n");
5107} 5101}
5108 5102
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 7a6214e9ae58..a362e3d7abc6 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -105,7 +105,7 @@ $(OUTPUT)/test_xdp_noinline.o: CLANG_FLAGS += -fno-inline
105 105
106BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris) 106BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
107BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) 107BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
108BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --version 2>&1 | grep LLVM) 108BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
109 109
110ifneq ($(BTF_LLC_PROBE),) 110ifneq ($(BTF_LLC_PROBE),)
111ifneq ($(BTF_PAHOLE_PROBE),) 111ifneq ($(BTF_PAHOLE_PROBE),)
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
index f2f28b6c8915..810de20e8e26 100644
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -158,6 +158,15 @@ struct bpf_map_def {
158 unsigned int numa_node; 158 unsigned int numa_node;
159}; 159};
160 160
161#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) \
162 struct ____btf_map_##name { \
163 type_key key; \
164 type_val value; \
165 }; \
166 struct ____btf_map_##name \
167 __attribute__ ((section(".maps." #name), used)) \
168 ____btf_map_##name = { }
169
161static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) = 170static int (*bpf_skb_load_bytes)(void *ctx, int off, void *to, int len) =
162 (void *) BPF_FUNC_skb_load_bytes; 171 (void *) BPF_FUNC_skb_load_bytes;
163static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) = 172static int (*bpf_skb_store_bytes)(void *ctx, int off, void *from, int len, int flags) =
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
index 3619f3023088..ffdd27737c9e 100644
--- a/tools/testing/selftests/bpf/test_btf.c
+++ b/tools/testing/selftests/bpf/test_btf.c
@@ -247,6 +247,34 @@ static struct btf_raw_test raw_tests[] = {
247 .max_entries = 4, 247 .max_entries = 4,
248}, 248},
249 249
250{
251 .descr = "struct test #3 Invalid member offset",
252 .raw_types = {
253 /* int */ /* [1] */
254 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
255 /* int64 */ /* [2] */
256 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 64, 8),
257
258 /* struct A { */ /* [3] */
259 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 2), 16),
260 BTF_MEMBER_ENC(NAME_TBD, 1, 64), /* int m; */
261 BTF_MEMBER_ENC(NAME_TBD, 2, 0), /* int64 n; */
262 /* } */
263 BTF_END_RAW,
264 },
265 .str_sec = "\0A\0m\0n\0",
266 .str_sec_size = sizeof("\0A\0m\0n\0"),
267 .map_type = BPF_MAP_TYPE_ARRAY,
268 .map_name = "struct_test3_map",
269 .key_size = sizeof(int),
270 .value_size = 16,
271 .key_type_id = 1,
272 .value_type_id = 3,
273 .max_entries = 4,
274 .btf_load_err = true,
275 .err_str = "Invalid member bits_offset",
276},
277
250/* Test member exceeds the size of struct. 278/* Test member exceeds the size of struct.
251 * 279 *
252 * struct A { 280 * struct A {
@@ -479,7 +507,7 @@ static struct btf_raw_test raw_tests[] = {
479 .key_size = sizeof(int), 507 .key_size = sizeof(int),
480 .value_size = sizeof(void *) * 4, 508 .value_size = sizeof(void *) * 4,
481 .key_type_id = 1, 509 .key_type_id = 1,
482 .value_type_id = 4, 510 .value_type_id = 5,
483 .max_entries = 4, 511 .max_entries = 4,
484}, 512},
485 513
@@ -1264,6 +1292,88 @@ static struct btf_raw_test raw_tests[] = {
1264 .err_str = "type != 0", 1292 .err_str = "type != 0",
1265}, 1293},
1266 1294
1295{
1296 .descr = "arraymap invalid btf key (a bit field)",
1297 .raw_types = {
1298 /* int */ /* [1] */
1299 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
1300 /* 32 bit int with 32 bit offset */ /* [2] */
1301 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 32, 32, 8),
1302 BTF_END_RAW,
1303 },
1304 .str_sec = "",
1305 .str_sec_size = sizeof(""),
1306 .map_type = BPF_MAP_TYPE_ARRAY,
1307 .map_name = "array_map_check_btf",
1308 .key_size = sizeof(int),
1309 .value_size = sizeof(int),
1310 .key_type_id = 2,
1311 .value_type_id = 1,
1312 .max_entries = 4,
1313 .map_create_err = true,
1314},
1315
1316{
1317 .descr = "arraymap invalid btf key (!= 32 bits)",
1318 .raw_types = {
1319 /* int */ /* [1] */
1320 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
1321 /* 16 bit int with 0 bit offset */ /* [2] */
1322 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 16, 2),
1323 BTF_END_RAW,
1324 },
1325 .str_sec = "",
1326 .str_sec_size = sizeof(""),
1327 .map_type = BPF_MAP_TYPE_ARRAY,
1328 .map_name = "array_map_check_btf",
1329 .key_size = sizeof(int),
1330 .value_size = sizeof(int),
1331 .key_type_id = 2,
1332 .value_type_id = 1,
1333 .max_entries = 4,
1334 .map_create_err = true,
1335},
1336
1337{
1338 .descr = "arraymap invalid btf value (too small)",
1339 .raw_types = {
1340 /* int */ /* [1] */
1341 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
1342 BTF_END_RAW,
1343 },
1344 .str_sec = "",
1345 .str_sec_size = sizeof(""),
1346 .map_type = BPF_MAP_TYPE_ARRAY,
1347 .map_name = "array_map_check_btf",
1348 .key_size = sizeof(int),
1349 /* btf_value_size < map->value_size */
1350 .value_size = sizeof(__u64),
1351 .key_type_id = 1,
1352 .value_type_id = 1,
1353 .max_entries = 4,
1354 .map_create_err = true,
1355},
1356
1357{
1358 .descr = "arraymap invalid btf value (too big)",
1359 .raw_types = {
1360 /* int */ /* [1] */
1361 BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
1362 BTF_END_RAW,
1363 },
1364 .str_sec = "",
1365 .str_sec_size = sizeof(""),
1366 .map_type = BPF_MAP_TYPE_ARRAY,
1367 .map_name = "array_map_check_btf",
1368 .key_size = sizeof(int),
1369 /* btf_value_size > map->value_size */
1370 .value_size = sizeof(__u16),
1371 .key_type_id = 1,
1372 .value_type_id = 1,
1373 .max_entries = 4,
1374 .map_create_err = true,
1375},
1376
1267}; /* struct btf_raw_test raw_tests[] */ 1377}; /* struct btf_raw_test raw_tests[] */
1268 1378
1269static const char *get_next_str(const char *start, const char *end) 1379static const char *get_next_str(const char *start, const char *end)
@@ -2023,7 +2133,7 @@ static struct btf_raw_test pprint_test = {
2023 BTF_ENUM_ENC(NAME_TBD, 2), 2133 BTF_ENUM_ENC(NAME_TBD, 2),
2024 BTF_ENUM_ENC(NAME_TBD, 3), 2134 BTF_ENUM_ENC(NAME_TBD, 3),
2025 /* struct pprint_mapv */ /* [16] */ 2135 /* struct pprint_mapv */ /* [16] */
2026 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 8), 28), 2136 BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, 8), 32),
2027 BTF_MEMBER_ENC(NAME_TBD, 11, 0), /* uint32_t ui32 */ 2137 BTF_MEMBER_ENC(NAME_TBD, 11, 0), /* uint32_t ui32 */
2028 BTF_MEMBER_ENC(NAME_TBD, 10, 32), /* uint16_t ui16 */ 2138 BTF_MEMBER_ENC(NAME_TBD, 10, 32), /* uint16_t ui16 */
2029 BTF_MEMBER_ENC(NAME_TBD, 12, 64), /* int32_t si32 */ 2139 BTF_MEMBER_ENC(NAME_TBD, 12, 64), /* int32_t si32 */
diff --git a/tools/testing/selftests/bpf/test_btf_haskv.c b/tools/testing/selftests/bpf/test_btf_haskv.c
index 8c7ca096ecf2..b21b876f475d 100644
--- a/tools/testing/selftests/bpf/test_btf_haskv.c
+++ b/tools/testing/selftests/bpf/test_btf_haskv.c
@@ -10,11 +10,6 @@ struct ipv_counts {
10 unsigned int v6; 10 unsigned int v6;
11}; 11};
12 12
13typedef int btf_map_key;
14typedef struct ipv_counts btf_map_value;
15btf_map_key dumm_key;
16btf_map_value dummy_value;
17
18struct bpf_map_def SEC("maps") btf_map = { 13struct bpf_map_def SEC("maps") btf_map = {
19 .type = BPF_MAP_TYPE_ARRAY, 14 .type = BPF_MAP_TYPE_ARRAY,
20 .key_size = sizeof(int), 15 .key_size = sizeof(int),
@@ -22,6 +17,8 @@ struct bpf_map_def SEC("maps") btf_map = {
22 .max_entries = 4, 17 .max_entries = 4,
23}; 18};
24 19
20BPF_ANNOTATE_KV_PAIR(btf_map, int, struct ipv_counts);
21
25struct dummy_tracepoint_args { 22struct dummy_tracepoint_args {
26 unsigned long long pad; 23 unsigned long long pad;
27 struct sock *sock; 24 struct sock *sock;
diff --git a/tools/testing/selftests/bpf/test_lwt_seg6local.sh b/tools/testing/selftests/bpf/test_lwt_seg6local.sh
index 270fa8f49573..785eabf2a593 100755
--- a/tools/testing/selftests/bpf/test_lwt_seg6local.sh
+++ b/tools/testing/selftests/bpf/test_lwt_seg6local.sh
@@ -115,14 +115,14 @@ ip netns exec ns2 ip -6 route add fb00::6 encap bpf in obj test_lwt_seg6local.o
115ip netns exec ns2 ip -6 route add fd00::1 dev veth3 via fb00::43 scope link 115ip netns exec ns2 ip -6 route add fd00::1 dev veth3 via fb00::43 scope link
116 116
117ip netns exec ns3 ip -6 route add fc42::1 dev veth5 via fb00::65 117ip netns exec ns3 ip -6 route add fc42::1 dev veth5 via fb00::65
118ip netns exec ns3 ip -6 route add fd00::1 encap seg6local action End.BPF obj test_lwt_seg6local.o sec add_egr_x dev veth4 118ip netns exec ns3 ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec add_egr_x dev veth4
119 119
120ip netns exec ns4 ip -6 route add fd00::2 encap seg6local action End.BPF obj test_lwt_seg6local.o sec pop_egr dev veth6 120ip netns exec ns4 ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec pop_egr dev veth6
121ip netns exec ns4 ip -6 addr add fc42::1 dev lo 121ip netns exec ns4 ip -6 addr add fc42::1 dev lo
122ip netns exec ns4 ip -6 route add fd00::3 dev veth7 via fb00::87 122ip netns exec ns4 ip -6 route add fd00::3 dev veth7 via fb00::87
123 123
124ip netns exec ns5 ip -6 route add fd00::4 table 117 dev veth9 via fb00::109 124ip netns exec ns5 ip -6 route add fd00::4 table 117 dev veth9 via fb00::109
125ip netns exec ns5 ip -6 route add fd00::3 encap seg6local action End.BPF obj test_lwt_seg6local.o sec inspect_t dev veth8 125ip netns exec ns5 ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec inspect_t dev veth8
126 126
127ip netns exec ns6 ip -6 addr add fb00::6/16 dev lo 127ip netns exec ns6 ip -6 addr add fb00::6/16 dev lo
128ip netns exec ns6 ip -6 addr add fd00::4/16 dev lo 128ip netns exec ns6 ip -6 addr add fd00::4/16 dev lo
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 2ecd27b670d7..41106d9d5cc7 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -4975,6 +4975,24 @@ static struct bpf_test tests[] = {
4975 .prog_type = BPF_PROG_TYPE_LWT_XMIT, 4975 .prog_type = BPF_PROG_TYPE_LWT_XMIT,
4976 }, 4976 },
4977 { 4977 {
4978 "make headroom for LWT_XMIT",
4979 .insns = {
4980 BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
4981 BPF_MOV64_IMM(BPF_REG_2, 34),
4982 BPF_MOV64_IMM(BPF_REG_3, 0),
4983 BPF_EMIT_CALL(BPF_FUNC_skb_change_head),
4984 /* split for s390 to succeed */
4985 BPF_MOV64_REG(BPF_REG_1, BPF_REG_6),
4986 BPF_MOV64_IMM(BPF_REG_2, 42),
4987 BPF_MOV64_IMM(BPF_REG_3, 0),
4988 BPF_EMIT_CALL(BPF_FUNC_skb_change_head),
4989 BPF_MOV64_IMM(BPF_REG_0, 0),
4990 BPF_EXIT_INSN(),
4991 },
4992 .result = ACCEPT,
4993 .prog_type = BPF_PROG_TYPE_LWT_XMIT,
4994 },
4995 {
4978 "invalid access of tc_classid for LWT_IN", 4996 "invalid access of tc_classid for LWT_IN",
4979 .insns = { 4997 .insns = {
4980 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 4998 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
@@ -11987,6 +12005,46 @@ static struct bpf_test tests[] = {
11987 .prog_type = BPF_PROG_TYPE_XDP, 12005 .prog_type = BPF_PROG_TYPE_XDP,
11988 }, 12006 },
11989 { 12007 {
12008 "xadd/w check whether src/dst got mangled, 1",
12009 .insns = {
12010 BPF_MOV64_IMM(BPF_REG_0, 1),
12011 BPF_MOV64_REG(BPF_REG_6, BPF_REG_0),
12012 BPF_MOV64_REG(BPF_REG_7, BPF_REG_10),
12013 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
12014 BPF_STX_XADD(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
12015 BPF_STX_XADD(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
12016 BPF_JMP_REG(BPF_JNE, BPF_REG_6, BPF_REG_0, 3),
12017 BPF_JMP_REG(BPF_JNE, BPF_REG_7, BPF_REG_10, 2),
12018 BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_10, -8),
12019 BPF_EXIT_INSN(),
12020 BPF_MOV64_IMM(BPF_REG_0, 42),
12021 BPF_EXIT_INSN(),
12022 },
12023 .result = ACCEPT,
12024 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
12025 .retval = 3,
12026 },
12027 {
12028 "xadd/w check whether src/dst got mangled, 2",
12029 .insns = {
12030 BPF_MOV64_IMM(BPF_REG_0, 1),
12031 BPF_MOV64_REG(BPF_REG_6, BPF_REG_0),
12032 BPF_MOV64_REG(BPF_REG_7, BPF_REG_10),
12033 BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -8),
12034 BPF_STX_XADD(BPF_W, BPF_REG_10, BPF_REG_0, -8),
12035 BPF_STX_XADD(BPF_W, BPF_REG_10, BPF_REG_0, -8),
12036 BPF_JMP_REG(BPF_JNE, BPF_REG_6, BPF_REG_0, 3),
12037 BPF_JMP_REG(BPF_JNE, BPF_REG_7, BPF_REG_10, 2),
12038 BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -8),
12039 BPF_EXIT_INSN(),
12040 BPF_MOV64_IMM(BPF_REG_0, 42),
12041 BPF_EXIT_INSN(),
12042 },
12043 .result = ACCEPT,
12044 .prog_type = BPF_PROG_TYPE_SCHED_CLS,
12045 .retval = 3,
12046 },
12047 {
11990 "bpf_get_stack return R0 within range", 12048 "bpf_get_stack return R0 within range",
11991 .insns = { 12049 .insns = {
11992 BPF_MOV64_REG(BPF_REG_6, BPF_REG_1), 12050 BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
@@ -12554,8 +12612,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
12554 } 12612 }
12555 12613
12556 if (fd_prog >= 0) { 12614 if (fd_prog >= 0) {
12615 __u8 tmp[TEST_DATA_LEN << 2];
12616 __u32 size_tmp = sizeof(tmp);
12617
12557 err = bpf_prog_test_run(fd_prog, 1, test->data, 12618 err = bpf_prog_test_run(fd_prog, 1, test->data,
12558 sizeof(test->data), NULL, NULL, 12619 sizeof(test->data), tmp, &size_tmp,
12559 &retval, NULL); 12620 &retval, NULL);
12560 if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) { 12621 if (err && errno != 524/*ENOTSUPP*/ && errno != EPERM) {
12561 printf("Unexpected bpf_prog_test_run error\n"); 12622 printf("Unexpected bpf_prog_test_run error\n");
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc b/tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc
new file mode 100644
index 000000000000..3b1f45e13a2e
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/00basic/snapshot.tc
@@ -0,0 +1,28 @@
1#!/bin/sh
2# description: Snapshot and tracing setting
3# flags: instance
4
5[ ! -f snapshot ] && exit_unsupported
6
7echo "Set tracing off"
8echo 0 > tracing_on
9
10echo "Allocate and take a snapshot"
11echo 1 > snapshot
12
13# Since trace buffer is empty, snapshot is also empty, but allocated
14grep -q "Snapshot is allocated" snapshot
15
16echo "Ensure keep tracing off"
17test `cat tracing_on` -eq 0
18
19echo "Set tracing on"
20echo 1 > tracing_on
21
22echo "Take a snapshot again"
23echo 1 > snapshot
24
25echo "Ensure keep tracing on"
26test `cat tracing_on` -eq 1
27
28exit 0
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index 78245d60d8bc..0f45633bd634 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -740,13 +740,6 @@ ipv6_rt_add()
740 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64" 740 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
741 log_test $? 2 "Attempt to add duplicate route - reject route" 741 log_test $? 2 "Attempt to add duplicate route - reject route"
742 742
743 # iproute2 prepend only sets NLM_F_CREATE
744 # - adds a new route; does NOT convert existing route to ECMP
745 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
746 run_cmd "$IP -6 ro prepend 2001:db8:104::/64 via 2001:db8:103::2"
747 check_route6 "2001:db8:104::/64 via 2001:db8:101::2 dev veth1 metric 1024 2001:db8:104::/64 via 2001:db8:103::2 dev veth3 metric 1024"
748 log_test $? 0 "Add new route for existing prefix (w/o NLM_F_EXCL)"
749
750 # route append with same prefix adds a new route 743 # route append with same prefix adds a new route
751 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND 744 # - iproute2 sets NLM_F_CREATE | NLM_F_APPEND
752 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2" 745 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
@@ -754,27 +747,6 @@ ipv6_rt_add()
754 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1" 747 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
755 log_test $? 0 "Append nexthop to existing route - gw" 748 log_test $? 0 "Append nexthop to existing route - gw"
756 749
757 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
758 run_cmd "$IP -6 ro append 2001:db8:104::/64 dev veth3"
759 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop dev veth3 weight 1"
760 log_test $? 0 "Append nexthop to existing route - dev only"
761
762 # multipath route can not have a nexthop that is a reject route
763 add_route6 "2001:db8:104::/64" "via 2001:db8:101::2"
764 run_cmd "$IP -6 ro append unreachable 2001:db8:104::/64"
765 log_test $? 2 "Append nexthop to existing route - reject route"
766
767 # reject route can not be converted to multipath route
768 run_cmd "$IP -6 ro flush 2001:db8:104::/64"
769 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
770 run_cmd "$IP -6 ro append 2001:db8:104::/64 via 2001:db8:103::2"
771 log_test $? 2 "Append nexthop to existing reject route - gw"
772
773 run_cmd "$IP -6 ro flush 2001:db8:104::/64"
774 run_cmd "$IP -6 ro add unreachable 2001:db8:104::/64"
775 run_cmd "$IP -6 ro append 2001:db8:104::/64 dev veth3"
776 log_test $? 2 "Append nexthop to existing reject route - dev only"
777
778 # insert mpath directly 750 # insert mpath directly
779 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2" 751 add_route6 "2001:db8:104::/64" "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
780 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1" 752 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::2 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
@@ -819,13 +791,6 @@ ipv6_rt_replace_single()
819 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::3 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1" 791 check_route6 "2001:db8:104::/64 metric 1024 nexthop via 2001:db8:101::3 dev veth1 weight 1 nexthop via 2001:db8:103::2 dev veth3 weight 1"
820 log_test $? 0 "Single path with multipath" 792 log_test $? 0 "Single path with multipath"
821 793
822 # single path with reject
823 #
824 add_initial_route6 "nexthop via 2001:db8:101::2"
825 run_cmd "$IP -6 ro replace unreachable 2001:db8:104::/64"
826 check_route6 "unreachable 2001:db8:104::/64 dev lo metric 1024"
827 log_test $? 0 "Single path with reject route"
828
829 # single path with single path using MULTIPATH attribute 794 # single path with single path using MULTIPATH attribute
830 # 795 #
831 add_initial_route6 "via 2001:db8:101::2" 796 add_initial_route6 "via 2001:db8:101::2"
@@ -873,12 +838,6 @@ ipv6_rt_replace_mpath()
873 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024" 838 check_route6 "2001:db8:104::/64 via 2001:db8:101::3 dev veth1 metric 1024"
874 log_test $? 0 "Multipath with single path via multipath attribute" 839 log_test $? 0 "Multipath with single path via multipath attribute"
875 840
876 # multipath with reject
877 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
878 run_cmd "$IP -6 ro replace unreachable 2001:db8:104::/64"
879 check_route6 "unreachable 2001:db8:104::/64 dev lo metric 1024"
880 log_test $? 0 "Multipath with reject route"
881
882 # route replace fails - invalid nexthop 1 841 # route replace fails - invalid nexthop 1
883 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2" 842 add_initial_route6 "nexthop via 2001:db8:101::2 nexthop via 2001:db8:103::2"
884 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3" 843 run_cmd "$IP -6 ro replace 2001:db8:104::/64 nexthop via 2001:db8:111::3 nexthop via 2001:db8:103::3"
diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index 77f762780199..e8c5dff448eb 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -402,7 +402,7 @@ int main(int argc, char *argv[])
402 exit(1); 402 exit(1);
403 } 403 }
404 404
405 fd = socket(AF_INET6, SOCK_STREAM, 0); 405 fd = socket(cfg_family, SOCK_STREAM, 0);
406 if (fd == -1) { 406 if (fd == -1) {
407 perror("socket"); 407 perror("socket");
408 exit(1); 408 exit(1);
diff --git a/tools/testing/selftests/net/udpgso_bench.sh b/tools/testing/selftests/net/udpgso_bench.sh
index 792fa4d0285e..850767befa47 100755
--- a/tools/testing/selftests/net/udpgso_bench.sh
+++ b/tools/testing/selftests/net/udpgso_bench.sh
@@ -35,9 +35,6 @@ run_udp() {
35 35
36 echo "udp gso" 36 echo "udp gso"
37 run_in_netns ${args} -S 37 run_in_netns ${args} -S
38
39 echo "udp gso zerocopy"
40 run_in_netns ${args} -S -z
41} 38}
42 39
43run_tcp() { 40run_tcp() {
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
index 95dd14648ba5..0f395dfb7774 100644
--- a/tools/usb/ffs-test.c
+++ b/tools/usb/ffs-test.c
@@ -44,12 +44,25 @@
44 44
45/******************** Little Endian Handling ********************************/ 45/******************** Little Endian Handling ********************************/
46 46
47#define cpu_to_le16(x) htole16(x) 47/*
48#define cpu_to_le32(x) htole32(x) 48 * cpu_to_le16/32 are used when initializing structures, a context where a
49 * function call is not allowed. To solve this, we code cpu_to_le16/32 in a way
50 * that allows them to be used when initializing structures.
51 */
52
53#if __BYTE_ORDER == __LITTLE_ENDIAN
54#define cpu_to_le16(x) (x)
55#define cpu_to_le32(x) (x)
56#else
57#define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
58#define cpu_to_le32(x) \
59 ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
60 (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
61#endif
62
49#define le32_to_cpu(x) le32toh(x) 63#define le32_to_cpu(x) le32toh(x)
50#define le16_to_cpu(x) le16toh(x) 64#define le16_to_cpu(x) le16toh(x)
51 65
52
53/******************** Messages and Errors ***********************************/ 66/******************** Messages and Errors ***********************************/
54 67
55static const char argv0[] = "ffs-test"; 68static const char argv0[] = "ffs-test";
diff --git a/tools/virtio/asm/barrier.h b/tools/virtio/asm/barrier.h
index 0ac3caf90877..d0351f83aebe 100644
--- a/tools/virtio/asm/barrier.h
+++ b/tools/virtio/asm/barrier.h
@@ -13,8 +13,8 @@
13} while (0); 13} while (0);
14/* Weak barriers should be used. If not - it's a bug */ 14/* Weak barriers should be used. If not - it's a bug */
15# define mb() abort() 15# define mb() abort()
16# define rmb() abort() 16# define dma_rmb() abort()
17# define wmb() abort() 17# define dma_wmb() abort()
18#else 18#else
19#error Please fill in barrier macros 19#error Please fill in barrier macros
20#endif 20#endif
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index fca8381bbe04..fb22bccfbc8a 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -52,6 +52,11 @@ static inline void *kmalloc(size_t s, gfp_t gfp)
52 return __kmalloc_fake; 52 return __kmalloc_fake;
53 return malloc(s); 53 return malloc(s);
54} 54}
55static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp)
56{
57 return kmalloc(n * s, gfp);
58}
59
55static inline void *kzalloc(size_t s, gfp_t gfp) 60static inline void *kzalloc(size_t s, gfp_t gfp)
56{ 61{
57 void *p = kmalloc(s, gfp); 62 void *p = kmalloc(s, gfp);
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 90d30fbe95ae..b20b751286fc 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -119,8 +119,12 @@ irqfd_shutdown(struct work_struct *work)
119{ 119{
120 struct kvm_kernel_irqfd *irqfd = 120 struct kvm_kernel_irqfd *irqfd =
121 container_of(work, struct kvm_kernel_irqfd, shutdown); 121 container_of(work, struct kvm_kernel_irqfd, shutdown);
122 struct kvm *kvm = irqfd->kvm;
122 u64 cnt; 123 u64 cnt;
123 124
125 /* Make sure irqfd has been initalized in assign path. */
126 synchronize_srcu(&kvm->irq_srcu);
127
124 /* 128 /*
125 * Synchronize with the wait-queue and unhook ourselves to prevent 129 * Synchronize with the wait-queue and unhook ourselves to prevent
126 * further events. 130 * further events.
@@ -387,7 +391,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
387 391
388 idx = srcu_read_lock(&kvm->irq_srcu); 392 idx = srcu_read_lock(&kvm->irq_srcu);
389 irqfd_update(kvm, irqfd); 393 irqfd_update(kvm, irqfd);
390 srcu_read_unlock(&kvm->irq_srcu, idx);
391 394
392 list_add_tail(&irqfd->list, &kvm->irqfds.items); 395 list_add_tail(&irqfd->list, &kvm->irqfds.items);
393 396
@@ -402,11 +405,6 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
402 if (events & EPOLLIN) 405 if (events & EPOLLIN)
403 schedule_work(&irqfd->inject); 406 schedule_work(&irqfd->inject);
404 407
405 /*
406 * do not drop the file until the irqfd is fully initialized, otherwise
407 * we might race against the EPOLLHUP
408 */
409 fdput(f);
410#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS 408#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
411 if (kvm_arch_has_irq_bypass()) { 409 if (kvm_arch_has_irq_bypass()) {
412 irqfd->consumer.token = (void *)irqfd->eventfd; 410 irqfd->consumer.token = (void *)irqfd->eventfd;
@@ -421,6 +419,13 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
421 } 419 }
422#endif 420#endif
423 421
422 srcu_read_unlock(&kvm->irq_srcu, idx);
423
424 /*
425 * do not drop the file until the irqfd is fully initialized, otherwise
426 * we might race against the EPOLLHUP
427 */
428 fdput(f);
424 return 0; 429 return 0;
425 430
426fail: 431fail: