]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 2 Sep 2017 00:16:40 +0000 (17:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 2 Sep 2017 00:16:40 +0000 (17:16 -0700)
Pull ARM SoC fixes from Olof Johansson:
 "A couple of late-arriving fixes before final 4.13:

   - A few reverts of DT bindings on Allwinner for their ethernet
     driver. Discussion didn't converge, and since bindings are
     considered ABI it makes sense to revert instead of having to
     support two bindings long-term.

   - A fix to enumerate GPIOs properly on Marvell Armada AP806"

* tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc:
  arm64: dts: marvell: fix number of GPIOs in Armada AP806 description
  arm: dts: sunxi: Revert EMAC changes
  arm64: dts: allwinner: Revert EMAC changes
  dt-bindings: net: Revert sun8i dwmac binding

826 files changed:
Documentation/fb/efifb.txt
Documentation/gpio/gpio-legacy.txt
Documentation/networking/switchdev.txt
Documentation/printk-formats.txt
Documentation/sysctl/net.txt
MAINTAINERS
Makefile
arch/alpha/include/asm/io.h
arch/alpha/include/asm/types.h
arch/alpha/include/asm/unistd.h
arch/alpha/include/uapi/asm/types.h
arch/alpha/include/uapi/asm/unistd.h
arch/alpha/kernel/core_marvel.c
arch/alpha/kernel/core_titan.c
arch/alpha/kernel/module.c
arch/alpha/kernel/smp.c
arch/alpha/kernel/systbls.S
arch/alpha/lib/Makefile
arch/alpha/lib/copy_user.S
arch/alpha/lib/ev6-copy_user.S
arch/arc/Kconfig
arch/arc/Makefile
arch/arc/boot/dts/axc001.dtsi
arch/arc/boot/dts/axc003.dtsi
arch/arc/boot/dts/axc003_idu.dtsi
arch/arc/boot/dts/axs10x_mb.dtsi
arch/arc/configs/haps_hs_defconfig
arch/arc/configs/haps_hs_smp_defconfig
arch/arc/configs/nps_defconfig
arch/arc/configs/nsim_700_defconfig
arch/arc/configs/nsim_hs_defconfig
arch/arc/configs/nsim_hs_smp_defconfig
arch/arc/configs/nsimosci_defconfig
arch/arc/configs/nsimosci_hs_defconfig
arch/arc/configs/nsimosci_hs_smp_defconfig
arch/arc/configs/tb10x_defconfig
arch/arc/include/asm/cache.h
arch/arc/include/asm/mmu.h
arch/arc/kernel/intc-arcv2.c
arch/arc/kernel/intc-compact.c
arch/arc/mm/cache.c
arch/arc/mm/dma.c
arch/arc/mm/tlb.c
arch/arc/plat-sim/Kconfig [deleted file]
arch/arc/plat-sim/platform.c
arch/arm/include/asm/kvm_host.h
arch/arm/include/asm/tlb.h
arch/arm64/include/asm/arch_timer.h
arch/arm64/include/asm/elf.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/kernel/fpsimd.c
arch/arm64/kernel/head.S
arch/arm64/kernel/kaslr.c
arch/arm64/mm/fault.c
arch/c6x/configs/dsk6455_defconfig
arch/c6x/configs/evmc6457_defconfig
arch/c6x/configs/evmc6472_defconfig
arch/c6x/configs/evmc6474_defconfig
arch/c6x/configs/evmc6678_defconfig
arch/c6x/platforms/megamod-pic.c
arch/c6x/platforms/plldata.c
arch/c6x/platforms/timer64.c
arch/ia64/include/asm/tlb.h
arch/mips/Kconfig
arch/mips/Makefile
arch/mips/boot/compressed/.gitignore [new file with mode: 0644]
arch/mips/cavium-octeon/octeon-usb.c
arch/mips/dec/int-handler.S
arch/mips/include/asm/cache.h
arch/mips/include/asm/cpu-features.h
arch/mips/include/asm/kvm_host.h
arch/mips/include/asm/octeon/cvmx-l2c-defs.h
arch/mips/include/asm/octeon/cvmx-l2d-defs.h [new file with mode: 0644]
arch/mips/include/asm/octeon/cvmx.h
arch/mips/kernel/smp.c
arch/mips/mm/uasm-mips.c
arch/mips/net/ebpf_jit.c [new file with mode: 0644]
arch/mips/pci/pci.c
arch/mips/vdso/gettimeofday.c
arch/powerpc/Kconfig
arch/powerpc/configs/powernv_defconfig
arch/powerpc/configs/ppc64_defconfig
arch/powerpc/configs/pseries_defconfig
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/include/asm/mmu_context.h
arch/powerpc/include/asm/pgtable-be-types.h
arch/powerpc/include/asm/pgtable-types.h
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/process.c
arch/powerpc/kernel/smp.c
arch/powerpc/kernel/watchdog.c
arch/powerpc/kvm/book3s_64_vio.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S
arch/powerpc/kvm/book3s_xive_template.c
arch/powerpc/platforms/powernv/idle.c
arch/powerpc/platforms/powernv/npu-dma.c
arch/s390/include/asm/mmu_context.h
arch/s390/include/asm/tlb.h
arch/s390/kvm/sthyi.c
arch/s390/mm/mmap.c
arch/s390/net/bpf_jit_comp.c
arch/sh/include/asm/tlb.h
arch/sparc/include/asm/page_32.h
arch/sparc/include/asm/spitfire.h
arch/sparc/kernel/cpu.c
arch/sparc/kernel/cpumap.c
arch/sparc/kernel/head_64.S
arch/sparc/kernel/pci_sun4v.c
arch/sparc/kernel/pcic.c
arch/sparc/kernel/setup_64.c
arch/sparc/lib/multi3.S
arch/sparc/mm/init_64.c
arch/um/include/asm/tlb.h
arch/x86/Kconfig
arch/x86/crypto/sha1_avx2_x86_64_asm.S
arch/x86/crypto/sha1_ssse3_glue.c
arch/x86/entry/entry_64.S
arch/x86/events/core.c
arch/x86/events/intel/bts.c
arch/x86/events/intel/p4.c
arch/x86/events/intel/rapl.c
arch/x86/events/intel/uncore.c
arch/x86/events/intel/uncore_nhmex.c
arch/x86/events/intel/uncore_snb.c
arch/x86/events/intel/uncore_snbep.c
arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/elf.h
arch/x86/include/asm/fpu/internal.h
arch/x86/include/asm/hypervisor.h
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/mmu_context.h
arch/x86/kernel/cpu/aperfmperf.c
arch/x86/kernel/cpu/mcheck/therm_throt.c
arch/x86/kernel/cpu/microcode/core.c
arch/x86/kernel/cpu/mtrr/main.c
arch/x86/kernel/head64.c
arch/x86/kernel/ksysfs.c
arch/x86/kernel/smpboot.c
arch/x86/kvm/cpuid.c
arch/x86/kvm/kvm_cache_regs.h
arch/x86/kvm/mmu.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/mm/init.c
arch/x86/mm/mmap.c
arch/x86/platform/uv/tlb_uv.c
arch/x86/um/user-offsets.c
arch/x86/xen/enlighten_hvm.c
arch/xtensa/include/asm/Kbuild
arch/xtensa/include/asm/device.h [deleted file]
arch/xtensa/include/asm/param.h [deleted file]
arch/xtensa/kernel/xtensa_ksyms.c
arch/xtensa/mm/cache.c
block/bfq-iosched.h
block/bfq-wf2q.c
block/bio-integrity.c
block/blk-mq-debugfs.c
block/blk-mq-pci.c
block/blk-mq.c
block/blk-throttle.c
block/bsg-lib.c
crypto/algif_skcipher.c
crypto/chacha20_generic.c
crypto/testmgr.h
drivers/acpi/acpica/nsxfeval.c
drivers/acpi/ec.c
drivers/acpi/internal.h
drivers/acpi/property.c
drivers/acpi/scan.c
drivers/acpi/spcr.c
drivers/android/binder.c
drivers/ata/ahci_da850.c
drivers/ata/libata-core.c
drivers/base/firmware_class.c
drivers/block/loop.c
drivers/block/loop.h
drivers/block/sunvdc.c
drivers/block/virtio_blk.c
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/block/zram/zram_drv.c
drivers/char/random.c
drivers/clocksource/Kconfig
drivers/clocksource/arm_arch_timer.c
drivers/clocksource/em_sti.c
drivers/clocksource/timer-of.c
drivers/cpufreq/intel_pstate.c
drivers/cpuidle/cpuidle-powernv.c
drivers/crypto/inside-secure/safexcel_hash.c
drivers/crypto/ixp4xx_crypto.c
drivers/dma-buf/sync_file.c
drivers/dma/tegra210-adma.c
drivers/gpio/gpio-mvebu.c
drivers/gpio/gpiolib-sysfs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
drivers/gpu/drm/bridge/sil-sii8620.c
drivers/gpu/drm/bridge/tc358767.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_plane.c
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/exynos/exynos_drm_fb.c
drivers/gpu/drm/i915/gvt/cmd_parser.c
drivers/gpu/drm/i915/gvt/execlist.c
drivers/gpu/drm/i915/gvt/firmware.c
drivers/gpu/drm/i915/gvt/gvt.h
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/scheduler.c
drivers/gpu/drm/i915/gvt/vgpu.c
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_render_state.c
drivers/gpu/drm/i915/i915_gem_shrinker.c
drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/i915/intel_bios.c
drivers/gpu/drm/i915/intel_color.c
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
drivers/gpu/drm/i915/intel_dsi_vbt.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_lrc.h
drivers/gpu/drm/i915/intel_lspcon.c
drivers/gpu/drm/i915/intel_panel.c
drivers/gpu/drm/imx/ipuv3-plane.c
drivers/gpu/drm/msm/Kconfig
drivers/gpu/drm/msm/adreno/a5xx_gpu.c
drivers/gpu/drm/msm/adreno/a5xx_gpu.h
drivers/gpu/drm/msm/adreno/adreno_gpu.c
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_encoder.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
drivers/gpu/drm/msm/msm_gem.c
drivers/gpu/drm/msm/msm_gem_submit.c
drivers/gpu/drm/msm/msm_gem_vma.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
drivers/gpu/drm/rockchip/rockchip_drm_vop.c
drivers/gpu/drm/rockchip/rockchip_drm_vop.h
drivers/gpu/drm/stm/Kconfig
drivers/gpu/drm/sun4i/sun4i_drv.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/ipu-v3/Kconfig
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-aspeed.c
drivers/i2c/busses/i2c-designware-platdrv.c
drivers/i2c/busses/i2c-designware-slave.c
drivers/i2c/busses/i2c-ismt.c
drivers/i2c/busses/i2c-simtec.c
drivers/i2c/i2c-core-acpi.c
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-core.h
drivers/i2c/muxes/Kconfig
drivers/iio/accel/bmc150-accel-core.c
drivers/iio/accel/st_accel_core.c
drivers/iio/adc/aspeed_adc.c
drivers/iio/adc/axp288_adc.c
drivers/iio/adc/ina2xx-adc.c
drivers/iio/adc/stm32-adc-core.c
drivers/iio/adc/sun4i-gpadc-iio.c
drivers/iio/adc/vf610_adc.c
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
drivers/iio/common/st_sensors/st_sensors_core.c
drivers/iio/imu/adis16480.c
drivers/iio/light/tsl2563.c
drivers/iio/magnetometer/st_magn_core.c
drivers/iio/pressure/bmp280-core.c
drivers/iio/pressure/bmp280.h
drivers/iio/pressure/st_pressure_core.c
drivers/iio/trigger/stm32-timer-trigger.c
drivers/infiniband/core/addr.c
drivers/infiniband/core/device.c
drivers/infiniband/core/umem_odp.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/core/verbs.c
drivers/infiniband/hw/cxgb4/mem.c
drivers/infiniband/hw/hfi1/mmu_rb.c
drivers/infiniband/hw/hns/hns_roce_ah.c
drivers/infiniband/hw/hns/hns_roce_hw_v1.c
drivers/infiniband/hw/i40iw/i40iw_ctrl.c
drivers/infiniband/hw/i40iw/i40iw_d.h
drivers/infiniband/hw/i40iw/i40iw_puda.c
drivers/infiniband/hw/i40iw/i40iw_status.h
drivers/infiniband/hw/i40iw/i40iw_uk.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/odp.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
drivers/infiniband/ulp/ipoib/ipoib.h
drivers/infiniband/ulp/ipoib/ipoib_cm.c
drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
drivers/infiniband/ulp/ipoib/ipoib_ib.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/ipoib/ipoib_multicast.c
drivers/input/joystick/xpad.c
drivers/input/misc/soc_button_array.c
drivers/input/mouse/alps.c
drivers/input/mouse/alps.h
drivers/input/mouse/elan_i2c_core.c
drivers/input/mouse/synaptics.c
drivers/input/mouse/trackpoint.c
drivers/input/mouse/trackpoint.h
drivers/iommu/amd_iommu_types.h
drivers/iommu/amd_iommu_v2.c
drivers/iommu/arm-smmu.c
drivers/iommu/intel-iommu.c
drivers/iommu/intel-svm.c
drivers/iommu/iommu-sysfs.c
drivers/irqchip/irq-atmel-aic-common.c
drivers/irqchip/irq-atmel-aic-common.h
drivers/irqchip/irq-atmel-aic.c
drivers/irqchip/irq-atmel-aic5.c
drivers/irqchip/irq-brcmstb-l2.c
drivers/irqchip/irq-gic-v3-its-platform-msi.c
drivers/irqchip/irq-gic-v3-its.c
drivers/irqchip/irq-gic-v3.c
drivers/irqchip/irq-gic.c
drivers/isdn/hysdn/hysdn_proclog.c
drivers/isdn/mISDN/fsm.c
drivers/isdn/mISDN/fsm.h
drivers/isdn/mISDN/layer1.c
drivers/isdn/mISDN/layer2.c
drivers/isdn/mISDN/tei.c
drivers/md/dm-mpath.c
drivers/md/dm.c
drivers/md/md.c
drivers/md/raid5-cache.c
drivers/mfd/da9062-core.c
drivers/misc/mei/pci-me.c
drivers/misc/mei/pci-txe.c
drivers/misc/mic/scif/scif_dma.c
drivers/misc/sgi-gru/grutlbpurge.c
drivers/mmc/core/block.c
drivers/mmc/core/mmc.c
drivers/mmc/host/omap_hsmmc.c
drivers/mmc/host/sdhci-xenon.c
drivers/mtd/mtd_blkdevs.c
drivers/mtd/nand/atmel/nand-controller.c
drivers/mtd/nand/atmel/pmecc.c
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/nand_timings.c
drivers/mtd/nand/nandsim.c
drivers/mtd/nand/sunxi_nand.c
drivers/net/bonding/bond_main.c
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/bcm_sf2.h
drivers/net/dsa/bcm_sf2_cfp.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/mt7530.h
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
drivers/net/ethernet/aquantia/atlantic/aq_hw.h
drivers/net/ethernet/aquantia/atlantic/aq_nic.c
drivers/net/ethernet/aquantia/atlantic/aq_ring.c
drivers/net/ethernet/aquantia/atlantic/aq_utils.h
drivers/net/ethernet/aquantia/atlantic/aq_vec.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h
drivers/net/ethernet/broadcom/b44.c
drivers/net/ethernet/broadcom/bcmsysport.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/sge.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
drivers/net/ethernet/chelsio/cxgb4vf/sge.c
drivers/net/ethernet/faraday/ftgmac100.c
drivers/net/ethernet/freescale/fman/mac.c
drivers/net/ethernet/ibm/ibmvnic.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
drivers/net/ethernet/marvell/mvpp2.c
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
drivers/net/ethernet/mellanox/mlx4/en_rx.c
drivers/net/ethernet/mellanox/mlx4/fw.c
drivers/net/ethernet/mellanox/mlx4/fw.h
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/srq.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
drivers/net/ethernet/netronome/nfp/flower/cmsg.c
drivers/net/ethernet/netronome/nfp/flower/match.c
drivers/net/ethernet/netronome/nfp/flower/offload.c
drivers/net/ethernet/netronome/nfp/nfp_main.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/netronome/nfp/nfp_net_main.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
drivers/net/ethernet/qlogic/qed/qed_mcp.c
drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
drivers/net/ethernet/realtek/r8169.c
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
drivers/net/ethernet/sfc/mcdi_port.c
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
drivers/net/ethernet/ti/cpsw-common.c
drivers/net/ethernet/ti/cpts.c
drivers/net/ethernet/ti/cpts.h
drivers/net/geneve.c
drivers/net/gtp.c
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/hyperv/rndis_filter.c
drivers/net/ipvlan/ipvlan_main.c
drivers/net/macsec.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/ppp/ppp_generic.c
drivers/net/tun.c
drivers/net/usb/asix.h
drivers/net/usb/asix_common.c
drivers/net/usb/asix_devices.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/lan78xx.c
drivers/net/usb/qmi_wwan.c
drivers/net/virtio_net.c
drivers/net/vxlan.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
drivers/net/wireless/intel/iwlwifi/cfg/9000.c
drivers/net/wireless/intel/iwlwifi/fw/file.h
drivers/net/wireless/intel/iwlwifi/iwl-config.h
drivers/net/wireless/intel/iwlwifi/iwl-drv.c
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/rs.c
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
drivers/net/wireless/ti/wl1251/main.c
drivers/ntb/ntb_transport.c
drivers/ntb/test/ntb_tool.c
drivers/nvme/host/core.c
drivers/nvme/host/fabrics.c
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/fc.c
drivers/of/device.c
drivers/parisc/dino.c
drivers/pci/msi.c
drivers/pci/pci.c
drivers/pci/probe.c
drivers/pci/quirks.c
drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/intel/pinctrl-merrifield.c
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c
drivers/pinctrl/zte/pinctrl-zx.c
drivers/ptp/ptp_clock.c
drivers/ptp/ptp_private.h
drivers/rtc/rtc-ds1307.c
drivers/s390/cio/vfio_ccw_cp.c
drivers/s390/net/qeth_l3_main.c
drivers/scsi/Kconfig
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/aacraid.h
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/bnx2fc/bnx2fc_hwi.c
drivers/scsi/bnx2i/bnx2i_init.c
drivers/scsi/csiostor/csio_hw.c
drivers/scsi/csiostor/csio_init.c
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
drivers/scsi/ipr.c
drivers/scsi/ipr.h
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/lpfc/lpfc_nvmet.c
drivers/scsi/lpfc/lpfc_nvmet.h
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/qedf/qedf.h
drivers/scsi/qedf/qedf_els.c
drivers/scsi/qedf/qedf_main.c
drivers/scsi/qla2xxx/qla_tmpl.c
drivers/scsi/qla2xxx/tcm_qla2xxx.c
drivers/scsi/scsi.c
drivers/scsi/sd.c
drivers/scsi/sd_zbc.c
drivers/scsi/ses.c
drivers/scsi/sg.c
drivers/scsi/st.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
drivers/staging/iio/resolver/ad2s1210.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/target/iscsi/cxgbit/cxgbit_cm.c
drivers/target/iscsi/cxgbit/cxgbit_target.c
drivers/target/iscsi/iscsi_target.c
drivers/target/iscsi/iscsi_target_login.c
drivers/target/target_core_tpg.c
drivers/target/target_core_transport.c
drivers/target/target_core_user.c
drivers/thunderbolt/eeprom.c
drivers/tty/pty.c
drivers/tty/serial/8250/8250_core.c
drivers/tty/serial/amba-pl011.c
drivers/tty/tty_io.c
drivers/usb/core/hcd.c
drivers/usb/core/hub.c
drivers/usb/core/quirks.c
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/udc/renesas_usb3.c
drivers/usb/host/pci-quirks.c
drivers/usb/host/pci-quirks.h
drivers/usb/host/xhci-pci.c
drivers/usb/musb/musb_host.c
drivers/usb/phy/phy-msm-usb.c
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/renesas_usbhs/rcar3.c
drivers/usb/serial/cp210x.c
drivers/usb/serial/option.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/pl2303.h
drivers/usb/storage/unusual_uas.h
drivers/usb/storage/usb.c
drivers/video/fbdev/efifb.c
drivers/video/fbdev/imxfb.c
drivers/video/fbdev/omap2/omapfb/dss/core.c
drivers/virtio/virtio_pci_common.c
drivers/xen/Makefile
drivers/xen/biomerge.c
drivers/xen/events/events_base.c
drivers/xen/gntdev.c
drivers/xen/xenbus/xenbus_xs.c
fs/binfmt_elf.c
fs/btrfs/disk-io.c
fs/btrfs/inode.c
fs/btrfs/raid56.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h
fs/ceph/addr.c
fs/ceph/cache.c
fs/cifs/dir.c
fs/cifs/smb2pdu.c
fs/cifs/smb2pdu.h
fs/dax.c
fs/devpts/inode.c
fs/eventpoll.c
fs/ext4/mballoc.c
fs/ext4/xattr.c
fs/fuse/file.c
fs/fuse/fuse_i.h
fs/iomap.c
fs/jfs/super.c
fs/nfs/Kconfig
fs/nfs/flexfilelayout/flexfilelayoutdev.c
fs/nfs/nfs4proc.c
fs/nfsd/nfs4xdr.c
fs/proc/meminfo.c
fs/proc/task_mmu.c
fs/quota/dquot.c
fs/select.c
fs/userfaultfd.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_log.c
fs/xfs/xfs_log_cil.c
fs/xfs/xfs_mount.c
include/asm-generic/tlb.h
include/asm-generic/topology.h
include/asm-generic/vmlinux.lds.h
include/linux/acpi.h
include/linux/ata.h
include/linux/blkdev.h
include/linux/bsg-lib.h
include/linux/compiler.h
include/linux/cpuhotplug.h
include/linux/device-mapper.h
include/linux/device.h
include/linux/devpts_fs.h
include/linux/fs.h
include/linux/i2c.h
include/linux/iio/common/st_sensors.h
include/linux/iio/iio.h
include/linux/iio/trigger.h
include/linux/iommu.h
include/linux/memblock.h
include/linux/memcontrol.h
include/linux/mlx4/device.h
include/linux/mlx5/driver.h
include/linux/mlx5/qp.h
include/linux/mm.h
include/linux/mm_types.h
include/linux/mmu_notifier.h
include/linux/mtd/nand.h
include/linux/net.h
include/linux/netdevice.h
include/linux/nmi.h
include/linux/nvme-fc-driver.h
include/linux/nvme.h
include/linux/oom.h
include/linux/pci.h
include/linux/perf_event.h
include/linux/pid.h
include/linux/pinctrl/pinconf-generic.h
include/linux/platform_data/st_sensors_pdata.h
include/linux/ptp_clock_kernel.h
include/linux/ptr_ring.h
include/linux/sched.h
include/linux/skb_array.h
include/linux/skbuff.h
include/linux/sync_file.h
include/linux/wait.h
include/net/addrconf.h
include/net/bonding.h
include/net/busy_poll.h
include/net/ip.h
include/net/ip6_fib.h
include/net/mac80211.h
include/net/sch_generic.h
include/net/sock.h
include/net/tcp.h
include/net/udp.h
include/rdma/ib_verbs.h
include/scsi/scsi_cmnd.h
include/target/iscsi/iscsi_target_core.h
include/uapi/drm/msm_drm.h
include/uapi/linux/loop.h
include/uapi/linux/ndctl.h
kernel/audit_watch.c
kernel/bpf/hashtab.c
kernel/cgroup/cpuset.c
kernel/events/core.c
kernel/events/uprobes.c
kernel/fork.c
kernel/futex.c
kernel/irq/chip.c
kernel/irq/ipi.c
kernel/kmod.c
kernel/kthread.c
kernel/pid.c
kernel/power/snapshot.c
kernel/sched/wait.c
kernel/signal.c
kernel/time/timer.c
kernel/trace/bpf_trace.c
kernel/trace/ftrace.c
kernel/trace/ring_buffer.c
kernel/trace/ring_buffer_benchmark.c
kernel/trace/trace.c
kernel/trace/trace_events_filter.c
kernel/trace/tracing_map.c
kernel/watchdog.c
kernel/watchdog_hld.c
lib/Kconfig.debug
lib/fault-inject.c
lib/mpi/mpicoder.c
lib/test_kmod.c
mm/balloon_compaction.c
mm/cma_debug.c
mm/debug.c
mm/filemap.c
mm/huge_memory.c
mm/hugetlb.c
mm/ksm.c
mm/madvise.c
mm/memblock.c
mm/memcontrol.c
mm/memory.c
mm/mempolicy.c
mm/migrate.c
mm/mmu_notifier.c
mm/mprotect.c
mm/nobootmem.c
mm/page-writeback.c
mm/page_alloc.c
mm/rmap.c
mm/shmem.c
mm/slub.c
mm/util.c
mm/vmalloc.c
net/batman-adv/translation-table.c
net/batman-adv/types.h
net/bridge/br_device.c
net/bridge/br_switchdev.c
net/core/datagram.c
net/core/dev.c
net/core/filter.c
net/core/skbuff.c
net/dccp/proto.c
net/dsa/dsa2.c
net/dsa/tag_ksz.c
net/dsa/tag_trailer.c
net/hsr/hsr_device.c
net/ipv4/af_inet.c
net/ipv4/cipso_ipv4.c
net/ipv4/esp4.c
net/ipv4/esp4_offload.c
net/ipv4/fib_semantics.c
net/ipv4/fou.c
net/ipv4/igmp.c
net/ipv4/ip_output.c
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/route.c
net/ipv4/tcp.c
net/ipv4/tcp_cong.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_output.c
net/ipv4/tcp_timer.c
net/ipv4/tcp_ulp.c
net/ipv4/udp.c
net/ipv4/udp_offload.c
net/ipv6/addrconf.c
net/ipv6/esp6.c
net/ipv6/esp6_offload.c
net/ipv6/ip6_fib.c
net/ipv6/ip6_output.c
net/ipv6/ipv6_sockglue.c
net/ipv6/output_core.c
net/ipv6/route.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/ipv6/udp_offload.c
net/irda/af_irda.c
net/kcm/kcmsock.c
net/key/af_key.c
net/l2tp/l2tp_core.c
net/l2tp/l2tp_core.h
net/l2tp/l2tp_netlink.c
net/mac80211/agg-rx.c
net/netfilter/nf_nat_core.c
net/netfilter/nft_compat.c
net/netfilter/nft_limit.c
net/openvswitch/actions.c
net/openvswitch/datapath.c
net/openvswitch/datapath.h
net/packet/af_packet.c
net/rds/ib_recv.c
net/rxrpc/call_accept.c
net/sched/act_ipt.c
net/sched/cls_api.c
net/sched/sch_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_fq_codel.c
net/sched/sch_generic.c
net/sched/sch_hfsc.c
net/sched/sch_hhf.c
net/sched/sch_htb.c
net/sched/sch_multiq.c
net/sched/sch_netem.c
net/sched/sch_sfq.c
net/sched/sch_tbf.c
net/sctp/ipv6.c
net/sctp/sctp_diag.c
net/sctp/socket.c
net/sunrpc/svcsock.c
net/tipc/bearer.c
net/tipc/bearer.h
net/tipc/msg.c
net/tipc/netlink_compat.c
net/tipc/node.c
net/tipc/socket.c
net/tipc/subscr.c
net/unix/af_unix.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c
scripts/Kbuild.include
scripts/Makefile.asm-generic
scripts/Makefile.build
scripts/Makefile.dtbinst
scripts/basic/Makefile
scripts/basic/fixdep.c
scripts/dtc/checks.c
scripts/get_maintainer.pl
scripts/parse-maintainers.pl
sound/core/control.c
sound/core/pcm_native.c
sound/core/seq/Kconfig
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_queue.c
sound/core/seq/seq_queue.h
sound/firewire/iso-resources.c
sound/firewire/motu/motu.c
sound/pci/emu10k1/emufx.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c
sound/soc/codecs/rt5670.c
sound/soc/codecs/rt5677.c
sound/soc/generic/simple-card-utils.c
sound/soc/intel/boards/cht_bsw_rt5672.c
sound/usb/mixer.c
sound/usb/mixer.h
sound/usb/mixer_quirks.c
sound/usb/quirks.c
tools/build/feature/test-bpf.c
tools/lib/bpf/bpf.c
tools/lib/bpf/libbpf.c
tools/objtool/arch/x86/decode.c
tools/testing/selftests/bpf/test_pkt_md_access.c
tools/testing/selftests/bpf/test_verifier.c
tools/testing/selftests/futex/Makefile
tools/testing/selftests/kmod/kmod.sh [changed mode: 0644->0755]
tools/testing/selftests/ntb/ntb_test.sh
tools/testing/selftests/sysctl/sysctl.sh [changed mode: 0644->0755]
tools/testing/selftests/timers/freq-step.c
virt/kvm/kvm_main.c

index a59916c29b3312cd4946a1d9a8da2331819e7845..1a85c1bdaf38a9ae7fb8b6555afc30abae661a20 100644 (file)
@@ -27,5 +27,11 @@ You have to add the following kernel parameters in your elilo.conf:
        Macbook Pro 17", iMac 20" :
                video=efifb:i20
 
+Accepted options:
+
+nowc   Don't map the framebuffer write combined. This can be used
+       to workaround side-effects and slowdowns on other CPU cores
+       when large amounts of console data are written.
+
 --
 Edgar Hucek <gimli@dark-green.com>
index b34fd94f70898a7f65c2a0313349588411eb8e81..5eacc147ea870c80bb06c38d43bd5b662c171194 100644 (file)
@@ -459,7 +459,7 @@ pin controller?
 
 This is done by registering "ranges" of pins, which are essentially
 cross-reference tables. These are described in
-Documentation/pinctrl.txt
+Documentation/driver-api/pinctl.rst
 
 While the pin allocation is totally managed by the pinctrl subsystem,
 gpio (under gpiolib) is still maintained by gpio drivers. It may happen
index 3e7b946dea2778441ce0599643535188699e16ca..5e40e1f68873b0f2b594c22a6e69ddb218ce56ec 100644 (file)
@@ -228,7 +228,7 @@ Learning on the device port should be enabled, as well as learning_sync:
        bridge link set dev DEV learning on self
        bridge link set dev DEV learning_sync on self
 
-Learning_sync attribute enables syncing of the learned/forgotton FDB entry to
+Learning_sync attribute enables syncing of the learned/forgotten FDB entry to
 the bridge's FDB.  It's possible, but not optimal, to enable learning on the
 device port and on the bridge port, and disable learning_sync.
 
@@ -245,7 +245,7 @@ the responsibility of the port driver/device to age out these entries.  If the
 port device supports ageing, when the FDB entry expires, it will notify the
 driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL.  If the
 device does not support ageing, the driver can simulate ageing using a
-garbage collection timer to monitor FBD entries.  Expired entries will be
+garbage collection timer to monitor FDB entries.  Expired entries will be
 notified to the bridge using SWITCHDEV_FDB_DEL.  See rocker driver for
 example of driver running ageing timer.
 
index 65ea5915178b4b9842474b7908d06660444aae34..074670b98bac784c27eecc18f672b2f1ad24f489 100644 (file)
@@ -58,20 +58,23 @@ Symbols/Function Pointers
        %ps     versatile_init
        %pB     prev_fn_of_versatile_init+0x88/0x88
 
-For printing symbols and function pointers. The ``S`` and ``s`` specifiers
-result in the symbol name with (``S``) or without (``s``) offsets. Where
-this is used on a kernel without KALLSYMS - the symbol address is
-printed instead.
+The ``F`` and ``f`` specifiers are for printing function pointers,
+for example, f->func, &gettimeofday. They have the same result as
+``S`` and ``s`` specifiers. But they do an extra conversion on
+ia64, ppc64 and parisc64 architectures where the function pointers
+are actually function descriptors.
+
+The ``S`` and ``s`` specifiers can be used for printing symbols
+from direct addresses, for example, __builtin_return_address(0),
+(void *)regs->ip. They result in the symbol name with (``S``) or
+without (``s``) offsets. If KALLSYMS are disabled then the symbol
+address is printed instead.
 
 The ``B`` specifier results in the symbol name with offsets and should be
 used when printing stack backtraces. The specifier takes into
 consideration the effect of compiler optimisations which may occur
 when tail-call``s are used and marked with the noreturn GCC attribute.
 
-On ia64, ppc64 and parisc64 architectures function pointers are
-actually function descriptors which must first be resolved. The ``F`` and
-``f`` specifiers perform this resolution and then provide the same
-functionality as the ``S`` and ``s`` specifiers.
 
 Kernel Pointers
 ===============
index 14db18c970b1b048c0ecc50d75e10efb674715ca..28596e03220b5528891c19316b7cfe2b53fcf331 100644 (file)
@@ -35,9 +35,34 @@ Table : Subdirectories in /proc/sys/net
 bpf_jit_enable
 --------------
 
-This enables Berkeley Packet Filter Just in Time compiler.
-Currently supported on x86_64 architecture, bpf_jit provides a framework
-to speed packet filtering, the one used by tcpdump/libpcap for example.
+This enables the BPF Just in Time (JIT) compiler. BPF is a flexible
+and efficient infrastructure allowing to execute bytecode at various
+hook points. It is used in a number of Linux kernel subsystems such
+as networking (e.g. XDP, tc), tracing (e.g. kprobes, uprobes, tracepoints)
+and security (e.g. seccomp). LLVM has a BPF back end that can compile
+restricted C into a sequence of BPF instructions. After program load
+through bpf(2) and passing a verifier in the kernel, a JIT will then
+translate these BPF proglets into native CPU instructions. There are
+two flavors of JITs, the newer eBPF JIT currently supported on:
+  - x86_64
+  - arm64
+  - ppc64
+  - sparc64
+  - mips64
+  - s390x
+
+And the older cBPF JIT supported on the following archs:
+  - arm
+  - mips
+  - ppc
+  - sparc
+
+eBPF JITs are a superset of cBPF JITs, meaning the kernel will
+migrate cBPF instructions into eBPF instructions and then JIT
+compile them transparently. Older cBPF JITs can only translate
+tcpdump filters, seccomp rules, etc, but not mentioned eBPF
+programs loaded through bpf(2).
+
 Values :
        0 - disable the JIT (default value)
        1 - enable the JIT
@@ -46,9 +71,9 @@ Values :
 bpf_jit_harden
 --------------
 
-This enables hardening for the Berkeley Packet Filter Just in Time compiler.
-Supported are eBPF JIT backends. Enabling hardening trades off performance,
-but can mitigate JIT spraying.
+This enables hardening for the BPF JIT compiler. Supported are eBPF
+JIT backends. Enabling hardening trades off performance, but can
+mitigate JIT spraying.
 Values :
        0 - disable JIT hardening (default value)
        1 - enable JIT hardening for unprivileged users only
@@ -57,11 +82,11 @@ Values :
 bpf_jit_kallsyms
 ----------------
 
-When Berkeley Packet Filter Just in Time compiler is enabled, then compiled
-images are unknown addresses to the kernel, meaning they neither show up in
-traces nor in /proc/kallsyms. This enables export of these addresses, which
-can be used for debugging/tracing. If bpf_jit_harden is enabled, this feature
-is disabled.
+When BPF JIT compiler is enabled, then compiled images are unknown
+addresses to the kernel, meaning they neither show up in traces nor
+in /proc/kallsyms. This enables export of these addresses, which can
+be used for debugging/tracing. If bpf_jit_harden is enabled, this
+feature is disabled.
 Values :
        0 - disable JIT kallsyms export (default value)
        1 - enable JIT kallsyms export for privileged users only
index 44cb004c765d5bc3e9b71844b08fca7f204cae61..1c3feffb1c1cfd2b46685907300a9f026fb67e6a 100644 (file)
@@ -1161,7 +1161,7 @@ M:        Brendan Higgins <brendanhiggins@google.com>
 R:     Benjamin Herrenschmidt <benh@kernel.crashing.org>
 R:     Joel Stanley <joel@jms.id.au>
 L:     linux-i2c@vger.kernel.org
-L:     openbmc@lists.ozlabs.org
+L:     openbmc@lists.ozlabs.org (moderated for non-subscribers)
 S:     Maintained
 F:     drivers/irqchip/irq-aspeed-i2c-ic.c
 F:     drivers/i2c/busses/i2c-aspeed.c
@@ -5834,7 +5834,7 @@ F:        drivers/staging/greybus/spi.c
 F:     drivers/staging/greybus/spilib.c
 F:     drivers/staging/greybus/spilib.h
 
-GREYBUS LOOBACK/TIME PROTOCOLS DRIVERS
+GREYBUS LOOPBACK/TIME PROTOCOLS DRIVERS
 M:     Bryan O'Donoghue <pure.logic@nexus-software.ie>
 S:     Maintained
 F:     drivers/staging/greybus/loopback.c
@@ -7110,7 +7110,6 @@ M:        Marc Zyngier <marc.zyngier@arm.com>
 L:     linux-kernel@vger.kernel.org
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
-T:     git git://git.infradead.org/users/jcooper/linux.git irqchip/core
 F:     Documentation/devicetree/bindings/interrupt-controller/
 F:     drivers/irqchip/
 
@@ -10383,7 +10382,7 @@ L:      linux-gpio@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
 S:     Maintained
 F:     Documentation/devicetree/bindings/pinctrl/
-F:     Documentation/pinctrl.txt
+F:     Documentation/driver-api/pinctl.rst
 F:     drivers/pinctrl/
 F:     include/linux/pinctrl/
 
@@ -14004,6 +14003,7 @@ F:      drivers/block/virtio_blk.c
 F:     include/linux/virtio*.h
 F:     include/uapi/linux/virtio_*.h
 F:     drivers/crypto/virtio/
+F:     mm/balloon_compaction.c
 
 VIRTIO CRYPTO DRIVER
 M:     Gonglei <arei.gonglei@huawei.com>
index 6eba23bcb5ad031d6365d938984dd3140a596018..8db6be7dca731f4cb5a552c45811ce334747dff9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 4
 PATCHLEVEL = 13
 SUBLEVEL = 0
-EXTRAVERSION = -rc4
+EXTRAVERSION = -rc7
 NAME = Fearless Coyote
 
 # *DOCUMENTATION*
@@ -396,7 +396,7 @@ LINUXINCLUDE    := \
 KBUILD_CPPFLAGS := -D__KERNEL__
 
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-                  -fno-strict-aliasing -fno-common \
+                  -fno-strict-aliasing -fno-common -fshort-wchar \
                   -Werror-implicit-function-declaration \
                   -Wno-format-security \
                   -std=gnu89 $(call cc-option,-fno-PIE)
@@ -442,7 +442,7 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
 # ===========================================================================
 # Rules shared between *config targets and build targets
 
-# Basic helpers built in scripts/
+# Basic helpers built in scripts/basic/
 PHONY += scripts_basic
 scripts_basic:
        $(Q)$(MAKE) $(build)=scripts/basic
@@ -505,7 +505,7 @@ ifeq ($(KBUILD_EXTMOD),)
                 endif
         endif
 endif
-# install and module_install need also be processed one by one
+# install and modules_install need also be processed one by one
 ifneq ($(filter install,$(MAKECMDGOALS)),)
         ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
                mixed-targets := 1
@@ -964,7 +964,7 @@ export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-
 export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
-# used by scripts/pacmage/Makefile
+# used by scripts/package/Makefile
 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
 
 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS)
@@ -992,8 +992,8 @@ include/generated/autoksyms.h: FORCE
 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
 
 # Final link of vmlinux with optional arch pass after final link
-    cmd_link-vmlinux =                                                 \
-       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;       \
+cmd_link-vmlinux =                                                 \
+       $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;    \
        $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
 vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE
@@ -1184,6 +1184,7 @@ PHONY += kselftest
 kselftest:
        $(Q)$(MAKE) -C tools/testing/selftests run_tests
 
+PHONY += kselftest-clean
 kselftest-clean:
        $(Q)$(MAKE) -C tools/testing/selftests clean
 
index ff4049155c840c2fc4bc9e8015b5282dadb57469..4d61d2a50c525aab2531e3bf670227cbd5e66bca 100644 (file)
@@ -299,6 +299,7 @@ static inline void __iomem * ioremap_nocache(unsigned long offset,
        return ioremap(offset, size);
 }
 
+#define ioremap_wc ioremap_nocache
 #define ioremap_uc ioremap_nocache
 
 static inline void iounmap(volatile void __iomem *addr)
index 4cb4b6d3452c0b3439c3aa3c0f928f74de09fb3a..0bc66e1d3a7e9c81f1cca84943f60cd91d85a625 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef _ALPHA_TYPES_H
 #define _ALPHA_TYPES_H
 
-#include <asm-generic/int-ll64.h>
+#include <uapi/asm/types.h>
 
 #endif /* _ALPHA_TYPES_H */
index b37153ecf2ac33e19b7df4b061afddf4238f7ebb..db7fc0f511e2ae9cc905a6bae64f9195562c013f 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <uapi/asm/unistd.h>
 
-#define NR_SYSCALLS                    514
+#define NR_SYSCALLS                    523
 
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
index 9fd3cd459777767e7c80c4c761ee88278f62b17d..8d1024d7be0546bc744adf163e87f9dc723539fe 100644 (file)
@@ -9,8 +9,18 @@
  * need to be careful to avoid a name clashes.
  */
 
-#ifndef __KERNEL__
+/*
+ * This is here because we used to use l64 for alpha
+ * and we don't want to impact user mode with our change to ll64
+ * in the kernel.
+ *
+ * However, some user programs are fine with this.  They can
+ * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
+ */
+#if !defined(__SANE_USERSPACE_TYPES__) && !defined(__KERNEL__)
 #include <asm-generic/int-l64.h>
+#else
+#include <asm-generic/int-ll64.h>
 #endif
 
 #endif /* _UAPI_ALPHA_TYPES_H */
index aa33bf5aacb6c1666203e38700939750c90cb5c5..a2945fea6c868096e6094780bd96384205806a74 100644 (file)
 #define __NR_getrandom                 511
 #define __NR_memfd_create              512
 #define __NR_execveat                  513
+#define __NR_seccomp                   514
+#define __NR_bpf                       515
+#define __NR_userfaultfd               516
+#define __NR_membarrier                        517
+#define __NR_mlock2                    518
+#define __NR_copy_file_range           519
+#define __NR_preadv2                   520
+#define __NR_pwritev2                  521
+#define __NR_statx                     522
+
+/* Alpha doesn't have protection keys. */
+#define __IGNORE_pkey_mprotect
+#define __IGNORE_pkey_alloc
+#define __IGNORE_pkey_free
 
 #endif /* _UAPI_ALPHA_UNISTD_H */
index d5f0580746a5d632452816b00427c212230b0810..03ff832b1cb4483e7d717def1c4f10ebe6c63619 100644 (file)
@@ -351,7 +351,7 @@ marvel_init_io7(struct io7 *io7)
        }
 }
 
-void
+void __init
 marvel_io7_present(gct6_node *node)
 {
        int pe;
@@ -369,6 +369,7 @@ marvel_io7_present(gct6_node *node)
 static void __init
 marvel_find_console_vga_hose(void)
 {
+#ifdef CONFIG_VGA_HOSE
        u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset);
 
        if (pu64[7] == 3) {     /* TERM_TYPE == graphics */
@@ -402,9 +403,10 @@ marvel_find_console_vga_hose(void)
                        pci_vga_hose = hose;
                }
        }
+#endif
 }
 
-gct6_search_struct gct_wanted_node_list[] = {
+gct6_search_struct gct_wanted_node_list[] __initdata = {
        { GCT_TYPE_HOSE, GCT_SUBTYPE_IO_PORT_MODULE, marvel_io7_present },
        { 0, 0, NULL }
 };
index 219bf271c0ba2e5f2d668af707df57fbbd00ccfd..b532d925443d50b02f3a54481de122c36d948f79 100644 (file)
@@ -461,6 +461,7 @@ titan_ioremap(unsigned long addr, unsigned long size)
        unsigned long *ptes;
        unsigned long pfn;
 
+#ifdef CONFIG_VGA_HOSE
        /*
         * Adjust the address and hose, if necessary.
         */ 
@@ -468,6 +469,7 @@ titan_ioremap(unsigned long addr, unsigned long size)
                h = pci_vga_hose->index;
                addr += pci_vga_hose->mem_space->start;
        }
+#endif
 
        /*
         * Find the hose.
index 936bc8f89a679f2f8aeb2f7e3cb41f11190a2d77..47632fa8c24e02418cdbac8d5c139f101aa51945 100644 (file)
@@ -181,6 +181,9 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
                switch (r_type) {
                case R_ALPHA_NONE:
                        break;
+               case R_ALPHA_REFLONG:
+                       *(u32 *)location = value;
+                       break;
                case R_ALPHA_REFQUAD:
                        /* BUG() can produce misaligned relocations. */
                        ((u32 *)location)[0] = value;
index 9fc560459ebd64ad3735f9b4dcd5ce6596b7bfee..f6726a74642703381c2151e9d927e267fcba0975 100644 (file)
@@ -115,7 +115,7 @@ wait_boot_cpu_to_stop(int cpuid)
 /*
  * Where secondaries begin a life of C.
  */
-void
+void __init
 smp_callin(void)
 {
        int cpuid = hard_smp_processor_id();
index 9b62e3fd4f038a925657beb15de3de89f8548473..5b4514abb23450998515530ebc824ae1857f27b9 100644 (file)
@@ -532,6 +532,15 @@ sys_call_table:
        .quad sys_getrandom
        .quad sys_memfd_create
        .quad sys_execveat
+       .quad sys_seccomp
+       .quad sys_bpf                           /* 515 */
+       .quad sys_userfaultfd
+       .quad sys_membarrier
+       .quad sys_mlock2
+       .quad sys_copy_file_range
+       .quad sys_preadv2                       /* 520 */
+       .quad sys_pwritev2
+       .quad sys_statx
 
        .size sys_call_table, . - sys_call_table
        .type sys_call_table, @object
index 7083434dd2419b7b3ef6ef8e74c204522d4a3257..a8081596036457af2149b37d356c64f2f1e7acc6 100644 (file)
@@ -20,12 +20,8 @@ lib-y =      __divqu.o __remqu.o __divlu.o __remlu.o \
        checksum.o \
        csum_partial_copy.o \
        $(ev67-y)strlen.o \
-       $(ev67-y)strcat.o \
-       strcpy.o \
-       $(ev67-y)strncat.o \
-       strncpy.o \
-       $(ev6-y)stxcpy.o \
-       $(ev6-y)stxncpy.o \
+       stycpy.o \
+       styncpy.o \
        $(ev67-y)strchr.o \
        $(ev67-y)strrchr.o \
        $(ev6-y)memchr.o \
@@ -49,3 +45,17 @@ AFLAGS___remlu.o =       -DREM -DINTSIZE
 $(addprefix $(obj)/,__divqu.o __remqu.o __divlu.o __remlu.o): \
                                                $(src)/$(ev6-y)divide.S FORCE
        $(call if_changed_rule,as_o_S)
+
+# There are direct branches between {str*cpy,str*cat} and stx*cpy.
+# Ensure the branches are within range by merging these objects.
+
+LDFLAGS_stycpy.o := -r
+LDFLAGS_styncpy.o := -r
+
+$(obj)/stycpy.o: $(obj)/strcpy.o $(obj)/$(ev67-y)strcat.o \
+                $(obj)/$(ev6-y)stxcpy.o FORCE
+       $(call if_changed,ld)
+
+$(obj)/styncpy.o: $(obj)/strncpy.o $(obj)/$(ev67-y)strncat.o \
+                $(obj)/$(ev6-y)stxncpy.o FORCE
+       $(call if_changed,ld)
index 159f1b7e6e495f098a28dc818c7c383ede2dda76..c277a1a4383e5fbb4bbb76b8c2c7802b8bbd6a26 100644 (file)
@@ -34,7 +34,7 @@
        .ent __copy_user
 __copy_user:
        .prologue 0
-       and $18,$18,$0
+       mov $18,$0
        and $16,7,$3
        beq $0,$35
        beq $3,$36
index 35e6710d070054b1c9987d0f5c10f1c29510b1a2..954ca03ebebef371a4e1dd873efce4493de53309 100644 (file)
                                # Pipeline info: Slotting & Comments
 __copy_user:
        .prologue 0
-       andq $18, $18, $0
-       subq $18, 32, $1        # .. E  .. ..   : Is this going to be a small copy?
-       beq $0, $zerolength     # U  .. .. ..   : U L U L
+       mov $18, $0             # .. .. .. E
+       subq $18, 32, $1        # .. .. E. ..   : Is this going to be a small copy?
+       nop                     # .. E  .. ..
+       beq $18, $zerolength    # U  .. .. ..   : U L U L
 
        and $16,7,$3            # .. .. .. E    : is leading dest misalignment
        ble $1, $onebyteloop    # .. .. U  ..   : 1st branch : small amount of data
index a5459698f0ee3762917c82c8cbf133e34643f021..7db85ab00c522315c3108930365fc57c59fd311c 100644 (file)
@@ -96,7 +96,6 @@ menu "ARC Architecture Configuration"
 
 menu "ARC Platform/SoC/Board"
 
-source "arch/arc/plat-sim/Kconfig"
 source "arch/arc/plat-tb10x/Kconfig"
 source "arch/arc/plat-axs10x/Kconfig"
 #New platform adds here
index 44ef35d339564623b2beb4a380a81da6a7790087..3a61cfcc38c0dd78f58247512a4d31231a2daa4b 100644 (file)
@@ -107,7 +107,7 @@ core-y              += arch/arc/
 # w/o this dtb won't embed into kernel binary
 core-y         += arch/arc/boot/dts/
 
-core-$(CONFIG_ARC_PLAT_SIM)    += arch/arc/plat-sim/
+core-y                         += arch/arc/plat-sim/
 core-$(CONFIG_ARC_PLAT_TB10X)  += arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
 core-$(CONFIG_ARC_PLAT_EZNPS)  += arch/arc/plat-eznps/
index 53ce226f77a59857615f8fc53fca3ba1c4f09749..a380ffa1a4589b11de92a5a0c21bc831e6dc751b 100644 (file)
 
 / {
        compatible = "snps,arc";
-       #address-cells = <1>;
-       #size-cells = <1>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_card {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
 
-               ranges = <0x00000000 0xf0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xf0000000 0x10000000>;
 
                core_clk: core_clk {
                        #clock-cells = <0>;
        mb_intc: dw-apb-ictl@0xe0012000 {
                #interrupt-cells = <1>;
                compatible = "snps,dw-apb-ictl";
-               reg = < 0xe0012000 0x200 >;
+               reg = < 0x0 0xe0012000 0x0 0x200 >;
                interrupt-controller;
                interrupt-parent = <&core_intc>;
                interrupts = < 7 >;
        };
 
        memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges = <0x00000000 0x80000000 0x20000000>;
                device_type = "memory";
-               reg = <0x80000000 0x1b000000>;  /* (512 - 32) MiB */
+               /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */
+               reg = <0x0 0x80000000 0x0 0x1b000000>;  /* (512 - 32) MiB */
        };
 
        reserved-memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                ranges;
                /*
                 * We just move frame buffer area to the very end of
                 */
                frame_buffer: frame_buffer@9e000000 {
                        compatible = "shared-dma-pool";
-                       reg = <0x9e000000 0x2000000>;
+                       reg = <0x0 0x9e000000 0x0 0x2000000>;
                        no-map;
                };
        };
index 14df46f141bf3450b8df0660bc0f248beef4669b..cc9239ef8d08c9f6efbe6dbee0323f283c4f5e37 100644 (file)
 
 / {
        compatible = "snps,arc";
-       #address-cells = <1>;
-       #size-cells = <1>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_card {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
 
-               ranges = <0x00000000 0xf0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xf0000000 0x10000000>;
 
                core_clk: core_clk {
                        #clock-cells = <0>;
        mb_intc: dw-apb-ictl@0xe0012000 {
                #interrupt-cells = <1>;
                compatible = "snps,dw-apb-ictl";
-               reg = < 0xe0012000 0x200 >;
+               reg = < 0x0 0xe0012000 0x0 0x200 >;
                interrupt-controller;
                interrupt-parent = <&core_intc>;
                interrupts = < 24 >;
        };
 
        memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges = <0x00000000 0x80000000 0x40000000>;
                device_type = "memory";
-               reg = <0x80000000 0x20000000>;  /* 512MiB */
+               /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */
+               reg = <0x0 0x80000000 0x0 0x20000000    /* 512 MiB low mem */
+                      0x1 0xc0000000 0x0 0x40000000>;  /* 1 GiB highmem */
        };
 
        reserved-memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                ranges;
                /*
                 * Move frame buffer out of IOC aperture (0x8z-0xAz).
                 */
                frame_buffer: frame_buffer@be000000 {
                        compatible = "shared-dma-pool";
-                       reg = <0xbe000000 0x2000000>;
+                       reg = <0x0 0xbe000000 0x0 0x2000000>;
                        no-map;
                };
        };
index 695f9fa1996bcbb2689e1bf98dc8fa661cc1c216..4ebb2170abecc7e00cd581a7ca6dcef6e94231e0 100644 (file)
 
 / {
        compatible = "snps,arc";
-       #address-cells = <1>;
-       #size-cells = <1>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_card {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
 
-               ranges = <0x00000000 0xf0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xf0000000 0x10000000>;
 
                core_clk: core_clk {
                        #clock-cells = <0>;
        mb_intc: dw-apb-ictl@0xe0012000 {
                #interrupt-cells = <1>;
                compatible = "snps,dw-apb-ictl";
-               reg = < 0xe0012000 0x200 >;
+               reg = < 0x0 0xe0012000 0x0 0x200 >;
                interrupt-controller;
                interrupt-parent = <&idu_intc>;
                interrupts = <0>;
        };
 
        memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges = <0x00000000 0x80000000 0x40000000>;
                device_type = "memory";
-               reg = <0x80000000 0x20000000>;  /* 512MiB */
+               /* CONFIG_KERNEL_RAM_BASE_ADDRESS needs to match low mem start */
+               reg = <0x0 0x80000000 0x0 0x20000000    /* 512 MiB low mem */
+                      0x1 0xc0000000 0x0 0x40000000>;  /* 1 GiB highmem */
        };
 
        reserved-memory {
-               #address-cells = <1>;
-               #size-cells = <1>;
+               #address-cells = <2>;
+               #size-cells = <2>;
                ranges;
                /*
                 * Move frame buffer out of IOC aperture (0x8z-0xAz).
                 */
                frame_buffer: frame_buffer@be000000 {
                        compatible = "shared-dma-pool";
-                       reg = <0xbe000000 0x2000000>;
+                       reg = <0x0 0xbe000000 0x0 0x2000000>;
                        no-map;
                };
        };
index 41cfb29b62c142ca48193359e8fedf20151cc9bf..0ff7e07edcd4d28bcf6266cedd590034b8aebd13 100644 (file)
@@ -13,7 +13,7 @@
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
-               ranges = <0x00000000 0xe0000000 0x10000000>;
+               ranges = <0x00000000 0x0 0xe0000000 0x10000000>;
                interrupt-parent = <&mb_intc>;
 
                i2sclk: i2sclk@100a0 {
index 57b3e599322f83d5babd0014c7d9ccf3a03578eb..db04ea4dd2d97237b843fd4b90706f2e0c8ef6d9 100644 (file)
@@ -21,7 +21,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs"
 CONFIG_PREEMPT=y
index f85985adebb245981d8a4130e8c0b91a45abe7dd..821a2e562f3f12422844556630d7136ad63097a8 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs_idu"
index ede625c76216616b097365a3274e09ccea97d3d6..7c9c706ae7f66eb29d4cf48ca0b95d5dd44630f5 100644 (file)
@@ -39,7 +39,6 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
index b0066a749d4c49d8a23e3bd33b4a52789789c913..6dff83a238b8591ba08f889e7d7013734ff587db 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_700"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
index ebe9ebb92933302af79f98dae000e8567b86ec6b..31ee51b987e7c5b97c2f044794f9d1c5b4eea73e 100644 (file)
@@ -26,7 +26,6 @@ CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs"
 CONFIG_PREEMPT=y
index 4bde43278be6757c5c739bfd58a9f030a80c7568..8d3b1f67cae421c423e55c2622b5a78ea3d67794 100644 (file)
@@ -24,7 +24,6 @@ CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs_idu"
index f6fb3d26557eb7c63b2f77263acfed80f0b45387..6168ce2ac2efdd869705a8a75e78f7f9b9c55af4 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci"
 # CONFIG_COMPACTION is not set
 CONFIG_NET=y
index b9f0fe00044b6c44d62a81a91064583cd9badee3..a70bdeb2b3fd03bdefd10388e69cd8e5b120ac0f 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci_hs"
 # CONFIG_COMPACTION is not set
index 155add7761ed63080bd81e830c819483fb55ee61..ef96406c446e823d4706e5c84b6ac0626d4b5812 100644 (file)
@@ -18,7 +18,6 @@ CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARC_PLAT_SIM=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 # CONFIG_ARC_TIMERS_64BIT is not set
index 4c5118384eb5f1c393208cde601fddc1be773494..f3018254939508e373662a2ae98f9d08be9425a2 100644 (file)
@@ -38,7 +38,6 @@ CONFIG_IP_MULTICAST=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
index 19ebddffb279db05ca8e53e2c4753665376cc9ad..02fd1cece6ef339209c993a6b56b87312e39d648 100644 (file)
@@ -96,7 +96,9 @@ extern unsigned long perip_base, perip_end;
 #define ARC_REG_SLC_FLUSH      0x904
 #define ARC_REG_SLC_INVALIDATE 0x905
 #define ARC_REG_SLC_RGN_START  0x914
+#define ARC_REG_SLC_RGN_START1 0x915
 #define ARC_REG_SLC_RGN_END    0x916
+#define ARC_REG_SLC_RGN_END1   0x917
 
 /* Bit val in SLC_CONTROL */
 #define SLC_CTRL_DIS           0x001
index db7319e9b506e9ece826fde788aba60adada59cb..efb79fafff1d12214dc41923a75b237a969214f5 100644 (file)
@@ -94,6 +94,8 @@ static inline int is_pae40_enabled(void)
        return IS_ENABLED(CONFIG_ARC_HAS_PAE40);
 }
 
+extern int pae40_exist_but_not_enab(void);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
index f928795fd07a813e9f6f3e6d86f325b45561b3dc..067ea362fb3efc3bc3a9217aaf197763eafb275e 100644 (file)
@@ -75,10 +75,20 @@ void arc_init_IRQ(void)
         * Set a default priority for all available interrupts to prevent
         * switching of register banks if Fast IRQ and multiple register banks
         * are supported by CPU.
+        * Also disable private-per-core IRQ lines so faulty external HW won't
+        * trigger interrupt that kernel is not ready to handle.
         */
        for (i = NR_EXCEPTIONS; i < irq_bcr.irqs + NR_EXCEPTIONS; i++) {
                write_aux_reg(AUX_IRQ_SELECT, i);
                write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
+
+               /*
+                * Only mask cpu private IRQs here.
+                * "common" interrupts are masked at IDU, otherwise it would
+                * need to be unmasked at each cpu, with IPIs
+                */
+               if (i < FIRST_EXT_IRQ)
+                       write_aux_reg(AUX_IRQ_ENABLE, 0);
        }
 
        /* setup status32, don't enable intr yet as kernel doesn't want */
index 7e608c6b0a018697fb22c52c7fb4ac46a45fe2f0..47b421fa0147be9604b1c808d378a0108f735b34 100644 (file)
@@ -27,7 +27,7 @@
  */
 void arc_init_IRQ(void)
 {
-       int level_mask = 0;
+       unsigned int level_mask = 0, i;
 
        /* Is timer high priority Interrupt (Level2 in ARCompact jargon) */
        level_mask |= IS_ENABLED(CONFIG_ARC_COMPACT_IRQ_LEVELS) << TIMER0_IRQ;
@@ -40,6 +40,18 @@ void arc_init_IRQ(void)
 
        if (level_mask)
                pr_info("Level-2 interrupts bitset %x\n", level_mask);
+
+       /*
+        * Disable all IRQ lines so faulty external hardware won't
+        * trigger interrupt that kernel is not ready to handle.
+        */
+       for (i = TIMER0_IRQ; i < NR_CPU_IRQS; i++) {
+               unsigned int ienb;
+
+               ienb = read_aux_reg(AUX_IENABLE);
+               ienb &= ~(1 << i);
+               write_aux_reg(AUX_IENABLE, ienb);
+       }
 }
 
 /*
index a867575a758b9845c09a84fb4515f17f08f1272b..7db283b46ebde8daccf779525e82526e47ad2722 100644 (file)
@@ -665,6 +665,7 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op)
        static DEFINE_SPINLOCK(lock);
        unsigned long flags;
        unsigned int ctrl;
+       phys_addr_t end;
 
        spin_lock_irqsave(&lock, flags);
 
@@ -694,8 +695,19 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op)
         * END needs to be setup before START (latter triggers the operation)
         * END can't be same as START, so add (l2_line_sz - 1) to sz
         */
-       write_aux_reg(ARC_REG_SLC_RGN_END, (paddr + sz + l2_line_sz - 1));
-       write_aux_reg(ARC_REG_SLC_RGN_START, paddr);
+       end = paddr + sz + l2_line_sz - 1;
+       if (is_pae40_enabled())
+               write_aux_reg(ARC_REG_SLC_RGN_END1, upper_32_bits(end));
+
+       write_aux_reg(ARC_REG_SLC_RGN_END, lower_32_bits(end));
+
+       if (is_pae40_enabled())
+               write_aux_reg(ARC_REG_SLC_RGN_START1, upper_32_bits(paddr));
+
+       write_aux_reg(ARC_REG_SLC_RGN_START, lower_32_bits(paddr));
+
+       /* Make sure "busy" bit reports correct stataus, see STAR 9001165532 */
+       read_aux_reg(ARC_REG_SLC_CTRL);
 
        while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY);
 
@@ -1111,6 +1123,13 @@ noinline void __init arc_ioc_setup(void)
        __dc_enable();
 }
 
+/*
+ * Cache related boot time checks/setups only needed on master CPU:
+ *  - Geometry checks (kernel build and hardware agree: e.g. L1_CACHE_BYTES)
+ *    Assume SMP only, so all cores will have same cache config. A check on
+ *    one core suffices for all
+ *  - IOC setup / dma callbacks only need to be done once
+ */
 void __init arc_cache_init_master(void)
 {
        unsigned int __maybe_unused cpu = smp_processor_id();
@@ -1190,12 +1209,27 @@ void __ref arc_cache_init(void)
 
        printk(arc_cache_mumbojumbo(0, str, sizeof(str)));
 
-       /*
-        * Only master CPU needs to execute rest of function:
-        *  - Assume SMP so all cores will have same cache config so
-        *    any geomtry checks will be same for all
-        *  - IOC setup / dma callbacks only need to be setup once
-        */
        if (!cpu)
                arc_cache_init_master();
+
+       /*
+        * In PAE regime, TLB and cache maintenance ops take wider addresses
+        * And even if PAE is not enabled in kernel, the upper 32-bits still need
+        * to be zeroed to keep the ops sane.
+        * As an optimization for more common !PAE enabled case, zero them out
+        * once at init, rather than checking/setting to 0 for every runtime op
+        */
+       if (is_isa_arcv2() && pae40_exist_but_not_enab()) {
+
+               if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE))
+                       write_aux_reg(ARC_REG_IC_PTAG_HI, 0);
+
+               if (IS_ENABLED(CONFIG_ARC_HAS_DCACHE))
+                       write_aux_reg(ARC_REG_DC_PTAG_HI, 0);
+
+               if (l2_line_sz) {
+                       write_aux_reg(ARC_REG_SLC_RGN_END1, 0);
+                       write_aux_reg(ARC_REG_SLC_RGN_START1, 0);
+               }
+       }
 }
index 71d3efff99d35c56c6f30bea8a6ab1cf1702d753..e9d93604ad0ff7b76a5458235b3ab4d0ef18aefb 100644 (file)
@@ -153,6 +153,19 @@ static void _dma_cache_sync(phys_addr_t paddr, size_t size,
        }
 }
 
+/*
+ * arc_dma_map_page - map a portion of a page for streaming DMA
+ *
+ * Ensure that any data held in the cache is appropriately discarded
+ * or written back.
+ *
+ * The device owns this memory once this call has completed.  The CPU
+ * can regain ownership by calling dma_unmap_page().
+ *
+ * Note: while it takes struct page as arg, caller can "abuse" it to pass
+ * a region larger than PAGE_SIZE, provided it is physically contiguous
+ * and this still works correctly
+ */
 static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
                unsigned long offset, size_t size, enum dma_data_direction dir,
                unsigned long attrs)
@@ -165,6 +178,24 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
        return plat_phys_to_dma(dev, paddr);
 }
 
+/*
+ * arc_dma_unmap_page - unmap a buffer previously mapped through dma_map_page()
+ *
+ * After this call, reads by the CPU to the buffer are guaranteed to see
+ * whatever the device wrote there.
+ *
+ * Note: historically this routine was not implemented for ARC
+ */
+static void arc_dma_unmap_page(struct device *dev, dma_addr_t handle,
+                              size_t size, enum dma_data_direction dir,
+                              unsigned long attrs)
+{
+       phys_addr_t paddr = plat_dma_to_phys(dev, handle);
+
+       if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+               _dma_cache_sync(paddr, size, dir);
+}
+
 static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
           int nents, enum dma_data_direction dir, unsigned long attrs)
 {
@@ -178,6 +209,18 @@ static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,
        return nents;
 }
 
+static void arc_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+                            int nents, enum dma_data_direction dir,
+                            unsigned long attrs)
+{
+       struct scatterlist *s;
+       int i;
+
+       for_each_sg(sg, s, nents, i)
+               arc_dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir,
+                                  attrs);
+}
+
 static void arc_dma_sync_single_for_cpu(struct device *dev,
                dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
 {
@@ -223,7 +266,9 @@ const struct dma_map_ops arc_dma_ops = {
        .free                   = arc_dma_free,
        .mmap                   = arc_dma_mmap,
        .map_page               = arc_dma_map_page,
+       .unmap_page             = arc_dma_unmap_page,
        .map_sg                 = arc_dma_map_sg,
+       .unmap_sg               = arc_dma_unmap_sg,
        .sync_single_for_device = arc_dma_sync_single_for_device,
        .sync_single_for_cpu    = arc_dma_sync_single_for_cpu,
        .sync_sg_for_cpu        = arc_dma_sync_sg_for_cpu,
index d0126fdfe2d8546d62883cbef419e4b76589cf18..b181f3ee38aab54565d8de8c1e5136375c6358cc 100644 (file)
 /* A copy of the ASID from the PID reg is kept in asid_cache */
 DEFINE_PER_CPU(unsigned int, asid_cache) = MM_CTXT_FIRST_CYCLE;
 
+static int __read_mostly pae_exists;
+
 /*
  * Utility Routine to erase a J-TLB entry
  * Caller needs to setup Index Reg (manually or via getIndex)
@@ -784,7 +786,7 @@ void read_decode_mmu_bcr(void)
                mmu->u_dtlb = mmu4->u_dtlb * 4;
                mmu->u_itlb = mmu4->u_itlb * 4;
                mmu->sasid = mmu4->sasid;
-               mmu->pae = mmu4->pae;
+               pae_exists = mmu->pae = mmu4->pae;
        }
 }
 
@@ -809,6 +811,11 @@ char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len)
        return buf;
 }
 
+int pae40_exist_but_not_enab(void)
+{
+       return pae_exists && !is_pae40_enabled();
+}
+
 void arc_mmu_init(void)
 {
        char str[256];
@@ -859,6 +866,9 @@ void arc_mmu_init(void)
        /* swapper_pg_dir is the pgd for the kernel, used by vmalloc */
        write_aux_reg(ARC_REG_SCRATCH_DATA0, swapper_pg_dir);
 #endif
+
+       if (pae40_exist_but_not_enab())
+               write_aux_reg(ARC_REG_TLBPD1HI, 0);
 }
 
 /*
diff --git a/arch/arc/plat-sim/Kconfig b/arch/arc/plat-sim/Kconfig
deleted file mode 100644 (file)
index ac6af96..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Copyright (C) 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-
-menuconfig ARC_PLAT_SIM
-       bool "ARC nSIM based simulation virtual platforms"
-       help
-         Support for nSIM based ARC simulation platforms
-         This includes the standalone nSIM (uart only) vs. System C OSCI VP
index aea87389e44bd517b196ec87de0edb4c0216b4b1..5cda56b1a2ead7bc54ca1ac63296fcd1f54fc43f 100644 (file)
  */
 
 static const char *simulation_compat[] __initconst = {
+#ifdef CONFIG_ISA_ARCOMPACT
        "snps,nsim",
-       "snps,nsim_hs",
        "snps,nsimosci",
+#else
+       "snps,nsim_hs",
        "snps,nsimosci_hs",
        "snps,zebu_hs",
+#endif
        NULL,
 };
 
index 127e2dd2e21ce12c7daa21e682ce72d36f6b1afd..4a879f6ff13bea92d189eec9370be73cd616705c 100644 (file)
@@ -225,12 +225,6 @@ int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
 
-/* We do not have shadow page tables, hence the empty hooks */
-static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
-                                                        unsigned long address)
-{
-}
-
 struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
 struct kvm_vcpu __percpu **kvm_get_running_vcpus(void);
 void kvm_arm_halt_guest(struct kvm *kvm);
index 3f2eb76243e3c5f9d387959acae740ce871e5afa..d5562f9ce60079139d360e5d6afac59469051454 100644 (file)
@@ -148,7 +148,8 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
+arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+                       unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
        tlb->fullmm = !(start | (end+1));
@@ -166,8 +167,14 @@ tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start
 }
 
 static inline void
-tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
+arch_tlb_finish_mmu(struct mmu_gather *tlb,
+                       unsigned long start, unsigned long end, bool force)
 {
+       if (force) {
+               tlb->range_start = start;
+               tlb->range_end = end;
+       }
+
        tlb_flush_mmu(tlb);
 
        /* keep the page table cache within bounds */
index 74d08e44a651b9e58de7d8a6075f6101083f5262..a652ce0a5cb2c33178ac2e447fad1159efb0c6a9 100644 (file)
@@ -65,13 +65,13 @@ DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
        u64 _val;                                                       \
        if (needs_unstable_timer_counter_workaround()) {                \
                const struct arch_timer_erratum_workaround *wa;         \
-               preempt_disable();                                      \
+               preempt_disable_notrace();                              \
                wa = __this_cpu_read(timer_unstable_counter_workaround); \
                if (wa && wa->read_##reg)                               \
                        _val = wa->read_##reg();                        \
                else                                                    \
                        _val = read_sysreg(reg);                        \
-               preempt_enable();                                       \
+               preempt_enable_notrace();                               \
        } else {                                                        \
                _val = read_sysreg(reg);                                \
        }                                                               \
index acae781f7359ece14f713e74e168deb6e47dd68b..3288c2b3673149b728ea52ee87bc65ba723c9811 100644 (file)
 
 /*
  * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
+ * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
-#define ELF_ET_DYN_BASE                0x100000000UL
+#define ELF_ET_DYN_BASE                (2 * TASK_SIZE_64 / 3)
 
 #ifndef __ASSEMBLY__
 
index d68630007b14f542865df7e49bc0efacefe9a39d..e923b58606e2bf8e33a76bd4a8a9a4c1336199c6 100644 (file)
@@ -326,12 +326,6 @@ void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
 
-/* We do not have shadow page tables, hence the empty hooks */
-static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
-                                                        unsigned long address)
-{
-}
-
 struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
 struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void);
 void kvm_arm_halt_guest(struct kvm *kvm);
index 06da8ea16bbe5e150bb7330ab0049c7438b25f8d..c7b4995868e14d78216c4b06ce87476dfe8a4789 100644 (file)
@@ -161,9 +161,11 @@ void fpsimd_flush_thread(void)
 {
        if (!system_supports_fpsimd())
                return;
+       preempt_disable();
        memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
        fpsimd_flush_task_state(current);
        set_thread_flag(TIF_FOREIGN_FPSTATE);
+       preempt_enable();
 }
 
 /*
index 973df7de7bf8d3e4fcde6dc2ba1590fa051964a2..adb0910b88f5f26c1562a7fef6f00f29ee9ec391 100644 (file)
@@ -354,7 +354,6 @@ __primary_switched:
        tst     x23, ~(MIN_KIMG_ALIGN - 1)      // already running randomized?
        b.ne    0f
        mov     x0, x21                         // pass FDT address in x0
-       mov     x1, x23                         // pass modulo offset in x1
        bl      kaslr_early_init                // parse FDT for KASLR options
        cbz     x0, 0f                          // KASLR disabled? just proceed
        orr     x23, x23, x0                    // record KASLR offset
index a9710efb8c017a735f9aa6518463d11b8d6264c9..47080c49cc7e77a3df120f061f7b10f90a8c2ec5 100644 (file)
@@ -75,7 +75,7 @@ extern void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, int *size,
  * containing function pointers) to be reinitialized, and zero-initialized
  * .bss variables will be reset to 0.
  */
-u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset)
+u64 __init kaslr_early_init(u64 dt_phys)
 {
        void *fdt;
        u64 seed, offset, mask, module_range;
@@ -131,15 +131,17 @@ u64 __init kaslr_early_init(u64 dt_phys, u64 modulo_offset)
        /*
         * The kernel Image should not extend across a 1GB/32MB/512MB alignment
         * boundary (for 4KB/16KB/64KB granule kernels, respectively). If this
-        * happens, increase the KASLR offset by the size of the kernel image
-        * rounded up by SWAPPER_BLOCK_SIZE.
+        * happens, round down the KASLR offset by (1 << SWAPPER_TABLE_SHIFT).
+        *
+        * NOTE: The references to _text and _end below will already take the
+        *       modulo offset (the physical displacement modulo 2 MB) into
+        *       account, given that the physical placement is controlled by
+        *       the loader, and will not change as a result of the virtual
+        *       mapping we choose.
         */
-       if ((((u64)_text + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT) !=
-           (((u64)_end + offset + modulo_offset) >> SWAPPER_TABLE_SHIFT)) {
-               u64 kimg_sz = _end - _text;
-               offset = (offset + round_up(kimg_sz, SWAPPER_BLOCK_SIZE))
-                               & mask;
-       }
+       if ((((u64)_text + offset) >> SWAPPER_TABLE_SHIFT) !=
+           (((u64)_end + offset) >> SWAPPER_TABLE_SHIFT))
+               offset = round_down(offset, 1 << SWAPPER_TABLE_SHIFT);
 
        if (IS_ENABLED(CONFIG_KASAN))
                /*
index 2509e4fe699225675f74876032e22b24b338a3b1..1f22a41565a38ac08083b29fcad216ca4ea1a2c9 100644 (file)
@@ -435,8 +435,11 @@ retry:
                 * the mmap_sem because it would already be released
                 * in __lock_page_or_retry in mm/filemap.c.
                 */
-               if (fatal_signal_pending(current))
+               if (fatal_signal_pending(current)) {
+                       if (!user_mode(regs))
+                               goto no_context;
                        return 0;
+               }
 
                /*
                 * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of
index 4663487c67a176472469348c957137ed12c68412..d764ea4cce7f51c739cc65408df3d469b87d66a1 100644 (file)
@@ -1,5 +1,4 @@
 CONFIG_SOC_TMS320C6455=y
-CONFIG_EXPERIMENTAL=y
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_SYSVIPC=y
 CONFIG_SPARSE_IRQ=y
@@ -25,7 +24,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=2
 CONFIG_BLK_DEV_RAM_SIZE=17000
-CONFIG_MISC_DEVICES=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
index bba40e195ec43d1e70d9c2ccc6a4876f4a96abfd..05d0b4a25ab1fcba6500106cc68a7e546aaeeb78 100644 (file)
@@ -1,5 +1,4 @@
 CONFIG_SOC_TMS320C6457=y
-CONFIG_EXPERIMENTAL=y
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_SYSVIPC=y
 CONFIG_SPARSE_IRQ=y
@@ -26,7 +25,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=2
 CONFIG_BLK_DEV_RAM_SIZE=17000
-CONFIG_MISC_DEVICES=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
index 8c46155f6d311befd6b2b6d90369149290c5fd4c..8d81fcf86b0e0e86ca9d8bca1a260e9217706b68 100644 (file)
@@ -1,5 +1,4 @@
 CONFIG_SOC_TMS320C6472=y
-CONFIG_EXPERIMENTAL=y
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_SYSVIPC=y
 CONFIG_SPARSE_IRQ=y
@@ -27,7 +26,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=2
 CONFIG_BLK_DEV_RAM_SIZE=17000
-CONFIG_MISC_DEVICES=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
index 15533f63231315d7282a0442d9ebd48ef35f0dd3..8156a98f3958be3af5d8a407f6dbae8d6f26bfd0 100644 (file)
@@ -1,5 +1,4 @@
 CONFIG_SOC_TMS320C6474=y
-CONFIG_EXPERIMENTAL=y
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_SYSVIPC=y
 CONFIG_SPARSE_IRQ=y
@@ -27,7 +26,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=2
 CONFIG_BLK_DEV_RAM_SIZE=17000
-CONFIG_MISC_DEVICES=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
index 5f126d4905b1973f502010959592b24a94d71aa5..c4f433c25b69d94618779049f9f38fa5ac872437 100644 (file)
@@ -1,5 +1,4 @@
 CONFIG_SOC_TMS320C6678=y
-CONFIG_EXPERIMENTAL=y
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_SYSVIPC=y
 CONFIG_SPARSE_IRQ=y
@@ -27,7 +26,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=2
 CONFIG_BLK_DEV_RAM_SIZE=17000
-CONFIG_MISC_DEVICES=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
index 43afc03e41251d45c2ccd0f0a00656ad5e368fe9..9519fa5f97d0c224b83d65abdacd7495a613de14 100644 (file)
@@ -208,14 +208,14 @@ static struct megamod_pic * __init init_megamod_pic(struct device_node *np)
 
        pic = kzalloc(sizeof(struct megamod_pic), GFP_KERNEL);
        if (!pic) {
-               pr_err("%s: Could not alloc PIC structure.\n", np->full_name);
+               pr_err("%pOF: Could not alloc PIC structure.\n", np);
                return NULL;
        }
 
        pic->irqhost = irq_domain_add_linear(np, NR_COMBINERS * 32,
                                             &megamod_domain_ops, pic);
        if (!pic->irqhost) {
-               pr_err("%s: Could not alloc host.\n", np->full_name);
+               pr_err("%pOF: Could not alloc host.\n", np);
                goto error_free;
        }
 
@@ -225,7 +225,7 @@ static struct megamod_pic * __init init_megamod_pic(struct device_node *np)
 
        pic->regs = of_iomap(np, 0);
        if (!pic->regs) {
-               pr_err("%s: Could not map registers.\n", np->full_name);
+               pr_err("%pOF: Could not map registers.\n", np);
                goto error_free;
        }
 
@@ -253,8 +253,8 @@ static struct megamod_pic * __init init_megamod_pic(struct device_node *np)
 
                irq_data = irq_get_irq_data(irq);
                if (!irq_data) {
-                       pr_err("%s: combiner-%d no irq_data for virq %d!\n",
-                              np->full_name, i, irq);
+                       pr_err("%pOF: combiner-%d no irq_data for virq %d!\n",
+                              np, i, irq);
                        continue;
                }
 
@@ -265,16 +265,16 @@ static struct megamod_pic * __init init_megamod_pic(struct device_node *np)
                 * of the core priority interrupts (4 - 15).
                 */
                if (hwirq < 4 || hwirq >= NR_PRIORITY_IRQS) {
-                       pr_err("%s: combiner-%d core irq %ld out of range!\n",
-                              np->full_name, i, hwirq);
+                       pr_err("%pOF: combiner-%d core irq %ld out of range!\n",
+                              np, i, hwirq);
                        continue;
                }
 
                /* record the mapping */
                mapping[hwirq - 4] = i;
 
-               pr_debug("%s: combiner-%d cascading to hwirq %ld\n",
-                        np->full_name, i, hwirq);
+               pr_debug("%pOF: combiner-%d cascading to hwirq %ld\n",
+                        np, i, hwirq);
 
                cascade_data[i].pic = pic;
                cascade_data[i].index = i;
@@ -290,8 +290,8 @@ static struct megamod_pic * __init init_megamod_pic(struct device_node *np)
        /* Finally, set up the MUX registers */
        for (i = 0; i < NR_MUX_OUTPUTS; i++) {
                if (mapping[i] != IRQ_UNMAPPED) {
-                       pr_debug("%s: setting mux %d to priority %d\n",
-                                np->full_name, mapping[i], i + 4);
+                       pr_debug("%pOF: setting mux %d to priority %d\n",
+                                np, mapping[i], i + 4);
                        set_megamod_mux(pic, mapping[i], i);
                }
        }
index 755359eb628622ffd60d2bdd6ebb3a060159620b..e8b6cc6a7b5ac4e97f20877e05817e209fff7e91 100644 (file)
@@ -436,8 +436,8 @@ void __init c64x_setup_clocks(void)
 
        err = of_property_read_u32(node, "clock-frequency", &val);
        if (err || val == 0) {
-               pr_err("%s: no clock-frequency found! Using %dMHz\n",
-                      node->full_name, (int)val / 1000000);
+               pr_err("%pOF: no clock-frequency found! Using %dMHz\n",
+                      node, (int)val / 1000000);
                val = 25000000;
        }
        clkin1.rate = val;
index 0bd0452ded80d53698dd1673e15be770d89f8ae8..241a9a607193a00a726fcda8da4d2921d9bcbc83 100644 (file)
@@ -204,14 +204,14 @@ void __init timer64_init(void)
 
        timer = of_iomap(np, 0);
        if (!timer) {
-               pr_debug("%s: Cannot map timer registers.\n", np->full_name);
+               pr_debug("%pOF: Cannot map timer registers.\n", np);
                goto out;
        }
-       pr_debug("%s: Timer registers=%p.\n", np->full_name, timer);
+       pr_debug("%pOF: Timer registers=%p.\n", np, timer);
 
        cd->irq = irq_of_parse_and_map(np, 0);
        if (cd->irq == NO_IRQ) {
-               pr_debug("%s: Cannot find interrupt.\n", np->full_name);
+               pr_debug("%pOF: Cannot find interrupt.\n", np);
                iounmap(timer);
                goto out;
        }
@@ -229,7 +229,7 @@ void __init timer64_init(void)
                dscr_set_devstate(timer64_devstate_id, DSCR_DEVSTATE_ENABLED);
        }
 
-       pr_debug("%s: Timer irq=%d.\n", np->full_name, cd->irq);
+       pr_debug("%pOF: Timer irq=%d.\n", np, cd->irq);
 
        clockevents_calc_mult_shift(cd, c6x_core_freq / TIMER_DIVISOR, 5);
 
index fced197b96264e01b20743e90706ed20cf30b242..cbe5ac3699bf0f9dbdfd726c112f6fc6bd1271f0 100644 (file)
@@ -168,7 +168,8 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb)
 
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
+arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+                       unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
        tlb->max = ARRAY_SIZE(tlb->local);
@@ -185,8 +186,11 @@ tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start
  * collected.
  */
 static inline void
-tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
+arch_tlb_finish_mmu(struct mmu_gather *tlb,
+                       unsigned long start, unsigned long end, bool force)
 {
+       if (force)
+               tlb->need_flush = 1;
        /*
         * Note: tlb->nr may be 0 at this point, so we can't rely on tlb->start_addr and
         * tlb->end_addr.
index 8dd20358464f8efabcad2185d2b6f56c4fe805fa..48d91d5be4e9b6cf56c1cd0849830e2708967aa2 100644 (file)
@@ -2260,7 +2260,7 @@ config CPU_R4K_CACHE_TLB
 
 config MIPS_MT_SMP
        bool "MIPS MT SMP support (1 TC on each available VPE)"
-       depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6
+       depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MIPSR6 && !CPU_MICROMIPS
        select CPU_MIPSR2_IRQ_VI
        select CPU_MIPSR2_IRQ_EI
        select SYNC_R4K
index 04343625b9292807d886951eaed6866426dfc42d..bc2708c9ada40cf4206cd228d84a6ebf634161b3 100644 (file)
@@ -243,8 +243,21 @@ include arch/mips/Kbuild.platforms
 ifdef CONFIG_PHYSICAL_START
 load-y                                 = $(CONFIG_PHYSICAL_START)
 endif
-entry-y                                = 0x$(shell $(NM) vmlinux 2>/dev/null \
+
+entry-noisa-y                          = 0x$(shell $(NM) vmlinux 2>/dev/null \
                                        | grep "\bkernel_entry\b" | cut -f1 -d \ )
+ifdef CONFIG_CPU_MICROMIPS
+  #
+  # Set the ISA bit, since the kernel_entry symbol in the ELF will have it
+  # clear which would lead to images containing addresses which bootloaders may
+  # jump to as MIPS32 code.
+  #
+  entry-y = $(patsubst %0,%1,$(patsubst %2,%3,$(patsubst %4,%5, \
+              $(patsubst %6,%7,$(patsubst %8,%9,$(patsubst %a,%b, \
+              $(patsubst %c,%d,$(patsubst %e,%f,$(entry-noisa-y)))))))))
+else
+  entry-y = $(entry-noisa-y)
+endif
 
 cflags-y                       += -I$(srctree)/arch/mips/include/asm/mach-generic
 drivers-$(CONFIG_PCI)          += arch/mips/pci/
diff --git a/arch/mips/boot/compressed/.gitignore b/arch/mips/boot/compressed/.gitignore
new file mode 100644 (file)
index 0000000..ebae133
--- /dev/null
@@ -0,0 +1,2 @@
+ashldi3.c
+bswapsi.c
index 542be1cd0f32c6cbe14cb0c3936ffe9cd11bd594..bfdfaf32d2c49742066329e800a6b535f363c3e1 100644 (file)
@@ -13,9 +13,9 @@
 #include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/of_platform.h>
+#include <linux/io.h>
 
 #include <asm/octeon/octeon.h>
-#include <asm/octeon/cvmx-gpio-defs.h>
 
 /* USB Control Register */
 union cvm_usbdrd_uctl_ctl {
index 1910223a9c02ba1474929905b235e43a07501aaa..cea2bb1621e68b211d5dc99fdad78f208b1ad8a3 100644 (file)
                 * Find irq with highest priority
                 */
                # open coded PTR_LA t1, cpu_mask_nr_tbl
-#if (_MIPS_SZPTR == 32)
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
                # open coded la t1, cpu_mask_nr_tbl
                lui     t1, %hi(cpu_mask_nr_tbl)
                addiu   t1, %lo(cpu_mask_nr_tbl)
-
-#endif
-#if (_MIPS_SZPTR == 64)
-               # open coded dla t1, cpu_mask_nr_tbl
-               .set    push
-               .set    noat
-               lui     t1, %highest(cpu_mask_nr_tbl)
-               lui     AT, %hi(cpu_mask_nr_tbl)
-               daddiu  t1, t1, %higher(cpu_mask_nr_tbl)
-               daddiu  AT, AT, %lo(cpu_mask_nr_tbl)
-               dsll    t1, 32
-               daddu   t1, t1, AT
-               .set    pop
+#else
+#error GCC `-msym32' option required for 64-bit DECstation builds
 #endif
 1:             lw      t2,(t1)
                nop
                 * Find irq with highest priority
                 */
                # open coded PTR_LA t1,asic_mask_nr_tbl
-#if (_MIPS_SZPTR == 32)
+#if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
                # open coded la t1, asic_mask_nr_tbl
                lui     t1, %hi(asic_mask_nr_tbl)
                addiu   t1, %lo(asic_mask_nr_tbl)
-
-#endif
-#if (_MIPS_SZPTR == 64)
-               # open coded dla t1, asic_mask_nr_tbl
-               .set    push
-               .set    noat
-               lui     t1, %highest(asic_mask_nr_tbl)
-               lui     AT, %hi(asic_mask_nr_tbl)
-               daddiu  t1, t1, %higher(asic_mask_nr_tbl)
-               daddiu  AT, AT, %lo(asic_mask_nr_tbl)
-               dsll    t1, 32
-               daddu   t1, t1, AT
-               .set    pop
+#else
+#error GCC `-msym32' option required for 64-bit DECstation builds
 #endif
 2:             lw      t2,(t1)
                nop
index fc67947ed6586c2e416b2f6cc588a4445b3761ab..8b14c2706aa52ca83e07ff4dcb37c71850d133bc 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef _ASM_CACHE_H
 #define _ASM_CACHE_H
 
+#include <kmalloc.h>
+
 #define L1_CACHE_SHIFT         CONFIG_MIPS_L1_CACHE_SHIFT
 #define L1_CACHE_BYTES         (1 << L1_CACHE_SHIFT)
 
index 8baa9033b181d2ca2e3f6e469315bdb8bf5345b5..721b698bfe3cf7e0274bb9f0bb4bf58bfecef29e 100644 (file)
 #ifndef cpu_scache_line_size
 #define cpu_scache_line_size() cpu_data[0].scache.linesz
 #endif
+#ifndef cpu_tcache_line_size
+#define cpu_tcache_line_size() cpu_data[0].tcache.linesz
+#endif
 
 #ifndef cpu_hwrena_impl_bits
 #define cpu_hwrena_impl_bits           0
index 2998479fd4e83f0ac4c6ccd7d89938c7cc9a6f5f..a9af1d2dcd699114d00a55689c29137cef384841 100644 (file)
@@ -938,11 +938,6 @@ void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
 
-static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
-                                                        unsigned long address)
-{
-}
-
 /* Emulation */
 int kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu, u32 *out);
 enum emulation_result update_pc(struct kvm_vcpu *vcpu, u32 cause);
index d045973ddb336abbe9b54b21a65b4fb1a6c4f5fe..3ea84acf1814cb2c874ac17dafc73c64db50b5dc 100644 (file)
 #define CVMX_L2C_DBG (CVMX_ADD_IO_SEG(0x0001180080000030ull))
 #define CVMX_L2C_CFG (CVMX_ADD_IO_SEG(0x0001180080000000ull))
 #define CVMX_L2C_CTL (CVMX_ADD_IO_SEG(0x0001180080800000ull))
+#define CVMX_L2C_ERR_TDTX(block_id)                                           \
+       (CVMX_ADD_IO_SEG(0x0001180080A007E0ull) + ((block_id) & 3) * 0x40000ull)
+#define CVMX_L2C_ERR_TTGX(block_id)                                           \
+       (CVMX_ADD_IO_SEG(0x0001180080A007E8ull) + ((block_id) & 3) * 0x40000ull)
 #define CVMX_L2C_LCKBASE (CVMX_ADD_IO_SEG(0x0001180080000058ull))
 #define CVMX_L2C_LCKOFF (CVMX_ADD_IO_SEG(0x0001180080000060ull))
 #define CVMX_L2C_PFCTL (CVMX_ADD_IO_SEG(0x0001180080000090ull))
                ((offset) & 1) * 8)
 #define CVMX_L2C_WPAR_PPX(offset) (CVMX_ADD_IO_SEG(0x0001180080840000ull)    + \
                ((offset) & 31) * 8)
-#define CVMX_L2D_FUS3 (CVMX_ADD_IO_SEG(0x00011800800007B8ull))
 
 
+union cvmx_l2c_err_tdtx {
+       uint64_t u64;
+       struct cvmx_l2c_err_tdtx_s {
+               __BITFIELD_FIELD(uint64_t dbe:1,
+               __BITFIELD_FIELD(uint64_t sbe:1,
+               __BITFIELD_FIELD(uint64_t vdbe:1,
+               __BITFIELD_FIELD(uint64_t vsbe:1,
+               __BITFIELD_FIELD(uint64_t syn:10,
+               __BITFIELD_FIELD(uint64_t reserved_22_49:28,
+               __BITFIELD_FIELD(uint64_t wayidx:18,
+               __BITFIELD_FIELD(uint64_t reserved_2_3:2,
+               __BITFIELD_FIELD(uint64_t type:2,
+               ;)))))))))
+       } s;
+};
+
+union cvmx_l2c_err_ttgx {
+       uint64_t u64;
+       struct cvmx_l2c_err_ttgx_s {
+               __BITFIELD_FIELD(uint64_t dbe:1,
+               __BITFIELD_FIELD(uint64_t sbe:1,
+               __BITFIELD_FIELD(uint64_t noway:1,
+               __BITFIELD_FIELD(uint64_t reserved_56_60:5,
+               __BITFIELD_FIELD(uint64_t syn:6,
+               __BITFIELD_FIELD(uint64_t reserved_22_49:28,
+               __BITFIELD_FIELD(uint64_t wayidx:15,
+               __BITFIELD_FIELD(uint64_t reserved_2_6:5,
+               __BITFIELD_FIELD(uint64_t type:2,
+               ;)))))))))
+       } s;
+};
+
 union cvmx_l2c_cfg {
        uint64_t u64;
        struct cvmx_l2c_cfg_s {
diff --git a/arch/mips/include/asm/octeon/cvmx-l2d-defs.h b/arch/mips/include/asm/octeon/cvmx-l2d-defs.h
new file mode 100644 (file)
index 0000000..a951ad5
--- /dev/null
@@ -0,0 +1,60 @@
+/***********************license start***************
+ * Author: Cavium Networks
+ *
+ * Contact: support@caviumnetworks.com
+ * This file is part of the OCTEON SDK
+ *
+ * Copyright (c) 2003-2017 Cavium, Inc.
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
+ * NONINFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this file; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * or visit http://www.gnu.org/licenses/.
+ *
+ * This file may also be available under a different license from Cavium.
+ * Contact Cavium Networks for more information
+ ***********************license end**************************************/
+
+#ifndef __CVMX_L2D_DEFS_H__
+#define __CVMX_L2D_DEFS_H__
+
+#define CVMX_L2D_ERR   (CVMX_ADD_IO_SEG(0x0001180080000010ull))
+#define CVMX_L2D_FUS3  (CVMX_ADD_IO_SEG(0x00011800800007B8ull))
+
+
+union cvmx_l2d_err {
+       uint64_t u64;
+       struct cvmx_l2d_err_s {
+               __BITFIELD_FIELD(uint64_t reserved_6_63:58,
+               __BITFIELD_FIELD(uint64_t bmhclsel:1,
+               __BITFIELD_FIELD(uint64_t ded_err:1,
+               __BITFIELD_FIELD(uint64_t sec_err:1,
+               __BITFIELD_FIELD(uint64_t ded_intena:1,
+               __BITFIELD_FIELD(uint64_t sec_intena:1,
+               __BITFIELD_FIELD(uint64_t ecc_ena:1,
+               ;)))))))
+       } s;
+};
+
+union cvmx_l2d_fus3 {
+       uint64_t u64;
+       struct cvmx_l2d_fus3_s {
+               __BITFIELD_FIELD(uint64_t reserved_40_63:24,
+               __BITFIELD_FIELD(uint64_t ema_ctl:3,
+               __BITFIELD_FIELD(uint64_t reserved_34_36:3,
+               __BITFIELD_FIELD(uint64_t q3fus:34,
+               ;))))
+       } s;
+};
+
+#endif
index 9742202f2a326c45c504de6d77b51eb523421c0c..e638735cc3ac56c84fc861f293e6f2217b7ba3cb 100644 (file)
@@ -62,6 +62,7 @@ enum cvmx_mips_space {
 #include <asm/octeon/cvmx-iob-defs.h>
 #include <asm/octeon/cvmx-ipd-defs.h>
 #include <asm/octeon/cvmx-l2c-defs.h>
+#include <asm/octeon/cvmx-l2d-defs.h>
 #include <asm/octeon/cvmx-l2t-defs.h>
 #include <asm/octeon/cvmx-led-defs.h>
 #include <asm/octeon/cvmx-mio-defs.h>
index 770d4d1516cbb1ff34cca30cdccbe6c1b0aeebdc..6bace7695788fbc3b7663aeb353a08a3c45503af 100644 (file)
@@ -376,9 +376,6 @@ asmlinkage void start_secondary(void)
        cpumask_set_cpu(cpu, &cpu_coherent_mask);
        notify_cpu_starting(cpu);
 
-       complete(&cpu_running);
-       synchronise_count_slave(cpu);
-
        set_cpu_online(cpu, true);
 
        set_cpu_sibling_map(cpu);
@@ -386,6 +383,9 @@ asmlinkage void start_secondary(void)
 
        calculate_cpu_foreign_map();
 
+       complete(&cpu_running);
+       synchronise_count_slave(cpu);
+
        /*
         * irq will be enabled in ->smp_finish(), enabling it too early
         * is dangerous.
index 3f74f6c1f065fb6b5d2b930dc1d164e1624e63f0..9fea6c6bbf49e3768e81ad3ffb8b8af2bbdef61f 100644 (file)
@@ -48,7 +48,7 @@
 
 #include "uasm.c"
 
-static const struct insn const insn_table[insn_invalid] = {
+static const struct insn insn_table[insn_invalid] = {
        [insn_addiu]    = {M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM},
        [insn_addu]     = {M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD},
        [insn_and]      = {M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD},
diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
new file mode 100644 (file)
index 0000000..3f87b96
--- /dev/null
@@ -0,0 +1,1950 @@
+/*
+ * Just-In-Time compiler for eBPF filters on MIPS
+ *
+ * Copyright (c) 2017 Cavium, Inc.
+ *
+ * Based on code from:
+ *
+ * Copyright (c) 2014 Imagination Technologies Ltd.
+ * Author: Markos Chandras <markos.chandras@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/bitops.h>
+#include <linux/errno.h>
+#include <linux/filter.h>
+#include <linux/bpf.h>
+#include <linux/slab.h>
+#include <asm/bitops.h>
+#include <asm/byteorder.h>
+#include <asm/cacheflush.h>
+#include <asm/cpu-features.h>
+#include <asm/uasm.h>
+
+/* Registers used by JIT */
+#define MIPS_R_ZERO    0
+#define MIPS_R_AT      1
+#define MIPS_R_V0      2       /* BPF_R0 */
+#define MIPS_R_V1      3
+#define MIPS_R_A0      4       /* BPF_R1 */
+#define MIPS_R_A1      5       /* BPF_R2 */
+#define MIPS_R_A2      6       /* BPF_R3 */
+#define MIPS_R_A3      7       /* BPF_R4 */
+#define MIPS_R_A4      8       /* BPF_R5 */
+#define MIPS_R_T4      12      /* BPF_AX */
+#define MIPS_R_T5      13
+#define MIPS_R_T6      14
+#define MIPS_R_T7      15
+#define MIPS_R_S0      16      /* BPF_R6 */
+#define MIPS_R_S1      17      /* BPF_R7 */
+#define MIPS_R_S2      18      /* BPF_R8 */
+#define MIPS_R_S3      19      /* BPF_R9 */
+#define MIPS_R_S4      20      /* BPF_TCC */
+#define MIPS_R_S5      21
+#define MIPS_R_S6      22
+#define MIPS_R_S7      23
+#define MIPS_R_T8      24
+#define MIPS_R_T9      25
+#define MIPS_R_SP      29
+#define MIPS_R_RA      31
+
+/* eBPF flags */
+#define EBPF_SAVE_S0   BIT(0)
+#define EBPF_SAVE_S1   BIT(1)
+#define EBPF_SAVE_S2   BIT(2)
+#define EBPF_SAVE_S3   BIT(3)
+#define EBPF_SAVE_S4   BIT(4)
+#define EBPF_SAVE_RA   BIT(5)
+#define EBPF_SEEN_FP   BIT(6)
+#define EBPF_SEEN_TC   BIT(7)
+#define EBPF_TCC_IN_V1 BIT(8)
+
+/*
+ * For the mips64 ISA, we need to track the value range or type for
+ * each JIT register.  The BPF machine requires zero extended 32-bit
+ * values, but the mips64 ISA requires sign extended 32-bit values.
+ * At each point in the BPF program we track the state of every
+ * register so that we can zero extend or sign extend as the BPF
+ * semantics require.
+ */
+enum reg_val_type {
+       /* uninitialized */
+       REG_UNKNOWN,
+       /* not known to be 32-bit compatible. */
+       REG_64BIT,
+       /* 32-bit compatible, no truncation needed for 64-bit ops. */
+       REG_64BIT_32BIT,
+       /* 32-bit compatible, need truncation for 64-bit ops. */
+       REG_32BIT,
+       /* 32-bit zero extended. */
+       REG_32BIT_ZERO_EX,
+       /* 32-bit no sign/zero extension needed. */
+       REG_32BIT_POS
+};
+
+/*
+ * high bit of offsets indicates if long branch conversion done at
+ * this insn.
+ */
+#define OFFSETS_B_CONV BIT(31)
+
+/**
+ * struct jit_ctx - JIT context
+ * @skf:               The sk_filter
+ * @stack_size:                eBPF stack size
+ * @tmp_offset:                eBPF $sp offset to 8-byte temporary memory
+ * @idx:               Instruction index
+ * @flags:             JIT flags
+ * @offsets:           Instruction offsets
+ * @target:            Memory location for the compiled filter
+ * @reg_val_types      Packed enum reg_val_type for each register.
+ */
+struct jit_ctx {
+       const struct bpf_prog *skf;
+       int stack_size;
+       int tmp_offset;
+       u32 idx;
+       u32 flags;
+       u32 *offsets;
+       u32 *target;
+       u64 *reg_val_types;
+       unsigned int long_b_conversion:1;
+       unsigned int gen_b_offsets:1;
+};
+
+static void set_reg_val_type(u64 *rvt, int reg, enum reg_val_type type)
+{
+       *rvt &= ~(7ull << (reg * 3));
+       *rvt |= ((u64)type << (reg * 3));
+}
+
+static enum reg_val_type get_reg_val_type(const struct jit_ctx *ctx,
+                                         int index, int reg)
+{
+       return (ctx->reg_val_types[index] >> (reg * 3)) & 7;
+}
+
+/* Simply emit the instruction if the JIT memory space has been allocated */
+#define emit_instr(ctx, func, ...)                     \
+do {                                                   \
+       if ((ctx)->target != NULL) {                    \
+               u32 *p = &(ctx)->target[ctx->idx];      \
+               uasm_i_##func(&p, ##__VA_ARGS__);       \
+       }                                               \
+       (ctx)->idx++;                                   \
+} while (0)
+
+static unsigned int j_target(struct jit_ctx *ctx, int target_idx)
+{
+       unsigned long target_va, base_va;
+       unsigned int r;
+
+       if (!ctx->target)
+               return 0;
+
+       base_va = (unsigned long)ctx->target;
+       target_va = base_va + (ctx->offsets[target_idx] & ~OFFSETS_B_CONV);
+
+       if ((base_va & ~0x0ffffffful) != (target_va & ~0x0ffffffful))
+               return (unsigned int)-1;
+       r = target_va & 0x0ffffffful;
+       return r;
+}
+
+/* Compute the immediate value for PC-relative branches. */
+static u32 b_imm(unsigned int tgt, struct jit_ctx *ctx)
+{
+       if (!ctx->gen_b_offsets)
+               return 0;
+
+       /*
+        * We want a pc-relative branch.  tgt is the instruction offset
+        * we want to jump to.
+
+        * Branch on MIPS:
+        * I: target_offset <- sign_extend(offset)
+        * I+1: PC += target_offset (delay slot)
+        *
+        * ctx->idx currently points to the branch instruction
+        * but the offset is added to the delay slot so we need
+        * to subtract 4.
+        */
+       return (ctx->offsets[tgt] & ~OFFSETS_B_CONV) -
+               (ctx->idx * 4) - 4;
+}
+
+int bpf_jit_enable __read_mostly;
+
+enum which_ebpf_reg {
+       src_reg,
+       src_reg_no_fp,
+       dst_reg,
+       dst_reg_fp_ok
+};
+
+/*
+ * For eBPF, the register mapping naturally falls out of the
+ * requirements of eBPF and the MIPS n64 ABI.  We don't maintain a
+ * separate frame pointer, so BPF_REG_10 relative accesses are
+ * adjusted to be $sp relative.
+ */
+int ebpf_to_mips_reg(struct jit_ctx *ctx, const struct bpf_insn *insn,
+                    enum which_ebpf_reg w)
+{
+       int ebpf_reg = (w == src_reg || w == src_reg_no_fp) ?
+               insn->src_reg : insn->dst_reg;
+
+       switch (ebpf_reg) {
+       case BPF_REG_0:
+               return MIPS_R_V0;
+       case BPF_REG_1:
+               return MIPS_R_A0;
+       case BPF_REG_2:
+               return MIPS_R_A1;
+       case BPF_REG_3:
+               return MIPS_R_A2;
+       case BPF_REG_4:
+               return MIPS_R_A3;
+       case BPF_REG_5:
+               return MIPS_R_A4;
+       case BPF_REG_6:
+               ctx->flags |= EBPF_SAVE_S0;
+               return MIPS_R_S0;
+       case BPF_REG_7:
+               ctx->flags |= EBPF_SAVE_S1;
+               return MIPS_R_S1;
+       case BPF_REG_8:
+               ctx->flags |= EBPF_SAVE_S2;
+               return MIPS_R_S2;
+       case BPF_REG_9:
+               ctx->flags |= EBPF_SAVE_S3;
+               return MIPS_R_S3;
+       case BPF_REG_10:
+               if (w == dst_reg || w == src_reg_no_fp)
+                       goto bad_reg;
+               ctx->flags |= EBPF_SEEN_FP;
+               /*
+                * Needs special handling, return something that
+                * cannot be clobbered just in case.
+                */
+               return MIPS_R_ZERO;
+       case BPF_REG_AX:
+               return MIPS_R_T4;
+       default:
+bad_reg:
+               WARN(1, "Illegal bpf reg: %d\n", ebpf_reg);
+               return -EINVAL;
+       }
+}
+/*
+ * eBPF stack frame will be something like:
+ *
+ *  Entry $sp ------>   +--------------------------------+
+ *                      |   $ra  (optional)              |
+ *                      +--------------------------------+
+ *                      |   $s0  (optional)              |
+ *                      +--------------------------------+
+ *                      |   $s1  (optional)              |
+ *                      +--------------------------------+
+ *                      |   $s2  (optional)              |
+ *                      +--------------------------------+
+ *                      |   $s3  (optional)              |
+ *                      +--------------------------------+
+ *                      |   $s4  (optional)              |
+ *                      +--------------------------------+
+ *                      |   tmp-storage  (if $ra saved)  |
+ * $sp + tmp_offset --> +--------------------------------+ <--BPF_REG_10
+ *                      |   BPF_REG_10 relative storage  |
+ *                      |    MAX_BPF_STACK (optional)    |
+ *                      |      .                         |
+ *                      |      .                         |
+ *                      |      .                         |
+ *     $sp -------->    +--------------------------------+
+ *
+ * If BPF_REG_10 is never referenced, then the MAX_BPF_STACK sized
+ * area is not allocated.
+ */
+static int gen_int_prologue(struct jit_ctx *ctx)
+{
+       int stack_adjust = 0;
+       int store_offset;
+       int locals_size;
+
+       if (ctx->flags & EBPF_SAVE_RA)
+               /*
+                * If RA we are doing a function call and may need
+                * extra 8-byte tmp area.
+                */
+               stack_adjust += 16;
+       if (ctx->flags & EBPF_SAVE_S0)
+               stack_adjust += 8;
+       if (ctx->flags & EBPF_SAVE_S1)
+               stack_adjust += 8;
+       if (ctx->flags & EBPF_SAVE_S2)
+               stack_adjust += 8;
+       if (ctx->flags & EBPF_SAVE_S3)
+               stack_adjust += 8;
+       if (ctx->flags & EBPF_SAVE_S4)
+               stack_adjust += 8;
+
+       BUILD_BUG_ON(MAX_BPF_STACK & 7);
+       locals_size = (ctx->flags & EBPF_SEEN_FP) ? MAX_BPF_STACK : 0;
+
+       stack_adjust += locals_size;
+       ctx->tmp_offset = locals_size;
+
+       ctx->stack_size = stack_adjust;
+
+       /*
+        * First instruction initializes the tail call count (TCC).
+        * On tail call we skip this instruction, and the TCC is
+        * passed in $v1 from the caller.
+        */
+       emit_instr(ctx, daddiu, MIPS_R_V1, MIPS_R_ZERO, MAX_TAIL_CALL_CNT);
+       if (stack_adjust)
+               emit_instr(ctx, daddiu, MIPS_R_SP, MIPS_R_SP, -stack_adjust);
+       else
+               return 0;
+
+       store_offset = stack_adjust - 8;
+
+       if (ctx->flags & EBPF_SAVE_RA) {
+               emit_instr(ctx, sd, MIPS_R_RA, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S0) {
+               emit_instr(ctx, sd, MIPS_R_S0, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S1) {
+               emit_instr(ctx, sd, MIPS_R_S1, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S2) {
+               emit_instr(ctx, sd, MIPS_R_S2, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S3) {
+               emit_instr(ctx, sd, MIPS_R_S3, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S4) {
+               emit_instr(ctx, sd, MIPS_R_S4, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+
+       if ((ctx->flags & EBPF_SEEN_TC) && !(ctx->flags & EBPF_TCC_IN_V1))
+               emit_instr(ctx, daddu, MIPS_R_S4, MIPS_R_V1, MIPS_R_ZERO);
+
+       return 0;
+}
+
+static int build_int_epilogue(struct jit_ctx *ctx, int dest_reg)
+{
+       const struct bpf_prog *prog = ctx->skf;
+       int stack_adjust = ctx->stack_size;
+       int store_offset = stack_adjust - 8;
+       int r0 = MIPS_R_V0;
+
+       if (dest_reg == MIPS_R_RA &&
+           get_reg_val_type(ctx, prog->len, BPF_REG_0) == REG_32BIT_ZERO_EX)
+               /* Don't let zero extended value escape. */
+               emit_instr(ctx, sll, r0, r0, 0);
+
+       if (ctx->flags & EBPF_SAVE_RA) {
+               emit_instr(ctx, ld, MIPS_R_RA, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S0) {
+               emit_instr(ctx, ld, MIPS_R_S0, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S1) {
+               emit_instr(ctx, ld, MIPS_R_S1, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S2) {
+               emit_instr(ctx, ld, MIPS_R_S2, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S3) {
+               emit_instr(ctx, ld, MIPS_R_S3, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       if (ctx->flags & EBPF_SAVE_S4) {
+               emit_instr(ctx, ld, MIPS_R_S4, store_offset, MIPS_R_SP);
+               store_offset -= 8;
+       }
+       emit_instr(ctx, jr, dest_reg);
+
+       if (stack_adjust)
+               emit_instr(ctx, daddiu, MIPS_R_SP, MIPS_R_SP, stack_adjust);
+       else
+               emit_instr(ctx, nop);
+
+       return 0;
+}
+
+static void gen_imm_to_reg(const struct bpf_insn *insn, int reg,
+                          struct jit_ctx *ctx)
+{
+       if (insn->imm >= S16_MIN && insn->imm <= S16_MAX) {
+               emit_instr(ctx, addiu, reg, MIPS_R_ZERO, insn->imm);
+       } else {
+               int lower = (s16)(insn->imm & 0xffff);
+               int upper = insn->imm - lower;
+
+               emit_instr(ctx, lui, reg, upper >> 16);
+               emit_instr(ctx, addiu, reg, reg, lower);
+       }
+
+}
+
+static int gen_imm_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
+                       int idx)
+{
+       int upper_bound, lower_bound;
+       int dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+
+       if (dst < 0)
+               return dst;
+
+       switch (BPF_OP(insn->code)) {
+       case BPF_MOV:
+       case BPF_ADD:
+               upper_bound = S16_MAX;
+               lower_bound = S16_MIN;
+               break;
+       case BPF_SUB:
+               upper_bound = -(int)S16_MIN;
+               lower_bound = -(int)S16_MAX;
+               break;
+       case BPF_AND:
+       case BPF_OR:
+       case BPF_XOR:
+               upper_bound = 0xffff;
+               lower_bound = 0;
+               break;
+       case BPF_RSH:
+       case BPF_LSH:
+       case BPF_ARSH:
+               /* Shift amounts are truncated, no need for bounds */
+               upper_bound = S32_MAX;
+               lower_bound = S32_MIN;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /*
+        * Immediate move clobbers the register, so no sign/zero
+        * extension needed.
+        */
+       if (BPF_CLASS(insn->code) == BPF_ALU64 &&
+           BPF_OP(insn->code) != BPF_MOV &&
+           get_reg_val_type(ctx, idx, insn->dst_reg) == REG_32BIT)
+               emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
+       /* BPF_ALU | BPF_LSH doesn't need separate sign extension */
+       if (BPF_CLASS(insn->code) == BPF_ALU &&
+           BPF_OP(insn->code) != BPF_LSH &&
+           BPF_OP(insn->code) != BPF_MOV &&
+           get_reg_val_type(ctx, idx, insn->dst_reg) != REG_32BIT)
+               emit_instr(ctx, sll, dst, dst, 0);
+
+       if (insn->imm >= lower_bound && insn->imm <= upper_bound) {
+               /* single insn immediate case */
+               switch (BPF_OP(insn->code) | BPF_CLASS(insn->code)) {
+               case BPF_ALU64 | BPF_MOV:
+                       emit_instr(ctx, daddiu, dst, MIPS_R_ZERO, insn->imm);
+                       break;
+               case BPF_ALU64 | BPF_AND:
+               case BPF_ALU | BPF_AND:
+                       emit_instr(ctx, andi, dst, dst, insn->imm);
+                       break;
+               case BPF_ALU64 | BPF_OR:
+               case BPF_ALU | BPF_OR:
+                       emit_instr(ctx, ori, dst, dst, insn->imm);
+                       break;
+               case BPF_ALU64 | BPF_XOR:
+               case BPF_ALU | BPF_XOR:
+                       emit_instr(ctx, xori, dst, dst, insn->imm);
+                       break;
+               case BPF_ALU64 | BPF_ADD:
+                       emit_instr(ctx, daddiu, dst, dst, insn->imm);
+                       break;
+               case BPF_ALU64 | BPF_SUB:
+                       emit_instr(ctx, daddiu, dst, dst, -insn->imm);
+                       break;
+               case BPF_ALU64 | BPF_RSH:
+                       emit_instr(ctx, dsrl_safe, dst, dst, insn->imm & 0x3f);
+                       break;
+               case BPF_ALU | BPF_RSH:
+                       emit_instr(ctx, srl, dst, dst, insn->imm & 0x1f);
+                       break;
+               case BPF_ALU64 | BPF_LSH:
+                       emit_instr(ctx, dsll_safe, dst, dst, insn->imm & 0x3f);
+                       break;
+               case BPF_ALU | BPF_LSH:
+                       emit_instr(ctx, sll, dst, dst, insn->imm & 0x1f);
+                       break;
+               case BPF_ALU64 | BPF_ARSH:
+                       emit_instr(ctx, dsra_safe, dst, dst, insn->imm & 0x3f);
+                       break;
+               case BPF_ALU | BPF_ARSH:
+                       emit_instr(ctx, sra, dst, dst, insn->imm & 0x1f);
+                       break;
+               case BPF_ALU | BPF_MOV:
+                       emit_instr(ctx, addiu, dst, MIPS_R_ZERO, insn->imm);
+                       break;
+               case BPF_ALU | BPF_ADD:
+                       emit_instr(ctx, addiu, dst, dst, insn->imm);
+                       break;
+               case BPF_ALU | BPF_SUB:
+                       emit_instr(ctx, addiu, dst, dst, -insn->imm);
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       } else {
+               /* multi insn immediate case */
+               if (BPF_OP(insn->code) == BPF_MOV) {
+                       gen_imm_to_reg(insn, dst, ctx);
+               } else {
+                       gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+                       switch (BPF_OP(insn->code) | BPF_CLASS(insn->code)) {
+                       case BPF_ALU64 | BPF_AND:
+                       case BPF_ALU | BPF_AND:
+                               emit_instr(ctx, and, dst, dst, MIPS_R_AT);
+                               break;
+                       case BPF_ALU64 | BPF_OR:
+                       case BPF_ALU | BPF_OR:
+                               emit_instr(ctx, or, dst, dst, MIPS_R_AT);
+                               break;
+                       case BPF_ALU64 | BPF_XOR:
+                       case BPF_ALU | BPF_XOR:
+                               emit_instr(ctx, xor, dst, dst, MIPS_R_AT);
+                               break;
+                       case BPF_ALU64 | BPF_ADD:
+                               emit_instr(ctx, daddu, dst, dst, MIPS_R_AT);
+                               break;
+                       case BPF_ALU64 | BPF_SUB:
+                               emit_instr(ctx, dsubu, dst, dst, MIPS_R_AT);
+                               break;
+                       case BPF_ALU | BPF_ADD:
+                               emit_instr(ctx, addu, dst, dst, MIPS_R_AT);
+                               break;
+                       case BPF_ALU | BPF_SUB:
+                               emit_instr(ctx, subu, dst, dst, MIPS_R_AT);
+                               break;
+                       default:
+                               return -EINVAL;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+static void * __must_check
+ool_skb_header_pointer(const struct sk_buff *skb, int offset,
+                      int len, void *buffer)
+{
+       return skb_header_pointer(skb, offset, len, buffer);
+}
+
+static int size_to_len(const struct bpf_insn *insn)
+{
+       switch (BPF_SIZE(insn->code)) {
+       case BPF_B:
+               return 1;
+       case BPF_H:
+               return 2;
+       case BPF_W:
+               return 4;
+       case BPF_DW:
+               return 8;
+       }
+       return 0;
+}
+
+static void emit_const_to_reg(struct jit_ctx *ctx, int dst, u64 value)
+{
+       if (value >= 0xffffffffffff8000ull || value < 0x8000ull) {
+               emit_instr(ctx, daddiu, dst, MIPS_R_ZERO, (int)value);
+       } else if (value >= 0xffffffff80000000ull ||
+                  (value < 0x80000000 && value > 0xffff)) {
+               emit_instr(ctx, lui, dst, (s32)(s16)(value >> 16));
+               emit_instr(ctx, ori, dst, dst, (unsigned int)(value & 0xffff));
+       } else {
+               int i;
+               bool seen_part = false;
+               int needed_shift = 0;
+
+               for (i = 0; i < 4; i++) {
+                       u64 part = (value >> (16 * (3 - i))) & 0xffff;
+
+                       if (seen_part && needed_shift > 0 && (part || i == 3)) {
+                               emit_instr(ctx, dsll_safe, dst, dst, needed_shift);
+                               needed_shift = 0;
+                       }
+                       if (part) {
+                               if (i == 0 || (!seen_part && i < 3 && part < 0x8000)) {
+                                       emit_instr(ctx, lui, dst, (s32)(s16)part);
+                                       needed_shift = -16;
+                               } else {
+                                       emit_instr(ctx, ori, dst,
+                                                  seen_part ? dst : MIPS_R_ZERO,
+                                                  (unsigned int)part);
+                               }
+                               seen_part = true;
+                       }
+                       if (seen_part)
+                               needed_shift += 16;
+               }
+       }
+}
+
+static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx)
+{
+       int off, b_off;
+
+       ctx->flags |= EBPF_SEEN_TC;
+       /*
+        * if (index >= array->map.max_entries)
+        *     goto out;
+        */
+       off = offsetof(struct bpf_array, map.max_entries);
+       emit_instr(ctx, lwu, MIPS_R_T5, off, MIPS_R_A1);
+       emit_instr(ctx, sltu, MIPS_R_AT, MIPS_R_T5, MIPS_R_A2);
+       b_off = b_imm(this_idx + 1, ctx);
+       emit_instr(ctx, bne, MIPS_R_AT, MIPS_R_ZERO, b_off);
+       /*
+        * if (--TCC < 0)
+        *     goto out;
+        */
+       /* Delay slot */
+       emit_instr(ctx, daddiu, MIPS_R_T5,
+                  (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4, -1);
+       b_off = b_imm(this_idx + 1, ctx);
+       emit_instr(ctx, bltz, MIPS_R_T5, b_off);
+       /*
+        * prog = array->ptrs[index];
+        * if (prog == NULL)
+        *     goto out;
+        */
+       /* Delay slot */
+       emit_instr(ctx, dsll, MIPS_R_T8, MIPS_R_A2, 3);
+       emit_instr(ctx, daddu, MIPS_R_T8, MIPS_R_T8, MIPS_R_A1);
+       off = offsetof(struct bpf_array, ptrs);
+       emit_instr(ctx, ld, MIPS_R_AT, off, MIPS_R_T8);
+       b_off = b_imm(this_idx + 1, ctx);
+       emit_instr(ctx, beq, MIPS_R_AT, MIPS_R_ZERO, b_off);
+       /* Delay slot */
+       emit_instr(ctx, nop);
+
+       /* goto *(prog->bpf_func + 4); */
+       off = offsetof(struct bpf_prog, bpf_func);
+       emit_instr(ctx, ld, MIPS_R_T9, off, MIPS_R_AT);
+       /* All systems are go... propagate TCC */
+       emit_instr(ctx, daddu, MIPS_R_V1, MIPS_R_T5, MIPS_R_ZERO);
+       /* Skip first instruction (TCC initialization) */
+       emit_instr(ctx, daddiu, MIPS_R_T9, MIPS_R_T9, 4);
+       return build_int_epilogue(ctx, MIPS_R_T9);
+}
+
+static bool use_bbit_insns(void)
+{
+       switch (current_cpu_type()) {
+       case CPU_CAVIUM_OCTEON:
+       case CPU_CAVIUM_OCTEON_PLUS:
+       case CPU_CAVIUM_OCTEON2:
+       case CPU_CAVIUM_OCTEON3:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static bool is_bad_offset(int b_off)
+{
+       return b_off > 0x1ffff || b_off < -0x20000;
+}
+
+/* Returns the number of insn slots consumed. */
+static int build_one_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
+                         int this_idx, int exit_idx)
+{
+       int src, dst, r, td, ts, mem_off, b_off;
+       bool need_swap, did_move, cmp_eq;
+       unsigned int target;
+       u64 t64;
+       s64 t64s;
+
+       switch (insn->code) {
+       case BPF_ALU64 | BPF_ADD | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_SUB | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_OR | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_AND | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_LSH | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_RSH | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_XOR | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_ARSH | BPF_K: /* ALU64_IMM */
+       case BPF_ALU64 | BPF_MOV | BPF_K: /* ALU64_IMM */
+       case BPF_ALU | BPF_MOV | BPF_K: /* ALU32_IMM */
+       case BPF_ALU | BPF_ADD | BPF_K: /* ALU32_IMM */
+       case BPF_ALU | BPF_SUB | BPF_K: /* ALU32_IMM */
+       case BPF_ALU | BPF_OR | BPF_K: /* ALU64_IMM */
+       case BPF_ALU | BPF_AND | BPF_K: /* ALU64_IMM */
+       case BPF_ALU | BPF_LSH | BPF_K: /* ALU64_IMM */
+       case BPF_ALU | BPF_RSH | BPF_K: /* ALU64_IMM */
+       case BPF_ALU | BPF_XOR | BPF_K: /* ALU64_IMM */
+       case BPF_ALU | BPF_ARSH | BPF_K: /* ALU64_IMM */
+               r = gen_imm_insn(insn, ctx, this_idx);
+               if (r < 0)
+                       return r;
+               break;
+       case BPF_ALU64 | BPF_MUL | BPF_K: /* ALU64_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               if (get_reg_val_type(ctx, this_idx, insn->dst_reg) == REG_32BIT)
+                       emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
+               if (insn->imm == 1) /* Mult by 1 is a nop */
+                       break;
+               gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+               emit_instr(ctx, dmultu, MIPS_R_AT, dst);
+               emit_instr(ctx, mflo, dst);
+               break;
+       case BPF_ALU64 | BPF_NEG | BPF_K: /* ALU64_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               if (get_reg_val_type(ctx, this_idx, insn->dst_reg) == REG_32BIT)
+                       emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
+               emit_instr(ctx, dsubu, dst, MIPS_R_ZERO, dst);
+               break;
+       case BPF_ALU | BPF_MUL | BPF_K: /* ALU_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
+               if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) {
+                       /* sign extend */
+                       emit_instr(ctx, sll, dst, dst, 0);
+               }
+               if (insn->imm == 1) /* Mult by 1 is a nop */
+                       break;
+               gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+               emit_instr(ctx, multu, dst, MIPS_R_AT);
+               emit_instr(ctx, mflo, dst);
+               break;
+       case BPF_ALU | BPF_NEG | BPF_K: /* ALU_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
+               if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) {
+                       /* sign extend */
+                       emit_instr(ctx, sll, dst, dst, 0);
+               }
+               emit_instr(ctx, subu, dst, MIPS_R_ZERO, dst);
+               break;
+       case BPF_ALU | BPF_DIV | BPF_K: /* ALU_IMM */
+       case BPF_ALU | BPF_MOD | BPF_K: /* ALU_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               if (insn->imm == 0) { /* Div by zero */
+                       b_off = b_imm(exit_idx, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, beq, MIPS_R_ZERO, MIPS_R_ZERO, b_off);
+                       emit_instr(ctx, addu, MIPS_R_V0, MIPS_R_ZERO, MIPS_R_ZERO);
+               }
+               td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
+               if (td == REG_64BIT || td == REG_32BIT_ZERO_EX)
+                       /* sign extend */
+                       emit_instr(ctx, sll, dst, dst, 0);
+               if (insn->imm == 1) {
+                       /* div by 1 is a nop, mod by 1 is zero */
+                       if (BPF_OP(insn->code) == BPF_MOD)
+                               emit_instr(ctx, addu, dst, MIPS_R_ZERO, MIPS_R_ZERO);
+                       break;
+               }
+               gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+               emit_instr(ctx, divu, dst, MIPS_R_AT);
+               if (BPF_OP(insn->code) == BPF_DIV)
+                       emit_instr(ctx, mflo, dst);
+               else
+                       emit_instr(ctx, mfhi, dst);
+               break;
+       case BPF_ALU64 | BPF_DIV | BPF_K: /* ALU_IMM */
+       case BPF_ALU64 | BPF_MOD | BPF_K: /* ALU_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               if (insn->imm == 0) { /* Div by zero */
+                       b_off = b_imm(exit_idx, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, beq, MIPS_R_ZERO, MIPS_R_ZERO, b_off);
+                       emit_instr(ctx, addu, MIPS_R_V0, MIPS_R_ZERO, MIPS_R_ZERO);
+               }
+               if (get_reg_val_type(ctx, this_idx, insn->dst_reg) == REG_32BIT)
+                       emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
+
+               if (insn->imm == 1) {
+                       /* div by 1 is a nop, mod by 1 is zero */
+                       if (BPF_OP(insn->code) == BPF_MOD)
+                               emit_instr(ctx, addu, dst, MIPS_R_ZERO, MIPS_R_ZERO);
+                       break;
+               }
+               gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+               emit_instr(ctx, ddivu, dst, MIPS_R_AT);
+               if (BPF_OP(insn->code) == BPF_DIV)
+                       emit_instr(ctx, mflo, dst);
+               else
+                       emit_instr(ctx, mfhi, dst);
+               break;
+       case BPF_ALU64 | BPF_MOV | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_ADD | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_SUB | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_XOR | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_OR | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_AND | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_MUL | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_DIV | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_MOD | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_LSH | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_RSH | BPF_X: /* ALU64_REG */
+       case BPF_ALU64 | BPF_ARSH | BPF_X: /* ALU64_REG */
+               src = ebpf_to_mips_reg(ctx, insn, src_reg);
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (src < 0 || dst < 0)
+                       return -EINVAL;
+               if (get_reg_val_type(ctx, this_idx, insn->dst_reg) == REG_32BIT)
+                       emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
+               did_move = false;
+               if (insn->src_reg == BPF_REG_10) {
+                       if (BPF_OP(insn->code) == BPF_MOV) {
+                               emit_instr(ctx, daddiu, dst, MIPS_R_SP, MAX_BPF_STACK);
+                               did_move = true;
+                       } else {
+                               emit_instr(ctx, daddiu, MIPS_R_AT, MIPS_R_SP, MAX_BPF_STACK);
+                               src = MIPS_R_AT;
+                       }
+               } else if (get_reg_val_type(ctx, this_idx, insn->src_reg) == REG_32BIT) {
+                       int tmp_reg = MIPS_R_AT;
+
+                       if (BPF_OP(insn->code) == BPF_MOV) {
+                               tmp_reg = dst;
+                               did_move = true;
+                       }
+                       emit_instr(ctx, daddu, tmp_reg, src, MIPS_R_ZERO);
+                       emit_instr(ctx, dinsu, tmp_reg, MIPS_R_ZERO, 32, 32);
+                       src = MIPS_R_AT;
+               }
+               switch (BPF_OP(insn->code)) {
+               case BPF_MOV:
+                       if (!did_move)
+                               emit_instr(ctx, daddu, dst, src, MIPS_R_ZERO);
+                       break;
+               case BPF_ADD:
+                       emit_instr(ctx, daddu, dst, dst, src);
+                       break;
+               case BPF_SUB:
+                       emit_instr(ctx, dsubu, dst, dst, src);
+                       break;
+               case BPF_XOR:
+                       emit_instr(ctx, xor, dst, dst, src);
+                       break;
+               case BPF_OR:
+                       emit_instr(ctx, or, dst, dst, src);
+                       break;
+               case BPF_AND:
+                       emit_instr(ctx, and, dst, dst, src);
+                       break;
+               case BPF_MUL:
+                       emit_instr(ctx, dmultu, dst, src);
+                       emit_instr(ctx, mflo, dst);
+                       break;
+               case BPF_DIV:
+               case BPF_MOD:
+                       b_off = b_imm(exit_idx, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, beq, src, MIPS_R_ZERO, b_off);
+                       emit_instr(ctx, movz, MIPS_R_V0, MIPS_R_ZERO, src);
+                       emit_instr(ctx, ddivu, dst, src);
+                       if (BPF_OP(insn->code) == BPF_DIV)
+                               emit_instr(ctx, mflo, dst);
+                       else
+                               emit_instr(ctx, mfhi, dst);
+                       break;
+               case BPF_LSH:
+                       emit_instr(ctx, dsllv, dst, dst, src);
+                       break;
+               case BPF_RSH:
+                       emit_instr(ctx, dsrlv, dst, dst, src);
+                       break;
+               case BPF_ARSH:
+                       emit_instr(ctx, dsrav, dst, dst, src);
+                       break;
+               default:
+                       pr_err("ALU64_REG NOT HANDLED\n");
+                       return -EINVAL;
+               }
+               break;
+       case BPF_ALU | BPF_MOV | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_ADD | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_SUB | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_XOR | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_OR | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_AND | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_MUL | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_DIV | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_MOD | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_LSH | BPF_X: /* ALU_REG */
+       case BPF_ALU | BPF_RSH | BPF_X: /* ALU_REG */
+               src = ebpf_to_mips_reg(ctx, insn, src_reg_no_fp);
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (src < 0 || dst < 0)
+                       return -EINVAL;
+               td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
+               if (td == REG_64BIT || td == REG_32BIT_ZERO_EX) {
+                       /* sign extend */
+                       emit_instr(ctx, sll, dst, dst, 0);
+               }
+               did_move = false;
+               ts = get_reg_val_type(ctx, this_idx, insn->src_reg);
+               if (ts == REG_64BIT || ts == REG_32BIT_ZERO_EX) {
+                       int tmp_reg = MIPS_R_AT;
+
+                       if (BPF_OP(insn->code) == BPF_MOV) {
+                               tmp_reg = dst;
+                               did_move = true;
+                       }
+                       /* sign extend */
+                       emit_instr(ctx, sll, tmp_reg, src, 0);
+                       src = MIPS_R_AT;
+               }
+               switch (BPF_OP(insn->code)) {
+               case BPF_MOV:
+                       if (!did_move)
+                               emit_instr(ctx, addu, dst, src, MIPS_R_ZERO);
+                       break;
+               case BPF_ADD:
+                       emit_instr(ctx, addu, dst, dst, src);
+                       break;
+               case BPF_SUB:
+                       emit_instr(ctx, subu, dst, dst, src);
+                       break;
+               case BPF_XOR:
+                       emit_instr(ctx, xor, dst, dst, src);
+                       break;
+               case BPF_OR:
+                       emit_instr(ctx, or, dst, dst, src);
+                       break;
+               case BPF_AND:
+                       emit_instr(ctx, and, dst, dst, src);
+                       break;
+               case BPF_MUL:
+                       emit_instr(ctx, mul, dst, dst, src);
+                       break;
+               case BPF_DIV:
+               case BPF_MOD:
+                       b_off = b_imm(exit_idx, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, beq, src, MIPS_R_ZERO, b_off);
+                       emit_instr(ctx, movz, MIPS_R_V0, MIPS_R_ZERO, src);
+                       emit_instr(ctx, divu, dst, src);
+                       if (BPF_OP(insn->code) == BPF_DIV)
+                               emit_instr(ctx, mflo, dst);
+                       else
+                               emit_instr(ctx, mfhi, dst);
+                       break;
+               case BPF_LSH:
+                       emit_instr(ctx, sllv, dst, dst, src);
+                       break;
+               case BPF_RSH:
+                       emit_instr(ctx, srlv, dst, dst, src);
+                       break;
+               default:
+                       pr_err("ALU_REG NOT HANDLED\n");
+                       return -EINVAL;
+               }
+               break;
+       case BPF_JMP | BPF_EXIT:
+               if (this_idx + 1 < exit_idx) {
+                       b_off = b_imm(exit_idx, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, beq, MIPS_R_ZERO, MIPS_R_ZERO, b_off);
+                       emit_instr(ctx, nop);
+               }
+               break;
+       case BPF_JMP | BPF_JEQ | BPF_K: /* JMP_IMM */
+       case BPF_JMP | BPF_JNE | BPF_K: /* JMP_IMM */
+               cmp_eq = (BPF_OP(insn->code) == BPF_JEQ);
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg_fp_ok);
+               if (dst < 0)
+                       return dst;
+               if (insn->imm == 0) {
+                       src = MIPS_R_ZERO;
+               } else {
+                       gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+                       src = MIPS_R_AT;
+               }
+               goto jeq_common;
+       case BPF_JMP | BPF_JEQ | BPF_X: /* JMP_REG */
+       case BPF_JMP | BPF_JNE | BPF_X:
+       case BPF_JMP | BPF_JSGT | BPF_X:
+       case BPF_JMP | BPF_JSGE | BPF_X:
+       case BPF_JMP | BPF_JGT | BPF_X:
+       case BPF_JMP | BPF_JGE | BPF_X:
+       case BPF_JMP | BPF_JSET | BPF_X:
+               src = ebpf_to_mips_reg(ctx, insn, src_reg_no_fp);
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (src < 0 || dst < 0)
+                       return -EINVAL;
+               td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
+               ts = get_reg_val_type(ctx, this_idx, insn->src_reg);
+               if (td == REG_32BIT && ts != REG_32BIT) {
+                       emit_instr(ctx, sll, MIPS_R_AT, src, 0);
+                       src = MIPS_R_AT;
+               } else if (ts == REG_32BIT && td != REG_32BIT) {
+                       emit_instr(ctx, sll, MIPS_R_AT, dst, 0);
+                       dst = MIPS_R_AT;
+               }
+               if (BPF_OP(insn->code) == BPF_JSET) {
+                       emit_instr(ctx, and, MIPS_R_AT, dst, src);
+                       cmp_eq = false;
+                       dst = MIPS_R_AT;
+                       src = MIPS_R_ZERO;
+               } else if (BPF_OP(insn->code) == BPF_JSGT) {
+                       emit_instr(ctx, dsubu, MIPS_R_AT, dst, src);
+                       if ((insn + 1)->code == (BPF_JMP | BPF_EXIT) && insn->off == 1) {
+                               b_off = b_imm(exit_idx, ctx);
+                               if (is_bad_offset(b_off))
+                                       return -E2BIG;
+                               emit_instr(ctx, blez, MIPS_R_AT, b_off);
+                               emit_instr(ctx, nop);
+                               return 2; /* We consumed the exit. */
+                       }
+                       b_off = b_imm(this_idx + insn->off + 1, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, bgtz, MIPS_R_AT, b_off);
+                       emit_instr(ctx, nop);
+                       break;
+               } else if (BPF_OP(insn->code) == BPF_JSGE) {
+                       emit_instr(ctx, slt, MIPS_R_AT, dst, src);
+                       cmp_eq = true;
+                       dst = MIPS_R_AT;
+                       src = MIPS_R_ZERO;
+               } else if (BPF_OP(insn->code) == BPF_JGT) {
+                       /* dst or src could be AT */
+                       emit_instr(ctx, dsubu, MIPS_R_T8, dst, src);
+                       emit_instr(ctx, sltu, MIPS_R_AT, dst, src);
+                       /* SP known to be non-zero, movz becomes boolean not */
+                       emit_instr(ctx, movz, MIPS_R_T9, MIPS_R_SP, MIPS_R_T8);
+                       emit_instr(ctx, movn, MIPS_R_T9, MIPS_R_ZERO, MIPS_R_T8);
+                       emit_instr(ctx, or, MIPS_R_AT, MIPS_R_T9, MIPS_R_AT);
+                       cmp_eq = true;
+                       dst = MIPS_R_AT;
+                       src = MIPS_R_ZERO;
+               } else if (BPF_OP(insn->code) == BPF_JGE) {
+                       emit_instr(ctx, sltu, MIPS_R_AT, dst, src);
+                       cmp_eq = true;
+                       dst = MIPS_R_AT;
+                       src = MIPS_R_ZERO;
+               } else { /* JNE/JEQ case */
+                       cmp_eq = (BPF_OP(insn->code) == BPF_JEQ);
+               }
+jeq_common:
+               /*
+                * If the next insn is EXIT and we are jumping arround
+                * only it, invert the sense of the compare and
+                * conditionally jump to the exit.  Poor man's branch
+                * chaining.
+                */
+               if ((insn + 1)->code == (BPF_JMP | BPF_EXIT) && insn->off == 1) {
+                       b_off = b_imm(exit_idx, ctx);
+                       if (is_bad_offset(b_off)) {
+                               target = j_target(ctx, exit_idx);
+                               if (target == (unsigned int)-1)
+                                       return -E2BIG;
+                               cmp_eq = !cmp_eq;
+                               b_off = 4 * 3;
+                               if (!(ctx->offsets[this_idx] & OFFSETS_B_CONV)) {
+                                       ctx->offsets[this_idx] |= OFFSETS_B_CONV;
+                                       ctx->long_b_conversion = 1;
+                               }
+                       }
+
+                       if (cmp_eq)
+                               emit_instr(ctx, bne, dst, src, b_off);
+                       else
+                               emit_instr(ctx, beq, dst, src, b_off);
+                       emit_instr(ctx, nop);
+                       if (ctx->offsets[this_idx] & OFFSETS_B_CONV) {
+                               emit_instr(ctx, j, target);
+                               emit_instr(ctx, nop);
+                       }
+                       return 2; /* We consumed the exit. */
+               }
+               b_off = b_imm(this_idx + insn->off + 1, ctx);
+               if (is_bad_offset(b_off)) {
+                       target = j_target(ctx, this_idx + insn->off + 1);
+                       if (target == (unsigned int)-1)
+                               return -E2BIG;
+                       cmp_eq = !cmp_eq;
+                       b_off = 4 * 3;
+                       if (!(ctx->offsets[this_idx] & OFFSETS_B_CONV)) {
+                               ctx->offsets[this_idx] |= OFFSETS_B_CONV;
+                               ctx->long_b_conversion = 1;
+                       }
+               }
+
+               if (cmp_eq)
+                       emit_instr(ctx, beq, dst, src, b_off);
+               else
+                       emit_instr(ctx, bne, dst, src, b_off);
+               emit_instr(ctx, nop);
+               if (ctx->offsets[this_idx] & OFFSETS_B_CONV) {
+                       emit_instr(ctx, j, target);
+                       emit_instr(ctx, nop);
+               }
+               break;
+       case BPF_JMP | BPF_JSGT | BPF_K: /* JMP_IMM */
+       case BPF_JMP | BPF_JSGE | BPF_K: /* JMP_IMM */
+               cmp_eq = (BPF_OP(insn->code) == BPF_JSGE);
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg_fp_ok);
+               if (dst < 0)
+                       return dst;
+
+               if (insn->imm == 0) {
+                       if ((insn + 1)->code == (BPF_JMP | BPF_EXIT) && insn->off == 1) {
+                               b_off = b_imm(exit_idx, ctx);
+                               if (is_bad_offset(b_off))
+                                       return -E2BIG;
+                               if (cmp_eq)
+                                       emit_instr(ctx, bltz, dst, b_off);
+                               else
+                                       emit_instr(ctx, blez, dst, b_off);
+                               emit_instr(ctx, nop);
+                               return 2; /* We consumed the exit. */
+                       }
+                       b_off = b_imm(this_idx + insn->off + 1, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       if (cmp_eq)
+                               emit_instr(ctx, bgez, dst, b_off);
+                       else
+                               emit_instr(ctx, bgtz, dst, b_off);
+                       emit_instr(ctx, nop);
+                       break;
+               }
+               /*
+                * only "LT" compare available, so we must use imm + 1
+                * to generate "GT"
+                */
+               t64s = insn->imm + (cmp_eq ? 0 : 1);
+               if (t64s >= S16_MIN && t64s <= S16_MAX) {
+                       emit_instr(ctx, slti, MIPS_R_AT, dst, (int)t64s);
+                       src = MIPS_R_AT;
+                       dst = MIPS_R_ZERO;
+                       cmp_eq = true;
+                       goto jeq_common;
+               }
+               emit_const_to_reg(ctx, MIPS_R_AT, (u64)t64s);
+               emit_instr(ctx, slt, MIPS_R_AT, dst, MIPS_R_AT);
+               src = MIPS_R_AT;
+               dst = MIPS_R_ZERO;
+               cmp_eq = true;
+               goto jeq_common;
+
+       case BPF_JMP | BPF_JGT | BPF_K:
+       case BPF_JMP | BPF_JGE | BPF_K:
+               cmp_eq = (BPF_OP(insn->code) == BPF_JGE);
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg_fp_ok);
+               if (dst < 0)
+                       return dst;
+               /*
+                * only "LT" compare available, so we must use imm + 1
+                * to generate "GT"
+                */
+               t64s = (u64)(u32)(insn->imm) + (cmp_eq ? 0 : 1);
+               if (t64s >= 0 && t64s <= S16_MAX) {
+                       emit_instr(ctx, sltiu, MIPS_R_AT, dst, (int)t64s);
+                       src = MIPS_R_AT;
+                       dst = MIPS_R_ZERO;
+                       cmp_eq = true;
+                       goto jeq_common;
+               }
+               emit_const_to_reg(ctx, MIPS_R_AT, (u64)t64s);
+               emit_instr(ctx, sltu, MIPS_R_AT, dst, MIPS_R_AT);
+               src = MIPS_R_AT;
+               dst = MIPS_R_ZERO;
+               cmp_eq = true;
+               goto jeq_common;
+
+       case BPF_JMP | BPF_JSET | BPF_K: /* JMP_IMM */
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg_fp_ok);
+               if (dst < 0)
+                       return dst;
+
+               if (use_bbit_insns() && hweight32((u32)insn->imm) == 1) {
+                       if ((insn + 1)->code == (BPF_JMP | BPF_EXIT) && insn->off == 1) {
+                               b_off = b_imm(exit_idx, ctx);
+                               if (is_bad_offset(b_off))
+                                       return -E2BIG;
+                               emit_instr(ctx, bbit0, dst, ffs((u32)insn->imm) - 1, b_off);
+                               emit_instr(ctx, nop);
+                               return 2; /* We consumed the exit. */
+                       }
+                       b_off = b_imm(this_idx + insn->off + 1, ctx);
+                       if (is_bad_offset(b_off))
+                               return -E2BIG;
+                       emit_instr(ctx, bbit1, dst, ffs((u32)insn->imm) - 1, b_off);
+                       emit_instr(ctx, nop);
+                       break;
+               }
+               t64 = (u32)insn->imm;
+               emit_const_to_reg(ctx, MIPS_R_AT, t64);
+               emit_instr(ctx, and, MIPS_R_AT, dst, MIPS_R_AT);
+               src = MIPS_R_AT;
+               dst = MIPS_R_ZERO;
+               cmp_eq = false;
+               goto jeq_common;
+
+       case BPF_JMP | BPF_JA:
+               /*
+                * Prefer relative branch for easier debugging, but
+                * fall back if needed.
+                */
+               b_off = b_imm(this_idx + insn->off + 1, ctx);
+               if (is_bad_offset(b_off)) {
+                       target = j_target(ctx, this_idx + insn->off + 1);
+                       if (target == (unsigned int)-1)
+                               return -E2BIG;
+                       emit_instr(ctx, j, target);
+               } else {
+                       emit_instr(ctx, b, b_off);
+               }
+               emit_instr(ctx, nop);
+               break;
+       case BPF_LD | BPF_DW | BPF_IMM:
+               if (insn->src_reg != 0)
+                       return -EINVAL;
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               t64 = ((u64)(u32)insn->imm) | ((u64)(insn + 1)->imm << 32);
+               emit_const_to_reg(ctx, dst, t64);
+               return 2; /* Double slot insn */
+
+       case BPF_JMP | BPF_CALL:
+               ctx->flags |= EBPF_SAVE_RA;
+               t64s = (s64)insn->imm + (s64)__bpf_call_base;
+               emit_const_to_reg(ctx, MIPS_R_T9, (u64)t64s);
+               emit_instr(ctx, jalr, MIPS_R_RA, MIPS_R_T9);
+               /* delay slot */
+               emit_instr(ctx, nop);
+               break;
+
+       case BPF_JMP | BPF_TAIL_CALL:
+               if (emit_bpf_tail_call(ctx, this_idx))
+                       return -EINVAL;
+               break;
+
+       case BPF_LD | BPF_B | BPF_ABS:
+       case BPF_LD | BPF_H | BPF_ABS:
+       case BPF_LD | BPF_W | BPF_ABS:
+       case BPF_LD | BPF_DW | BPF_ABS:
+               ctx->flags |= EBPF_SAVE_RA;
+
+               gen_imm_to_reg(insn, MIPS_R_A1, ctx);
+               emit_instr(ctx, addiu, MIPS_R_A2, MIPS_R_ZERO, size_to_len(insn));
+
+               if (insn->imm < 0) {
+                       emit_const_to_reg(ctx, MIPS_R_T9, (u64)bpf_internal_load_pointer_neg_helper);
+               } else {
+                       emit_const_to_reg(ctx, MIPS_R_T9, (u64)ool_skb_header_pointer);
+                       emit_instr(ctx, daddiu, MIPS_R_A3, MIPS_R_SP, ctx->tmp_offset);
+               }
+               goto ld_skb_common;
+
+       case BPF_LD | BPF_B | BPF_IND:
+       case BPF_LD | BPF_H | BPF_IND:
+       case BPF_LD | BPF_W | BPF_IND:
+       case BPF_LD | BPF_DW | BPF_IND:
+               ctx->flags |= EBPF_SAVE_RA;
+               src = ebpf_to_mips_reg(ctx, insn, src_reg_no_fp);
+               if (src < 0)
+                       return src;
+               ts = get_reg_val_type(ctx, this_idx, insn->src_reg);
+               if (ts == REG_32BIT_ZERO_EX) {
+                       /* sign extend */
+                       emit_instr(ctx, sll, MIPS_R_A1, src, 0);
+                       src = MIPS_R_A1;
+               }
+               if (insn->imm >= S16_MIN && insn->imm <= S16_MAX) {
+                       emit_instr(ctx, daddiu, MIPS_R_A1, src, insn->imm);
+               } else {
+                       gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+                       emit_instr(ctx, daddu, MIPS_R_A1, MIPS_R_AT, src);
+               }
+               /* truncate to 32-bit int */
+               emit_instr(ctx, sll, MIPS_R_A1, MIPS_R_A1, 0);
+               emit_instr(ctx, daddiu, MIPS_R_A3, MIPS_R_SP, ctx->tmp_offset);
+               emit_instr(ctx, slt, MIPS_R_AT, MIPS_R_A1, MIPS_R_ZERO);
+
+               emit_const_to_reg(ctx, MIPS_R_T8, (u64)bpf_internal_load_pointer_neg_helper);
+               emit_const_to_reg(ctx, MIPS_R_T9, (u64)ool_skb_header_pointer);
+               emit_instr(ctx, addiu, MIPS_R_A2, MIPS_R_ZERO, size_to_len(insn));
+               emit_instr(ctx, movn, MIPS_R_T9, MIPS_R_T8, MIPS_R_AT);
+
+ld_skb_common:
+               emit_instr(ctx, jalr, MIPS_R_RA, MIPS_R_T9);
+               /* delay slot move */
+               emit_instr(ctx, daddu, MIPS_R_A0, MIPS_R_S0, MIPS_R_ZERO);
+
+               /* Check the error value */
+               b_off = b_imm(exit_idx, ctx);
+               if (is_bad_offset(b_off)) {
+                       target = j_target(ctx, exit_idx);
+                       if (target == (unsigned int)-1)
+                               return -E2BIG;
+
+                       if (!(ctx->offsets[this_idx] & OFFSETS_B_CONV)) {
+                               ctx->offsets[this_idx] |= OFFSETS_B_CONV;
+                               ctx->long_b_conversion = 1;
+                       }
+                       emit_instr(ctx, bne, MIPS_R_V0, MIPS_R_ZERO, 4 * 3);
+                       emit_instr(ctx, nop);
+                       emit_instr(ctx, j, target);
+                       emit_instr(ctx, nop);
+               } else {
+                       emit_instr(ctx, beq, MIPS_R_V0, MIPS_R_ZERO, b_off);
+                       emit_instr(ctx, nop);
+               }
+
+#ifdef __BIG_ENDIAN
+               need_swap = false;
+#else
+               need_swap = true;
+#endif
+               dst = MIPS_R_V0;
+               switch (BPF_SIZE(insn->code)) {
+               case BPF_B:
+                       emit_instr(ctx, lbu, dst, 0, MIPS_R_V0);
+                       break;
+               case BPF_H:
+                       emit_instr(ctx, lhu, dst, 0, MIPS_R_V0);
+                       if (need_swap)
+                               emit_instr(ctx, wsbh, dst, dst);
+                       break;
+               case BPF_W:
+                       emit_instr(ctx, lw, dst, 0, MIPS_R_V0);
+                       if (need_swap) {
+                               emit_instr(ctx, wsbh, dst, dst);
+                               emit_instr(ctx, rotr, dst, dst, 16);
+                       }
+                       break;
+               case BPF_DW:
+                       emit_instr(ctx, ld, dst, 0, MIPS_R_V0);
+                       if (need_swap) {
+                               emit_instr(ctx, dsbh, dst, dst);
+                               emit_instr(ctx, dshd, dst, dst);
+                       }
+                       break;
+               }
+
+               break;
+       case BPF_ALU | BPF_END | BPF_FROM_BE:
+       case BPF_ALU | BPF_END | BPF_FROM_LE:
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               td = get_reg_val_type(ctx, this_idx, insn->dst_reg);
+               if (insn->imm == 64 && td == REG_32BIT)
+                       emit_instr(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
+
+               if (insn->imm != 64 &&
+                   (td == REG_64BIT || td == REG_32BIT_ZERO_EX)) {
+                       /* sign extend */
+                       emit_instr(ctx, sll, dst, dst, 0);
+               }
+
+#ifdef __BIG_ENDIAN
+               need_swap = (BPF_SRC(insn->code) == BPF_FROM_LE);
+#else
+               need_swap = (BPF_SRC(insn->code) == BPF_FROM_BE);
+#endif
+               if (insn->imm == 16) {
+                       if (need_swap)
+                               emit_instr(ctx, wsbh, dst, dst);
+                       emit_instr(ctx, andi, dst, dst, 0xffff);
+               } else if (insn->imm == 32) {
+                       if (need_swap) {
+                               emit_instr(ctx, wsbh, dst, dst);
+                               emit_instr(ctx, rotr, dst, dst, 16);
+                       }
+               } else { /* 64-bit*/
+                       if (need_swap) {
+                               emit_instr(ctx, dsbh, dst, dst);
+                               emit_instr(ctx, dshd, dst, dst);
+                       }
+               }
+               break;
+
+       case BPF_ST | BPF_B | BPF_MEM:
+       case BPF_ST | BPF_H | BPF_MEM:
+       case BPF_ST | BPF_W | BPF_MEM:
+       case BPF_ST | BPF_DW | BPF_MEM:
+               if (insn->dst_reg == BPF_REG_10) {
+                       ctx->flags |= EBPF_SEEN_FP;
+                       dst = MIPS_R_SP;
+                       mem_off = insn->off + MAX_BPF_STACK;
+               } else {
+                       dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+                       if (dst < 0)
+                               return dst;
+                       mem_off = insn->off;
+               }
+               gen_imm_to_reg(insn, MIPS_R_AT, ctx);
+               switch (BPF_SIZE(insn->code)) {
+               case BPF_B:
+                       emit_instr(ctx, sb, MIPS_R_AT, mem_off, dst);
+                       break;
+               case BPF_H:
+                       emit_instr(ctx, sh, MIPS_R_AT, mem_off, dst);
+                       break;
+               case BPF_W:
+                       emit_instr(ctx, sw, MIPS_R_AT, mem_off, dst);
+                       break;
+               case BPF_DW:
+                       emit_instr(ctx, sd, MIPS_R_AT, mem_off, dst);
+                       break;
+               }
+               break;
+
+       case BPF_LDX | BPF_B | BPF_MEM:
+       case BPF_LDX | BPF_H | BPF_MEM:
+       case BPF_LDX | BPF_W | BPF_MEM:
+       case BPF_LDX | BPF_DW | BPF_MEM:
+               if (insn->src_reg == BPF_REG_10) {
+                       ctx->flags |= EBPF_SEEN_FP;
+                       src = MIPS_R_SP;
+                       mem_off = insn->off + MAX_BPF_STACK;
+               } else {
+                       src = ebpf_to_mips_reg(ctx, insn, src_reg_no_fp);
+                       if (src < 0)
+                               return src;
+                       mem_off = insn->off;
+               }
+               dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+               if (dst < 0)
+                       return dst;
+               switch (BPF_SIZE(insn->code)) {
+               case BPF_B:
+                       emit_instr(ctx, lbu, dst, mem_off, src);
+                       break;
+               case BPF_H:
+                       emit_instr(ctx, lhu, dst, mem_off, src);
+                       break;
+               case BPF_W:
+                       emit_instr(ctx, lw, dst, mem_off, src);
+                       break;
+               case BPF_DW:
+                       emit_instr(ctx, ld, dst, mem_off, src);
+                       break;
+               }
+               break;
+
+       case BPF_STX | BPF_B | BPF_MEM:
+       case BPF_STX | BPF_H | BPF_MEM:
+       case BPF_STX | BPF_W | BPF_MEM:
+       case BPF_STX | BPF_DW | BPF_MEM:
+       case BPF_STX | BPF_W | BPF_XADD:
+       case BPF_STX | BPF_DW | BPF_XADD:
+               if (insn->dst_reg == BPF_REG_10) {
+                       ctx->flags |= EBPF_SEEN_FP;
+                       dst = MIPS_R_SP;
+                       mem_off = insn->off + MAX_BPF_STACK;
+               } else {
+                       dst = ebpf_to_mips_reg(ctx, insn, dst_reg);
+                       if (dst < 0)
+                               return dst;
+                       mem_off = insn->off;
+               }
+               src = ebpf_to_mips_reg(ctx, insn, src_reg_no_fp);
+               if (src < 0)
+                       return dst;
+               if (BPF_MODE(insn->code) == BPF_XADD) {
+                       switch (BPF_SIZE(insn->code)) {
+                       case BPF_W:
+                               if (get_reg_val_type(ctx, this_idx, insn->src_reg) == REG_32BIT) {
+                                       emit_instr(ctx, sll, MIPS_R_AT, src, 0);
+                                       src = MIPS_R_AT;
+                               }
+                               emit_instr(ctx, ll, MIPS_R_T8, mem_off, dst);
+                               emit_instr(ctx, addu, MIPS_R_T8, MIPS_R_T8, src);
+                               emit_instr(ctx, sc, MIPS_R_T8, mem_off, dst);
+                               /*
+                                * On failure back up to LL (-4
+                                * instructions of 4 bytes each
+                                */
+                               emit_instr(ctx, beq, MIPS_R_T8, MIPS_R_ZERO, -4 * 4);
+                               emit_instr(ctx, nop);
+                               break;
+                       case BPF_DW:
+                               if (get_reg_val_type(ctx, this_idx, insn->src_reg) == REG_32BIT) {
+                                       emit_instr(ctx, daddu, MIPS_R_AT, src, MIPS_R_ZERO);
+                                       emit_instr(ctx, dinsu, MIPS_R_AT, MIPS_R_ZERO, 32, 32);
+                                       src = MIPS_R_AT;
+                               }
+                               emit_instr(ctx, lld, MIPS_R_T8, mem_off, dst);
+                               emit_instr(ctx, daddu, MIPS_R_T8, MIPS_R_T8, src);
+                               emit_instr(ctx, scd, MIPS_R_T8, mem_off, dst);
+                               emit_instr(ctx, beq, MIPS_R_T8, MIPS_R_ZERO, -4 * 4);
+                               emit_instr(ctx, nop);
+                               break;
+                       }
+               } else { /* BPF_MEM */
+                       switch (BPF_SIZE(insn->code)) {
+                       case BPF_B:
+                               emit_instr(ctx, sb, src, mem_off, dst);
+                               break;
+                       case BPF_H:
+                               emit_instr(ctx, sh, src, mem_off, dst);
+                               break;
+                       case BPF_W:
+                               emit_instr(ctx, sw, src, mem_off, dst);
+                               break;
+                       case BPF_DW:
+                               if (get_reg_val_type(ctx, this_idx, insn->src_reg) == REG_32BIT) {
+                                       emit_instr(ctx, daddu, MIPS_R_AT, src, MIPS_R_ZERO);
+                                       emit_instr(ctx, dinsu, MIPS_R_AT, MIPS_R_ZERO, 32, 32);
+                                       src = MIPS_R_AT;
+                               }
+                               emit_instr(ctx, sd, src, mem_off, dst);
+                               break;
+                       }
+               }
+               break;
+
+       default:
+               pr_err("NOT HANDLED %d - (%02x)\n",
+                      this_idx, (unsigned int)insn->code);
+               return -EINVAL;
+       }
+       return 1;
+}
+
+#define RVT_VISITED_MASK 0xc000000000000000ull
+#define RVT_FALL_THROUGH 0x4000000000000000ull
+#define RVT_BRANCH_TAKEN 0x8000000000000000ull
+#define RVT_DONE (RVT_FALL_THROUGH | RVT_BRANCH_TAKEN)
+
+static int build_int_body(struct jit_ctx *ctx)
+{
+       const struct bpf_prog *prog = ctx->skf;
+       const struct bpf_insn *insn;
+       int i, r;
+
+       for (i = 0; i < prog->len; ) {
+               insn = prog->insnsi + i;
+               if ((ctx->reg_val_types[i] & RVT_VISITED_MASK) == 0) {
+                       /* dead instruction, don't emit it. */
+                       i++;
+                       continue;
+               }
+
+               if (ctx->target == NULL)
+                       ctx->offsets[i] = (ctx->offsets[i] & OFFSETS_B_CONV) | (ctx->idx * 4);
+
+               r = build_one_insn(insn, ctx, i, prog->len);
+               if (r < 0)
+                       return r;
+               i += r;
+       }
+       /* epilogue offset */
+       if (ctx->target == NULL)
+               ctx->offsets[i] = ctx->idx * 4;
+
+       /*
+        * All exits have an offset of the epilogue, some offsets may
+        * not have been set due to banch-around threading, so set
+        * them now.
+        */
+       if (ctx->target == NULL)
+               for (i = 0; i < prog->len; i++) {
+                       insn = prog->insnsi + i;
+                       if (insn->code == (BPF_JMP | BPF_EXIT))
+                               ctx->offsets[i] = ctx->idx * 4;
+               }
+       return 0;
+}
+
+/* return the last idx processed, or negative for error */
+static int reg_val_propagate_range(struct jit_ctx *ctx, u64 initial_rvt,
+                                  int start_idx, bool follow_taken)
+{
+       const struct bpf_prog *prog = ctx->skf;
+       const struct bpf_insn *insn;
+       u64 exit_rvt = initial_rvt;
+       u64 *rvt = ctx->reg_val_types;
+       int idx;
+       int reg;
+
+       for (idx = start_idx; idx < prog->len; idx++) {
+               rvt[idx] = (rvt[idx] & RVT_VISITED_MASK) | exit_rvt;
+               insn = prog->insnsi + idx;
+               switch (BPF_CLASS(insn->code)) {
+               case BPF_ALU:
+                       switch (BPF_OP(insn->code)) {
+                       case BPF_ADD:
+                       case BPF_SUB:
+                       case BPF_MUL:
+                       case BPF_DIV:
+                       case BPF_OR:
+                       case BPF_AND:
+                       case BPF_LSH:
+                       case BPF_RSH:
+                       case BPF_NEG:
+                       case BPF_MOD:
+                       case BPF_XOR:
+                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT);
+                               break;
+                       case BPF_MOV:
+                               if (BPF_SRC(insn->code)) {
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT);
+                               } else {
+                                       /* IMM to REG move*/
+                                       if (insn->imm >= 0)
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT_POS);
+                                       else
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT);
+                               }
+                               break;
+                       case BPF_END:
+                               if (insn->imm == 64)
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT);
+                               else if (insn->imm == 32)
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT);
+                               else /* insn->imm == 16 */
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT_POS);
+                               break;
+                       }
+                       rvt[idx] |= RVT_DONE;
+                       break;
+               case BPF_ALU64:
+                       switch (BPF_OP(insn->code)) {
+                       case BPF_MOV:
+                               if (BPF_SRC(insn->code)) {
+                                       /* REG to REG move*/
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT);
+                               } else {
+                                       /* IMM to REG move*/
+                                       if (insn->imm >= 0)
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT_POS);
+                                       else
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT_32BIT);
+                               }
+                               break;
+                       default:
+                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT);
+                       }
+                       rvt[idx] |= RVT_DONE;
+                       break;
+               case BPF_LD:
+                       switch (BPF_SIZE(insn->code)) {
+                       case BPF_DW:
+                               if (BPF_MODE(insn->code) == BPF_IMM) {
+                                       s64 val;
+
+                                       val = (s64)((u32)insn->imm | ((u64)(insn + 1)->imm << 32));
+                                       if (val > 0 && val <= S32_MAX)
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT_POS);
+                                       else if (val >= S32_MIN && val <= S32_MAX)
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT_32BIT);
+                                       else
+                                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT);
+                                       rvt[idx] |= RVT_DONE;
+                                       idx++;
+                               } else {
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT);
+                               }
+                               break;
+                       case BPF_B:
+                       case BPF_H:
+                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT_POS);
+                               break;
+                       case BPF_W:
+                               if (BPF_MODE(insn->code) == BPF_IMM)
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg,
+                                                        insn->imm >= 0 ? REG_32BIT_POS : REG_32BIT);
+                               else
+                                       set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT);
+                               break;
+                       }
+                       rvt[idx] |= RVT_DONE;
+                       break;
+               case BPF_LDX:
+                       switch (BPF_SIZE(insn->code)) {
+                       case BPF_DW:
+                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_64BIT);
+                               break;
+                       case BPF_B:
+                       case BPF_H:
+                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT_POS);
+                               break;
+                       case BPF_W:
+                               set_reg_val_type(&exit_rvt, insn->dst_reg, REG_32BIT);
+                               break;
+                       }
+                       rvt[idx] |= RVT_DONE;
+                       break;
+               case BPF_JMP:
+                       switch (BPF_OP(insn->code)) {
+                       case BPF_EXIT:
+                               rvt[idx] = RVT_DONE | exit_rvt;
+                               rvt[prog->len] = exit_rvt;
+                               return idx;
+                       case BPF_JA:
+                               rvt[idx] |= RVT_DONE;
+                               idx += insn->off;
+                               break;
+                       case BPF_JEQ:
+                       case BPF_JGT:
+                       case BPF_JGE:
+                       case BPF_JSET:
+                       case BPF_JNE:
+                       case BPF_JSGT:
+                       case BPF_JSGE:
+                               if (follow_taken) {
+                                       rvt[idx] |= RVT_BRANCH_TAKEN;
+                                       idx += insn->off;
+                                       follow_taken = false;
+                               } else {
+                                       rvt[idx] |= RVT_FALL_THROUGH;
+                               }
+                               break;
+                       case BPF_CALL:
+                               set_reg_val_type(&exit_rvt, BPF_REG_0, REG_64BIT);
+                               /* Upon call return, argument registers are clobbered. */
+                               for (reg = BPF_REG_0; reg <= BPF_REG_5; reg++)
+                                       set_reg_val_type(&exit_rvt, reg, REG_64BIT);
+
+                               rvt[idx] |= RVT_DONE;
+                               break;
+                       default:
+                               WARN(1, "Unhandled BPF_JMP case.\n");
+                               rvt[idx] |= RVT_DONE;
+                               break;
+                       }
+                       break;
+               default:
+                       rvt[idx] |= RVT_DONE;
+                       break;
+               }
+       }
+       return idx;
+}
+
+/*
+ * Track the value range (i.e. 32-bit vs. 64-bit) of each register at
+ * each eBPF insn.  This allows unneeded sign and zero extension
+ * operations to be omitted.
+ *
+ * Doesn't handle yet confluence of control paths with conflicting
+ * ranges, but it is good enough for most sane code.
+ */
+static int reg_val_propagate(struct jit_ctx *ctx)
+{
+       const struct bpf_prog *prog = ctx->skf;
+       u64 exit_rvt;
+       int reg;
+       int i;
+
+       /*
+        * 11 registers * 3 bits/reg leaves top bits free for other
+        * uses.  Bit-62..63 used to see if we have visited an insn.
+        */
+       exit_rvt = 0;
+
+       /* Upon entry, argument registers are 64-bit. */
+       for (reg = BPF_REG_1; reg <= BPF_REG_5; reg++)
+               set_reg_val_type(&exit_rvt, reg, REG_64BIT);
+
+       /*
+        * First follow all conditional branches on the fall-through
+        * edge of control flow..
+        */
+       reg_val_propagate_range(ctx, exit_rvt, 0, false);
+restart_search:
+       /*
+        * Then repeatedly find the first conditional branch where
+        * both edges of control flow have not been taken, and follow
+        * the branch taken edge.  We will end up restarting the
+        * search once per conditional branch insn.
+        */
+       for (i = 0; i < prog->len; i++) {
+               u64 rvt = ctx->reg_val_types[i];
+
+               if ((rvt & RVT_VISITED_MASK) == RVT_DONE ||
+                   (rvt & RVT_VISITED_MASK) == 0)
+                       continue;
+               if ((rvt & RVT_VISITED_MASK) == RVT_FALL_THROUGH) {
+                       reg_val_propagate_range(ctx, rvt & ~RVT_VISITED_MASK, i, true);
+               } else { /* RVT_BRANCH_TAKEN */
+                       WARN(1, "Unexpected RVT_BRANCH_TAKEN case.\n");
+                       reg_val_propagate_range(ctx, rvt & ~RVT_VISITED_MASK, i, false);
+               }
+               goto restart_search;
+       }
+       /*
+        * Eventually all conditional branches have been followed on
+        * both branches and we are done.  Any insn that has not been
+        * visited at this point is dead.
+        */
+
+       return 0;
+}
+
+static void jit_fill_hole(void *area, unsigned int size)
+{
+       u32 *p;
+
+       /* We are guaranteed to have aligned memory. */
+       for (p = area; size >= sizeof(u32); size -= sizeof(u32))
+               uasm_i_break(&p, BRK_BUG); /* Increments p */
+}
+
+struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
+{
+       struct bpf_prog *orig_prog = prog;
+       bool tmp_blinded = false;
+       struct bpf_prog *tmp;
+       struct bpf_binary_header *header = NULL;
+       struct jit_ctx ctx;
+       unsigned int image_size;
+       u8 *image_ptr;
+
+       if (!bpf_jit_enable || !cpu_has_mips64r2)
+               return prog;
+
+       tmp = bpf_jit_blind_constants(prog);
+       /* If blinding was requested and we failed during blinding,
+        * we must fall back to the interpreter.
+        */
+       if (IS_ERR(tmp))
+               return orig_prog;
+       if (tmp != prog) {
+               tmp_blinded = true;
+               prog = tmp;
+       }
+
+       memset(&ctx, 0, sizeof(ctx));
+
+       ctx.offsets = kcalloc(prog->len + 1, sizeof(*ctx.offsets), GFP_KERNEL);
+       if (ctx.offsets == NULL)
+               goto out_err;
+
+       ctx.reg_val_types = kcalloc(prog->len + 1, sizeof(*ctx.reg_val_types), GFP_KERNEL);
+       if (ctx.reg_val_types == NULL)
+               goto out_err;
+
+       ctx.skf = prog;
+
+       if (reg_val_propagate(&ctx))
+               goto out_err;
+
+       /*
+        * First pass discovers used resources and instruction offsets
+        * assuming short branches are used.
+        */
+       if (build_int_body(&ctx))
+               goto out_err;
+
+       /*
+        * If no calls are made (EBPF_SAVE_RA), then tail call count
+        * in $v1, else we must save in n$s4.
+        */
+       if (ctx.flags & EBPF_SEEN_TC) {
+               if (ctx.flags & EBPF_SAVE_RA)
+                       ctx.flags |= EBPF_SAVE_S4;
+               else
+                       ctx.flags |= EBPF_TCC_IN_V1;
+       }
+
+       /*
+        * Second pass generates offsets, if any branches are out of
+        * range a jump-around long sequence is generated, and we have
+        * to try again from the beginning to generate the new
+        * offsets.  This is done until no additional conversions are
+        * necessary.
+        */
+       do {
+               ctx.idx = 0;
+               ctx.gen_b_offsets = 1;
+               ctx.long_b_conversion = 0;
+               if (gen_int_prologue(&ctx))
+                       goto out_err;
+               if (build_int_body(&ctx))
+                       goto out_err;
+               if (build_int_epilogue(&ctx, MIPS_R_RA))
+                       goto out_err;
+       } while (ctx.long_b_conversion);
+
+       image_size = 4 * ctx.idx;
+
+       header = bpf_jit_binary_alloc(image_size, &image_ptr,
+                                     sizeof(u32), jit_fill_hole);
+       if (header == NULL)
+               goto out_err;
+
+       ctx.target = (u32 *)image_ptr;
+
+       /* Third pass generates the code */
+       ctx.idx = 0;
+       if (gen_int_prologue(&ctx))
+               goto out_err;
+       if (build_int_body(&ctx))
+               goto out_err;
+       if (build_int_epilogue(&ctx, MIPS_R_RA))
+               goto out_err;
+
+       /* Update the icache */
+       flush_icache_range((unsigned long)ctx.target,
+                          (unsigned long)(ctx.target + ctx.idx * sizeof(u32)));
+
+       if (bpf_jit_enable > 1)
+               /* Dump JIT code */
+               bpf_jit_dump(prog->len, image_size, 2, ctx.target);
+
+       bpf_jit_binary_lock_ro(header);
+       prog->bpf_func = (void *)ctx.target;
+       prog->jited = 1;
+       prog->jited_len = image_size;
+out_normal:
+       if (tmp_blinded)
+               bpf_jit_prog_release_other(prog, prog == orig_prog ?
+                                          tmp : orig_prog);
+       kfree(ctx.offsets);
+       kfree(ctx.reg_val_types);
+
+       return prog;
+
+out_err:
+       prog = orig_prog;
+       if (header)
+               bpf_jit_binary_free(header);
+       goto out_normal;
+}
index bd67ac74fe2d3420509a03647a20856341bb70c8..9632436d74d7a74b3d584ab6e87a1fc7e55827cc 100644 (file)
@@ -28,16 +28,15 @@ EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
 
 static int __init pcibios_set_cache_line_size(void)
 {
-       struct cpuinfo_mips *c = &current_cpu_data;
        unsigned int lsize;
 
        /*
         * Set PCI cacheline size to that of the highest level in the
         * cache hierarchy.
         */
-       lsize = c->dcache.linesz;
-       lsize = c->scache.linesz ? : lsize;
-       lsize = c->tcache.linesz ? : lsize;
+       lsize = cpu_dcache_line_size();
+       lsize = cpu_scache_line_size() ? : lsize;
+       lsize = cpu_tcache_line_size() ? : lsize;
 
        BUG_ON(!lsize);
 
index 974276e828b2cdd3eecb07493f480a8779da2d41..e2690d7ca4ddd992e69fffe802cac6355ad14de8 100644 (file)
@@ -35,7 +35,8 @@ static __always_inline long gettimeofday_fallback(struct timeval *_tv,
        "       syscall\n"
        : "=r" (ret), "=r" (error)
        : "r" (tv), "r" (tz), "r" (nr)
-       : "memory");
+       : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+         "$14", "$15", "$24", "$25", "hi", "lo", "memory");
 
        return error ? -ret : ret;
 }
@@ -55,7 +56,8 @@ static __always_inline long clock_gettime_fallback(clockid_t _clkid,
        "       syscall\n"
        : "=r" (ret), "=r" (error)
        : "r" (clkid), "r" (ts), "r" (nr)
-       : "memory");
+       : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13",
+         "$14", "$15", "$24", "$25", "hi", "lo", "memory");
 
        return error ? -ret : ret;
 }
index 36f858c37ca70b576e851a52ada48e2400de86a1..81b0031f909f6d65855ed3051505a4baa9469a64 100644 (file)
@@ -199,7 +199,7 @@ config PPC
        select HAVE_OPTPROBES                   if PPC64
        select HAVE_PERF_EVENTS
        select HAVE_PERF_EVENTS_NMI             if PPC64
-       select HAVE_HARDLOCKUP_DETECTOR_PERF    if HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
+       select HAVE_HARDLOCKUP_DETECTOR_PERF    if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
        select HAVE_PERF_REGS
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_RCU_TABLE_FREE              if SMP
index 0695ce047d565199e4501333fa41ece48cdf9e45..34fc9bbfca9e68d6372e1d34b79ebf95d978e685 100644 (file)
@@ -293,7 +293,8 @@ CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
 CONFIG_DEBUG_STACK_USAGE=y
 CONFIG_DEBUG_STACKOVERFLOW=y
-CONFIG_LOCKUP_DETECTOR=y
+CONFIG_SOFTLOCKUP_DETECTOR=y
+CONFIG_HARDLOCKUP_DETECTOR=y
 CONFIG_LATENCYTOP=y
 CONFIG_SCHED_TRACER=y
 CONFIG_BLK_DEV_IO_TRACE=y
index 5175028c56ce74e3e50a2b30eabccf7b87ed8f0e..c5246d29f3859965316bd4d48e4e816283439bf0 100644 (file)
@@ -324,7 +324,8 @@ CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
 CONFIG_DEBUG_STACK_USAGE=y
 CONFIG_DEBUG_STACKOVERFLOW=y
-CONFIG_LOCKUP_DETECTOR=y
+CONFIG_SOFTLOCKUP_DETECTOR=y
+CONFIG_HARDLOCKUP_DETECTOR=y
 CONFIG_DEBUG_MUTEXES=y
 CONFIG_LATENCYTOP=y
 CONFIG_SCHED_TRACER=y
index 1a61aa20dfbac9d5072ae83ef90640b8be380bd3..fd5d98a0b95c7b1ae5fda56892c2ecd43ea29f3a 100644 (file)
@@ -291,7 +291,8 @@ CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_KERNEL=y
 CONFIG_DEBUG_STACK_USAGE=y
 CONFIG_DEBUG_STACKOVERFLOW=y
-CONFIG_LOCKUP_DETECTOR=y
+CONFIG_SOFTLOCKUP_DETECTOR=y
+CONFIG_HARDLOCKUP_DETECTOR=y
 CONFIG_LATENCYTOP=y
 CONFIG_SCHED_TRACER=y
 CONFIG_BLK_DEV_IO_TRACE=y
index 8b3f1238d07f18eda49eb9326934427cf2d83736..e372ed871c513b00e78f69898601c598ee5a026b 100644 (file)
@@ -67,11 +67,6 @@ extern int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
 extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 
-static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
-                                                        unsigned long address)
-{
-}
-
 #define HPTEG_CACHE_NUM                        (1 << 15)
 #define HPTEG_HASH_BITS_PTE            13
 #define HPTEG_HASH_BITS_PTE_LONG       12
index 0c76675394c5930d5cecf2ac01a2718c8e9b6c1f..35bec1c5bd5aa63567be4847c2073be53fa0390c 100644 (file)
@@ -90,6 +90,24 @@ static inline void switch_mm_irqs_off(struct mm_struct *prev,
        /* Mark this context has been used on the new CPU */
        if (!cpumask_test_cpu(smp_processor_id(), mm_cpumask(next))) {
                cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
+
+               /*
+                * This full barrier orders the store to the cpumask above vs
+                * a subsequent operation which allows this CPU to begin loading
+                * translations for next.
+                *
+                * When using the radix MMU that operation is the load of the
+                * MMU context id, which is then moved to SPRN_PID.
+                *
+                * For the hash MMU it is either the first load from slb_cache
+                * in switch_slb(), and/or the store of paca->mm_ctx_id in
+                * copy_mm_to_paca().
+                *
+                * On the read side the barrier is in pte_xchg(), which orders
+                * the store to the PTE vs the load of mm_cpumask.
+                */
+               smp_mb();
+
                new_on_cpu = true;
        }
 
index 9c0f5db5cf461a92e72185701b4cbc1df168dfcc..67e7e3d990f44ef495ee02b6fcb3ba16053bd5c5 100644 (file)
@@ -87,6 +87,7 @@ static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
        unsigned long *p = (unsigned long *)ptep;
        __be64 prev;
 
+       /* See comment in switch_mm_irqs_off() */
        prev = (__force __be64)__cmpxchg_u64(p, (__force unsigned long)pte_raw(old),
                                             (__force unsigned long)pte_raw(new));
 
index 8bd3b13fe2fb2e8bd1c5762c4e080c9cd921edaa..369a164b545c09087e0740fd6c32ea282a7b5245 100644 (file)
@@ -62,6 +62,7 @@ static inline bool pte_xchg(pte_t *ptep, pte_t old, pte_t new)
 {
        unsigned long *p = (unsigned long *)ptep;
 
+       /* See comment in switch_mm_irqs_off() */
        return pte_val(old) == __cmpxchg_u64(p, pte_val(old), pte_val(new));
 }
 #endif
index 49d8422767b4de686ec0ee64fbf69ac415f05003..e925c1c99c71cab982967e7f7df6325e3135506f 100644 (file)
@@ -223,17 +223,27 @@ system_call_exit:
        andi.   r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
        bne-    .Lsyscall_exit_work
 
-       /* If MSR_FP and MSR_VEC are set in user msr, then no need to restore */
-       li      r7,MSR_FP
+       andi.   r0,r8,MSR_FP
+       beq 2f
 #ifdef CONFIG_ALTIVEC
-       oris    r7,r7,MSR_VEC@h
+       andis.  r0,r8,MSR_VEC@h
+       bne     3f
 #endif
-       and     r0,r8,r7
-       cmpd    r0,r7
-       bne     .Lsyscall_restore_math
-.Lsyscall_restore_math_cont:
+2:     addi    r3,r1,STACK_FRAME_OVERHEAD
+#ifdef CONFIG_PPC_BOOK3S
+       li      r10,MSR_RI
+       mtmsrd  r10,1           /* Restore RI */
+#endif
+       bl      restore_math
+#ifdef CONFIG_PPC_BOOK3S
+       li      r11,0
+       mtmsrd  r11,1
+#endif
+       ld      r8,_MSR(r1)
+       ld      r3,RESULT(r1)
+       li      r11,-MAX_ERRNO
 
-       cmpld   r3,r11
+3:     cmpld   r3,r11
        ld      r5,_CCR(r1)
        bge-    .Lsyscall_error
 .Lsyscall_error_cont:
@@ -267,40 +277,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
        std     r5,_CCR(r1)
        b       .Lsyscall_error_cont
 
-.Lsyscall_restore_math:
-       /*
-        * Some initial tests from restore_math to avoid the heavyweight
-        * C code entry and MSR manipulations.
-        */
-       LOAD_REG_IMMEDIATE(r0, MSR_TS_MASK)
-       and.    r0,r0,r8
-       bne     1f
-
-       ld      r7,PACACURRENT(r13)
-       lbz     r0,THREAD+THREAD_LOAD_FP(r7)
-#ifdef CONFIG_ALTIVEC
-       lbz     r6,THREAD+THREAD_LOAD_VEC(r7)
-       add     r0,r0,r6
-#endif
-       cmpdi   r0,0
-       beq     .Lsyscall_restore_math_cont
-
-1:     addi    r3,r1,STACK_FRAME_OVERHEAD
-#ifdef CONFIG_PPC_BOOK3S
-       li      r10,MSR_RI
-       mtmsrd  r10,1           /* Restore RI */
-#endif
-       bl      restore_math
-#ifdef CONFIG_PPC_BOOK3S
-       li      r11,0
-       mtmsrd  r11,1
-#endif
-       /* Restore volatiles, reload MSR from updated one */
-       ld      r8,_MSR(r1)
-       ld      r3,RESULT(r1)
-       li      r11,-MAX_ERRNO
-       b       .Lsyscall_restore_math_cont
-
 /* Traced system call support */
 .Lsyscall_dotrace:
        bl      save_nvgprs
index 9f3e2c932dccc1c3a1158fc174a8cf57e63dd75d..1f0fd361e09b9415f81242d67d9b939f36fd63ba 100644 (file)
@@ -362,7 +362,8 @@ void enable_kernel_vsx(void)
 
        cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX);
 
-       if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) {
+       if (current->thread.regs &&
+           (current->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP))) {
                check_if_tm_restore_required(current);
                /*
                 * If a thread has already been reclaimed then the
@@ -386,7 +387,7 @@ void flush_vsx_to_thread(struct task_struct *tsk)
 {
        if (tsk->thread.regs) {
                preempt_disable();
-               if (tsk->thread.regs->msr & MSR_VSX) {
+               if (tsk->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP)) {
                        BUG_ON(tsk != current);
                        giveup_vsx(tsk);
                }
@@ -511,10 +512,6 @@ void restore_math(struct pt_regs *regs)
 {
        unsigned long msr;
 
-       /*
-        * Syscall exit makes a similar initial check before branching
-        * to restore_math. Keep them in synch.
-        */
        if (!msr_tm_active(regs->msr) &&
                !current->thread.load_fp && !loadvec(current->thread))
                return;
index cf0e1245b8cc1c78948a4004be2d20c5b5ac0b78..8d3320562c70f3ef7308645fb7b805fc14794e42 100644 (file)
@@ -351,7 +351,7 @@ static void nmi_ipi_lock_start(unsigned long *flags)
        hard_irq_disable();
        while (atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1) {
                raw_local_irq_restore(*flags);
-               cpu_relax();
+               spin_until_cond(atomic_read(&__nmi_ipi_lock) == 0);
                raw_local_irq_save(*flags);
                hard_irq_disable();
        }
@@ -360,7 +360,7 @@ static void nmi_ipi_lock_start(unsigned long *flags)
 static void nmi_ipi_lock(void)
 {
        while (atomic_cmpxchg(&__nmi_ipi_lock, 0, 1) == 1)
-               cpu_relax();
+               spin_until_cond(atomic_read(&__nmi_ipi_lock) == 0);
 }
 
 static void nmi_ipi_unlock(void)
@@ -475,7 +475,7 @@ int smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us)
        nmi_ipi_lock_start(&flags);
        while (nmi_ipi_busy_count) {
                nmi_ipi_unlock_end(&flags);
-               cpu_relax();
+               spin_until_cond(nmi_ipi_busy_count == 0);
                nmi_ipi_lock_start(&flags);
        }
 
index b67f8b03a32d0f12ce29eeb4ac3be0a97384fe72..34721a257a770c450baac0288f8006c94ff1975b 100644 (file)
@@ -71,15 +71,20 @@ static inline void wd_smp_lock(unsigned long *flags)
         * This may be called from low level interrupt handlers at some
         * point in future.
         */
-       local_irq_save(*flags);
-       while (unlikely(test_and_set_bit_lock(0, &__wd_smp_lock)))
-               cpu_relax();
+       raw_local_irq_save(*flags);
+       hard_irq_disable(); /* Make it soft-NMI safe */
+       while (unlikely(test_and_set_bit_lock(0, &__wd_smp_lock))) {
+               raw_local_irq_restore(*flags);
+               spin_until_cond(!test_bit(0, &__wd_smp_lock));
+               raw_local_irq_save(*flags);
+               hard_irq_disable();
+       }
 }
 
 static inline void wd_smp_unlock(unsigned long *flags)
 {
        clear_bit_unlock(0, &__wd_smp_lock);
-       local_irq_restore(*flags);
+       raw_local_irq_restore(*flags);
 }
 
 static void wd_lockup_ipi(struct pt_regs *regs)
@@ -96,10 +101,10 @@ static void wd_lockup_ipi(struct pt_regs *regs)
                nmi_panic(regs, "Hard LOCKUP");
 }
 
-static void set_cpu_stuck(int cpu, u64 tb)
+static void set_cpumask_stuck(const struct cpumask *cpumask, u64 tb)
 {
-       cpumask_set_cpu(cpu, &wd_smp_cpus_stuck);
-       cpumask_clear_cpu(cpu, &wd_smp_cpus_pending);
+       cpumask_or(&wd_smp_cpus_stuck, &wd_smp_cpus_stuck, cpumask);
+       cpumask_andnot(&wd_smp_cpus_pending, &wd_smp_cpus_pending, cpumask);
        if (cpumask_empty(&wd_smp_cpus_pending)) {
                wd_smp_last_reset_tb = tb;
                cpumask_andnot(&wd_smp_cpus_pending,
@@ -107,6 +112,10 @@ static void set_cpu_stuck(int cpu, u64 tb)
                                &wd_smp_cpus_stuck);
        }
 }
+static void set_cpu_stuck(int cpu, u64 tb)
+{
+       set_cpumask_stuck(cpumask_of(cpu), tb);
+}
 
 static void watchdog_smp_panic(int cpu, u64 tb)
 {
@@ -135,11 +144,9 @@ static void watchdog_smp_panic(int cpu, u64 tb)
        }
        smp_flush_nmi_ipi(1000000);
 
-       /* Take the stuck CPU out of the watch group */
-       for_each_cpu(c, &wd_smp_cpus_pending)
-               set_cpu_stuck(c, tb);
+       /* Take the stuck CPUs out of the watch group */
+       set_cpumask_stuck(&wd_smp_cpus_pending, tb);
 
-out:
        wd_smp_unlock(&flags);
 
        printk_safe_flush();
@@ -152,6 +159,11 @@ out:
 
        if (hardlockup_panic)
                nmi_panic(NULL, "Hard LOCKUP");
+
+       return;
+
+out:
+       wd_smp_unlock(&flags);
 }
 
 static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
@@ -258,9 +270,11 @@ static void wd_timer_fn(unsigned long data)
 
 void arch_touch_nmi_watchdog(void)
 {
+       unsigned long ticks = tb_ticks_per_usec * wd_timer_period_ms * 1000;
        int cpu = smp_processor_id();
 
-       watchdog_timer_interrupt(cpu);
+       if (get_tb() - per_cpu(wd_timer_tb, cpu) >= ticks)
+               watchdog_timer_interrupt(cpu);
 }
 EXPORT_SYMBOL(arch_touch_nmi_watchdog);
 
@@ -283,6 +297,8 @@ static void stop_watchdog_timer_on(unsigned int cpu)
 
 static int start_wd_on_cpu(unsigned int cpu)
 {
+       unsigned long flags;
+
        if (cpumask_test_cpu(cpu, &wd_cpus_enabled)) {
                WARN_ON(1);
                return 0;
@@ -297,12 +313,14 @@ static int start_wd_on_cpu(unsigned int cpu)
        if (!cpumask_test_cpu(cpu, &watchdog_cpumask))
                return 0;
 
+       wd_smp_lock(&flags);
        cpumask_set_cpu(cpu, &wd_cpus_enabled);
        if (cpumask_weight(&wd_cpus_enabled) == 1) {
                cpumask_set_cpu(cpu, &wd_smp_cpus_pending);
                wd_smp_last_reset_tb = get_tb();
        }
-       smp_wmb();
+       wd_smp_unlock(&flags);
+
        start_watchdog_timer_on(cpu);
 
        return 0;
@@ -310,12 +328,17 @@ static int start_wd_on_cpu(unsigned int cpu)
 
 static int stop_wd_on_cpu(unsigned int cpu)
 {
+       unsigned long flags;
+
        if (!cpumask_test_cpu(cpu, &wd_cpus_enabled))
                return 0; /* Can happen in CPU unplug case */
 
        stop_watchdog_timer_on(cpu);
 
+       wd_smp_lock(&flags);
        cpumask_clear_cpu(cpu, &wd_cpus_enabled);
+       wd_smp_unlock(&flags);
+
        wd_smp_clear_cpu_pending(cpu, get_tb());
 
        return 0;
index a160c14304eba22bd83ee98b8f052a2ed8bf7a3f..53766e2bc029e25efc87270f6983e3b7975be31d 100644 (file)
@@ -294,32 +294,26 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
                                   struct kvm_create_spapr_tce_64 *args)
 {
        struct kvmppc_spapr_tce_table *stt = NULL;
+       struct kvmppc_spapr_tce_table *siter;
        unsigned long npages, size;
        int ret = -ENOMEM;
        int i;
+       int fd = -1;
 
        if (!args->size)
                return -EINVAL;
 
-       /* Check this LIOBN hasn't been previously allocated */
-       list_for_each_entry(stt, &kvm->arch.spapr_tce_tables, list) {
-               if (stt->liobn == args->liobn)
-                       return -EBUSY;
-       }
-
        size = _ALIGN_UP(args->size, PAGE_SIZE >> 3);
        npages = kvmppc_tce_pages(size);
        ret = kvmppc_account_memlimit(kvmppc_stt_pages(npages), true);
-       if (ret) {
-               stt = NULL;
-               goto fail;
-       }
+       if (ret)
+               return ret;
 
        ret = -ENOMEM;
        stt = kzalloc(sizeof(*stt) + npages * sizeof(struct page *),
                      GFP_KERNEL);
        if (!stt)
-               goto fail;
+               goto fail_acct;
 
        stt->liobn = args->liobn;
        stt->page_shift = args->page_shift;
@@ -334,24 +328,42 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
                        goto fail;
        }
 
-       kvm_get_kvm(kvm);
+       ret = fd = anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops,
+                                   stt, O_RDWR | O_CLOEXEC);
+       if (ret < 0)
+               goto fail;
 
        mutex_lock(&kvm->lock);
-       list_add_rcu(&stt->list, &kvm->arch.spapr_tce_tables);
+
+       /* Check this LIOBN hasn't been previously allocated */
+       ret = 0;
+       list_for_each_entry(siter, &kvm->arch.spapr_tce_tables, list) {
+               if (siter->liobn == args->liobn) {
+                       ret = -EBUSY;
+                       break;
+               }
+       }
+
+       if (!ret) {
+               list_add_rcu(&stt->list, &kvm->arch.spapr_tce_tables);
+               kvm_get_kvm(kvm);
+       }
 
        mutex_unlock(&kvm->lock);
 
-       return anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops,
-                               stt, O_RDWR | O_CLOEXEC);
+       if (!ret)
+               return fd;
 
-fail:
-       if (stt) {
-               for (i = 0; i < npages; i++)
-                       if (stt->pages[i])
-                               __free_page(stt->pages[i]);
+       put_unused_fd(fd);
 
-               kfree(stt);
-       }
+ fail:
+       for (i = 0; i < npages; i++)
+               if (stt->pages[i])
+                       __free_page(stt->pages[i]);
+
+       kfree(stt);
+ fail_acct:
+       kvmppc_account_memlimit(kvmppc_stt_pages(npages), false);
        return ret;
 }
 
index c52184a8efdf025c1efffc6dd7310e9374dca630..9c9c983b864f8d64a81eac456adc405cc0252e5d 100644 (file)
@@ -1291,6 +1291,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
        /* Hypervisor doorbell - exit only if host IPI flag set */
        cmpwi   r12, BOOK3S_INTERRUPT_H_DOORBELL
        bne     3f
+BEGIN_FTR_SECTION
+       PPC_MSGSYNC
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
        lbz     r0, HSTATE_HOST_IPI(r13)
        cmpwi   r0, 0
        beq     4f
index 4636ca6e7d383b7d3ce26b18df01152b8087a8ec..d1ed2c41b5d246dde6d53c34530bc30dc63656b9 100644 (file)
@@ -16,7 +16,22 @@ static void GLUE(X_PFX,ack_pending)(struct kvmppc_xive_vcpu *xc)
        u8 cppr;
        u16 ack;
 
-       /* XXX DD1 bug workaround: Check PIPR vs. CPPR first ! */
+       /*
+        * Ensure any previous store to CPPR is ordered vs.
+        * the subsequent loads from PIPR or ACK.
+        */
+       eieio();
+
+       /*
+        * DD1 bug workaround: If PIPR is less favored than CPPR
+        * ignore the interrupt or we might incorrectly lose an IPB
+        * bit.
+        */
+       if (cpu_has_feature(CPU_FTR_POWER9_DD1)) {
+               u8 pipr = __x_readb(__x_tima + TM_QW1_OS + TM_PIPR);
+               if (pipr >= xc->hw_cppr)
+                       return;
+       }
 
        /* Perform the acknowledge OS to register cycle. */
        ack = be16_to_cpu(__x_readw(__x_tima + TM_SPC_ACK_OS_REG));
@@ -235,6 +250,11 @@ skip_ipi:
        /*
         * If we found an interrupt, adjust what the guest CPPR should
         * be as if we had just fetched that interrupt from HW.
+        *
+        * Note: This can only make xc->cppr smaller as the previous
+        * loop will only exit with hirq != 0 if prio is lower than
+        * the current xc->cppr. Thus we don't need to re-check xc->mfrr
+        * for pending IPIs.
         */
        if (hirq)
                xc->cppr = prio;
@@ -380,6 +400,12 @@ X_STATIC int GLUE(X_PFX,h_cppr)(struct kvm_vcpu *vcpu, unsigned long cppr)
        old_cppr = xc->cppr;
        xc->cppr = cppr;
 
+       /*
+        * Order the above update of xc->cppr with the subsequent
+        * read of xc->mfrr inside push_pending_to_hw()
+        */
+       smp_mb();
+
        /*
         * We are masking less, we need to look for pending things
         * to deliver and set VP pending bits accordingly to trigger
@@ -420,21 +446,37 @@ X_STATIC int GLUE(X_PFX,h_eoi)(struct kvm_vcpu *vcpu, unsigned long xirr)
         * used to signal MFRR changes is EOId when fetched from
         * the queue.
         */
-       if (irq == XICS_IPI || irq == 0)
+       if (irq == XICS_IPI || irq == 0) {
+               /*
+                * This barrier orders the setting of xc->cppr vs.
+                * subsquent test of xc->mfrr done inside
+                * scan_interrupts and push_pending_to_hw
+                */
+               smp_mb();
                goto bail;
+       }
 
        /* Find interrupt source */
        sb = kvmppc_xive_find_source(xive, irq, &src);
        if (!sb) {
                pr_devel(" source not found !\n");
                rc = H_PARAMETER;
+               /* Same as above */
+               smp_mb();
                goto bail;
        }
        state = &sb->irq_state[src];
        kvmppc_xive_select_irq(state, &hw_num, &xd);
 
        state->in_eoi = true;
-       mb();
+
+       /*
+        * This barrier orders both setting of in_eoi above vs,
+        * subsequent test of guest_priority, and the setting
+        * of xc->cppr vs. subsquent test of xc->mfrr done inside
+        * scan_interrupts and push_pending_to_hw
+        */
+       smp_mb();
 
 again:
        if (state->guest_priority == MASKED) {
@@ -461,6 +503,14 @@ again:
 
        }
 
+       /*
+        * This barrier orders the above guest_priority check
+        * and spin_lock/unlock with clearing in_eoi below.
+        *
+        * It also has to be a full mb() as it must ensure
+        * the MMIOs done in source_eoi() are completed before
+        * state->in_eoi is visible.
+        */
        mb();
        state->in_eoi = false;
 bail:
@@ -495,6 +545,18 @@ X_STATIC int GLUE(X_PFX,h_ipi)(struct kvm_vcpu *vcpu, unsigned long server,
        /* Locklessly write over MFRR */
        xc->mfrr = mfrr;
 
+       /*
+        * The load of xc->cppr below and the subsequent MMIO store
+        * to the IPI must happen after the above mfrr update is
+        * globally visible so that:
+        *
+        * - Synchronize with another CPU doing an H_EOI or a H_CPPR
+        *   updating xc->cppr then reading xc->mfrr.
+        *
+        * - The target of the IPI sees the xc->mfrr update
+        */
+       mb();
+
        /* Shoot the IPI if most favored than target cppr */
        if (mfrr < xc->cppr)
                __x_writeq(0, __x_trig_page(&xc->vp_ipi_data));
index 2abee070373fb3a8b757b8d3cb269e5d0b89dff6..a553aeea7af683812ba2f5a80d65e97cda163919 100644 (file)
@@ -56,6 +56,7 @@ u64 pnv_first_deep_stop_state = MAX_STOP_STATE;
  */
 static u64 pnv_deepest_stop_psscr_val;
 static u64 pnv_deepest_stop_psscr_mask;
+static u64 pnv_deepest_stop_flag;
 static bool deepest_stop_found;
 
 static int pnv_save_sprs_for_deep_states(void)
@@ -185,8 +186,40 @@ static void pnv_alloc_idle_core_states(void)
 
        update_subcore_sibling_mask();
 
-       if (supported_cpuidle_states & OPAL_PM_LOSE_FULL_CONTEXT)
-               pnv_save_sprs_for_deep_states();
+       if (supported_cpuidle_states & OPAL_PM_LOSE_FULL_CONTEXT) {
+               int rc = pnv_save_sprs_for_deep_states();
+
+               if (likely(!rc))
+                       return;
+
+               /*
+                * The stop-api is unable to restore hypervisor
+                * resources on wakeup from platform idle states which
+                * lose full context. So disable such states.
+                */
+               supported_cpuidle_states &= ~OPAL_PM_LOSE_FULL_CONTEXT;
+               pr_warn("cpuidle-powernv: Disabling idle states that lose full context\n");
+               pr_warn("cpuidle-powernv: Idle power-savings, CPU-Hotplug affected\n");
+
+               if (cpu_has_feature(CPU_FTR_ARCH_300) &&
+                   (pnv_deepest_stop_flag & OPAL_PM_LOSE_FULL_CONTEXT)) {
+                       /*
+                        * Use the default stop state for CPU-Hotplug
+                        * if available.
+                        */
+                       if (default_stop_found) {
+                               pnv_deepest_stop_psscr_val =
+                                       pnv_default_stop_val;
+                               pnv_deepest_stop_psscr_mask =
+                                       pnv_default_stop_mask;
+                               pr_warn("cpuidle-powernv: Offlined CPUs will stop with psscr = 0x%016llx\n",
+                                       pnv_deepest_stop_psscr_val);
+                       } else { /* Fallback to snooze loop for CPU-Hotplug */
+                               deepest_stop_found = false;
+                               pr_warn("cpuidle-powernv: Offlined CPUs will busy wait\n");
+                       }
+               }
+       }
 }
 
 u32 pnv_get_supported_cpuidle_states(void)
@@ -375,7 +408,8 @@ unsigned long pnv_cpu_offline(unsigned int cpu)
                                                pnv_deepest_stop_psscr_val;
                srr1 = power9_idle_stop(psscr);
 
-       } else if (idle_states & OPAL_PM_WINKLE_ENABLED) {
+       } else if ((idle_states & OPAL_PM_WINKLE_ENABLED) &&
+                  (idle_states & OPAL_PM_LOSE_FULL_CONTEXT)) {
                srr1 = power7_idle_insn(PNV_THREAD_WINKLE);
        } else if ((idle_states & OPAL_PM_SLEEP_ENABLED) ||
                   (idle_states & OPAL_PM_SLEEP_ENABLED_ER1)) {
@@ -553,6 +587,7 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
                        max_residency_ns = residency_ns[i];
                        pnv_deepest_stop_psscr_val = psscr_val[i];
                        pnv_deepest_stop_psscr_mask = psscr_mask[i];
+                       pnv_deepest_stop_flag = flags[i];
                        deepest_stop_found = true;
                }
 
index b5d960d6db3d0b18d33273b31ac67e03caebd02b..4c7b8591f7379931a1d319c8edd5995610ca6d8c 100644 (file)
@@ -614,15 +614,6 @@ static void pnv_npu2_mn_change_pte(struct mmu_notifier *mn,
        mmio_invalidate(npu_context, 1, address, true);
 }
 
-static void pnv_npu2_mn_invalidate_page(struct mmu_notifier *mn,
-                                       struct mm_struct *mm,
-                                       unsigned long address)
-{
-       struct npu_context *npu_context = mn_to_npu_context(mn);
-
-       mmio_invalidate(npu_context, 1, address, true);
-}
-
 static void pnv_npu2_mn_invalidate_range(struct mmu_notifier *mn,
                                        struct mm_struct *mm,
                                        unsigned long start, unsigned long end)
@@ -640,7 +631,6 @@ static void pnv_npu2_mn_invalidate_range(struct mmu_notifier *mn,
 static const struct mmu_notifier_ops nv_nmmu_notifier_ops = {
        .release = pnv_npu2_mn_release,
        .change_pte = pnv_npu2_mn_change_pte,
-       .invalidate_page = pnv_npu2_mn_invalidate_page,
        .invalidate_range = pnv_npu2_mn_invalidate_range,
 };
 
index 4541ac44b35f0e39b831b3eba2e5669d29dd9f89..24bc41622a983cf353c6d414d521cbd94cd43cbb 100644 (file)
@@ -44,6 +44,11 @@ static inline int init_new_context(struct task_struct *tsk,
                mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
                                   _ASCE_USER_BITS | _ASCE_TYPE_REGION3;
                break;
+       case -PAGE_SIZE:
+               /* forked 5-level task, set new asce with new_mm->pgd */
+               mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
+                       _ASCE_USER_BITS | _ASCE_TYPE_REGION1;
+               break;
        case 1UL << 53:
                /* forked 4-level task, set new asce with new mm->pgd */
                mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
index 7317b3108a88859a91523c45f1e52c08cb22fdc4..2eb8ff0d6fca443543c32ac80ff690b4b67be1ef 100644 (file)
@@ -47,10 +47,9 @@ struct mmu_table_batch {
 extern void tlb_table_flush(struct mmu_gather *tlb);
 extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
 
-static inline void tlb_gather_mmu(struct mmu_gather *tlb,
-                                 struct mm_struct *mm,
-                                 unsigned long start,
-                                 unsigned long end)
+static inline void
+arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+                       unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
        tlb->start = start;
@@ -76,9 +75,15 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
        tlb_flush_mmu_free(tlb);
 }
 
-static inline void tlb_finish_mmu(struct mmu_gather *tlb,
-                                 unsigned long start, unsigned long end)
+static inline void
+arch_tlb_finish_mmu(struct mmu_gather *tlb,
+               unsigned long start, unsigned long end, bool force)
 {
+       if (force) {
+               tlb->start = start;
+               tlb->end = end;
+       }
+
        tlb_flush_mmu(tlb);
 }
 
index 926b5244263efd3dd1fadf637ce4790251367e60..a2e5c24f47a7471a1e7730f654b8ce4599434ef0 100644 (file)
@@ -394,7 +394,7 @@ static int sthyi(u64 vaddr)
                "srl     %[cc],28\n"
                : [cc] "=d" (cc)
                : [code] "d" (code), [addr] "a" (addr)
-               : "memory", "cc");
+               : "3", "memory", "cc");
        return cc;
 }
 
@@ -425,7 +425,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
        VCPU_EVENT(vcpu, 3, "STHYI: fc: %llu addr: 0x%016llx", code, addr);
        trace_kvm_s390_handle_sthyi(vcpu, code, addr);
 
-       if (reg1 == reg2 || reg1 & 1 || reg2 & 1 || addr & ~PAGE_MASK)
+       if (reg1 == reg2 || reg1 & 1 || reg2 & 1)
                return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
        if (code & 0xffff) {
@@ -433,6 +433,9 @@ int handle_sthyi(struct kvm_vcpu *vcpu)
                goto out;
        }
 
+       if (addr & ~PAGE_MASK)
+               return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
+
        /*
         * If the page has not yet been faulted in, we want to do that
         * now and not after all the expensive calculations.
index 2e10d2b8ad359607981ce381e27c3bf22e2e184d..5bea139517a2edc21dc50074d2c2e9a94dabb19e 100644 (file)
@@ -119,7 +119,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
                return addr;
 
 check_asce_limit:
-       if (addr + len > current->mm->context.asce_limit) {
+       if (addr + len > current->mm->context.asce_limit &&
+           addr + len <= TASK_SIZE) {
                rc = crst_table_upgrade(mm, addr + len);
                if (rc)
                        return (unsigned long) rc;
@@ -183,7 +184,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
        }
 
 check_asce_limit:
-       if (addr + len > current->mm->context.asce_limit) {
+       if (addr + len > current->mm->context.asce_limit &&
+           addr + len <= TASK_SIZE) {
                rc = crst_table_upgrade(mm, addr + len);
                if (rc)
                        return (unsigned long) rc;
index 01c6fbc3e85b62fdec83bacea0f76a88126bfe84..1803797fc885cf799337b5d61f30ae726628b8d6 100644 (file)
@@ -1253,7 +1253,8 @@ static int bpf_jit_prog(struct bpf_jit *jit, struct bpf_prog *fp)
                insn_count = bpf_jit_insn(jit, fp, i);
                if (insn_count < 0)
                        return -1;
-               jit->addrs[i + 1] = jit->prg; /* Next instruction address */
+               /* Next instruction address */
+               jit->addrs[i + insn_count] = jit->prg;
        }
        bpf_jit_epilogue(jit);
 
index 46e0d635e36f711aff9a88c45955905d7fbf3cc2..51a8bc967e75f1e3c96a70783e9da439310edbcb 100644 (file)
@@ -36,7 +36,8 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
+arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+               unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
        tlb->start = start;
@@ -47,9 +48,10 @@ tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start
 }
 
 static inline void
-tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
+arch_tlb_finish_mmu(struct mmu_gather *tlb,
+               unsigned long start, unsigned long end, bool force)
 {
-       if (tlb->fullmm)
+       if (tlb->fullmm || force)
                flush_tlb_mm(tlb->mm);
 
        /* keep the page table cache within bounds */
index 0efd0583a8c9da1afc2acc508f2e2e1a5388441d..6249214148c24bb44f2203117200768a410cee2d 100644 (file)
@@ -68,6 +68,7 @@ typedef struct { unsigned long iopgprot; } iopgprot_t;
 #define iopgprot_val(x)        ((x).iopgprot)
 
 #define __pte(x)       ((pte_t) { (x) } )
+#define __pmd(x)       ((pmd_t) { { (x) }, })
 #define __iopte(x)     ((iopte_t) { (x) } )
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __ctxd(x)      ((ctxd_t) { (x) } )
@@ -95,6 +96,7 @@ typedef unsigned long iopgprot_t;
 #define iopgprot_val(x)        (x)
 
 #define __pte(x)       (x)
+#define __pmd(x)       ((pmd_t) { { (x) }, })
 #define __iopte(x)     (x)
 #define __pgd(x)       (x)
 #define __ctxd(x)      (x)
index 1d8321c827a8821bb4e9f4989eb883cd761370db..1b1286d0506910c0f9a92ab6af14e272dd008d61 100644 (file)
 #define SUN4V_CHIP_NIAGARA5    0x05
 #define SUN4V_CHIP_SPARC_M6    0x06
 #define SUN4V_CHIP_SPARC_M7    0x07
+#define SUN4V_CHIP_SPARC_M8    0x08
 #define SUN4V_CHIP_SPARC64X    0x8a
 #define SUN4V_CHIP_SPARC_SN    0x8b
 #define SUN4V_CHIP_UNKNOWN     0xff
 
+/*
+ * The following CPU_ID_xxx constants are used
+ * to identify the CPU type in the setup phase
+ * (see head_64.S)
+ */
+#define CPU_ID_NIAGARA1                ('1')
+#define CPU_ID_NIAGARA2                ('2')
+#define CPU_ID_NIAGARA3                ('3')
+#define CPU_ID_NIAGARA4                ('4')
+#define CPU_ID_NIAGARA5                ('5')
+#define CPU_ID_M6              ('6')
+#define CPU_ID_M7              ('7')
+#define CPU_ID_M8              ('8')
+#define CPU_ID_SONOMA1         ('N')
+
 #ifndef __ASSEMBLY__
 
 enum ultra_tlb_layout {
index 493e023a468a919c61d77451e43e0a4a2e414bbe..ef4f18f7a67402ed8baceb2ea05ee7f6368cc404 100644 (file)
@@ -506,6 +506,12 @@ static void __init sun4v_cpu_probe(void)
                sparc_pmu_type = "sparc-m7";
                break;
 
+       case SUN4V_CHIP_SPARC_M8:
+               sparc_cpu_type = "SPARC-M8";
+               sparc_fpu_type = "SPARC-M8 integrated FPU";
+               sparc_pmu_type = "sparc-m8";
+               break;
+
        case SUN4V_CHIP_SPARC_SN:
                sparc_cpu_type = "SPARC-SN";
                sparc_fpu_type = "SPARC-SN integrated FPU";
index 45c820e1cba5d949ff936f15392ca3c0c8578a34..90d550bbfeefe484f1560940f111235f26332d7a 100644 (file)
@@ -328,6 +328,7 @@ static int iterate_cpu(struct cpuinfo_tree *t, unsigned int root_index)
        case SUN4V_CHIP_NIAGARA5:
        case SUN4V_CHIP_SPARC_M6:
        case SUN4V_CHIP_SPARC_M7:
+       case SUN4V_CHIP_SPARC_M8:
        case SUN4V_CHIP_SPARC_SN:
        case SUN4V_CHIP_SPARC64X:
                rover_inc_table = niagara_iterate_method;
index 41a4073286671eff51f275bfca4ae6d9d01db74d..78e0211753d28f14f955af865704248b1e5daf24 100644 (file)
@@ -424,22 +424,25 @@ EXPORT_SYMBOL(sun4v_chip_type)
         nop
 
 70:    ldub    [%g1 + 7], %g2
-       cmp     %g2, '3'
+       cmp     %g2, CPU_ID_NIAGARA3
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_NIAGARA3, %g4
-       cmp     %g2, '4'
+       cmp     %g2, CPU_ID_NIAGARA4
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_NIAGARA4, %g4
-       cmp     %g2, '5'
+       cmp     %g2, CPU_ID_NIAGARA5
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_NIAGARA5, %g4
-       cmp     %g2, '6'
+       cmp     %g2, CPU_ID_M6
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_SPARC_M6, %g4
-       cmp     %g2, '7'
+       cmp     %g2, CPU_ID_M7
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_SPARC_M7, %g4
-       cmp     %g2, 'N'
+       cmp     %g2, CPU_ID_M8
+       be,pt   %xcc, 5f
+        mov    SUN4V_CHIP_SPARC_M8, %g4
+       cmp     %g2, CPU_ID_SONOMA1
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_SPARC_SN, %g4
        ba,pt   %xcc, 49f
@@ -448,10 +451,10 @@ EXPORT_SYMBOL(sun4v_chip_type)
 91:    sethi   %hi(prom_cpu_compatible), %g1
        or      %g1, %lo(prom_cpu_compatible), %g1
        ldub    [%g1 + 17], %g2
-       cmp     %g2, '1'
+       cmp     %g2, CPU_ID_NIAGARA1
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_NIAGARA1, %g4
-       cmp     %g2, '2'
+       cmp     %g2, CPU_ID_NIAGARA2
        be,pt   %xcc, 5f
         mov    SUN4V_CHIP_NIAGARA2, %g4
        
@@ -600,6 +603,9 @@ niagara_tlb_fixup:
        be,pt   %xcc, niagara4_patch
         nop
        cmp     %g1, SUN4V_CHIP_SPARC_M7
+       be,pt   %xcc, niagara4_patch
+        nop
+       cmp     %g1, SUN4V_CHIP_SPARC_M8
        be,pt   %xcc, niagara4_patch
         nop
        cmp     %g1, SUN4V_CHIP_SPARC_SN
index f10e2f7123949dedc8904ea37895d402ed097d2b..9ebebf1fd93d2f5db8c09804c336b006041b28af 100644 (file)
@@ -1266,8 +1266,6 @@ static int pci_sun4v_probe(struct platform_device *op)
                         * ATU group, but ATU hcalls won't be available.
                         */
                        hv_atu = false;
-                       pr_err(PFX "Could not register hvapi ATU err=%d\n",
-                              err);
                } else {
                        pr_info(PFX "Registered hvapi ATU major[%lu] minor[%lu]\n",
                                vatu_major, vatu_minor);
index a38787b843220807d0f5527f864981fc75e8486f..732af9a9f6ddef510e39da7d6eca5547e210296e 100644 (file)
@@ -602,7 +602,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 {
        struct pci_dev *dev;
        int i, has_io, has_mem;
-       unsigned int cmd;
+       unsigned int cmd = 0;
        struct linux_pcic *pcic;
        /* struct linux_pbm_info* pbm = &pcic->pbm; */
        int node;
index 4d9c3e13c15056b5d60e7ccd266b36cfe29d2c00..150ee7d4b059a69e174dff7c7d16ff906f73e1ed 100644 (file)
@@ -288,10 +288,17 @@ static void __init sun4v_patch(void)
 
        sun4v_patch_2insn_range(&__sun4v_2insn_patch,
                                &__sun4v_2insn_patch_end);
-       if (sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
-           sun4v_chip_type == SUN4V_CHIP_SPARC_SN)
+
+       switch (sun4v_chip_type) {
+       case SUN4V_CHIP_SPARC_M7:
+       case SUN4V_CHIP_SPARC_M8:
+       case SUN4V_CHIP_SPARC_SN:
                sun_m7_patch_2insn_range(&__sun_m7_2insn_patch,
                                         &__sun_m7_2insn_patch_end);
+               break;
+       default:
+               break;
+       }
 
        sun4v_hvapi_init();
 }
@@ -529,6 +536,7 @@ static void __init init_sparc64_elf_hwcap(void)
                    sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
+                   sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC64X)
                        cap |= HWCAP_SPARC_BLKINIT;
@@ -538,6 +546,7 @@ static void __init init_sparc64_elf_hwcap(void)
                    sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
+                   sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
                    sun4v_chip_type == SUN4V_CHIP_SPARC64X)
                        cap |= HWCAP_SPARC_N2;
@@ -568,6 +577,7 @@ static void __init init_sparc64_elf_hwcap(void)
                            sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
+                           sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC64X)
                                cap |= (AV_SPARC_VIS | AV_SPARC_VIS2 |
@@ -578,6 +588,7 @@ static void __init init_sparc64_elf_hwcap(void)
                            sun4v_chip_type == SUN4V_CHIP_NIAGARA5 ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC_M6 ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC_M7 ||
+                           sun4v_chip_type == SUN4V_CHIP_SPARC_M8 ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC_SN ||
                            sun4v_chip_type == SUN4V_CHIP_SPARC64X)
                                cap |= (AV_SPARC_VIS3 | AV_SPARC_HPC |
index d6b6c97fe3c73061f911737a5da23ab41a3eab77..703127aaf4a5015ee4a1099e6129735f7162222b 100644 (file)
@@ -5,26 +5,26 @@
        .align  4
 ENTRY(__multi3) /* %o0 = u, %o1 = v */
        mov     %o1, %g1
-       srl     %o3, 0, %g4
-       mulx    %g4, %g1, %o1
+       srl     %o3, 0, %o4
+       mulx    %o4, %g1, %o1
        srlx    %g1, 0x20, %g3
-       mulx    %g3, %g4, %g5
-       sllx    %g5, 0x20, %o5
-       srl     %g1, 0, %g4
+       mulx    %g3, %o4, %g7
+       sllx    %g7, 0x20, %o5
+       srl     %g1, 0, %o4
        sub     %o1, %o5, %o5
        srlx    %o5, 0x20, %o5
-       addcc   %g5, %o5, %g5
+       addcc   %g7, %o5, %g7
        srlx    %o3, 0x20, %o5
-       mulx    %g4, %o5, %g4
+       mulx    %o4, %o5, %o4
        mulx    %g3, %o5, %o5
        sethi   %hi(0x80000000), %g3
-       addcc   %g5, %g4, %g5
-       srlx    %g5, 0x20, %g5
+       addcc   %g7, %o4, %g7
+       srlx    %g7, 0x20, %g7
        add     %g3, %g3, %g3
        movcc   %xcc, %g0, %g3
-       addcc   %o5, %g5, %o5
-       sllx    %g4, 0x20, %g4
-       add     %o1, %g4, %o1
+       addcc   %o5, %g7, %o5
+       sllx    %o4, 0x20, %o4
+       add     %o1, %o4, %o1
        add     %o5, %g3, %g2
        mulx    %g1, %o2, %g1
        add     %g1, %g2, %g1
index fed73f14aa49befee59b93b0fcab02f65f7e10d2..afa0099f374852e0cf093088d942512008a45a68 100644 (file)
@@ -1944,12 +1944,22 @@ static void __init setup_page_offset(void)
                        break;
                case SUN4V_CHIP_SPARC_M7:
                case SUN4V_CHIP_SPARC_SN:
-               default:
                        /* M7 and later support 52-bit virtual addresses.  */
                        sparc64_va_hole_top =    0xfff8000000000000UL;
                        sparc64_va_hole_bottom = 0x0008000000000000UL;
                        max_phys_bits = 49;
                        break;
+               case SUN4V_CHIP_SPARC_M8:
+               default:
+                       /* M8 and later support 54-bit virtual addresses.
+                        * However, restricting M8 and above VA bits to 53
+                        * as 4-level page table cannot support more than
+                        * 53 VA bits.
+                        */
+                       sparc64_va_hole_top =    0xfff0000000000000UL;
+                       sparc64_va_hole_bottom = 0x0010000000000000UL;
+                       max_phys_bits = 51;
+                       break;
                }
        }
 
@@ -2161,6 +2171,7 @@ static void __init sun4v_linear_pte_xor_finalize(void)
         */
        switch (sun4v_chip_type) {
        case SUN4V_CHIP_SPARC_M7:
+       case SUN4V_CHIP_SPARC_M8:
        case SUN4V_CHIP_SPARC_SN:
                pagecv_flag = 0x00;
                break;
@@ -2313,6 +2324,7 @@ void __init paging_init(void)
         */
        switch (sun4v_chip_type) {
        case SUN4V_CHIP_SPARC_M7:
+       case SUN4V_CHIP_SPARC_M8:
        case SUN4V_CHIP_SPARC_SN:
                page_cache4v_flag = _PAGE_CP_4V;
                break;
index 600a2e9bfee2feea2a6dbc8b91d2a5a872d9d8d3..344d95619d0334659e6f4a9f3a5bff70ae95f67c 100644 (file)
@@ -45,7 +45,8 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
+arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+               unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
        tlb->start = start;
@@ -80,13 +81,19 @@ tlb_flush_mmu(struct mmu_gather *tlb)
        tlb_flush_mmu_free(tlb);
 }
 
-/* tlb_finish_mmu
+/* arch_tlb_finish_mmu
  *     Called at the end of the shootdown operation to free up any resources
  *     that were required.
  */
 static inline void
-tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
+arch_tlb_finish_mmu(struct mmu_gather *tlb,
+               unsigned long start, unsigned long end, bool force)
 {
+       if (force) {
+               tlb->start = start;
+               tlb->end = end;
+               tlb->need_flush = 1;
+       }
        tlb_flush_mmu(tlb);
 
        /* keep the page table cache within bounds */
index 781521b7cf9ef6b6766dac9249a3568f257c4fa8..323cb065be5eda120b44dac79618a13301ece231 100644 (file)
@@ -100,6 +100,7 @@ config X86
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
        select GENERIC_TIME_VSYSCALL
+       select HARDLOCKUP_CHECK_TIMESTAMP       if X86_64
        select HAVE_ACPI_APEI                   if ACPI
        select HAVE_ACPI_APEI_NMI               if ACPI
        select HAVE_ALIGNED_STRUCT_PAGE         if SLUB
@@ -163,7 +164,7 @@ config X86
        select HAVE_PCSPKR_PLATFORM
        select HAVE_PERF_EVENTS
        select HAVE_PERF_EVENTS_NMI
-       select HAVE_HARDLOCKUP_DETECTOR_PERF    if HAVE_PERF_EVENTS_NMI
+       select HAVE_HARDLOCKUP_DETECTOR_PERF    if PERF_EVENTS && HAVE_PERF_EVENTS_NMI
        select HAVE_PERF_REGS
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_REGS_AND_STACK_ACCESS_API
index 1cd792db15efe760e3a6fc8b17b9a4c4e6f35233..1eab79c9ac484172a63d9cc0c4a409b7fffe7e8b 100644 (file)
        .set T1, REG_T1
 .endm
 
-#define K_BASE         %r8
 #define HASH_PTR       %r9
+#define BLOCKS_CTR     %r8
 #define BUFFER_PTR     %r10
 #define BUFFER_PTR2    %r13
-#define BUFFER_END     %r11
 
 #define PRECALC_BUF    %r14
 #define WK_BUF         %r15
                 * blended AVX2 and ALU instruction scheduling
                 * 1 vector iteration per 8 rounds
                 */
-               vmovdqu ((i * 2) + PRECALC_OFFSET)(BUFFER_PTR), W_TMP
+               vmovdqu (i * 2)(BUFFER_PTR), W_TMP
        .elseif ((i & 7) == 1)
-               vinsertf128 $1, (((i-1) * 2)+PRECALC_OFFSET)(BUFFER_PTR2),\
+               vinsertf128 $1, ((i-1) * 2)(BUFFER_PTR2),\
                         WY_TMP, WY_TMP
        .elseif ((i & 7) == 2)
                vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY
        .elseif ((i & 7) == 4)
-               vpaddd  K_XMM(K_BASE), WY, WY_TMP
+               vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
        .elseif ((i & 7) == 7)
                vmovdqu  WY_TMP, PRECALC_WK(i&~7)
 
                vpxor   WY, WY_TMP, WY_TMP
        .elseif ((i & 7) == 7)
                vpxor   WY_TMP2, WY_TMP, WY
-               vpaddd  K_XMM(K_BASE), WY, WY_TMP
+               vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
                vmovdqu WY_TMP, PRECALC_WK(i&~7)
 
                PRECALC_ROTATE_WY
                vpsrld  $30, WY, WY
                vpor    WY, WY_TMP, WY
        .elseif ((i & 7) == 7)
-               vpaddd  K_XMM(K_BASE), WY, WY_TMP
+               vpaddd  K_XMM + K_XMM_AR(%rip), WY, WY_TMP
                vmovdqu WY_TMP, PRECALC_WK(i&~7)
 
                PRECALC_ROTATE_WY
 
 .endm
 
+/* Add constant only if (%2 > %3) condition met (uses RTA as temp)
+ * %1 + %2 >= %3 ? %4 : 0
+ */
+.macro ADD_IF_GE a, b, c, d
+       mov     \a, RTA
+       add     $\d, RTA
+       cmp     $\c, \b
+       cmovge  RTA, \a
+.endm
+
 /*
  * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining
  */
        lea     (2*4*80+32)(%rsp), WK_BUF
 
        # Precalc WK for first 2 blocks
-       PRECALC_OFFSET = 0
+       ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 2, 64
        .set i, 0
        .rept    160
                PRECALC i
                .set i, i + 1
        .endr
-       PRECALC_OFFSET = 128
+
+       /* Go to next block if needed */
+       ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 3, 128
+       ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
        xchg    WK_BUF, PRECALC_BUF
 
        .align 32
@@ -479,8 +491,8 @@ _loop:
         * we use K_BASE value as a signal of a last block,
         * it is set below by: cmovae BUFFER_PTR, K_BASE
         */
-       cmp     K_BASE, BUFFER_PTR
-       jne     _begin
+       test BLOCKS_CTR, BLOCKS_CTR
+       jnz _begin
        .align 32
        jmp     _end
        .align 32
@@ -512,10 +524,10 @@ _loop0:
                .set j, j+2
        .endr
 
-       add     $(2*64), BUFFER_PTR       /* move to next odd-64-byte block */
-       cmp     BUFFER_END, BUFFER_PTR    /* is current block the last one? */
-       cmovae  K_BASE, BUFFER_PTR      /* signal the last iteration smartly */
-
+       /* Update Counter */
+       sub $1, BLOCKS_CTR
+       /* Move to the next block only if needed*/
+       ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 4, 128
        /*
         * rounds
         * 60,62,64,66,68
@@ -532,8 +544,8 @@ _loop0:
        UPDATE_HASH     12(HASH_PTR), D
        UPDATE_HASH     16(HASH_PTR), E
 
-       cmp     K_BASE, BUFFER_PTR      /* is current block the last one? */
-       je      _loop
+       test    BLOCKS_CTR, BLOCKS_CTR
+       jz      _loop
 
        mov     TB, B
 
@@ -575,10 +587,10 @@ _loop2:
                .set j, j+2
        .endr
 
-       add     $(2*64), BUFFER_PTR2      /* move to next even-64-byte block */
-
-       cmp     BUFFER_END, BUFFER_PTR2   /* is current block the last one */
-       cmovae  K_BASE, BUFFER_PTR       /* signal the last iteration smartly */
+       /* update counter */
+       sub     $1, BLOCKS_CTR
+       /* Move to the next block only if needed*/
+       ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
 
        jmp     _loop3
 _loop3:
@@ -641,19 +653,12 @@ _loop3:
 
        avx2_zeroupper
 
-       lea     K_XMM_AR(%rip), K_BASE
-
+       /* Setup initial values */
        mov     CTX, HASH_PTR
        mov     BUF, BUFFER_PTR
-       lea     64(BUF), BUFFER_PTR2
-
-       shl     $6, CNT                 /* mul by 64 */
-       add     BUF, CNT
-       add     $64, CNT
-       mov     CNT, BUFFER_END
 
-       cmp     BUFFER_END, BUFFER_PTR2
-       cmovae  K_BASE, BUFFER_PTR2
+       mov     BUF, BUFFER_PTR2
+       mov     CNT, BLOCKS_CTR
 
        xmm_mov BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP
 
index f960a043cdeba4a36f4ba20fddf81369f8ced38f..fc61739150e7c2c5a484c020b14441551fe5403a 100644 (file)
@@ -201,7 +201,7 @@ asmlinkage void sha1_transform_avx2(u32 *digest, const char *data,
 
 static bool avx2_usable(void)
 {
-       if (false && avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
+       if (avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
                && boot_cpu_has(X86_FEATURE_BMI1)
                && boot_cpu_has(X86_FEATURE_BMI2))
                return true;
index d271fb79248f3569c6a0a934f707d91f398562b8..6d078b89a5e887de4d9cbe1c42f3ed34d9682642 100644 (file)
@@ -1211,6 +1211,8 @@ ENTRY(nmi)
         * other IST entries.
         */
 
+       ASM_CLAC
+
        /* Use %rdx as our temp variable throughout */
        pushq   %rdx
 
index 8e3db8f642a7a02dd8f99db3a25dedbfd1deb01a..af12e294caeda5f518cf8b80ce5765996f1d8c56 100644 (file)
@@ -2114,7 +2114,7 @@ static void refresh_pce(void *ignored)
        load_mm_cr4(this_cpu_read(cpu_tlbstate.loaded_mm));
 }
 
-static void x86_pmu_event_mapped(struct perf_event *event)
+static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)
 {
        if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
                return;
@@ -2129,22 +2129,20 @@ static void x86_pmu_event_mapped(struct perf_event *event)
         * For now, this can't happen because all callers hold mmap_sem
         * for write.  If this changes, we'll need a different solution.
         */
-       lockdep_assert_held_exclusive(&current->mm->mmap_sem);
+       lockdep_assert_held_exclusive(&mm->mmap_sem);
 
-       if (atomic_inc_return(&current->mm->context.perf_rdpmc_allowed) == 1)
-               on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1);
+       if (atomic_inc_return(&mm->context.perf_rdpmc_allowed) == 1)
+               on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1);
 }
 
-static void x86_pmu_event_unmapped(struct perf_event *event)
+static void x86_pmu_event_unmapped(struct perf_event *event, struct mm_struct *mm)
 {
-       if (!current->mm)
-               return;
 
        if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
                return;
 
-       if (atomic_dec_and_test(&current->mm->context.perf_rdpmc_allowed))
-               on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1);
+       if (atomic_dec_and_test(&mm->context.perf_rdpmc_allowed))
+               on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1);
 }
 
 static int x86_pmu_event_idx(struct perf_event *event)
index 8ae8c5ce3a1f94debb2fe81f5652cbd7b35f2c4a..ddd8d3516bfcfa58fc3baf7b3f4f70b7231190ab 100644 (file)
@@ -69,7 +69,7 @@ struct bts_buffer {
        struct bts_phys buf[0];
 };
 
-struct pmu bts_pmu;
+static struct pmu bts_pmu;
 
 static size_t buf_size(struct page *page)
 {
index eb0533558c2b705957a30704218b983eda65e61e..d32c0eed38ca92665d378fa2d0792eed12aad818 100644 (file)
@@ -587,7 +587,7 @@ static __initconst const u64 p4_hw_cache_event_ids
  * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are
  * either up to date automatically or not applicable at all.
  */
-struct p4_event_alias {
+static struct p4_event_alias {
        u64 original;
        u64 alternative;
 } p4_event_aliases[] = {
index a45e2114a8460925b44bd6e0983f3ee37e83d861..8e2457cb6b4a416e1c84d9baa990ea512ec74ba0 100644 (file)
@@ -559,7 +559,7 @@ static struct attribute_group rapl_pmu_format_group = {
        .attrs = rapl_formats_attr,
 };
 
-const struct attribute_group *rapl_attr_groups[] = {
+static const struct attribute_group *rapl_attr_groups[] = {
        &rapl_pmu_attr_group,
        &rapl_pmu_format_group,
        &rapl_pmu_events_group,
index 44ec523287f670dff8eee3e3c9eb1bb1606489b6..1c5390f1cf0992787afa8d34bb361f622b00dcb2 100644 (file)
@@ -721,7 +721,7 @@ static struct attribute *uncore_pmu_attrs[] = {
        NULL,
 };
 
-static struct attribute_group uncore_pmu_attr_group = {
+static const struct attribute_group uncore_pmu_attr_group = {
        .attrs = uncore_pmu_attrs,
 };
 
index cda56933200503662d133050fc47bdae050e8d61..6a5cbe90f8593eb23a7a403132240fc9afc87c9d 100644 (file)
@@ -272,7 +272,7 @@ static struct attribute *nhmex_uncore_ubox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_ubox_format_group = {
+static const struct attribute_group nhmex_uncore_ubox_format_group = {
        .name           = "format",
        .attrs          = nhmex_uncore_ubox_formats_attr,
 };
@@ -299,7 +299,7 @@ static struct attribute *nhmex_uncore_cbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_cbox_format_group = {
+static const struct attribute_group nhmex_uncore_cbox_format_group = {
        .name = "format",
        .attrs = nhmex_uncore_cbox_formats_attr,
 };
@@ -407,7 +407,7 @@ static struct attribute *nhmex_uncore_bbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_bbox_format_group = {
+static const struct attribute_group nhmex_uncore_bbox_format_group = {
        .name = "format",
        .attrs = nhmex_uncore_bbox_formats_attr,
 };
@@ -484,7 +484,7 @@ static struct attribute *nhmex_uncore_sbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_sbox_format_group = {
+static const struct attribute_group nhmex_uncore_sbox_format_group = {
        .name                   = "format",
        .attrs                  = nhmex_uncore_sbox_formats_attr,
 };
@@ -898,7 +898,7 @@ static struct attribute *nhmex_uncore_mbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_mbox_format_group = {
+static const struct attribute_group nhmex_uncore_mbox_format_group = {
        .name           = "format",
        .attrs          = nhmex_uncore_mbox_formats_attr,
 };
@@ -1163,7 +1163,7 @@ static struct attribute *nhmex_uncore_rbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhmex_uncore_rbox_format_group = {
+static const struct attribute_group nhmex_uncore_rbox_format_group = {
        .name = "format",
        .attrs = nhmex_uncore_rbox_formats_attr,
 };
index a3dcc12bef4ab3a67aab29c6acf3480920e06952..db1127ce685eb8ea687bb4e0279f13ad5706a59f 100644 (file)
@@ -130,7 +130,7 @@ static struct attribute *snb_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group snb_uncore_format_group = {
+static const struct attribute_group snb_uncore_format_group = {
        .name           = "format",
        .attrs          = snb_uncore_formats_attr,
 };
@@ -289,7 +289,7 @@ static struct attribute *snb_uncore_imc_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group snb_uncore_imc_format_group = {
+static const struct attribute_group snb_uncore_imc_format_group = {
        .name = "format",
        .attrs = snb_uncore_imc_formats_attr,
 };
@@ -769,7 +769,7 @@ static struct attribute *nhm_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group nhm_uncore_format_group = {
+static const struct attribute_group nhm_uncore_format_group = {
        .name = "format",
        .attrs = nhm_uncore_formats_attr,
 };
index 4f9127644b80abd87d4c49204dde197a9ade7ac2..db1fe377e6dd9ddfcfbc006a7346879f263d408a 100644 (file)
@@ -602,27 +602,27 @@ static struct uncore_event_desc snbep_uncore_qpi_events[] = {
        { /* end: all zeroes */ },
 };
 
-static struct attribute_group snbep_uncore_format_group = {
+static const struct attribute_group snbep_uncore_format_group = {
        .name = "format",
        .attrs = snbep_uncore_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_ubox_format_group = {
+static const struct attribute_group snbep_uncore_ubox_format_group = {
        .name = "format",
        .attrs = snbep_uncore_ubox_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_cbox_format_group = {
+static const struct attribute_group snbep_uncore_cbox_format_group = {
        .name = "format",
        .attrs = snbep_uncore_cbox_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_pcu_format_group = {
+static const struct attribute_group snbep_uncore_pcu_format_group = {
        .name = "format",
        .attrs = snbep_uncore_pcu_formats_attr,
 };
 
-static struct attribute_group snbep_uncore_qpi_format_group = {
+static const struct attribute_group snbep_uncore_qpi_format_group = {
        .name = "format",
        .attrs = snbep_uncore_qpi_formats_attr,
 };
@@ -1431,27 +1431,27 @@ static struct attribute *ivbep_uncore_qpi_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group ivbep_uncore_format_group = {
+static const struct attribute_group ivbep_uncore_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_ubox_format_group = {
+static const struct attribute_group ivbep_uncore_ubox_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_ubox_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_cbox_format_group = {
+static const struct attribute_group ivbep_uncore_cbox_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_cbox_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_pcu_format_group = {
+static const struct attribute_group ivbep_uncore_pcu_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_pcu_formats_attr,
 };
 
-static struct attribute_group ivbep_uncore_qpi_format_group = {
+static const struct attribute_group ivbep_uncore_qpi_format_group = {
        .name = "format",
        .attrs = ivbep_uncore_qpi_formats_attr,
 };
@@ -1887,7 +1887,7 @@ static struct attribute *knl_uncore_ubox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_ubox_format_group = {
+static const struct attribute_group knl_uncore_ubox_format_group = {
        .name = "format",
        .attrs = knl_uncore_ubox_formats_attr,
 };
@@ -1927,7 +1927,7 @@ static struct attribute *knl_uncore_cha_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_cha_format_group = {
+static const struct attribute_group knl_uncore_cha_format_group = {
        .name = "format",
        .attrs = knl_uncore_cha_formats_attr,
 };
@@ -2037,7 +2037,7 @@ static struct attribute *knl_uncore_pcu_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_pcu_format_group = {
+static const struct attribute_group knl_uncore_pcu_format_group = {
        .name = "format",
        .attrs = knl_uncore_pcu_formats_attr,
 };
@@ -2187,7 +2187,7 @@ static struct attribute *knl_uncore_irp_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group knl_uncore_irp_format_group = {
+static const struct attribute_group knl_uncore_irp_format_group = {
        .name = "format",
        .attrs = knl_uncore_irp_formats_attr,
 };
@@ -2385,7 +2385,7 @@ static struct attribute *hswep_uncore_ubox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group hswep_uncore_ubox_format_group = {
+static const struct attribute_group hswep_uncore_ubox_format_group = {
        .name = "format",
        .attrs = hswep_uncore_ubox_formats_attr,
 };
@@ -2439,7 +2439,7 @@ static struct attribute *hswep_uncore_cbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group hswep_uncore_cbox_format_group = {
+static const struct attribute_group hswep_uncore_cbox_format_group = {
        .name = "format",
        .attrs = hswep_uncore_cbox_formats_attr,
 };
@@ -2621,7 +2621,7 @@ static struct attribute *hswep_uncore_sbox_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group hswep_uncore_sbox_format_group = {
+static const struct attribute_group hswep_uncore_sbox_format_group = {
        .name = "format",
        .attrs = hswep_uncore_sbox_formats_attr,
 };
@@ -3314,7 +3314,7 @@ static struct attribute *skx_uncore_cha_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_uncore_chabox_format_group = {
+static const struct attribute_group skx_uncore_chabox_format_group = {
        .name = "format",
        .attrs = skx_uncore_cha_formats_attr,
 };
@@ -3427,7 +3427,7 @@ static struct attribute *skx_uncore_iio_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_uncore_iio_format_group = {
+static const struct attribute_group skx_uncore_iio_format_group = {
        .name = "format",
        .attrs = skx_uncore_iio_formats_attr,
 };
@@ -3484,7 +3484,7 @@ static struct attribute *skx_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_uncore_format_group = {
+static const struct attribute_group skx_uncore_format_group = {
        .name = "format",
        .attrs = skx_uncore_formats_attr,
 };
@@ -3605,7 +3605,7 @@ static struct attribute *skx_upi_uncore_formats_attr[] = {
        NULL,
 };
 
-static struct attribute_group skx_upi_uncore_format_group = {
+static const struct attribute_group skx_upi_uncore_format_group = {
        .name = "format",
        .attrs = skx_upi_uncore_formats_attr,
 };
index ca3c48c0872f4beba6b03ac92c50eb6a352b3006..5a28e8e55e36fd2164c0cda175288a7fcc534c4b 100644 (file)
 #define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */
 #define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */
 #define X86_FEATURE_AVIC       (15*32+13) /* Virtual Interrupt Controller */
-#define X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE (15*32+15) /* Virtual VMLOAD VMSAVE */
+#define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */
 #define X86_FEATURE_AVX512VBMI  (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
index 1c18d83d3f094d1f5abfa09a08b67e9cb6b7376d..9aeb91935ce02387d8dae5e2f51bf1750f420a43 100644 (file)
@@ -247,11 +247,11 @@ extern int force_personality32;
 
 /*
  * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
+ * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
 #define ELF_ET_DYN_BASE                (mmap_is_ia32() ? 0x000400000UL : \
-                                                 0x100000000UL)
+                                                 (TASK_SIZE / 3 * 2))
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this CPU supports.  This could be done in user space,
index 255645f60ca2b4be333de67a10c6780f364e6fb2..554cdb205d17586887e6b599c991b2fc090ba38a 100644 (file)
@@ -450,10 +450,10 @@ static inline int copy_fpregs_to_fpstate(struct fpu *fpu)
        return 0;
 }
 
-static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate)
+static inline void __copy_kernel_to_fpregs(union fpregs_state *fpstate, u64 mask)
 {
        if (use_xsave()) {
-               copy_kernel_to_xregs(&fpstate->xsave, -1);
+               copy_kernel_to_xregs(&fpstate->xsave, mask);
        } else {
                if (use_fxsr())
                        copy_kernel_to_fxregs(&fpstate->fxsave);
@@ -477,7 +477,7 @@ static inline void copy_kernel_to_fpregs(union fpregs_state *fpstate)
                        : : [addr] "m" (fpstate));
        }
 
-       __copy_kernel_to_fpregs(fpstate);
+       __copy_kernel_to_fpregs(fpstate, -1);
 }
 
 extern int copy_fpstate_to_sigframe(void __user *buf, void __user *fp, int size);
index 21126155a739f4a3495499f052abcd3eab5a0bb7..0ead9dbb91301d0f7f8923dcf33f25515bd182b8 100644 (file)
@@ -43,6 +43,9 @@ struct hypervisor_x86 {
 
        /* pin current vcpu to specified physical cpu (run rarely) */
        void            (*pin_vcpu)(int);
+
+       /* called during init_mem_mapping() to setup early mappings. */
+       void            (*init_mem_mapping)(void);
 };
 
 extern const struct hypervisor_x86 *x86_hyper;
@@ -57,8 +60,15 @@ extern const struct hypervisor_x86 x86_hyper_kvm;
 extern void init_hypervisor_platform(void);
 extern bool hypervisor_x2apic_available(void);
 extern void hypervisor_pin_vcpu(int cpu);
+
+static inline void hypervisor_init_mem_mapping(void)
+{
+       if (x86_hyper && x86_hyper->init_mem_mapping)
+               x86_hyper->init_mem_mapping();
+}
 #else
 static inline void init_hypervisor_platform(void) { }
 static inline bool hypervisor_x2apic_available(void) { return false; }
+static inline void hypervisor_init_mem_mapping(void) { }
 #endif /* CONFIG_HYPERVISOR_GUEST */
 #endif /* _ASM_X86_HYPERVISOR_H */
index 87ac4fba6d8e12f07e8a9f191bdb028a1c3e6234..92c9032502d87b3291268f2c98b04ec4cb59854d 100644 (file)
@@ -492,6 +492,7 @@ struct kvm_vcpu_arch {
        unsigned long cr4;
        unsigned long cr4_guest_owned_bits;
        unsigned long cr8;
+       u32 pkru;
        u32 hflags;
        u64 efer;
        u64 apic_base;
@@ -1374,8 +1375,6 @@ int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
 int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
 void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event);
 void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu);
-void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
-                                          unsigned long address);
 
 void kvm_define_shared_msr(unsigned index, u32 msr);
 int kvm_set_shared_msr(unsigned index, u64 val, u64 mask);
index 265c907d7d4c9b8c69e24792a20c5a3dfb6c95ee..7a234be7e29846618cbdafb0153705cb8a8566b3 100644 (file)
@@ -140,9 +140,7 @@ static inline int init_new_context(struct task_struct *tsk,
                mm->context.execute_only_pkey = -1;
        }
        #endif
-       init_new_context_ldt(tsk, mm);
-
-       return 0;
+       return init_new_context_ldt(tsk, mm);
 }
 static inline void destroy_context(struct mm_struct *mm)
 {
index 7cf7c70b6ef2a20483361fb8333a85ace25bf1d7..0ee83321a3136fcca7a00a3b7e6c375e7a51e13f 100644 (file)
@@ -40,13 +40,16 @@ static void aperfmperf_snapshot_khz(void *dummy)
        struct aperfmperf_sample *s = this_cpu_ptr(&samples);
        ktime_t now = ktime_get();
        s64 time_delta = ktime_ms_delta(now, s->time);
+       unsigned long flags;
 
        /* Don't bother re-computing within the cache threshold time. */
        if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS)
                return;
 
+       local_irq_save(flags);
        rdmsrl(MSR_IA32_APERF, aperf);
        rdmsrl(MSR_IA32_MPERF, mperf);
+       local_irq_restore(flags);
 
        aperf_delta = aperf - s->aperf;
        mperf_delta = mperf - s->mperf;
index d7cc190ae45719bf84d721e781dc7fde00c85e14..f7370abd33c67570ad713a03a20f9114e6ad6399 100644 (file)
@@ -122,7 +122,7 @@ static struct attribute *thermal_throttle_attrs[] = {
        NULL
 };
 
-static struct attribute_group thermal_attr_group = {
+static const struct attribute_group thermal_attr_group = {
        .attrs  = thermal_throttle_attrs,
        .name   = "thermal_throttle"
 };
index 9cb98ee103db1bf0cdc2349614fe0d4e59cfb21f..86e8f0b2537b3eaedd2da204d67c94947a1b16f1 100644 (file)
@@ -561,7 +561,7 @@ static struct attribute *mc_default_attrs[] = {
        NULL
 };
 
-static struct attribute_group mc_attr_group = {
+static const struct attribute_group mc_attr_group = {
        .attrs                  = mc_default_attrs,
        .name                   = "microcode",
 };
@@ -707,7 +707,7 @@ static struct attribute *cpu_root_microcode_attrs[] = {
        NULL
 };
 
-static struct attribute_group cpu_root_microcode_group = {
+static const struct attribute_group cpu_root_microcode_group = {
        .name  = "microcode",
        .attrs = cpu_root_microcode_attrs,
 };
index c5bb63be4ba1e6a2df1203fe73079faad9fc62e7..40d5a8a752125ed5d26a7605d5eabad572879bfc 100644 (file)
@@ -237,6 +237,18 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ
        stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask);
 }
 
+static void set_mtrr_cpuslocked(unsigned int reg, unsigned long base,
+                               unsigned long size, mtrr_type type)
+{
+       struct set_mtrr_data data = { .smp_reg = reg,
+                                     .smp_base = base,
+                                     .smp_size = size,
+                                     .smp_type = type
+                                   };
+
+       stop_machine_cpuslocked(mtrr_rendezvous_handler, &data, cpu_online_mask);
+}
+
 static void set_mtrr_from_inactive_cpu(unsigned int reg, unsigned long base,
                                      unsigned long size, mtrr_type type)
 {
@@ -370,7 +382,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
        /* Search for an empty MTRR */
        i = mtrr_if->get_free_region(base, size, replace);
        if (i >= 0) {
-               set_mtrr(i, base, size, type);
+               set_mtrr_cpuslocked(i, base, size, type);
                if (likely(replace < 0)) {
                        mtrr_usage_table[i] = 1;
                } else {
@@ -378,7 +390,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
                        if (increment)
                                mtrr_usage_table[i]++;
                        if (unlikely(replace != i)) {
-                               set_mtrr(replace, 0, 0, 0);
+                               set_mtrr_cpuslocked(replace, 0, 0, 0);
                                mtrr_usage_table[replace] = 0;
                        }
                }
@@ -506,7 +518,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
                goto out;
        }
        if (--mtrr_usage_table[reg] < 1)
-               set_mtrr(reg, 0, 0, 0);
+               set_mtrr_cpuslocked(reg, 0, 0, 0);
        error = reg;
  out:
        mutex_unlock(&mtrr_mutex);
index 46c3c73e7f43f5fbb56fe0028d8aafb64a3f8a9e..9ba79543d9ee9f1ee19bce38955467afa04b125f 100644 (file)
@@ -53,6 +53,7 @@ void __head __startup_64(unsigned long physaddr)
        pudval_t *pud;
        pmdval_t *pmd, pmd_entry;
        int i;
+       unsigned int *next_pgt_ptr;
 
        /* Is the address too large? */
        if (physaddr >> MAX_PHYSMEM_BITS)
@@ -91,9 +92,9 @@ void __head __startup_64(unsigned long physaddr)
         * creates a bunch of nonsense entries but that is fine --
         * it avoids problems around wraparound.
         */
-
-       pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
-       pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
+       next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr);
+       pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
+       pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
 
        if (IS_ENABLED(CONFIG_X86_5LEVEL)) {
                p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
index 4afc67f5facc497606e2fb898ba7b7d402f04caa..06e1ff5562c0b4a5a28f3c052ed74b545c7ccca0 100644 (file)
@@ -55,7 +55,7 @@ static struct bin_attribute *boot_params_data_attrs[] = {
        NULL,
 };
 
-static struct attribute_group boot_params_attr_group = {
+static const struct attribute_group boot_params_attr_group = {
        .attrs = boot_params_version_attrs,
        .bin_attrs = boot_params_data_attrs,
 };
@@ -202,7 +202,7 @@ static struct bin_attribute *setup_data_data_attrs[] = {
        NULL,
 };
 
-static struct attribute_group setup_data_attr_group = {
+static const struct attribute_group setup_data_attr_group = {
        .attrs = setup_data_type_attrs,
        .bin_attrs = setup_data_data_attrs,
 };
index b474c8de7fba09cfe27d1e0124f694d152654570..54b9e89d4d6be3844b8b3c310433467d0e5f1481 100644 (file)
@@ -971,7 +971,8 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
  * Returns zero if CPU booted OK, else error code from
  * ->wakeup_secondary_cpu.
  */
-static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
+static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
+                      int *cpu0_nmi_registered)
 {
        volatile u32 *trampoline_status =
                (volatile u32 *) __va(real_mode_header->trampoline_status);
@@ -979,7 +980,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
        unsigned long start_ip = real_mode_header->trampoline_start;
 
        unsigned long boot_error = 0;
-       int cpu0_nmi_registered = 0;
        unsigned long timeout;
 
        idle->thread.sp = (unsigned long)task_pt_regs(idle);
@@ -1035,7 +1035,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
                boot_error = apic->wakeup_secondary_cpu(apicid, start_ip);
        else
                boot_error = wakeup_cpu_via_init_nmi(cpu, start_ip, apicid,
-                                                    &cpu0_nmi_registered);
+                                                    cpu0_nmi_registered);
 
        if (!boot_error) {
                /*
@@ -1080,12 +1080,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
                 */
                smpboot_restore_warm_reset_vector();
        }
-       /*
-        * Clean up the nmi handler. Do this after the callin and callout sync
-        * to avoid impact of possible long unregister time.
-        */
-       if (cpu0_nmi_registered)
-               unregister_nmi_handler(NMI_LOCAL, "wake_cpu0");
 
        return boot_error;
 }
@@ -1093,8 +1087,9 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
 int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        int apicid = apic->cpu_present_to_apicid(cpu);
+       int cpu0_nmi_registered = 0;
        unsigned long flags;
-       int err;
+       int err, ret = 0;
 
        WARN_ON(irqs_disabled());
 
@@ -1131,10 +1126,11 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
 
        common_cpu_up(cpu, tidle);
 
-       err = do_boot_cpu(apicid, cpu, tidle);
+       err = do_boot_cpu(apicid, cpu, tidle, &cpu0_nmi_registered);
        if (err) {
                pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu);
-               return -EIO;
+               ret = -EIO;
+               goto unreg_nmi;
        }
 
        /*
@@ -1150,7 +1146,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
                touch_nmi_watchdog();
        }
 
-       return 0;
+unreg_nmi:
+       /*
+        * Clean up the nmi handler. Do this after the callin and callout sync
+        * to avoid impact of possible long unregister time.
+        */
+       if (cpu0_nmi_registered)
+               unregister_nmi_handler(NMI_LOCAL, "wake_cpu0");
+
+       return ret;
 }
 
 /**
index 59ca2eea522c466937287c3e660b8f38e49c12aa..19adbb4184439dd6c40c39cd6dec2afe5a9ae83a 100644 (file)
@@ -469,7 +469,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
                        entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
                        cpuid_mask(&entry->ecx, CPUID_7_ECX);
                        /* PKU is not yet implemented for shadow paging. */
-                       if (!tdp_enabled)
+                       if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
                                entry->ecx &= ~F(PKU);
                        entry->edx &= kvm_cpuid_7_0_edx_x86_features;
                        entry->edx &= get_scattered_cpuid_leaf(7, 0, CPUID_EDX);
index 762cdf2595f992fd4ac8bb1e4c2c8914b344db04..e1e89ee4af750dc51f78cfbf8aa71e22d77b4cd1 100644 (file)
@@ -84,11 +84,6 @@ static inline u64 kvm_read_edx_eax(struct kvm_vcpu *vcpu)
                | ((u64)(kvm_register_read(vcpu, VCPU_REGS_RDX) & -1u) << 32);
 }
 
-static inline u32 kvm_read_pkru(struct kvm_vcpu *vcpu)
-{
-       return kvm_x86_ops->get_pkru(vcpu);
-}
-
 static inline void enter_guest_mode(struct kvm_vcpu *vcpu)
 {
        vcpu->arch.hflags |= HF_GUEST_MASK;
index d7d248a000dd6772681f3f5541e344f9677a2d1d..4b9a3ae6b725d37bdeeb5aeb24c0a9c2716228f4 100644 (file)
@@ -185,7 +185,7 @@ static inline u8 permission_fault(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
                * index of the protection domain, so pte_pkey * 2 is
                * is the index of the first bit for the domain.
                */
-               pkru_bits = (kvm_read_pkru(vcpu) >> (pte_pkey * 2)) & 3;
+               pkru_bits = (vcpu->arch.pkru >> (pte_pkey * 2)) & 3;
 
                /* clear present bit, replace PFEC.RSVD with ACC_USER_MASK. */
                offset = (pfec & ~1) +
index 1107626938ccff4f26da130f8b570928ca7c8efb..af256b786a70cccd14906fe926e2b790156967a4 100644 (file)
@@ -1100,7 +1100,7 @@ static __init int svm_hardware_setup(void)
 
        if (vls) {
                if (!npt_enabled ||
-                   !boot_cpu_has(X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE) ||
+                   !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
                    !IS_ENABLED(CONFIG_X86_64)) {
                        vls = false;
                } else {
@@ -1777,11 +1777,6 @@ static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
        to_svm(vcpu)->vmcb->save.rflags = rflags;
 }
 
-static u32 svm_get_pkru(struct kvm_vcpu *vcpu)
-{
-       return 0;
-}
-
 static void svm_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
 {
        switch (reg) {
@@ -5413,8 +5408,6 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .get_rflags = svm_get_rflags,
        .set_rflags = svm_set_rflags,
 
-       .get_pkru = svm_get_pkru,
-
        .tlb_flush = svm_flush_tlb,
 
        .run = svm_vcpu_run,
index 9b21b12230354e334900e6536b7612285f75b7e3..c6ef2940119bfdfb00f0547c321697280ebae0fa 100644 (file)
@@ -636,8 +636,6 @@ struct vcpu_vmx {
 
        u64 current_tsc_ratio;
 
-       bool guest_pkru_valid;
-       u32 guest_pkru;
        u32 host_pkru;
 
        /*
@@ -2383,11 +2381,6 @@ static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
                to_vmx(vcpu)->emulation_required = emulation_required(vcpu);
 }
 
-static u32 vmx_get_pkru(struct kvm_vcpu *vcpu)
-{
-       return to_vmx(vcpu)->guest_pkru;
-}
-
 static u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu)
 {
        u32 interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
@@ -9020,8 +9013,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
        if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
                vmx_set_interrupt_shadow(vcpu, 0);
 
-       if (vmx->guest_pkru_valid)
-               __write_pkru(vmx->guest_pkru);
+       if (static_cpu_has(X86_FEATURE_PKU) &&
+           kvm_read_cr4_bits(vcpu, X86_CR4_PKE) &&
+           vcpu->arch.pkru != vmx->host_pkru)
+               __write_pkru(vcpu->arch.pkru);
 
        atomic_switch_perf_msrs(vmx);
        debugctlmsr = get_debugctlmsr();
@@ -9169,13 +9164,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
         * back on host, so it is safe to read guest PKRU from current
         * XSAVE.
         */
-       if (boot_cpu_has(X86_FEATURE_OSPKE)) {
-               vmx->guest_pkru = __read_pkru();
-               if (vmx->guest_pkru != vmx->host_pkru) {
-                       vmx->guest_pkru_valid = true;
+       if (static_cpu_has(X86_FEATURE_PKU) &&
+           kvm_read_cr4_bits(vcpu, X86_CR4_PKE)) {
+               vcpu->arch.pkru = __read_pkru();
+               if (vcpu->arch.pkru != vmx->host_pkru)
                        __write_pkru(vmx->host_pkru);
-               } else
-                       vmx->guest_pkru_valid = false;
        }
 
        /*
@@ -11682,8 +11675,6 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
        .get_rflags = vmx_get_rflags,
        .set_rflags = vmx_set_rflags,
 
-       .get_pkru = vmx_get_pkru,
-
        .tlb_flush = vmx_flush_tlb,
 
        .run = vmx_vcpu_run,
index d734aa8c5b4f7290e365badd00ea962fd0af9acd..272320eb328c9bc8c2d0cf839a097a30ca27491f 100644 (file)
@@ -3245,7 +3245,12 @@ static void fill_xsave(u8 *dest, struct kvm_vcpu *vcpu)
                        u32 size, offset, ecx, edx;
                        cpuid_count(XSTATE_CPUID, index,
                                    &size, &offset, &ecx, &edx);
-                       memcpy(dest + offset, src, size);
+                       if (feature == XFEATURE_MASK_PKRU)
+                               memcpy(dest + offset, &vcpu->arch.pkru,
+                                      sizeof(vcpu->arch.pkru));
+                       else
+                               memcpy(dest + offset, src, size);
+
                }
 
                valid -= feature;
@@ -3283,7 +3288,11 @@ static void load_xsave(struct kvm_vcpu *vcpu, u8 *src)
                        u32 size, offset, ecx, edx;
                        cpuid_count(XSTATE_CPUID, index,
                                    &size, &offset, &ecx, &edx);
-                       memcpy(dest, src + offset, size);
+                       if (feature == XFEATURE_MASK_PKRU)
+                               memcpy(&vcpu->arch.pkru, src + offset,
+                                      sizeof(vcpu->arch.pkru));
+                       else
+                               memcpy(dest, src + offset, size);
                }
 
                valid -= feature;
@@ -6725,17 +6734,6 @@ void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu)
 }
 EXPORT_SYMBOL_GPL(kvm_vcpu_reload_apic_access_page);
 
-void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
-                                          unsigned long address)
-{
-       /*
-        * The physical address of apic access page is stored in the VMCS.
-        * Update it when it becomes invalid.
-        */
-       if (address == gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT))
-               kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD);
-}
-
 /*
  * Returns 1 to let vcpu_run() continue the guest execution loop without
  * exiting to the userspace.  Otherwise, the value will be returned to the
@@ -7633,7 +7631,9 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
         */
        vcpu->guest_fpu_loaded = 1;
        __kernel_fpu_begin();
-       __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
+       /* PKRU is separately restored in kvm_x86_ops->run.  */
+       __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state,
+                               ~XFEATURE_MASK_PKRU);
        trace_kvm_fpu(1);
 }
 
index 673541eb3b3f16c8c029349d597d67f4bb83a77a..bf3f1065d6addb88b898ba3a86089cccff6ed15e 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/dma.h>           /* for MAX_DMA_PFN */
 #include <asm/microcode.h>
 #include <asm/kaslr.h>
+#include <asm/hypervisor.h>
 
 /*
  * We need to define the tracepoints somewhere, and tlb.c
@@ -636,6 +637,8 @@ void __init init_mem_mapping(void)
        load_cr3(swapper_pg_dir);
        __flush_tlb_all();
 
+       hypervisor_init_mem_mapping();
+
        early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
 }
 
index 229d04a83f8561ec08e394f57d8cb5d671bd56ff..a88cfbfbd0781a4d20c398d7ca1b30f50f05be43 100644 (file)
@@ -50,8 +50,7 @@ unsigned long tasksize_64bit(void)
 static unsigned long stack_maxrandom_size(unsigned long task_size)
 {
        unsigned long max = 0;
-       if ((current->flags & PF_RANDOMIZE) &&
-               !(current->personality & ADDR_NO_RANDOMIZE)) {
+       if (current->flags & PF_RANDOMIZE) {
                max = (-1UL) & __STACK_RND_MASK(task_size == tasksize_32bit());
                max <<= PAGE_SHIFT;
        }
@@ -79,13 +78,13 @@ static int mmap_is_legacy(void)
 
 static unsigned long arch_rnd(unsigned int rndbits)
 {
+       if (!(current->flags & PF_RANDOMIZE))
+               return 0;
        return (get_random_long() & ((1UL << rndbits) - 1)) << PAGE_SHIFT;
 }
 
 unsigned long arch_mmap_rnd(void)
 {
-       if (!(current->flags & PF_RANDOMIZE))
-               return 0;
        return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits);
 }
 
index 3e4bdb442fbcfc783059be96efe4d4e2d6b58b47..f44c0bc95aa2f45ad42462a5f23f4db4672d1257 100644 (file)
@@ -26,7 +26,7 @@
 static struct bau_operations ops __ro_after_init;
 
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
-static int timeout_base_ns[] = {
+static const int timeout_base_ns[] = {
                20,
                160,
                1280,
@@ -1216,7 +1216,7 @@ static struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg,
  * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register.
  * Such a message must be ignored.
  */
-void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
+static void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
 {
        unsigned long mmr_image;
        unsigned char swack_vec;
index ae4cd58c0c7a403c8ba40f978e5d4221ce94bfc6..02250b2633b839c7fa56704d804dd4953f244121 100644 (file)
@@ -50,7 +50,7 @@ void foo(void)
        DEFINE(HOST_GS, GS);
        DEFINE(HOST_ORIG_AX, ORIG_EAX);
 #else
-#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
+#ifdef FP_XSTATE_MAGIC1
        DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
 #else
        DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
index 87d791356ea9052f79f23e00f5d0024ff8cf0b7f..de503c225ae1f194b10c71b44528ad2a2a7a4c0d 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/setup.h>
 #include <asm/hypervisor.h>
 #include <asm/e820/api.h>
+#include <asm/early_ioremap.h>
 
 #include <asm/xen/cpuid.h>
 #include <asm/xen/hypervisor.h>
 #include "mmu.h"
 #include "smp.h"
 
-void __ref xen_hvm_init_shared_info(void)
+static unsigned long shared_info_pfn;
+
+void xen_hvm_init_shared_info(void)
 {
        struct xen_add_to_physmap xatp;
-       u64 pa;
-
-       if (HYPERVISOR_shared_info == &xen_dummy_shared_info) {
-               /*
-                * Search for a free page starting at 4kB physical address.
-                * Low memory is preferred to avoid an EPT large page split up
-                * by the mapping.
-                * Starting below X86_RESERVE_LOW (usually 64kB) is fine as
-                * the BIOS used for HVM guests is well behaved and won't
-                * clobber memory other than the first 4kB.
-                */
-               for (pa = PAGE_SIZE;
-                    !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) ||
-                    memblock_is_reserved(pa);
-                    pa += PAGE_SIZE)
-                       ;
-
-               memblock_reserve(pa, PAGE_SIZE);
-               HYPERVISOR_shared_info = __va(pa);
-       }
 
        xatp.domid = DOMID_SELF;
        xatp.idx = 0;
        xatp.space = XENMAPSPACE_shared_info;
-       xatp.gpfn = virt_to_pfn(HYPERVISOR_shared_info);
+       xatp.gpfn = shared_info_pfn;
        if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
                BUG();
 }
 
+static void __init reserve_shared_info(void)
+{
+       u64 pa;
+
+       /*
+        * Search for a free page starting at 4kB physical address.
+        * Low memory is preferred to avoid an EPT large page split up
+        * by the mapping.
+        * Starting below X86_RESERVE_LOW (usually 64kB) is fine as
+        * the BIOS used for HVM guests is well behaved and won't
+        * clobber memory other than the first 4kB.
+        */
+       for (pa = PAGE_SIZE;
+            !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) ||
+            memblock_is_reserved(pa);
+            pa += PAGE_SIZE)
+               ;
+
+       shared_info_pfn = PHYS_PFN(pa);
+
+       memblock_reserve(pa, PAGE_SIZE);
+       HYPERVISOR_shared_info = early_memremap(pa, PAGE_SIZE);
+}
+
+static void __init xen_hvm_init_mem_mapping(void)
+{
+       early_memunmap(HYPERVISOR_shared_info, PAGE_SIZE);
+       HYPERVISOR_shared_info = __va(PFN_PHYS(shared_info_pfn));
+}
+
 static void __init init_hvm_pv_info(void)
 {
        int major, minor;
@@ -153,6 +166,7 @@ static void __init xen_hvm_guest_init(void)
 
        init_hvm_pv_info();
 
+       reserve_shared_info();
        xen_hvm_init_shared_info();
 
        /*
@@ -218,5 +232,6 @@ const struct hypervisor_x86 x86_hyper_xen_hvm = {
        .init_platform          = xen_hvm_guest_init,
        .pin_vcpu               = xen_pin_vcpu,
        .x2apic_available       = xen_x2apic_para_available,
+       .init_mem_mapping       = xen_hvm_init_mem_mapping,
 };
 EXPORT_SYMBOL(x86_hyper_xen_hvm);
index 2d716ebc5a5e90d62c3759e01a512e0ff6ab9de4..dff7cc39437caba214fac506f57009837f2223c8 100644 (file)
@@ -1,5 +1,6 @@
 generic-y += bug.h
 generic-y += clkdev.h
+generic-y += device.h
 generic-y += div64.h
 generic-y += dma-contiguous.h
 generic-y += emergency-restart.h
@@ -17,6 +18,7 @@ generic-y += local.h
 generic-y += local64.h
 generic-y += mcs_spinlock.h
 generic-y += mm-arch-hooks.h
+generic-y += param.h
 generic-y += percpu.h
 generic-y += preempt.h
 generic-y += rwsem.h
diff --git a/arch/xtensa/include/asm/device.h b/arch/xtensa/include/asm/device.h
deleted file mode 100644 (file)
index 1deeb8e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Arch specific extensions to struct device
- *
- * This file is released under the GPLv2
- */
-#ifndef _ASM_XTENSA_DEVICE_H
-#define _ASM_XTENSA_DEVICE_H
-
-struct dev_archdata {
-};
-
-struct pdev_archdata {
-};
-
-#endif /* _ASM_XTENSA_DEVICE_H */
diff --git a/arch/xtensa/include/asm/param.h b/arch/xtensa/include/asm/param.h
deleted file mode 100644 (file)
index 0a70e78..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * include/asm-xtensa/param.h
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2001 - 2005 Tensilica Inc.
- */
-#ifndef _XTENSA_PARAM_H
-#define _XTENSA_PARAM_H
-
-#include <uapi/asm/param.h>
-
-# define HZ            CONFIG_HZ       /* internal timer frequency */
-# define USER_HZ       100             /* for user interfaces in "ticks" */
-# define CLOCKS_PER_SEC (USER_HZ)      /* frequnzy at which times() counts */
-#endif /* _XTENSA_PARAM_H */
index d159e9b9c01837ba5aa9e77d50c3c14e475ce367..672391003e40fac4f814fe5b6aa1dc04e791c81b 100644 (file)
@@ -94,13 +94,11 @@ unsigned long __sync_fetch_and_or_4(unsigned long *p, unsigned long v)
 }
 EXPORT_SYMBOL(__sync_fetch_and_or_4);
 
-#ifdef CONFIG_NET
 /*
  * Networking support
  */
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(csum_partial_copy_generic);
-#endif /* CONFIG_NET */
 
 /*
  * Architecture-specific symbols
index 1a804a2f9a5be6212c57febc01f6d28f47b8c91a..3c75c4e597da8f086f65de51201e0d37d6672733 100644 (file)
@@ -103,6 +103,7 @@ void clear_user_highpage(struct page *page, unsigned long vaddr)
        clear_page_alias(kvaddr, paddr);
        preempt_enable();
 }
+EXPORT_SYMBOL(clear_user_highpage);
 
 void copy_user_highpage(struct page *dst, struct page *src,
                        unsigned long vaddr, struct vm_area_struct *vma)
@@ -119,10 +120,7 @@ void copy_user_highpage(struct page *dst, struct page *src,
        copy_page_alias(dst_vaddr, src_vaddr, dst_paddr, src_paddr);
        preempt_enable();
 }
-
-#endif /* DCACHE_WAY_SIZE > PAGE_SIZE */
-
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+EXPORT_SYMBOL(copy_user_highpage);
 
 /*
  * Any time the kernel writes to a user page cache page, or it is about to
@@ -176,7 +174,7 @@ void flush_dcache_page(struct page *page)
 
        /* There shouldn't be an entry in the cache for this page anymore. */
 }
-
+EXPORT_SYMBOL(flush_dcache_page);
 
 /*
  * For now, flush the whole cache. FIXME??
@@ -188,6 +186,7 @@ void local_flush_cache_range(struct vm_area_struct *vma,
        __flush_invalidate_dcache_all();
        __invalidate_icache_all();
 }
+EXPORT_SYMBOL(local_flush_cache_range);
 
 /* 
  * Remove any entry in the cache for this page. 
@@ -207,8 +206,9 @@ void local_flush_cache_page(struct vm_area_struct *vma, unsigned long address,
        __flush_invalidate_dcache_page_alias(virt, phys);
        __invalidate_icache_page_alias(virt, phys);
 }
+EXPORT_SYMBOL(local_flush_cache_page);
 
-#endif
+#endif /* DCACHE_WAY_SIZE > PAGE_SIZE */
 
 void
 update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
@@ -225,7 +225,7 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
 
        flush_tlb_page(vma, addr);
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
        if (!PageReserved(page) && test_bit(PG_arch_1, &page->flags)) {
                unsigned long phys = page_to_phys(page);
@@ -256,7 +256,7 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
  * flush_dcache_page() on the page.
  */
 
-#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
+#if (DCACHE_WAY_SIZE > PAGE_SIZE)
 
 void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
                unsigned long vaddr, void *dst, const void *src,
index 63e771ab56d80ade8cd5b5e8ccd86f2fac5f0573..859f0a8c97c8a1bf58b6ed4dc016c0ce0fb355ad 100644 (file)
@@ -71,17 +71,29 @@ struct bfq_service_tree {
  *
  * bfq_sched_data is the basic scheduler queue.  It supports three
  * ioprio_classes, and can be used either as a toplevel queue or as an
- * intermediate queue on a hierarchical setup.  @next_in_service
- * points to the active entity of the sched_data service trees that
- * will be scheduled next. It is used to reduce the number of steps
- * needed for each hierarchical-schedule update.
+ * intermediate queue in a hierarchical setup.
  *
  * The supported ioprio_classes are the same as in CFQ, in descending
  * priority order, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE.
  * Requests from higher priority queues are served before all the
  * requests from lower priority queues; among requests of the same
  * queue requests are served according to B-WF2Q+.
- * All the fields are protected by the queue lock of the containing bfqd.
+ *
+ * The schedule is implemented by the service trees, plus the field
+ * @next_in_service, which points to the entity on the active trees
+ * that will be served next, if 1) no changes in the schedule occurs
+ * before the current in-service entity is expired, 2) the in-service
+ * queue becomes idle when it expires, and 3) if the entity pointed by
+ * in_service_entity is not a queue, then the in-service child entity
+ * of the entity pointed by in_service_entity becomes idle on
+ * expiration. This peculiar definition allows for the following
+ * optimization, not yet exploited: while a given entity is still in
+ * service, we already know which is the best candidate for next
+ * service among the other active entitities in the same parent
+ * entity. We can then quickly compare the timestamps of the
+ * in-service entity with those of such best candidate.
+ *
+ * All fields are protected by the lock of the containing bfqd.
  */
 struct bfq_sched_data {
        /* entity in service */
index 979f8f21b7e2b17268b2db3c9510c333fccbe10f..911aa7431dbeb08d6db591c1a0f577bd3af56e22 100644 (file)
@@ -188,21 +188,23 @@ static bool bfq_update_parent_budget(struct bfq_entity *next_in_service)
 
 /*
  * This function tells whether entity stops being a candidate for next
- * service, according to the following logic.
+ * service, according to the restrictive definition of the field
+ * next_in_service. In particular, this function is invoked for an
+ * entity that is about to be set in service.
  *
- * This function is invoked for an entity that is about to be set in
- * service. If such an entity is a queue, then the entity is no longer
- * a candidate for next service (i.e, a candidate entity to serve
- * after the in-service entity is expired). The function then returns
- * true.
+ * If entity is a queue, then the entity is no longer a candidate for
+ * next service according to the that definition, because entity is
+ * about to become the in-service queue. This function then returns
+ * true if entity is a queue.
  *
- * In contrast, the entity could stil be a candidate for next service
- * if it is not a queue, and has more than one child. In fact, even if
- * one of its children is about to be set in service, other children
- * may still be the next to serve. As a consequence, a non-queue
- * entity is not a candidate for next-service only if it has only one
- * child. And only if this condition holds, then the function returns
- * true for a non-queue entity.
+ * In contrast, entity could still be a candidate for next service if
+ * it is not a queue, and has more than one active child. In fact,
+ * even if one of its children is about to be set in service, other
+ * active children may still be the next to serve, for the parent
+ * entity, even according to the above definition. As a consequence, a
+ * non-queue entity is not a candidate for next-service only if it has
+ * only one active child. And only if this condition holds, then this
+ * function returns true for a non-queue entity.
  */
 static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
 {
@@ -213,6 +215,18 @@ static bool bfq_no_longer_next_in_service(struct bfq_entity *entity)
 
        bfqg = container_of(entity, struct bfq_group, entity);
 
+       /*
+        * The field active_entities does not always contain the
+        * actual number of active children entities: it happens to
+        * not account for the in-service entity in case the latter is
+        * removed from its active tree (which may get done after
+        * invoking the function bfq_no_longer_next_in_service in
+        * bfq_get_next_queue). Fortunately, here, i.e., while
+        * bfq_no_longer_next_in_service is not yet completed in
+        * bfq_get_next_queue, bfq_active_extract has not yet been
+        * invoked, and thus active_entities still coincides with the
+        * actual number of active entities.
+        */
        if (bfqg->active_entities == 1)
                return true;
 
@@ -954,7 +968,7 @@ static void bfq_update_fin_time_enqueue(struct bfq_entity *entity,
  * one of its children receives a new request.
  *
  * Basically, this function updates the timestamps of entity and
- * inserts entity into its active tree, ater possible extracting it
+ * inserts entity into its active tree, ater possibly extracting it
  * from its idle tree.
  */
 static void __bfq_activate_entity(struct bfq_entity *entity,
@@ -1048,7 +1062,7 @@ static void __bfq_requeue_entity(struct bfq_entity *entity)
                entity->start = entity->finish;
                /*
                 * In addition, if the entity had more than one child
-                * when set in service, then was not extracted from
+                * when set in service, then it was not extracted from
                 * the active tree. This implies that the position of
                 * the entity in the active tree may need to be
                 * changed now, because we have just updated the start
@@ -1056,9 +1070,8 @@ static void __bfq_requeue_entity(struct bfq_entity *entity)
                 * time in a moment (the requeueing is then, more
                 * precisely, a repositioning in this case). To
                 * implement this repositioning, we: 1) dequeue the
-                * entity here, 2) update the finish time and
-                * requeue the entity according to the new
-                * timestamps below.
+                * entity here, 2) update the finish time and requeue
+                * the entity according to the new timestamps below.
                 */
                if (entity->tree)
                        bfq_active_extract(st, entity);
@@ -1105,9 +1118,10 @@ static void __bfq_activate_requeue_entity(struct bfq_entity *entity,
 
 
 /**
- * bfq_activate_entity - activate or requeue an entity representing a bfq_queue,
- *                      and activate, requeue or reposition all ancestors
- *                      for which such an update becomes necessary.
+ * bfq_activate_requeue_entity - activate or requeue an entity representing a
+ *                              bfq_queue, and activate, requeue or reposition
+ *                              all ancestors for which such an update becomes
+ *                              necessary.
  * @entity: the entity to activate.
  * @non_blocking_wait_rq: true if this entity was waiting for a request
  * @requeue: true if this is a requeue, which implies that bfqq is
@@ -1135,9 +1149,9 @@ static void bfq_activate_requeue_entity(struct bfq_entity *entity,
  * @ins_into_idle_tree: if false, the entity will not be put into the
  *                     idle tree.
  *
- * Deactivates an entity, independently from its previous state.  Must
+ * Deactivates an entity, independently of its previous state.  Must
  * be invoked only if entity is on a service tree. Extracts the entity
- * from that tree, and if necessary and allowed, puts it on the idle
+ * from that tree, and if necessary and allowed, puts it into the idle
  * tree.
  */
 bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree)
@@ -1158,8 +1172,10 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree)
        st = bfq_entity_service_tree(entity);
        is_in_service = entity == sd->in_service_entity;
 
-       if (is_in_service)
+       if (is_in_service) {
                bfq_calc_finish(entity, entity->service);
+               sd->in_service_entity = NULL;
+       }
 
        if (entity->tree == &st->active)
                bfq_active_extract(st, entity);
@@ -1177,7 +1193,7 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity, bool ins_into_idle_tree)
 /**
  * bfq_deactivate_entity - deactivate an entity representing a bfq_queue.
  * @entity: the entity to deactivate.
- * @ins_into_idle_tree: true if the entity can be put on the idle tree
+ * @ins_into_idle_tree: true if the entity can be put into the idle tree
  */
 static void bfq_deactivate_entity(struct bfq_entity *entity,
                                  bool ins_into_idle_tree,
@@ -1208,16 +1224,29 @@ static void bfq_deactivate_entity(struct bfq_entity *entity,
                         */
                        bfq_update_next_in_service(sd, NULL);
 
-               if (sd->next_in_service)
+               if (sd->next_in_service || sd->in_service_entity) {
                        /*
-                        * The parent entity is still backlogged,
-                        * because next_in_service is not NULL. So, no
-                        * further upwards deactivation must be
-                        * performed.  Yet, next_in_service has
-                        * changed.  Then the schedule does need to be
-                        * updated upwards.
+                        * The parent entity is still active, because
+                        * either next_in_service or in_service_entity
+                        * is not NULL. So, no further upwards
+                        * deactivation must be performed.  Yet,
+                        * next_in_service has changed. Then the
+                        * schedule does need to be updated upwards.
+                        *
+                        * NOTE If in_service_entity is not NULL, then
+                        * next_in_service may happen to be NULL,
+                        * although the parent entity is evidently
+                        * active. This happens if 1) the entity
+                        * pointed by in_service_entity is the only
+                        * active entity in the parent entity, and 2)
+                        * according to the definition of
+                        * next_in_service, the in_service_entity
+                        * cannot be considered as
+                        * next_in_service. See the comments on the
+                        * definition of next_in_service for details.
                         */
                        break;
+               }
 
                /*
                 * If we get here, then the parent is no more
@@ -1494,47 +1523,34 @@ struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd)
 
                /*
                 * If entity is no longer a candidate for next
-                * service, then we extract it from its active tree,
-                * for the following reason. To further boost the
-                * throughput in some special case, BFQ needs to know
-                * which is the next candidate entity to serve, while
-                * there is already an entity in service. In this
-                * respect, to make it easy to compute/update the next
-                * candidate entity to serve after the current
-                * candidate has been set in service, there is a case
-                * where it is necessary to extract the current
-                * candidate from its service tree. Such a case is
-                * when the entity just set in service cannot be also
-                * a candidate for next service. Details about when
-                * this conditions holds are reported in the comments
-                * on the function bfq_no_longer_next_in_service()
-                * invoked below.
+                * service, then it must be extracted from its active
+                * tree, so as to make sure that it won't be
+                * considered when computing next_in_service. See the
+                * comments on the function
+                * bfq_no_longer_next_in_service() for details.
                 */
                if (bfq_no_longer_next_in_service(entity))
                        bfq_active_extract(bfq_entity_service_tree(entity),
                                           entity);
 
                /*
-                * For the same reason why we may have just extracted
-                * entity from its active tree, we may need to update
-                * next_in_service for the sched_data of entity too,
-                * regardless of whether entity has been extracted.
-                * In fact, even if entity has not been extracted, a
-                * descendant entity may get extracted. Such an event
-                * would cause a change in next_in_service for the
-                * level of the descendant entity, and thus possibly
-                * back to upper levels.
+                * Even if entity is not to be extracted according to
+                * the above check, a descendant entity may get
+                * extracted in one of the next iterations of this
+                * loop. Such an event could cause a change in
+                * next_in_service for the level of the descendant
+                * entity, and thus possibly back to this level.
                 *
-                * We cannot perform the resulting needed update
-                * before the end of this loop, because, to know which
-                * is the correct next-to-serve candidate entity for
-                * each level, we need first to find the leaf entity
-                * to set in service. In fact, only after we know
-                * which is the next-to-serve leaf entity, we can
-                * discover whether the parent entity of the leaf
-                * entity becomes the next-to-serve, and so on.
+                * However, we cannot perform the resulting needed
+                * update of next_in_service for this level before the
+                * end of the whole loop, because, to know which is
+                * the correct next-to-serve candidate entity for each
+                * level, we need first to find the leaf entity to set
+                * in service. In fact, only after we know which is
+                * the next-to-serve leaf entity, we can discover
+                * whether the parent entity of the leaf entity
+                * becomes the next-to-serve, and so on.
                 */
-
        }
 
        bfqq = bfq_entity_to_bfqq(entity);
index 83e92beb3c9feb25f3be917e2b675f90b1544b5f..9b1ea478577b033195f34b457c85ad16eb759c6a 100644 (file)
@@ -387,9 +387,11 @@ static void bio_integrity_verify_fn(struct work_struct *work)
  */
 bool __bio_integrity_endio(struct bio *bio)
 {
-       if (bio_op(bio) == REQ_OP_READ && !bio->bi_status) {
-               struct bio_integrity_payload *bip = bio_integrity(bio);
+       struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
+       struct bio_integrity_payload *bip = bio_integrity(bio);
 
+       if (bio_op(bio) == REQ_OP_READ && !bio->bi_status &&
+           (bip->bip_flags & BIP_BLOCK_INTEGRITY) && bi->profile->verify_fn) {
                INIT_WORK(&bip->bip_work, bio_integrity_verify_fn);
                queue_work(kintegrityd_wq, &bip->bip_work);
                return false;
index 9ebc2945f991e9ff5d50c5191de45ca1025f1201..4f927a58dff86183a95baf9c7f4eb474c218f0f2 100644 (file)
@@ -75,6 +75,8 @@ static const char *const blk_queue_flag_name[] = {
        QUEUE_FLAG_NAME(STATS),
        QUEUE_FLAG_NAME(POLL_STATS),
        QUEUE_FLAG_NAME(REGISTERED),
+       QUEUE_FLAG_NAME(SCSI_PASSTHROUGH),
+       QUEUE_FLAG_NAME(QUIESCED),
 };
 #undef QUEUE_FLAG_NAME
 
@@ -265,6 +267,7 @@ static const char *const cmd_flag_name[] = {
        CMD_FLAG_NAME(RAHEAD),
        CMD_FLAG_NAME(BACKGROUND),
        CMD_FLAG_NAME(NOUNMAP),
+       CMD_FLAG_NAME(NOWAIT),
 };
 #undef CMD_FLAG_NAME
 
index 0c3354cf3552877d7542cdb32f0ce4102a79fcce..76944e3271bf34a730e62fa0b27266abce86942e 100644 (file)
@@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev)
        for (queue = 0; queue < set->nr_hw_queues; queue++) {
                mask = pci_irq_get_affinity(pdev, queue);
                if (!mask)
-                       return -EINVAL;
+                       goto fallback;
 
                for_each_cpu(cpu, mask)
                        set->mq_map[cpu] = queue;
        }
 
        return 0;
+
+fallback:
+       WARN_ON_ONCE(set->nr_hw_queues > 1);
+       for_each_possible_cpu(cpu)
+               set->mq_map[cpu] = 0;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);
index 041f7b7fa0d6def444e9349b6cf748afc8e89b2d..4603b115e234887860cbb28520c36ba9e5e7efd8 100644 (file)
@@ -301,11 +301,12 @@ static struct request *blk_mq_get_request(struct request_queue *q,
        struct elevator_queue *e = q->elevator;
        struct request *rq;
        unsigned int tag;
+       struct blk_mq_ctx *local_ctx = NULL;
 
        blk_queue_enter_live(q);
        data->q = q;
        if (likely(!data->ctx))
-               data->ctx = blk_mq_get_ctx(q);
+               data->ctx = local_ctx = blk_mq_get_ctx(q);
        if (likely(!data->hctx))
                data->hctx = blk_mq_map_queue(q, data->ctx->cpu);
        if (op & REQ_NOWAIT)
@@ -324,6 +325,10 @@ static struct request *blk_mq_get_request(struct request_queue *q,
 
        tag = blk_mq_get_tag(data);
        if (tag == BLK_MQ_TAG_FAIL) {
+               if (local_ctx) {
+                       blk_mq_put_ctx(local_ctx);
+                       data->ctx = NULL;
+               }
                blk_queue_exit(q);
                return NULL;
        }
@@ -355,13 +360,13 @@ struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,
                return ERR_PTR(ret);
 
        rq = blk_mq_get_request(q, NULL, op, &alloc_data);
-
-       blk_mq_put_ctx(alloc_data.ctx);
        blk_queue_exit(q);
 
        if (!rq)
                return ERR_PTR(-EWOULDBLOCK);
 
+       blk_mq_put_ctx(alloc_data.ctx);
+
        rq->__data_len = 0;
        rq->__sector = (sector_t) -1;
        rq->bio = rq->biotail = NULL;
@@ -406,7 +411,6 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
        alloc_data.ctx = __blk_mq_get_ctx(q, cpu);
 
        rq = blk_mq_get_request(q, NULL, op, &alloc_data);
-
        blk_queue_exit(q);
 
        if (!rq)
@@ -679,8 +683,8 @@ EXPORT_SYMBOL(blk_mq_kick_requeue_list);
 void blk_mq_delay_kick_requeue_list(struct request_queue *q,
                                    unsigned long msecs)
 {
-       kblockd_schedule_delayed_work(&q->requeue_work,
-                                     msecs_to_jiffies(msecs));
+       kblockd_mod_delayed_work_on(WORK_CPU_UNBOUND, &q->requeue_work,
+                                   msecs_to_jiffies(msecs));
 }
 EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list);
 
index a7285bf2831c7bdbb89b753fccb198f8640e8780..80f5481fe9f6c1603e477349732dac62c3baf204 100644 (file)
@@ -382,6 +382,14 @@ static unsigned int tg_iops_limit(struct throtl_grp *tg, int rw)
        }                                                               \
 } while (0)
 
+static inline unsigned int throtl_bio_data_size(struct bio *bio)
+{
+       /* assume it's one sector */
+       if (unlikely(bio_op(bio) == REQ_OP_DISCARD))
+               return 512;
+       return bio->bi_iter.bi_size;
+}
+
 static void throtl_qnode_init(struct throtl_qnode *qn, struct throtl_grp *tg)
 {
        INIT_LIST_HEAD(&qn->node);
@@ -934,6 +942,7 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio,
        bool rw = bio_data_dir(bio);
        u64 bytes_allowed, extra_bytes, tmp;
        unsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;
+       unsigned int bio_size = throtl_bio_data_size(bio);
 
        jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw];
 
@@ -947,14 +956,14 @@ static bool tg_with_in_bps_limit(struct throtl_grp *tg, struct bio *bio,
        do_div(tmp, HZ);
        bytes_allowed = tmp;
 
-       if (tg->bytes_disp[rw] + bio->bi_iter.bi_size <= bytes_allowed) {
+       if (tg->bytes_disp[rw] + bio_size <= bytes_allowed) {
                if (wait)
                        *wait = 0;
                return true;
        }
 
        /* Calc approx time to dispatch */
-       extra_bytes = tg->bytes_disp[rw] + bio->bi_iter.bi_size - bytes_allowed;
+       extra_bytes = tg->bytes_disp[rw] + bio_size - bytes_allowed;
        jiffy_wait = div64_u64(extra_bytes * HZ, tg_bps_limit(tg, rw));
 
        if (!jiffy_wait)
@@ -1034,11 +1043,12 @@ static bool tg_may_dispatch(struct throtl_grp *tg, struct bio *bio,
 static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio)
 {
        bool rw = bio_data_dir(bio);
+       unsigned int bio_size = throtl_bio_data_size(bio);
 
        /* Charge the bio to the group */
-       tg->bytes_disp[rw] += bio->bi_iter.bi_size;
+       tg->bytes_disp[rw] += bio_size;
        tg->io_disp[rw]++;
-       tg->last_bytes_disp[rw] += bio->bi_iter.bi_size;
+       tg->last_bytes_disp[rw] += bio_size;
        tg->last_io_disp[rw]++;
 
        /*
index c4513b23f57a6438af6ae38367c072931edf138c..dd56d7460cb91d504aa22ae9215d00f97c844359 100644 (file)
 #include <scsi/scsi_cmnd.h>
 
 /**
- * bsg_destroy_job - routine to teardown/delete a bsg job
+ * bsg_teardown_job - routine to teardown a bsg job
  * @job: bsg_job that is to be torn down
  */
-static void bsg_destroy_job(struct kref *kref)
+static void bsg_teardown_job(struct kref *kref)
 {
        struct bsg_job *job = container_of(kref, struct bsg_job, kref);
        struct request *rq = job->req;
 
-       blk_end_request_all(rq, BLK_STS_OK);
-
        put_device(job->dev);   /* release reference for the request */
 
        kfree(job->request_payload.sg_list);
        kfree(job->reply_payload.sg_list);
-       kfree(job);
+
+       blk_end_request_all(rq, BLK_STS_OK);
 }
 
 void bsg_job_put(struct bsg_job *job)
 {
-       kref_put(&job->kref, bsg_destroy_job);
+       kref_put(&job->kref, bsg_teardown_job);
 }
 EXPORT_SYMBOL_GPL(bsg_job_put);
 
@@ -100,7 +99,7 @@ EXPORT_SYMBOL_GPL(bsg_job_done);
  */
 static void bsg_softirq_done(struct request *rq)
 {
-       struct bsg_job *job = rq->special;
+       struct bsg_job *job = blk_mq_rq_to_pdu(rq);
 
        bsg_job_put(job);
 }
@@ -122,33 +121,20 @@ static int bsg_map_buffer(struct bsg_buffer *buf, struct request *req)
 }
 
 /**
- * bsg_create_job - create the bsg_job structure for the bsg request
+ * bsg_prepare_job - create the bsg_job structure for the bsg request
  * @dev: device that is being sent the bsg request
  * @req: BSG request that needs a job structure
  */
-static int bsg_create_job(struct device *dev, struct request *req)
+static int bsg_prepare_job(struct device *dev, struct request *req)
 {
        struct request *rsp = req->next_rq;
-       struct request_queue *q = req->q;
        struct scsi_request *rq = scsi_req(req);
-       struct bsg_job *job;
+       struct bsg_job *job = blk_mq_rq_to_pdu(req);
        int ret;
 
-       BUG_ON(req->special);
-
-       job = kzalloc(sizeof(struct bsg_job) + q->bsg_job_size, GFP_KERNEL);
-       if (!job)
-               return -ENOMEM;
-
-       req->special = job;
-       job->req = req;
-       if (q->bsg_job_size)
-               job->dd_data = (void *)&job[1];
        job->request = rq->cmd;
        job->request_len = rq->cmd_len;
-       job->reply = rq->sense;
-       job->reply_len = SCSI_SENSE_BUFFERSIZE; /* Size of sense buffer
-                                                * allocated */
+
        if (req->bio) {
                ret = bsg_map_buffer(&job->request_payload, req);
                if (ret)
@@ -187,7 +173,6 @@ static void bsg_request_fn(struct request_queue *q)
 {
        struct device *dev = q->queuedata;
        struct request *req;
-       struct bsg_job *job;
        int ret;
 
        if (!get_device(dev))
@@ -199,7 +184,7 @@ static void bsg_request_fn(struct request_queue *q)
                        break;
                spin_unlock_irq(q->queue_lock);
 
-               ret = bsg_create_job(dev, req);
+               ret = bsg_prepare_job(dev, req);
                if (ret) {
                        scsi_req(req)->result = ret;
                        blk_end_request_all(req, BLK_STS_OK);
@@ -207,8 +192,7 @@ static void bsg_request_fn(struct request_queue *q)
                        continue;
                }
 
-               job = req->special;
-               ret = q->bsg_job_fn(job);
+               ret = q->bsg_job_fn(blk_mq_rq_to_pdu(req));
                spin_lock_irq(q->queue_lock);
                if (ret)
                        break;
@@ -219,6 +203,35 @@ static void bsg_request_fn(struct request_queue *q)
        spin_lock_irq(q->queue_lock);
 }
 
+static int bsg_init_rq(struct request_queue *q, struct request *req, gfp_t gfp)
+{
+       struct bsg_job *job = blk_mq_rq_to_pdu(req);
+       struct scsi_request *sreq = &job->sreq;
+
+       memset(job, 0, sizeof(*job));
+
+       scsi_req_init(sreq);
+       sreq->sense_len = SCSI_SENSE_BUFFERSIZE;
+       sreq->sense = kzalloc(sreq->sense_len, gfp);
+       if (!sreq->sense)
+               return -ENOMEM;
+
+       job->req = req;
+       job->reply = sreq->sense;
+       job->reply_len = sreq->sense_len;
+       job->dd_data = job + 1;
+
+       return 0;
+}
+
+static void bsg_exit_rq(struct request_queue *q, struct request *req)
+{
+       struct bsg_job *job = blk_mq_rq_to_pdu(req);
+       struct scsi_request *sreq = &job->sreq;
+
+       kfree(sreq->sense);
+}
+
 /**
  * bsg_setup_queue - Create and add the bsg hooks so we can receive requests
  * @dev: device to attach bsg device to
@@ -235,7 +248,9 @@ struct request_queue *bsg_setup_queue(struct device *dev, char *name,
        q = blk_alloc_queue(GFP_KERNEL);
        if (!q)
                return ERR_PTR(-ENOMEM);
-       q->cmd_size = sizeof(struct scsi_request);
+       q->cmd_size = sizeof(struct bsg_job) + dd_job_size;
+       q->init_rq_fn = bsg_init_rq;
+       q->exit_rq_fn = bsg_exit_rq;
        q->request_fn = bsg_request_fn;
 
        ret = blk_init_allocated_queue(q);
@@ -243,7 +258,6 @@ struct request_queue *bsg_setup_queue(struct device *dev, char *name,
                goto out_cleanup_queue;
 
        q->queuedata = dev;
-       q->bsg_job_size = dd_job_size;
        q->bsg_job_fn = job_fn;
        queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q);
        queue_flag_set_unlocked(QUEUE_FLAG_SCSI_PASSTHROUGH, q);
index 43839b00fe6c42fff5f8afbc04ffdff4e61a147d..903605dbc1a50282e8e3d7ced0bba148ec7ebe9c 100644 (file)
@@ -87,8 +87,13 @@ static void skcipher_free_async_sgls(struct skcipher_async_req *sreq)
        }
        sgl = sreq->tsg;
        n = sg_nents(sgl);
-       for_each_sg(sgl, sg, n, i)
-               put_page(sg_page(sg));
+       for_each_sg(sgl, sg, n, i) {
+               struct page *page = sg_page(sg);
+
+               /* some SGs may not have a page mapped */
+               if (page && page_ref_count(page))
+                       put_page(page);
+       }
 
        kfree(sreq->tsg);
 }
index 8b3c04d625c3bb0ee667a8a61a0c1e4499b0b486..4a45fa4890c0e45eb74124d39b9fee35823ac4dd 100644 (file)
@@ -91,9 +91,14 @@ int crypto_chacha20_crypt(struct skcipher_request *req)
        crypto_chacha20_init(state, ctx, walk.iv);
 
        while (walk.nbytes > 0) {
+               unsigned int nbytes = walk.nbytes;
+
+               if (nbytes < walk.total)
+                       nbytes = round_down(nbytes, walk.stride);
+
                chacha20_docrypt(state, walk.dst.virt.addr, walk.src.virt.addr,
-                                walk.nbytes);
-               err = skcipher_walk_done(&walk, 0);
+                                nbytes);
+               err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
        }
 
        return err;
index 6ceb0e2758bbccd4f0542a5f9628e9f3e987ce7c..d54971d2d1c8694805bb8618b8673c8490f9e8bb 100644 (file)
@@ -32675,6 +32675,10 @@ static const struct cipher_testvec chacha20_enc_tv_template[] = {
                          "\x5b\x86\x2f\x37\x30\xe3\x7c\xfd"
                          "\xc4\xfd\x80\x6c\x22\xf2\x21",
                .rlen   = 375,
+               .also_non_np = 1,
+               .np     = 3,
+               .tap    = { 375 - 20, 4, 16 },
+
        }, { /* RFC7539 A.2. Test Vector #3 */
                .key    = "\x1c\x92\x40\xa5\xeb\x55\xd3\x8a"
                          "\xf3\x33\x88\x86\x04\xf6\xb5\xf0"
@@ -33049,6 +33053,9 @@ static const struct cipher_testvec chacha20_enc_tv_template[] = {
                          "\xa1\xed\xad\xd5\x76\xfa\x24\x8f"
                          "\x98",
                .rlen   = 1281,
+               .also_non_np = 1,
+               .np     = 3,
+               .tap    = { 1200, 1, 80 },
        },
 };
 
index 538c61677c100e9361bc556154719b7b2368740e..783f4c838aee4c1daabdea8ac8d6f21e75060492 100644 (file)
@@ -100,9 +100,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
                free_buffer_on_error = TRUE;
        }
 
-       status = acpi_get_handle(handle, pathname, &target_handle);
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
+       if (pathname) {
+               status = acpi_get_handle(handle, pathname, &target_handle);
+               if (ACPI_FAILURE(status)) {
+                       return_ACPI_STATUS(status);
+               }
+       } else {
+               target_handle = handle;
        }
 
        full_pathname = acpi_ns_get_external_pathname(target_handle);
index 62068a5e814f026a44e212bd2b93941590a3fe53..ae3d6d15263307c2c159fd459d09bc93ef66fa03 100644 (file)
@@ -1741,7 +1741,7 @@ error:
  * functioning ECDT EC first in order to handle the events.
  * https://bugzilla.kernel.org/show_bug.cgi?id=115021
  */
-int __init acpi_ec_ecdt_start(void)
+static int __init acpi_ec_ecdt_start(void)
 {
        acpi_handle handle;
 
@@ -2003,20 +2003,17 @@ static inline void acpi_ec_query_exit(void)
 int __init acpi_ec_init(void)
 {
        int result;
+       int ecdt_fail, dsdt_fail;
 
        /* register workqueue for _Qxx evaluations */
        result = acpi_ec_query_init();
        if (result)
-               goto err_exit;
-       /* Now register the driver for the EC */
-       result = acpi_bus_register_driver(&acpi_ec_driver);
-       if (result)
-               goto err_exit;
+               return result;
 
-err_exit:
-       if (result)
-               acpi_ec_query_exit();
-       return result;
+       /* Drivers must be started after acpi_ec_query_init() */
+       ecdt_fail = acpi_ec_ecdt_start();
+       dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
+       return ecdt_fail && dsdt_fail ? -ENODEV : 0;
 }
 
 /* EC driver currently not unloadable */
index 58dd7ab3c6538bd490b45e2e420c3d822ecf8c3e..3f5af4d7a73989f86cdcc80c1e8e7b949a975702 100644 (file)
@@ -185,7 +185,6 @@ typedef int (*acpi_ec_query_func) (void *data);
 int acpi_ec_init(void);
 int acpi_ec_ecdt_probe(void);
 int acpi_ec_dsdt_probe(void);
-int acpi_ec_ecdt_start(void);
 void acpi_ec_block_transactions(void);
 void acpi_ec_unblock_transactions(void);
 int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
index 917c789f953dfb280f6f00895ce1fcf7ae2484ec..476a52c60cf3de98b18abe2c35a681c2be3ae058 100644 (file)
@@ -1047,7 +1047,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(
        fwnode_for_each_child_node(fwnode, child) {
                u32 nr;
 
-               if (!fwnode_property_read_u32(fwnode, prop_name, &nr))
+               if (fwnode_property_read_u32(child, prop_name, &nr))
                        continue;
 
                if (val == nr)
index 33897298f03e3ed680272ba6f4109077d434a0d8..70fd5502c2843a7cb0338245767a3c7dc2aeb308 100644 (file)
@@ -2084,7 +2084,6 @@ int __init acpi_scan_init(void)
 
        acpi_gpe_apply_masked_gpes();
        acpi_update_all_gpes();
-       acpi_ec_ecdt_start();
 
        acpi_scan_initialized = true;
 
index 4ac3e06b41d846440d35079dfa54885111eec0df..98aa8c808a3346dc559e2f419ae4378dec075ffc 100644 (file)
 #include <linux/kernel.h>
 #include <linux/serial_core.h>
 
+/*
+ * Erratum 44 for QDF2432v1 and QDF2400v1 SoCs describes the BUSY bit as
+ * occasionally getting stuck as 1. To avoid the potential for a hang, check
+ * TXFE == 0 instead of BUSY == 1. This may not be suitable for all UART
+ * implementations, so only do so if an affected platform is detected in
+ * parse_spcr().
+ */
+bool qdf2400_e44_present;
+EXPORT_SYMBOL(qdf2400_e44_present);
+
 /*
  * Some Qualcomm Datacenter Technologies SoCs have a defective UART BUSY bit.
  * Detect them by examining the OEM fields in the SPCR header, similiar to PCI
@@ -147,8 +157,30 @@ int __init parse_spcr(bool earlycon)
                goto done;
        }
 
-       if (qdf2400_erratum_44_present(&table->header))
-               uart = "qdf2400_e44";
+       /*
+        * If the E44 erratum is required, then we need to tell the pl011
+        * driver to implement the work-around.
+        *
+        * The global variable is used by the probe function when it
+        * creates the UARTs, whether or not they're used as a console.
+        *
+        * If the user specifies "traditional" earlycon, the qdf2400_e44
+        * console name matches the EARLYCON_DECLARE() statement, and
+        * SPCR is not used.  Parameter "earlycon" is false.
+        *
+        * If the user specifies "SPCR" earlycon, then we need to update
+        * the console name so that it also says "qdf2400_e44".  Parameter
+        * "earlycon" is true.
+        *
+        * For consistency, if we change the console name, then we do it
+        * for everyone, not just earlycon.
+        */
+       if (qdf2400_erratum_44_present(&table->header)) {
+               qdf2400_e44_present = true;
+               if (earlycon)
+                       uart = "qdf2400_e44";
+       }
+
        if (xgene_8250_erratum_present(table))
                iotype = "mmio32";
 
index f7665c31fecaf3f46b64e17a821f9b8528def937..831cdd7d197dbed87d8a55c530af8df50da15419 100644 (file)
@@ -3362,7 +3362,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
        const char *failure_string;
        struct binder_buffer *buffer;
 
-       if (proc->tsk != current)
+       if (proc->tsk != current->group_leader)
                return -EINVAL;
 
        if ((vma->vm_end - vma->vm_start) > SZ_4M)
index 1a50cd3b4233bdf467049f3308c636fe32c0caf4..9b34dff6453633fcc9cf63393eb6fe553af29dbe 100644 (file)
@@ -216,12 +216,16 @@ static int ahci_da850_probe(struct platform_device *pdev)
                return rc;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-       if (!res)
+       if (!res) {
+               rc = -ENODEV;
                goto disable_resources;
+       }
 
        pwrdn_reg = devm_ioremap(dev, res->start, resource_size(res));
-       if (!pwrdn_reg)
+       if (!pwrdn_reg) {
+               rc = -ENOMEM;
                goto disable_resources;
+       }
 
        da850_sata_init(dev, pwrdn_reg, hpriv->mmio, mpy);
 
index fa7dd4394c02b642c00119bd00a4b59b18921a0d..1945a8ea20998490b48aa70dfe56c4fbaad744ea 100644 (file)
@@ -2411,6 +2411,9 @@ static void ata_dev_config_trusted(struct ata_device *dev)
        u64 trusted_cap;
        unsigned int err;
 
+       if (!ata_id_has_trusted(dev->id))
+               return;
+
        if (!ata_identify_page_supported(dev, ATA_LOG_SECURITY)) {
                ata_dev_warn(dev,
                             "Security Log not supported\n");
index b9f907eedbf770ee32359468d2b8d07e57bde667..bfbe1e15412889dfb40e699af7c3623a06d83253 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/syscore_ops.h>
 #include <linux/reboot.h>
 #include <linux/security.h>
-#include <linux/swait.h>
 
 #include <generated/utsrelease.h>
 
@@ -112,13 +111,13 @@ static inline long firmware_loading_timeout(void)
  * state of the firmware loading.
  */
 struct fw_state {
-       struct swait_queue_head wq;
+       struct completion completion;
        enum fw_status status;
 };
 
 static void fw_state_init(struct fw_state *fw_st)
 {
-       init_swait_queue_head(&fw_st->wq);
+       init_completion(&fw_st->completion);
        fw_st->status = FW_STATUS_UNKNOWN;
 }
 
@@ -131,9 +130,7 @@ static int __fw_state_wait_common(struct fw_state *fw_st, long timeout)
 {
        long ret;
 
-       ret = swait_event_interruptible_timeout(fw_st->wq,
-                               __fw_state_is_done(READ_ONCE(fw_st->status)),
-                               timeout);
+       ret = wait_for_completion_killable_timeout(&fw_st->completion, timeout);
        if (ret != 0 && fw_st->status == FW_STATUS_ABORTED)
                return -ENOENT;
        if (!ret)
@@ -148,35 +145,34 @@ static void __fw_state_set(struct fw_state *fw_st,
        WRITE_ONCE(fw_st->status, status);
 
        if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED)
-               swake_up(&fw_st->wq);
+               complete_all(&fw_st->completion);
 }
 
 #define fw_state_start(fw_st)                                  \
        __fw_state_set(fw_st, FW_STATUS_LOADING)
 #define fw_state_done(fw_st)                                   \
        __fw_state_set(fw_st, FW_STATUS_DONE)
+#define fw_state_aborted(fw_st)                                        \
+       __fw_state_set(fw_st, FW_STATUS_ABORTED)
 #define fw_state_wait(fw_st)                                   \
        __fw_state_wait_common(fw_st, MAX_SCHEDULE_TIMEOUT)
 
-#ifndef CONFIG_FW_LOADER_USER_HELPER
-
-#define fw_state_is_aborted(fw_st)     false
-
-#else /* CONFIG_FW_LOADER_USER_HELPER */
-
 static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
 {
        return fw_st->status == status;
 }
 
+#define fw_state_is_aborted(fw_st)                             \
+       __fw_state_check(fw_st, FW_STATUS_ABORTED)
+
+#ifdef CONFIG_FW_LOADER_USER_HELPER
+
 #define fw_state_aborted(fw_st)                                        \
        __fw_state_set(fw_st, FW_STATUS_ABORTED)
 #define fw_state_is_done(fw_st)                                        \
        __fw_state_check(fw_st, FW_STATUS_DONE)
 #define fw_state_is_loading(fw_st)                             \
        __fw_state_check(fw_st, FW_STATUS_LOADING)
-#define fw_state_is_aborted(fw_st)                             \
-       __fw_state_check(fw_st, FW_STATUS_ABORTED)
 #define fw_state_wait_timeout(fw_st, timeout)                  \
        __fw_state_wait_common(fw_st, timeout)
 
@@ -1200,6 +1196,28 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
        return 1; /* need to load */
 }
 
+/*
+ * Batched requests need only one wake, we need to do this step last due to the
+ * fallback mechanism. The buf is protected with kref_get(), and it won't be
+ * released until the last user calls release_firmware().
+ *
+ * Failed batched requests are possible as well, in such cases we just share
+ * the struct firmware_buf and won't release it until all requests are woken
+ * and have gone through this same path.
+ */
+static void fw_abort_batch_reqs(struct firmware *fw)
+{
+       struct firmware_buf *buf;
+
+       /* Loaded directly? */
+       if (!fw || !fw->priv)
+               return;
+
+       buf = fw->priv;
+       if (!fw_state_is_aborted(&buf->fw_st))
+               fw_state_aborted(&buf->fw_st);
+}
+
 /* called from request_firmware() and request_firmware_work_func() */
 static int
 _request_firmware(const struct firmware **firmware_p, const char *name,
@@ -1243,6 +1261,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
 
  out:
        if (ret < 0) {
+               fw_abort_batch_reqs(fw);
                release_firmware(fw);
                fw = NULL;
        }
index ef8334949b4217d9d0f1f964432c16a56ed244c4..f321b96405f55746490b50132f583c0124b192bb 100644 (file)
@@ -221,8 +221,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
 }
 
 static int
-figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit,
-                loff_t logical_blocksize)
+figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit)
 {
        loff_t size = get_size(offset, sizelimit, lo->lo_backing_file);
        sector_t x = (sector_t)size;
@@ -234,12 +233,6 @@ figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit,
                lo->lo_offset = offset;
        if (lo->lo_sizelimit != sizelimit)
                lo->lo_sizelimit = sizelimit;
-       if (lo->lo_flags & LO_FLAGS_BLOCKSIZE) {
-               lo->lo_logical_blocksize = logical_blocksize;
-               blk_queue_physical_block_size(lo->lo_queue, lo->lo_blocksize);
-               blk_queue_logical_block_size(lo->lo_queue,
-                                            lo->lo_logical_blocksize);
-       }
        set_capacity(lo->lo_disk, x);
        bd_set_size(bdev, (loff_t)get_capacity(bdev->bd_disk) << 9);
        /* let user-space know about the new size */
@@ -820,7 +813,6 @@ static void loop_config_discard(struct loop_device *lo)
        struct file *file = lo->lo_backing_file;
        struct inode *inode = file->f_mapping->host;
        struct request_queue *q = lo->lo_queue;
-       int lo_bits = 9;
 
        /*
         * We use punch hole to reclaim the free space used by the
@@ -840,11 +832,9 @@ static void loop_config_discard(struct loop_device *lo)
 
        q->limits.discard_granularity = inode->i_sb->s_blocksize;
        q->limits.discard_alignment = 0;
-       if (lo->lo_flags & LO_FLAGS_BLOCKSIZE)
-               lo_bits = blksize_bits(lo->lo_logical_blocksize);
 
-       blk_queue_max_discard_sectors(q, UINT_MAX >> lo_bits);
-       blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> lo_bits);
+       blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
+       blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> 9);
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
 }
 
@@ -938,7 +928,6 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
 
        lo->use_dio = false;
        lo->lo_blocksize = lo_blocksize;
-       lo->lo_logical_blocksize = 512;
        lo->lo_device = bdev;
        lo->lo_flags = lo_flags;
        lo->lo_backing_file = file;
@@ -1104,7 +1093,6 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
        int err;
        struct loop_func_table *xfer;
        kuid_t uid = current_uid();
-       int lo_flags = lo->lo_flags;
 
        if (lo->lo_encrypt_key_size &&
            !uid_eq(lo->lo_key_owner, uid) &&
@@ -1137,26 +1125,9 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
        if (err)
                goto exit;
 
-       if (info->lo_flags & LO_FLAGS_BLOCKSIZE) {
-               if (!(lo->lo_flags & LO_FLAGS_BLOCKSIZE))
-                       lo->lo_logical_blocksize = 512;
-               lo->lo_flags |= LO_FLAGS_BLOCKSIZE;
-               if (LO_INFO_BLOCKSIZE(info) != 512 &&
-                   LO_INFO_BLOCKSIZE(info) != 1024 &&
-                   LO_INFO_BLOCKSIZE(info) != 2048 &&
-                   LO_INFO_BLOCKSIZE(info) != 4096)
-                       return -EINVAL;
-               if (LO_INFO_BLOCKSIZE(info) > lo->lo_blocksize)
-                       return -EINVAL;
-       }
-
        if (lo->lo_offset != info->lo_offset ||
-           lo->lo_sizelimit != info->lo_sizelimit ||
-           lo->lo_flags != lo_flags ||
-           ((lo->lo_flags & LO_FLAGS_BLOCKSIZE) &&
-            lo->lo_logical_blocksize != LO_INFO_BLOCKSIZE(info))) {
-               if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit,
-                                    LO_INFO_BLOCKSIZE(info))) {
+           lo->lo_sizelimit != info->lo_sizelimit) {
+               if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit)) {
                        err = -EFBIG;
                        goto exit;
                }
@@ -1348,8 +1319,7 @@ static int loop_set_capacity(struct loop_device *lo)
        if (unlikely(lo->lo_state != Lo_bound))
                return -ENXIO;
 
-       return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit,
-                               lo->lo_logical_blocksize);
+       return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
 }
 
 static int loop_set_dio(struct loop_device *lo, unsigned long arg)
index 2c096b9a17b8ccd756065d5102b293796a5833ad..fecd3f97ef8c7cd9f825e6c58777a1a2bc6f3461 100644 (file)
@@ -49,7 +49,6 @@ struct loop_device {
        struct file *   lo_backing_file;
        struct block_device *lo_device;
        unsigned        lo_blocksize;
-       unsigned        lo_logical_blocksize;
        void            *key_data; 
 
        gfp_t           old_gfp_mask;
index 6b16ead1da5871abcef5b2233733f281158596a8..ad9749463d4fa9a382afa7f24587bbbe3a2efcc9 100644 (file)
@@ -875,6 +875,56 @@ static void print_version(void)
                printk(KERN_INFO "%s", version);
 }
 
+struct vdc_check_port_data {
+       int     dev_no;
+       char    *type;
+};
+
+static int vdc_device_probed(struct device *dev, void *arg)
+{
+       struct vio_dev *vdev = to_vio_dev(dev);
+       struct vdc_check_port_data *port_data;
+
+       port_data = (struct vdc_check_port_data *)arg;
+
+       if ((vdev->dev_no == port_data->dev_no) &&
+           (!(strcmp((char *)&vdev->type, port_data->type))) &&
+               dev_get_drvdata(dev)) {
+               /* This device has already been configured
+                * by vdc_port_probe()
+                */
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
+/* Determine whether the VIO device is part of an mpgroup
+ * by locating all the virtual-device-port nodes associated
+ * with the parent virtual-device node for the VIO device
+ * and checking whether any of these nodes are vdc-ports
+ * which have already been configured.
+ *
+ * Returns true if this device is part of an mpgroup and has
+ * already been probed.
+ */
+static bool vdc_port_mpgroup_check(struct vio_dev *vdev)
+{
+       struct vdc_check_port_data port_data;
+       struct device *dev;
+
+       port_data.dev_no = vdev->dev_no;
+       port_data.type = (char *)&vdev->type;
+
+       dev = device_find_child(vdev->dev.parent, &port_data,
+                               vdc_device_probed);
+
+       if (dev)
+               return true;
+
+       return false;
+}
+
 static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
 {
        struct mdesc_handle *hp;
@@ -893,6 +943,14 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
                goto err_out_release_mdesc;
        }
 
+       /* Check if this device is part of an mpgroup */
+       if (vdc_port_mpgroup_check(vdev)) {
+               printk(KERN_WARNING
+                       "VIO: Ignoring extra vdisk port %s",
+                       dev_name(&vdev->dev));
+               goto err_out_release_mdesc;
+       }
+
        port = kzalloc(sizeof(*port), GFP_KERNEL);
        err = -ENOMEM;
        if (!port) {
@@ -943,6 +1001,9 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        if (err)
                goto err_out_free_tx_ring;
 
+       /* Note that the device driver_data is used to determine
+        * whether the port has been probed.
+        */
        dev_set_drvdata(&vdev->dev, port);
 
        mdesc_release(hp);
index 1498b899a593e31951c835f4f537d1bb03d0e596..d3d5523862c227d86166a56fba230467b9b545fc 100644 (file)
@@ -381,6 +381,7 @@ static void virtblk_config_changed_work(struct work_struct *work)
        struct request_queue *q = vblk->disk->queue;
        char cap_str_2[10], cap_str_10[10];
        char *envp[] = { "RESIZE=1", NULL };
+       unsigned long long nblocks;
        u64 capacity;
 
        /* Host must always specify the capacity. */
@@ -393,16 +394,19 @@ static void virtblk_config_changed_work(struct work_struct *work)
                capacity = (sector_t)-1;
        }
 
-       string_get_size(capacity, queue_logical_block_size(q),
+       nblocks = DIV_ROUND_UP_ULL(capacity, queue_logical_block_size(q) >> 9);
+
+       string_get_size(nblocks, queue_logical_block_size(q),
                        STRING_UNITS_2, cap_str_2, sizeof(cap_str_2));
-       string_get_size(capacity, queue_logical_block_size(q),
+       string_get_size(nblocks, queue_logical_block_size(q),
                        STRING_UNITS_10, cap_str_10, sizeof(cap_str_10));
 
        dev_notice(&vdev->dev,
-                 "new size: %llu %d-byte logical blocks (%s/%s)\n",
-                 (unsigned long long)capacity,
-                 queue_logical_block_size(q),
-                 cap_str_10, cap_str_2);
+                  "new size: %llu %d-byte logical blocks (%s/%s)\n",
+                  nblocks,
+                  queue_logical_block_size(q),
+                  cap_str_10,
+                  cap_str_2);
 
        set_capacity(vblk->disk, capacity);
        revalidate_disk(vblk->disk);
index 792da683e70dafafa6f69e224b8e57272d3e6be1..2adb8599be93147bf7e9e89d3d65d43b6305bff0 100644 (file)
@@ -244,6 +244,7 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
 {
        struct pending_req *req, *n;
        unsigned int j, r;
+       bool busy = false;
 
        for (r = 0; r < blkif->nr_rings; r++) {
                struct xen_blkif_ring *ring = &blkif->rings[r];
@@ -261,8 +262,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
                 * don't have any discard_io or other_io requests. So, checking
                 * for inflight IO is enough.
                 */
-               if (atomic_read(&ring->inflight) > 0)
-                       return -EBUSY;
+               if (atomic_read(&ring->inflight) > 0) {
+                       busy = true;
+                       continue;
+               }
 
                if (ring->irq) {
                        unbind_from_irqhandler(ring->irq, ring);
@@ -300,6 +303,9 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
                WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages));
                ring->active = false;
        }
+       if (busy)
+               return -EBUSY;
+
        blkif->nr_ring_pages = 0;
        /*
         * blkif->rings was allocated in connect_ring, so we should free it in
index 98e34e4c62b8b228a6ee6d37256e860ee7d3c2b7..2468c28d477110e6bcb2cbf5225dd481c6ec5b95 100644 (file)
@@ -2075,9 +2075,9 @@ static int blkfront_resume(struct xenbus_device *dev)
                        /*
                         * Get the bios in the request so we can re-queue them.
                         */
-                       if (req_op(shadow[i].request) == REQ_OP_FLUSH ||
-                           req_op(shadow[i].request) == REQ_OP_DISCARD ||
-                           req_op(shadow[i].request) == REQ_OP_SECURE_ERASE ||
+                       if (req_op(shadow[j].request) == REQ_OP_FLUSH ||
+                           req_op(shadow[j].request) == REQ_OP_DISCARD ||
+                           req_op(shadow[j].request) == REQ_OP_SECURE_ERASE ||
                            shadow[j].request->cmd_flags & REQ_FUA) {
                                /*
                                 * Flush operations don't contain bios, so
index 856d5dc02451d44b59695127994017877cd02b38..3b1b6340ba13a2977ffd0a13424ce95322f67f0e 100644 (file)
@@ -308,7 +308,7 @@ static ssize_t comp_algorithm_store(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t len)
 {
        struct zram *zram = dev_to_zram(dev);
-       char compressor[CRYPTO_MAX_ALG_NAME];
+       char compressor[ARRAY_SIZE(zram->compressor)];
        size_t sz;
 
        strlcpy(compressor, buf, sizeof(compressor));
@@ -327,7 +327,7 @@ static ssize_t comp_algorithm_store(struct device *dev,
                return -EBUSY;
        }
 
-       strlcpy(zram->compressor, compressor, sizeof(compressor));
+       strcpy(zram->compressor, compressor);
        up_write(&zram->init_lock);
        return len;
 }
index afa3ce7d3e729a1ad1485d129aa1d26646292f74..8ad92707e45f23b890203d5c5468d47473acf636 100644 (file)
@@ -1492,7 +1492,7 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
 #ifndef CONFIG_WARN_ALL_UNSEEDED_RANDOM
        print_once = true;
 #endif
-       pr_notice("random: %s called from %pF with crng_init=%d\n",
+       pr_notice("random: %s called from %pS with crng_init=%d\n",
                  func_name, caller, crng_init);
 }
 
index fcae5ca6ac9234debecf5a4f84521405aa64a74c..54a67f8a28ebfb929610ea07697d7c7e4eb33de1 100644 (file)
@@ -262,7 +262,7 @@ config CLKSRC_LPC32XX
 
 config CLKSRC_PISTACHIO
        bool "Clocksource for Pistachio SoC" if COMPILE_TEST
-       depends on HAS_IOMEM
+       depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
        select TIMER_OF
        help
          Enables the clocksource for the Pistachio SoC.
index aae87c4c546ee06203195654087cd9ef8b43d57a..72bbfccef1132c3a962d9e93d4bd6c459f1b368d 100644 (file)
@@ -1440,7 +1440,7 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
         * While unlikely, it's theoretically possible that none of the frames
         * in a timer expose the combination of feature we want.
         */
-       for (i = i; i < timer_count; i++) {
+       for (i = 0; i < timer_count; i++) {
                timer = &timers[i];
 
                frame = arch_timer_mem_find_best_frame(timer);
index bc48cbf6a7957198d4ecd6bf91840df350843d48..269db74a065815e2211194fbda9774dcf1e80041 100644 (file)
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "failed to get irq\n");
-               return -EINVAL;
+               return irq;
        }
 
        /* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
        if (IS_ERR(p->base))
                return PTR_ERR(p->base);
 
-       if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
-                            IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-                            dev_name(&pdev->dev), p)) {
+       ret = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+                              IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+                              dev_name(&pdev->dev), p);
+       if (ret) {
                dev_err(&pdev->dev, "failed to request low IRQ\n");
-               return -ENOENT;
+               return ret;
        }
 
        /* get hold of clock */
index d509b500a7b5f8565514352a0313cb4704976042..4d7aef9d9c15422df0e9973e72379b2e21256f47 100644 (file)
@@ -128,9 +128,9 @@ static __init int timer_base_init(struct device_node *np,
        const char *name = of_base->name ? of_base->name : np->full_name;
 
        of_base->base = of_io_request_and_map(np, of_base->index, name);
-       if (!of_base->base) {
+       if (IS_ERR(of_base->base)) {
                pr_err("Failed to iomap (%s)\n", name);
-               return -ENXIO;
+               return PTR_ERR(of_base->base);
        }
 
        return 0;
index 0566455f233ed3cd663506321f08f7ae546862be..65ee4fcace1f260632cf53c150c3260cc27240ad 100644 (file)
@@ -1613,8 +1613,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time)
 
 static inline int32_t get_avg_frequency(struct cpudata *cpu)
 {
-       return mul_ext_fp(cpu->sample.core_avg_perf,
-                         cpu->pstate.max_pstate_physical * cpu->pstate.scaling);
+       return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz);
 }
 
 static inline int32_t get_avg_pstate(struct cpudata *cpu)
index 37b0698b7193e60be4107a8be107285e55c65877..42896a67aeae38325cbda2acb7ca655c1b43915c 100644 (file)
@@ -235,6 +235,7 @@ static inline int validate_dt_prop_sizes(const char *prop1, int prop1_len,
        return -1;
 }
 
+extern u32 pnv_get_supported_cpuidle_states(void);
 static int powernv_add_idle_states(void)
 {
        struct device_node *power_mgt;
@@ -248,6 +249,8 @@ static int powernv_add_idle_states(void)
        const char *names[CPUIDLE_STATE_MAX];
        u32 has_stop_states = 0;
        int i, rc;
+       u32 supported_flags = pnv_get_supported_cpuidle_states();
+
 
        /* Currently we have snooze statically defined */
 
@@ -362,6 +365,13 @@ static int powernv_add_idle_states(void)
        for (i = 0; i < dt_idle_states; i++) {
                unsigned int exit_latency, target_residency;
                bool stops_timebase = false;
+
+               /*
+                * Skip the platform idle state whose flag isn't in
+                * the supported_cpuidle_states flag mask.
+                */
+               if ((flags[i] & supported_flags) != flags[i])
+                       continue;
                /*
                 * If an idle state has exit latency beyond
                 * POWERNV_THRESHOLD_LATENCY_NS then don't use it
index 8527a5899a2f7b6a3245a4a52ca4c0283b2f4666..3f819399cd95519a9956ed1d3ecba76fa2aa62b4 100644 (file)
@@ -883,10 +883,7 @@ static int safexcel_hmac_sha1_setkey(struct crypto_ahash *tfm, const u8 *key,
        if (ret)
                return ret;
 
-       memcpy(ctx->ipad, &istate.state, SHA1_DIGEST_SIZE);
-       memcpy(ctx->opad, &ostate.state, SHA1_DIGEST_SIZE);
-
-       for (i = 0; i < ARRAY_SIZE(istate.state); i++) {
+       for (i = 0; i < SHA1_DIGEST_SIZE / sizeof(u32); i++) {
                if (ctx->ipad[i] != le32_to_cpu(istate.state[i]) ||
                    ctx->opad[i] != le32_to_cpu(ostate.state[i])) {
                        ctx->base.needs_inv = true;
@@ -894,6 +891,9 @@ static int safexcel_hmac_sha1_setkey(struct crypto_ahash *tfm, const u8 *key,
                }
        }
 
+       memcpy(ctx->ipad, &istate.state, SHA1_DIGEST_SIZE);
+       memcpy(ctx->opad, &ostate.state, SHA1_DIGEST_SIZE);
+
        return 0;
 }
 
index 427cbe01272926acd38eba211dceb28fec61db64..dadc4a808df5a37764adf45df9f90dc1fce5b03a 100644 (file)
@@ -1073,7 +1073,7 @@ static int aead_perform(struct aead_request *req, int encrypt,
                req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags,
                                &crypt->icv_rev_aes);
                if (unlikely(!req_ctx->hmac_virt))
-                       goto free_buf_src;
+                       goto free_buf_dst;
                if (!encrypt) {
                        scatterwalk_map_and_copy(req_ctx->hmac_virt,
                                req->src, cryptlen, authsize, 0);
@@ -1088,10 +1088,10 @@ static int aead_perform(struct aead_request *req, int encrypt,
        BUG_ON(qmgr_stat_overflow(SEND_QID));
        return -EINPROGRESS;
 
-free_buf_src:
-       free_buf_chain(dev, req_ctx->src, crypt->src_buf);
 free_buf_dst:
        free_buf_chain(dev, req_ctx->dst, crypt->dst_buf);
+free_buf_src:
+       free_buf_chain(dev, req_ctx->src, crypt->src_buf);
        crypt->ctl_flags = CTL_FLAG_UNUSED;
        return -ENOMEM;
 }
index d7e219d2669daf01c935bd18c0836cb88a34e075..66fb40d0ebdbbec521499cd58cf2e1d55c195878 100644 (file)
@@ -304,7 +304,7 @@ static int sync_file_release(struct inode *inode, struct file *file)
 {
        struct sync_file *sync_file = file->private_data;
 
-       if (test_bit(POLL_ENABLED, &sync_file->fence->flags))
+       if (test_bit(POLL_ENABLED, &sync_file->flags))
                dma_fence_remove_callback(sync_file->fence, &sync_file->cb);
        dma_fence_put(sync_file->fence);
        kfree(sync_file);
@@ -318,7 +318,8 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait)
 
        poll_wait(file, &sync_file->wq, wait);
 
-       if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) {
+       if (list_empty(&sync_file->cb.node) &&
+           !test_and_set_bit(POLL_ENABLED, &sync_file->flags)) {
                if (dma_fence_add_callback(sync_file->fence, &sync_file->cb,
                                           fence_check_cb_func) < 0)
                        wake_up_all(&sync_file->wq);
index b10cbaa82ff537b1cfb68d93d80aecdfebcd6c22..b26256f23d67fbdf58206adf2a253fcf40c50091 100644 (file)
@@ -717,8 +717,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
                tdc->chan_addr = tdma->base_addr + ADMA_CH_REG_OFFSET(i);
 
                tdc->irq = of_irq_get(pdev->dev.of_node, i);
-               if (tdc->irq < 0) {
-                       ret = tdc->irq;
+               if (tdc->irq <= 0) {
+                       ret = tdc->irq ?: -ENXIO;
                        goto irq_dispose;
                }
 
index e338c374356294f97c1b331c4c04a4977d495290..45c65f805fd6ba5a3899b5c29a9651fa2d6dcc43 100644 (file)
@@ -557,7 +557,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc)
        edge_cause = mvebu_gpio_read_edge_cause(mvchip);
        edge_mask  = mvebu_gpio_read_edge_mask(mvchip);
 
-       cause = (data_in ^ level_mask) | (edge_cause & edge_mask);
+       cause = (data_in & level_mask) | (edge_cause & edge_mask);
 
        for (i = 0; i < mvchip->chip.ngpio; i++) {
                int irq;
index 16fe9742597b540ff4d82e869dc13d66326bbd2a..fc80add5fedb57dc07b6f567eef138494452316e 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/sysfs.h>
+#include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/interrupt.h>
@@ -432,6 +433,11 @@ static struct attribute *gpiochip_attrs[] = {
 };
 ATTRIBUTE_GROUPS(gpiochip);
 
+static struct gpio_desc *gpio_to_valid_desc(int gpio)
+{
+       return gpio_is_valid(gpio) ? gpio_to_desc(gpio) : NULL;
+}
+
 /*
  * /sys/class/gpio/export ... write-only
  *     integer N ... number of GPIO to export (full access)
@@ -450,7 +456,7 @@ static ssize_t export_store(struct class *class,
        if (status < 0)
                goto done;
 
-       desc = gpio_to_desc(gpio);
+       desc = gpio_to_valid_desc(gpio);
        /* reject invalid GPIOs */
        if (!desc) {
                pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
@@ -493,7 +499,7 @@ static ssize_t unexport_store(struct class *class,
        if (status < 0)
                goto done;
 
-       desc = gpio_to_desc(gpio);
+       desc = gpio_to_valid_desc(gpio);
        /* reject bogus commands (gpio_unexport ignores them) */
        if (!desc) {
                pr_warn("%s: invalid GPIO %ld\n", __func__, gpio);
index 6558a3ed57a7f6a1127f81aa0e1b5a861aa21b8d..e1cde6b80027fe1cad56b6169c38aadac1974e3e 100644 (file)
@@ -146,36 +146,6 @@ static void amdgpu_mn_invalidate_node(struct amdgpu_mn_node *node,
        }
 }
 
-/**
- * amdgpu_mn_invalidate_page - callback to notify about mm change
- *
- * @mn: our notifier
- * @mn: the mm this callback is about
- * @address: address of invalidate page
- *
- * Invalidation of a single page. Blocks for all BOs mapping it
- * and unmap them by move them into system domain again.
- */
-static void amdgpu_mn_invalidate_page(struct mmu_notifier *mn,
-                                     struct mm_struct *mm,
-                                     unsigned long address)
-{
-       struct amdgpu_mn *rmn = container_of(mn, struct amdgpu_mn, mn);
-       struct interval_tree_node *it;
-
-       mutex_lock(&rmn->lock);
-
-       it = interval_tree_iter_first(&rmn->objects, address, address);
-       if (it) {
-               struct amdgpu_mn_node *node;
-
-               node = container_of(it, struct amdgpu_mn_node, it);
-               amdgpu_mn_invalidate_node(node, address, address);
-       }
-
-       mutex_unlock(&rmn->lock);
-}
-
 /**
  * amdgpu_mn_invalidate_range_start - callback to notify about mm change
  *
@@ -215,7 +185,6 @@ static void amdgpu_mn_invalidate_range_start(struct mmu_notifier *mn,
 
 static const struct mmu_notifier_ops amdgpu_mn_ops = {
        .release = amdgpu_mn_release,
-       .invalidate_page = amdgpu_mn_invalidate_page,
        .invalidate_range_start = amdgpu_mn_invalidate_range_start,
 };
 
index a6899180b265721831837282e6c66d12a8bccf48..c586f44312f9772fb93f8b1442827c842d610594 100644 (file)
@@ -244,6 +244,12 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
                struct dma_fence *f = e->fence;
                struct amd_sched_fence *s_fence = to_amd_sched_fence(f);
 
+               if (dma_fence_is_signaled(f)) {
+                       hash_del(&e->node);
+                       dma_fence_put(f);
+                       kmem_cache_free(amdgpu_sync_slab, e);
+                       continue;
+               }
                if (ring && s_fence) {
                        /* For fences from the same ring it is sufficient
                         * when they are scheduled.
@@ -256,13 +262,6 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
                        }
                }
 
-               if (dma_fence_is_signaled(f)) {
-                       hash_del(&e->node);
-                       dma_fence_put(f);
-                       kmem_cache_free(amdgpu_sync_slab, e);
-                       continue;
-               }
-
                return f;
        }
 
index 2d51a2269fc610ffc705abcb7a49c1bdcaffbae9..5131bfb94f065ceb20ba61713f990b76f11103cb 100644 (file)
@@ -597,9 +597,9 @@ static void sii8620_mt_read_devcap(struct sii8620 *ctx, bool xdevcap)
 static void sii8620_mt_read_devcap_reg_recv(struct sii8620 *ctx,
                struct sii8620_mt_msg *msg)
 {
-       u8 reg = msg->reg[0] & 0x7f;
+       u8 reg = msg->reg[1] & 0x7f;
 
-       if (msg->reg[0] & 0x80)
+       if (msg->reg[1] & 0x80)
                ctx->xdevcap[reg] = msg->ret;
        else
                ctx->devcap[reg] = msg->ret;
index 5c26488e7a2d7a0320ddf321375b8ff4c200185f..0529e500c5341ed5e0d93bb658cd42d9288b13ad 100644 (file)
@@ -1255,7 +1255,7 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
        /* port@2 is the output port */
        ret = drm_of_find_panel_or_bridge(dev->of_node, 2, 0, &tc->panel, NULL);
-       if (ret)
+       if (ret && ret != -ENODEV)
                return ret;
 
        /* Shut down GPIO is optional */
index c0f336d23f9ccab1d375eda63f8381d62ccf0f00..aed25c4183bb0e5df17a751e25a33c907b91d9b1 100644 (file)
@@ -1655,6 +1655,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
        if (config->funcs->atomic_check)
                ret = config->funcs->atomic_check(state->dev, state);
 
+       if (ret)
+               return ret;
+
        if (!state->allow_modeset) {
                for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
                        if (drm_atomic_crtc_needs_modeset(crtc_state)) {
@@ -1665,7 +1668,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
                }
        }
 
-       return ret;
+       return 0;
 }
 EXPORT_SYMBOL(drm_atomic_check_only);
 
@@ -2167,10 +2170,10 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
        struct drm_atomic_state *state;
        struct drm_modeset_acquire_ctx ctx;
        struct drm_plane *plane;
-       struct drm_out_fence_state *fence_state = NULL;
+       struct drm_out_fence_state *fence_state;
        unsigned plane_mask;
        int ret = 0;
-       unsigned int i, j, num_fences = 0;
+       unsigned int i, j, num_fences;
 
        /* disallow for drivers not supporting atomic: */
        if (!drm_core_check_feature(dev, DRIVER_ATOMIC))
@@ -2211,6 +2214,8 @@ retry:
        plane_mask = 0;
        copied_objs = 0;
        copied_props = 0;
+       fence_state = NULL;
+       num_fences = 0;
 
        for (i = 0; i < arg->count_objs; i++) {
                uint32_t obj_id, count_props;
index 8dc11064253d9e5ed58f8c817a471b36c25c5951..cdaac37907b1e4577565625f6485a7cf3de25088 100644 (file)
@@ -255,13 +255,13 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
        struct drm_gem_object *obj = ptr;
        struct drm_device *dev = obj->dev;
 
+       if (dev->driver->gem_close_object)
+               dev->driver->gem_close_object(obj, file_priv);
+
        if (drm_core_check_feature(dev, DRIVER_PRIME))
                drm_gem_remove_prime_handles(obj, file_priv);
        drm_vma_node_revoke(&obj->vma_node, file_priv);
 
-       if (dev->driver->gem_close_object)
-               dev->driver->gem_close_object(obj, file_priv);
-
        drm_gem_object_handle_put_unlocked(obj);
 
        return 0;
index 5dc8c4350602a561fe4cfd77fce77e26770696fb..e40c12fabbdeaf9a325811d25e17c30990637e12 100644 (file)
@@ -601,6 +601,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 
                crtc = drm_crtc_find(dev, plane_req->crtc_id);
                if (!crtc) {
+                       drm_framebuffer_put(fb);
                        DRM_DEBUG_KMS("Unknown crtc ID %d\n",
                                      plane_req->crtc_id);
                        return -ENOENT;
index 5bd93169dac2059a0981cc2f24b8c9032447ba9e..6463fc2c736fd4db5881a259b21848328b7f6cea 100644 (file)
@@ -270,8 +270,8 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
                if (ret)
                        return ret;
 
-               if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
-                       DRM_ERROR("relocation %u outside object", i);
+               if (r->reloc_offset > bo->obj->base.size - sizeof(*ptr)) {
+                       DRM_ERROR("relocation %u outside object\n", i);
                        return -EINVAL;
                }
 
index d48fd7c918f880df0b3a27da5e8fa4f09c011b04..73217c281c9a87e51ac2a3d8ddf235b227ba2a1d 100644 (file)
@@ -145,13 +145,19 @@ static struct drm_framebuffer *
 exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
                      const struct drm_mode_fb_cmd2 *mode_cmd)
 {
+       const struct drm_format_info *info = drm_get_format_info(dev, mode_cmd);
        struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
        struct drm_gem_object *obj;
        struct drm_framebuffer *fb;
        int i;
        int ret;
 
-       for (i = 0; i < drm_format_num_planes(mode_cmd->pixel_format); i++) {
+       for (i = 0; i < info->num_planes; i++) {
+               unsigned int height = (i == 0) ? mode_cmd->height :
+                                    DIV_ROUND_UP(mode_cmd->height, info->vsub);
+               unsigned long size = height * mode_cmd->pitches[i] +
+                                    mode_cmd->offsets[i];
+
                obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[i]);
                if (!obj) {
                        DRM_ERROR("failed to lookup gem object\n");
@@ -160,6 +166,12 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
                }
 
                exynos_gem[i] = to_exynos_gem(obj);
+
+               if (size > exynos_gem[i]->size) {
+                       i++;
+                       ret = -EINVAL;
+                       goto err;
+               }
        }
 
        fb = exynos_drm_framebuffer_init(dev, mode_cmd, exynos_gem, i);
index 713848c3634946bea6c9805a3a705c22c1b8c08c..e556a46cd4c292773b5e5dfca629c21625b05c43 100644 (file)
@@ -2714,7 +2714,7 @@ static int shadow_indirect_ctx(struct intel_shadow_wa_ctx *wa_ctx)
 unmap_src:
        i915_gem_object_unpin_map(obj);
 put_obj:
-       i915_gem_object_put(wa_ctx->indirect_ctx.obj);
+       i915_gem_object_put(obj);
        return ret;
 }
 
index 700050556242480e6fbf8eb4a8d97c6307e9390d..1648887d3f55248cf055524a2f0e341062f0cd8d 100644 (file)
@@ -46,6 +46,8 @@
 #define same_context(a, b) (((a)->context_id == (b)->context_id) && \
                ((a)->lrca == (b)->lrca))
 
+static void clean_workloads(struct intel_vgpu *vgpu, unsigned long engine_mask);
+
 static int context_switch_events[] = {
        [RCS] = RCS_AS_CONTEXT_SWITCH,
        [BCS] = BCS_AS_CONTEXT_SWITCH,
@@ -499,10 +501,10 @@ static void release_shadow_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx)
 static int complete_execlist_workload(struct intel_vgpu_workload *workload)
 {
        struct intel_vgpu *vgpu = workload->vgpu;
-       struct intel_vgpu_execlist *execlist =
-               &vgpu->execlist[workload->ring_id];
+       int ring_id = workload->ring_id;
+       struct intel_vgpu_execlist *execlist = &vgpu->execlist[ring_id];
        struct intel_vgpu_workload *next_workload;
-       struct list_head *next = workload_q_head(vgpu, workload->ring_id)->next;
+       struct list_head *next = workload_q_head(vgpu, ring_id)->next;
        bool lite_restore = false;
        int ret;
 
@@ -512,10 +514,25 @@ static int complete_execlist_workload(struct intel_vgpu_workload *workload)
        release_shadow_batch_buffer(workload);
        release_shadow_wa_ctx(&workload->wa_ctx);
 
-       if (workload->status || vgpu->resetting)
+       if (workload->status || (vgpu->resetting_eng & ENGINE_MASK(ring_id))) {
+               /* if workload->status is not successful means HW GPU
+                * has occurred GPU hang or something wrong with i915/GVT,
+                * and GVT won't inject context switch interrupt to guest.
+                * So this error is a vGPU hang actually to the guest.
+                * According to this we should emunlate a vGPU hang. If
+                * there are pending workloads which are already submitted
+                * from guest, we should clean them up like HW GPU does.
+                *
+                * if it is in middle of engine resetting, the pending
+                * workloads won't be submitted to HW GPU and will be
+                * cleaned up during the resetting process later, so doing
+                * the workload clean up here doesn't have any impact.
+                **/
+               clean_workloads(vgpu, ENGINE_MASK(ring_id));
                goto out;
+       }
 
-       if (!list_empty(workload_q_head(vgpu, workload->ring_id))) {
+       if (!list_empty(workload_q_head(vgpu, ring_id))) {
                struct execlist_ctx_descriptor_format *this_desc, *next_desc;
 
                next_workload = container_of(next,
index 5dad9298b2d5dbbe7b626895806e6008047bbd6a..a26c1705430eb2134d002b68ddcb26d272684bd9 100644 (file)
@@ -72,11 +72,13 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt)
        struct intel_gvt_device_info *info = &gvt->device_info;
        struct pci_dev *pdev = gvt->dev_priv->drm.pdev;
        struct intel_gvt_mmio_info *e;
+       struct gvt_mmio_block *block = gvt->mmio.mmio_block;
+       int num = gvt->mmio.num_mmio_block;
        struct gvt_firmware_header *h;
        void *firmware;
        void *p;
        unsigned long size, crc32_start;
-       int i;
+       int i, j;
        int ret;
 
        size = sizeof(*h) + info->mmio_size + info->cfg_space_size;
@@ -105,6 +107,13 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt)
        hash_for_each(gvt->mmio.mmio_info_table, i, e, node)
                *(u32 *)(p + e->offset) = I915_READ_NOTRACE(_MMIO(e->offset));
 
+       for (i = 0; i < num; i++, block++) {
+               for (j = 0; j < block->size; j += 4)
+                       *(u32 *)(p + INTEL_GVT_MMIO_OFFSET(block->offset) + j) =
+                               I915_READ_NOTRACE(_MMIO(INTEL_GVT_MMIO_OFFSET(
+                                                       block->offset) + j));
+       }
+
        memcpy(gvt->firmware.mmio, p, info->mmio_size);
 
        crc32_start = offsetof(struct gvt_firmware_header, crc32) + 4;
index 3a74e79eac2f6c13fef32e1611b539db7b8f46c3..2964a4d01a66da5d2fb06d256ed35fa83fa96a38 100644 (file)
@@ -149,7 +149,7 @@ struct intel_vgpu {
        bool active;
        bool pv_notified;
        bool failsafe;
-       bool resetting;
+       unsigned int resetting_eng;
        void *sched_data;
        struct vgpu_sched_ctl sched_ctl;
 
@@ -195,6 +195,15 @@ struct intel_gvt_fence {
        unsigned long vgpu_allocated_fence_num;
 };
 
+/* Special MMIO blocks. */
+struct gvt_mmio_block {
+       unsigned int device;
+       i915_reg_t   offset;
+       unsigned int size;
+       gvt_mmio_func read;
+       gvt_mmio_func write;
+};
+
 #define INTEL_GVT_MMIO_HASH_BITS 11
 
 struct intel_gvt_mmio {
@@ -214,6 +223,9 @@ struct intel_gvt_mmio {
 /* This reg could be accessed by unaligned address */
 #define F_UNALIGN      (1 << 6)
 
+       struct gvt_mmio_block *mmio_block;
+       unsigned int num_mmio_block;
+
        DECLARE_HASHTABLE(mmio_info_table, INTEL_GVT_MMIO_HASH_BITS);
        unsigned int num_tracked_mmio;
 };
index 17febe830ff6984e06bb81cb91601a76b67d5f2a..feed9921b3b3eb05e6e8dce5e1b510f4d6fc9479 100644 (file)
@@ -2857,31 +2857,15 @@ static int init_skl_mmio_info(struct intel_gvt *gvt)
        return 0;
 }
 
-/* Special MMIO blocks. */
-static struct gvt_mmio_block {
-       unsigned int device;
-       i915_reg_t   offset;
-       unsigned int size;
-       gvt_mmio_func read;
-       gvt_mmio_func write;
-} gvt_mmio_blocks[] = {
-       {D_SKL_PLUS, _MMIO(CSR_MMIO_START_RANGE), 0x3000, NULL, NULL},
-       {D_ALL, _MMIO(MCHBAR_MIRROR_BASE_SNB), 0x40000, NULL, NULL},
-       {D_ALL, _MMIO(VGT_PVINFO_PAGE), VGT_PVINFO_SIZE,
-               pvinfo_mmio_read, pvinfo_mmio_write},
-       {D_ALL, LGC_PALETTE(PIPE_A, 0), 1024, NULL, NULL},
-       {D_ALL, LGC_PALETTE(PIPE_B, 0), 1024, NULL, NULL},
-       {D_ALL, LGC_PALETTE(PIPE_C, 0), 1024, NULL, NULL},
-};
-
 static struct gvt_mmio_block *find_mmio_block(struct intel_gvt *gvt,
                                              unsigned int offset)
 {
        unsigned long device = intel_gvt_get_device_type(gvt);
-       struct gvt_mmio_block *block = gvt_mmio_blocks;
+       struct gvt_mmio_block *block = gvt->mmio.mmio_block;
+       int num = gvt->mmio.num_mmio_block;
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(gvt_mmio_blocks); i++, block++) {
+       for (i = 0; i < num; i++, block++) {
                if (!(device & block->device))
                        continue;
                if (offset >= INTEL_GVT_MMIO_OFFSET(block->offset) &&
@@ -2912,6 +2896,17 @@ void intel_gvt_clean_mmio_info(struct intel_gvt *gvt)
        gvt->mmio.mmio_attribute = NULL;
 }
 
+/* Special MMIO blocks. */
+static struct gvt_mmio_block mmio_blocks[] = {
+       {D_SKL_PLUS, _MMIO(CSR_MMIO_START_RANGE), 0x3000, NULL, NULL},
+       {D_ALL, _MMIO(MCHBAR_MIRROR_BASE_SNB), 0x40000, NULL, NULL},
+       {D_ALL, _MMIO(VGT_PVINFO_PAGE), VGT_PVINFO_SIZE,
+               pvinfo_mmio_read, pvinfo_mmio_write},
+       {D_ALL, LGC_PALETTE(PIPE_A, 0), 1024, NULL, NULL},
+       {D_ALL, LGC_PALETTE(PIPE_B, 0), 1024, NULL, NULL},
+       {D_ALL, LGC_PALETTE(PIPE_C, 0), 1024, NULL, NULL},
+};
+
 /**
  * intel_gvt_setup_mmio_info - setup MMIO information table for GVT device
  * @gvt: GVT device
@@ -2951,6 +2946,9 @@ int intel_gvt_setup_mmio_info(struct intel_gvt *gvt)
                        goto err;
        }
 
+       gvt->mmio.mmio_block = mmio_blocks;
+       gvt->mmio.num_mmio_block = ARRAY_SIZE(mmio_blocks);
+
        gvt_dbg_mmio("traced %u virtual mmio registers\n",
                     gvt->mmio.num_tracked_mmio);
        return 0;
@@ -3030,7 +3028,7 @@ int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset,
        gvt_mmio_func func;
        int ret;
 
-       if (WARN_ON(bytes > 4))
+       if (WARN_ON(bytes > 8))
                return -EINVAL;
 
        /*
index 4f7057d62d88b393ce77670f9100bc2d3b246014..22e08eb2d0b7c66faf01741656fb33d1535925f3 100644 (file)
@@ -432,7 +432,8 @@ static void complete_current_workload(struct intel_gvt *gvt, int ring_id)
 
                i915_gem_request_put(fetch_and_zero(&workload->req));
 
-               if (!workload->status && !vgpu->resetting) {
+               if (!workload->status && !(vgpu->resetting_eng &
+                                          ENGINE_MASK(ring_id))) {
                        update_guest_context(workload);
 
                        for_each_set_bit(event, workload->pending_events,
index 90c14e6e3ea06b8de36d90284132659eb80f72c6..3deadcbd5a245c039169f1a10c6c91cc791d3a66 100644 (file)
@@ -480,11 +480,13 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
 {
        struct intel_gvt *gvt = vgpu->gvt;
        struct intel_gvt_workload_scheduler *scheduler = &gvt->scheduler;
+       unsigned int resetting_eng = dmlr ? ALL_ENGINES : engine_mask;
 
        gvt_dbg_core("------------------------------------------\n");
        gvt_dbg_core("resseting vgpu%d, dmlr %d, engine_mask %08x\n",
                     vgpu->id, dmlr, engine_mask);
-       vgpu->resetting = true;
+
+       vgpu->resetting_eng = resetting_eng;
 
        intel_vgpu_stop_schedule(vgpu);
        /*
@@ -497,7 +499,7 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
                mutex_lock(&gvt->lock);
        }
 
-       intel_vgpu_reset_execlist(vgpu, dmlr ? ALL_ENGINES : engine_mask);
+       intel_vgpu_reset_execlist(vgpu, resetting_eng);
 
        /* full GPU reset or device model level reset */
        if (engine_mask == ALL_ENGINES || dmlr) {
@@ -520,7 +522,7 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
                }
        }
 
-       vgpu->resetting = false;
+       vgpu->resetting_eng = 0;
        gvt_dbg_core("reset vgpu%d done\n", vgpu->id);
        gvt_dbg_core("------------------------------------------\n");
 }
index 00d8967c8512048f5fb46f629c9c76ace1161bbf..d1bd53b73738446f5d01cc7aae2b585f675de6b7 100644 (file)
@@ -4580,7 +4580,7 @@ static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
 
                sseu->slice_mask |= BIT(s);
 
-               if (IS_GEN9_BC(dev_priv))
+               if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv))
                        sseu->subslice_mask =
                                INTEL_INFO(dev_priv)->sseu.subslice_mask;
 
index 39ed58a21fc1f517f56d179d48b3b9bef00e9410..e1e971ee2ed57aae59dd505a49e8a6ee546e58ff 100644 (file)
@@ -688,19 +688,19 @@ static inline bool skip_rcs_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static bool
-needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt,
-                 struct intel_engine_cs *engine,
-                 struct i915_gem_context *to)
+needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt, struct intel_engine_cs *engine)
 {
+       struct i915_gem_context *from = engine->legacy_active_context;
+
        if (!ppgtt)
                return false;
 
        /* Always load the ppgtt on first use */
-       if (!engine->legacy_active_context)
+       if (!from)
                return true;
 
        /* Same context without new entries, skip */
-       if (engine->legacy_active_context == to &&
+       if ((!from->ppgtt || from->ppgtt == ppgtt) &&
            !(intel_engine_flag(engine) & ppgtt->pd_dirty_rings))
                return false;
 
@@ -744,7 +744,7 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
        if (skip_rcs_switch(ppgtt, engine, to))
                return 0;
 
-       if (needs_pd_load_pre(ppgtt, engine, to)) {
+       if (needs_pd_load_pre(ppgtt, engine)) {
                /* Older GENs and non render rings still want the load first,
                 * "PP_DCLV followed by PP_DIR_BASE register through Load
                 * Register Immediate commands in Ring Buffer before submitting
@@ -841,7 +841,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
                struct i915_hw_ppgtt *ppgtt =
                        to->ppgtt ?: req->i915->mm.aliasing_ppgtt;
 
-               if (needs_pd_load_pre(ppgtt, engine, to)) {
+               if (needs_pd_load_pre(ppgtt, engine)) {
                        int ret;
 
                        trace_switch_mm(engine, to);
@@ -852,6 +852,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
                        ppgtt->pd_dirty_rings &= ~intel_engine_flag(engine);
                }
 
+               engine->legacy_active_context = to;
                return 0;
        }
 
index 7032c542a9b1d007c4bc69e328db040b88efc15d..4dd4c2159a92e26d91fd98e560c587a91b964e48 100644 (file)
@@ -242,6 +242,10 @@ int i915_gem_render_state_emit(struct drm_i915_gem_request *req)
                        goto err_unpin;
        }
 
+       ret = req->engine->emit_flush(req, EMIT_INVALIDATE);
+       if (ret)
+               goto err_unpin;
+
        ret = req->engine->emit_bb_start(req,
                                         so->batch_offset, so->batch_size,
                                         I915_DISPATCH_SECURE);
index 1032f98add112a66a19fb186a2b28de773caadf8..77fb3980813143d2d9e3432c0ebb994a4bcad032 100644 (file)
@@ -43,16 +43,21 @@ static bool shrinker_lock(struct drm_i915_private *dev_priv, bool *unlock)
                return true;
 
        case MUTEX_TRYLOCK_FAILED:
+               *unlock = false;
+               preempt_disable();
                do {
                        cpu_relax();
                        if (mutex_trylock(&dev_priv->drm.struct_mutex)) {
-       case MUTEX_TRYLOCK_SUCCESS:
                                *unlock = true;
-                               return true;
+                               break;
                        }
                } while (!need_resched());
+               preempt_enable();
+               return *unlock;
 
-               return false;
+       case MUTEX_TRYLOCK_SUCCESS:
+               *unlock = true;
+               return true;
        }
 
        BUG();
index 9cd22f83b0cfaee680ed06c5bde67db6fc89d0fa..f33d90226704108e71ee5662e01977e32b627fcb 100644 (file)
@@ -1601,11 +1601,11 @@ static int gen8_emit_oa_config(struct drm_i915_gem_request *req)
        u32 *cs;
        int i;
 
-       cs = intel_ring_begin(req, n_flex_regs * 2 + 4);
+       cs = intel_ring_begin(req, ARRAY_SIZE(flex_mmio) * 2 + 4);
        if (IS_ERR(cs))
                return PTR_ERR(cs);
 
-       *cs++ = MI_LOAD_REGISTER_IMM(n_flex_regs + 1);
+       *cs++ = MI_LOAD_REGISTER_IMM(ARRAY_SIZE(flex_mmio) + 1);
 
        *cs++ = i915_mmio_reg_offset(GEN8_OACTXCONTROL);
        *cs++ = (dev_priv->perf.oa.period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
index 639d45c1dd2e6ac24013431aa6da84abb9f0b089..7ea7fd1e8856dc7bf98f3a6a6fdce0366db1f089 100644 (file)
@@ -1120,8 +1120,8 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
        bool is_dvi, is_hdmi, is_dp, is_edp, is_crt;
        uint8_t aux_channel, ddc_pin;
        /* Each DDI port can have more than one value on the "DVO Port" field,
-        * so look for all the possible values for each port and abort if more
-        * than one is found. */
+        * so look for all the possible values for each port.
+        */
        int dvo_ports[][3] = {
                {DVO_PORT_HDMIA, DVO_PORT_DPA, -1},
                {DVO_PORT_HDMIB, DVO_PORT_DPB, -1},
@@ -1130,7 +1130,10 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
                {DVO_PORT_CRT, DVO_PORT_HDMIE, DVO_PORT_DPE},
        };
 
-       /* Find the child device to use, abort if more than one found. */
+       /*
+        * Find the first child device to reference the port, report if more
+        * than one found.
+        */
        for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
                it = dev_priv->vbt.child_dev + i;
 
@@ -1140,11 +1143,11 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 
                        if (it->common.dvo_port == dvo_ports[port][j]) {
                                if (child) {
-                                       DRM_DEBUG_KMS("More than one child device for port %c in VBT.\n",
+                                       DRM_DEBUG_KMS("More than one child device for port %c in VBT, using the first.\n",
                                                      port_name(port));
-                                       return;
+                               } else {
+                                       child = it;
                                }
-                               child = it;
                        }
                }
        }
index 306c6b06b330bfc57f75a992c60468cb9d88e81c..17c4ae7e4e7c51e85de97cb8c803b280115de8cf 100644 (file)
@@ -398,6 +398,7 @@ static void bdw_load_gamma_lut(struct drm_crtc_state *state, u32 offset)
                }
 
                /* Program the max register to clamp values > 1.0. */
+               i = lut_size - 1;
                I915_WRITE(PREC_PAL_GC_MAX(pipe, 0),
                           drm_color_lut_extract(lut[i].red, 16));
                I915_WRITE(PREC_PAL_GC_MAX(pipe, 1),
index 9edeaaef77adf6c38e23733769e271147698f02a..d3b3252a874252641af555d8797a72e20056a34b 100644 (file)
@@ -1762,7 +1762,7 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv,
        if (dev_priv->vbt.edp.low_vswing) {
                if (voltage == VOLTAGE_INFO_0_85V) {
                        *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_85V);
-                       return cnl_ddi_translations_dp_0_85V;
+                       return cnl_ddi_translations_edp_0_85V;
                } else if (voltage == VOLTAGE_INFO_0_95V) {
                        *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_95V);
                        return cnl_ddi_translations_edp_0_95V;
index 9471c88d449eaf84adf3411d61135bf090be9b96..cc484b56eeaa33213a0832f43770132a1b165df1 100644 (file)
@@ -3485,6 +3485,13 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)
            !gpu_reset_clobbers_display(dev_priv))
                return;
 
+       /* We have a modeset vs reset deadlock, defensively unbreak it.
+        *
+        * FIXME: We can do a _lot_ better, this is just a first iteration.
+        */
+       i915_gem_set_wedged(dev_priv);
+       DRM_DEBUG_DRIVER("Wedging GPU to avoid deadlocks with pending modeset updates\n");
+
        /*
         * Need mode_config.mutex so that we don't
         * trample ongoing ->detect() and whatnot.
index 6e09ceb71500ceeedce5836c3772861f47aeda21..150a156f3b1e9a2bff7f32bbf1ed1905eb71ca8b 100644 (file)
@@ -46,7 +46,7 @@ static u32 dcs_get_backlight(struct intel_connector *connector)
        struct intel_encoder *encoder = connector->encoder;
        struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
        struct mipi_dsi_device *dsi_device;
-       u8 data;
+       u8 data = 0;
        enum port port;
 
        /* FIXME: Need to take care of 16 bit brightness level */
index 7158c7ce9c0941a05654261e2443bac8b2315b08..91c07b0c8db912dbb24a08fc045dee7a899b237b 100644 (file)
@@ -306,7 +306,7 @@ static void bxt_exec_gpio(struct drm_i915_private *dev_priv,
 
        if (!gpio_desc) {
                gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
-                                                "panel", gpio_index,
+                                                NULL, gpio_index,
                                                 value ? GPIOD_OUT_LOW :
                                                 GPIOD_OUT_HIGH);
 
index 7404cf2aac28690e2e5367de5a93164062a909b4..2afa4daa88e8cc695085c99d7a6d8b33c87a869a 100644 (file)
@@ -1221,6 +1221,14 @@ static int intel_init_workaround_bb(struct intel_engine_cs *engine)
        return ret;
 }
 
+static u8 gtiir[] = {
+       [RCS] = 0,
+       [BCS] = 0,
+       [VCS] = 1,
+       [VCS2] = 1,
+       [VECS] = 3,
+};
+
 static int gen8_init_common_ring(struct intel_engine_cs *engine)
 {
        struct drm_i915_private *dev_priv = engine->i915;
@@ -1245,9 +1253,22 @@ static int gen8_init_common_ring(struct intel_engine_cs *engine)
 
        DRM_DEBUG_DRIVER("Execlists enabled for %s\n", engine->name);
 
-       /* After a GPU reset, we may have requests to replay */
+       GEM_BUG_ON(engine->id >= ARRAY_SIZE(gtiir));
+
+       /*
+        * Clear any pending interrupt state.
+        *
+        * We do it twice out of paranoia that some of the IIR are double
+        * buffered, and if we only reset it once there may still be
+        * an interrupt pending.
+        */
+       I915_WRITE(GEN8_GT_IIR(gtiir[engine->id]),
+                  GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift);
+       I915_WRITE(GEN8_GT_IIR(gtiir[engine->id]),
+                  GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift);
        clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
 
+       /* After a GPU reset, we may have requests to replay */
        submit = false;
        for (n = 0; n < ARRAY_SIZE(engine->execlist_port); n++) {
                if (!port_isset(&port[n]))
index 52b3a1fd4059bab91a898f7f498a79af2c117a4b..57ef5833c4274958f3eed9f39b66a598dcfd1cd7 100644 (file)
@@ -63,7 +63,6 @@ enum {
 };
 
 /* Logical Rings */
-void intel_logical_ring_stop(struct intel_engine_cs *engine);
 void intel_logical_ring_cleanup(struct intel_engine_cs *engine);
 int logical_render_ring_init(struct intel_engine_cs *engine);
 int logical_xcs_ring_init(struct intel_engine_cs *engine);
index 5abef482eacf1b24780edea4c40ab7e593a42dc6..beb9baaf2f2e4e573956f1ea842c2963dce95bd7 100644 (file)
@@ -210,8 +210,8 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
        struct drm_device *dev = intel_dig_port->base.base.dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
 
-       if (!IS_GEN9(dev_priv)) {
-               DRM_ERROR("LSPCON is supported on GEN9 only\n");
+       if (!HAS_LSPCON(dev_priv)) {
+               DRM_ERROR("LSPCON is not supported on this platform\n");
                return false;
        }
 
index 96c2cbd81869e7e55dedc8ce09f53938466bee70..593349be8b9dfce328d20ea3ca5d1b22e41da320 100644 (file)
@@ -469,7 +469,7 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector,
 
        if (i915.invert_brightness > 0 ||
            dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) {
-               return panel->backlight.max - val;
+               return panel->backlight.max - val + panel->backlight.min;
        }
 
        return val;
index 6276bb834b4fe15529652e73c07e901617abc194..d3845989a29dfcba4bf4b03f5740f9945d1bdcdf 100644 (file)
@@ -545,15 +545,13 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
                return;
        }
 
+       ics = ipu_drm_fourcc_to_colorspace(fb->format->format);
        switch (ipu_plane->dp_flow) {
        case IPU_DP_FLOW_SYNC_BG:
-               ipu_dp_setup_channel(ipu_plane->dp,
-                                       IPUV3_COLORSPACE_RGB,
-                                       IPUV3_COLORSPACE_RGB);
+               ipu_dp_setup_channel(ipu_plane->dp, ics, IPUV3_COLORSPACE_RGB);
                ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
                break;
        case IPU_DP_FLOW_SYNC_FG:
-               ics = ipu_drm_fourcc_to_colorspace(state->fb->format->format);
                ipu_dp_setup_channel(ipu_plane->dp, ics,
                                        IPUV3_COLORSPACE_UNKNOWN);
                /* Enable local alpha on partial plane */
index b638d192ce5e046cc29e87459cc36e988e498ea8..99d39b2aefa675941d42c86b3c9b5a4d2cda937b 100644 (file)
@@ -5,7 +5,7 @@ config DRM_MSM
        depends on ARCH_QCOM || (ARM && COMPILE_TEST)
        depends on OF && COMMON_CLK
        depends on MMU
-       select QCOM_MDT_LOADER
+       select QCOM_MDT_LOADER if ARCH_QCOM
        select REGULATOR
        select DRM_KMS_HELPER
        select DRM_PANEL
index b4b54f1c24bc1995a032493838d99e8e31dff9e9..f9eae03aa1dcaef072974d60216fb6b09ef81e66 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/cpumask.h>
 #include <linux/qcom_scm.h>
 #include <linux/dma-mapping.h>
-#include <linux/of_reserved_mem.h>
+#include <linux/of_address.h>
 #include <linux/soc/qcom/mdt_loader.h>
 #include "msm_gem.h"
 #include "msm_mmu.h"
@@ -26,16 +26,34 @@ static void a5xx_dump(struct msm_gpu *gpu);
 
 #define GPU_PAS_ID 13
 
-#if IS_ENABLED(CONFIG_QCOM_MDT_LOADER)
-
 static int zap_shader_load_mdt(struct device *dev, const char *fwname)
 {
        const struct firmware *fw;
+       struct device_node *np;
+       struct resource r;
        phys_addr_t mem_phys;
        ssize_t mem_size;
        void *mem_region = NULL;
        int ret;
 
+       if (!IS_ENABLED(CONFIG_ARCH_QCOM))
+               return -EINVAL;
+
+       np = of_get_child_by_name(dev->of_node, "zap-shader");
+       if (!np)
+               return -ENODEV;
+
+       np = of_parse_phandle(np, "memory-region", 0);
+       if (!np)
+               return -EINVAL;
+
+       ret = of_address_to_resource(np, 0, &r);
+       if (ret)
+               return ret;
+
+       mem_phys = r.start;
+       mem_size = resource_size(&r);
+
        /* Request the MDT file for the firmware */
        ret = request_firmware(&fw, fwname, dev);
        if (ret) {
@@ -51,7 +69,7 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname)
        }
 
        /* Allocate memory for the firmware image */
-       mem_region = dmam_alloc_coherent(dev, mem_size, &mem_phys, GFP_KERNEL);
+       mem_region = memremap(mem_phys, mem_size,  MEMREMAP_WC);
        if (!mem_region) {
                ret = -ENOMEM;
                goto out;
@@ -69,16 +87,13 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname)
                DRM_DEV_ERROR(dev, "Unable to authorize the image\n");
 
 out:
+       if (mem_region)
+               memunmap(mem_region);
+
        release_firmware(fw);
 
        return ret;
 }
-#else
-static int zap_shader_load_mdt(struct device *dev, const char *fwname)
-{
-       return -ENODEV;
-}
-#endif
 
 static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
        struct msm_file_private *ctx)
@@ -117,12 +132,10 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
        gpu->funcs->flush(gpu);
 }
 
-struct a5xx_hwcg {
+static const struct {
        u32 offset;
        u32 value;
-};
-
-static const struct a5xx_hwcg a530_hwcg[] = {
+} a5xx_hwcg[] = {
        {REG_A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222},
        {REG_A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222},
        {REG_A5XX_RBBM_CLOCK_CNTL_SP2, 0x02222222},
@@ -217,38 +230,16 @@ static const struct a5xx_hwcg a530_hwcg[] = {
        {REG_A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}
 };
 
-static const struct {
-       int (*test)(struct adreno_gpu *gpu);
-       const struct a5xx_hwcg *regs;
-       unsigned int count;
-} a5xx_hwcg_regs[] = {
-       { adreno_is_a530, a530_hwcg, ARRAY_SIZE(a530_hwcg), },
-};
-
-static void _a5xx_enable_hwcg(struct msm_gpu *gpu,
-               const struct a5xx_hwcg *regs, unsigned int count)
+void a5xx_set_hwcg(struct msm_gpu *gpu, bool state)
 {
        unsigned int i;
 
-       for (i = 0; i < count; i++)
-               gpu_write(gpu, regs[i].offset, regs[i].value);
+       for (i = 0; i < ARRAY_SIZE(a5xx_hwcg); i++)
+               gpu_write(gpu, a5xx_hwcg[i].offset,
+                       state ? a5xx_hwcg[i].value : 0);
 
-       gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, 0xAAA8AA00);
-       gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, 0x182);
-}
-
-static void a5xx_enable_hwcg(struct msm_gpu *gpu)
-{
-       struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
-       unsigned int i;
-
-       for (i = 0; i < ARRAY_SIZE(a5xx_hwcg_regs); i++) {
-               if (a5xx_hwcg_regs[i].test(adreno_gpu)) {
-                       _a5xx_enable_hwcg(gpu, a5xx_hwcg_regs[i].regs,
-                               a5xx_hwcg_regs[i].count);
-                       return;
-               }
-       }
+       gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, state ? 0xAAA8AA00 : 0);
+       gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, state ? 0x182 : 0x180);
 }
 
 static int a5xx_me_init(struct msm_gpu *gpu)
@@ -377,45 +368,6 @@ static int a5xx_zap_shader_resume(struct msm_gpu *gpu)
        return ret;
 }
 
-/* Set up a child device to "own" the zap shader */
-static int a5xx_zap_shader_dev_init(struct device *parent, struct device *dev)
-{
-       struct device_node *node;
-       int ret;
-
-       if (dev->parent)
-               return 0;
-
-       /* Find the sub-node for the zap shader */
-       node = of_get_child_by_name(parent->of_node, "zap-shader");
-       if (!node) {
-               DRM_DEV_ERROR(parent, "zap-shader not found in device tree\n");
-               return -ENODEV;
-       }
-
-       dev->parent = parent;
-       dev->of_node = node;
-       dev_set_name(dev, "adreno_zap_shader");
-
-       ret = device_register(dev);
-       if (ret) {
-               DRM_DEV_ERROR(parent, "Couldn't register zap shader device\n");
-               goto out;
-       }
-
-       ret = of_reserved_mem_device_init(dev);
-       if (ret) {
-               DRM_DEV_ERROR(parent, "Unable to set up the reserved memory\n");
-               device_unregister(dev);
-       }
-
-out:
-       if (ret)
-               dev->parent = NULL;
-
-       return ret;
-}
-
 static int a5xx_zap_shader_init(struct msm_gpu *gpu)
 {
        static bool loaded;
@@ -444,11 +396,7 @@ static int a5xx_zap_shader_init(struct msm_gpu *gpu)
                return -ENODEV;
        }
 
-       ret = a5xx_zap_shader_dev_init(&pdev->dev, &a5xx_gpu->zap_dev);
-
-       if (!ret)
-               ret = zap_shader_load_mdt(&a5xx_gpu->zap_dev,
-                       adreno_gpu->info->zapfw);
+       ret = zap_shader_load_mdt(&pdev->dev, adreno_gpu->info->zapfw);
 
        loaded = !ret;
 
@@ -545,7 +493,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
        gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL1, 0xA6FFFFFF);
 
        /* Enable HWCG */
-       a5xx_enable_hwcg(gpu);
+       a5xx_set_hwcg(gpu, true);
 
        gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F);
 
@@ -691,9 +639,6 @@ static void a5xx_destroy(struct msm_gpu *gpu)
 
        DBG("%s", gpu->name);
 
-       if (a5xx_gpu->zap_dev.parent)
-               device_unregister(&a5xx_gpu->zap_dev);
-
        if (a5xx_gpu->pm4_bo) {
                if (a5xx_gpu->pm4_iova)
                        msm_gem_put_iova(a5xx_gpu->pm4_bo, gpu->aspace);
@@ -920,31 +865,30 @@ static const u32 a5xx_registers[] = {
        0x0000, 0x0002, 0x0004, 0x0020, 0x0022, 0x0026, 0x0029, 0x002B,
        0x002E, 0x0035, 0x0038, 0x0042, 0x0044, 0x0044, 0x0047, 0x0095,
        0x0097, 0x00BB, 0x03A0, 0x0464, 0x0469, 0x046F, 0x04D2, 0x04D3,
-       0x04E0, 0x0533, 0x0540, 0x0555, 0xF400, 0xF400, 0xF800, 0xF807,
-       0x0800, 0x081A, 0x081F, 0x0841, 0x0860, 0x0860, 0x0880, 0x08A0,
-       0x0B00, 0x0B12, 0x0B15, 0x0B28, 0x0B78, 0x0B7F, 0x0BB0, 0x0BBD,
-       0x0BC0, 0x0BC6, 0x0BD0, 0x0C53, 0x0C60, 0x0C61, 0x0C80, 0x0C82,
-       0x0C84, 0x0C85, 0x0C90, 0x0C98, 0x0CA0, 0x0CA0, 0x0CB0, 0x0CB2,
-       0x2180, 0x2185, 0x2580, 0x2585, 0x0CC1, 0x0CC1, 0x0CC4, 0x0CC7,
-       0x0CCC, 0x0CCC, 0x0CD0, 0x0CD8, 0x0CE0, 0x0CE5, 0x0CE8, 0x0CE8,
-       0x0CEC, 0x0CF1, 0x0CFB, 0x0D0E, 0x2100, 0x211E, 0x2140, 0x2145,
-       0x2500, 0x251E, 0x2540, 0x2545, 0x0D10, 0x0D17, 0x0D20, 0x0D23,
-       0x0D30, 0x0D30, 0x20C0, 0x20C0, 0x24C0, 0x24C0, 0x0E40, 0x0E43,
-       0x0E4A, 0x0E4A, 0x0E50, 0x0E57, 0x0E60, 0x0E7C, 0x0E80, 0x0E8E,
-       0x0E90, 0x0E96, 0x0EA0, 0x0EA8, 0x0EB0, 0x0EB2, 0xE140, 0xE147,
-       0xE150, 0xE187, 0xE1A0, 0xE1A9, 0xE1B0, 0xE1B6, 0xE1C0, 0xE1C7,
-       0xE1D0, 0xE1D1, 0xE200, 0xE201, 0xE210, 0xE21C, 0xE240, 0xE268,
-       0xE000, 0xE006, 0xE010, 0xE09A, 0xE0A0, 0xE0A4, 0xE0AA, 0xE0EB,
-       0xE100, 0xE105, 0xE380, 0xE38F, 0xE3B0, 0xE3B0, 0xE400, 0xE405,
-       0xE408, 0xE4E9, 0xE4F0, 0xE4F0, 0xE280, 0xE280, 0xE282, 0xE2A3,
-       0xE2A5, 0xE2C2, 0xE940, 0xE947, 0xE950, 0xE987, 0xE9A0, 0xE9A9,
-       0xE9B0, 0xE9B6, 0xE9C0, 0xE9C7, 0xE9D0, 0xE9D1, 0xEA00, 0xEA01,
-       0xEA10, 0xEA1C, 0xEA40, 0xEA68, 0xE800, 0xE806, 0xE810, 0xE89A,
-       0xE8A0, 0xE8A4, 0xE8AA, 0xE8EB, 0xE900, 0xE905, 0xEB80, 0xEB8F,
-       0xEBB0, 0xEBB0, 0xEC00, 0xEC05, 0xEC08, 0xECE9, 0xECF0, 0xECF0,
-       0xEA80, 0xEA80, 0xEA82, 0xEAA3, 0xEAA5, 0xEAC2, 0xA800, 0xA8FF,
-       0xAC60, 0xAC60, 0xB000, 0xB97F, 0xB9A0, 0xB9BF,
-       ~0
+       0x04E0, 0x0533, 0x0540, 0x0555, 0x0800, 0x081A, 0x081F, 0x0841,
+       0x0860, 0x0860, 0x0880, 0x08A0, 0x0B00, 0x0B12, 0x0B15, 0x0B28,
+       0x0B78, 0x0B7F, 0x0BB0, 0x0BBD, 0x0BC0, 0x0BC6, 0x0BD0, 0x0C53,
+       0x0C60, 0x0C61, 0x0C80, 0x0C82, 0x0C84, 0x0C85, 0x0C90, 0x0C98,
+       0x0CA0, 0x0CA0, 0x0CB0, 0x0CB2, 0x2180, 0x2185, 0x2580, 0x2585,
+       0x0CC1, 0x0CC1, 0x0CC4, 0x0CC7, 0x0CCC, 0x0CCC, 0x0CD0, 0x0CD8,
+       0x0CE0, 0x0CE5, 0x0CE8, 0x0CE8, 0x0CEC, 0x0CF1, 0x0CFB, 0x0D0E,
+       0x2100, 0x211E, 0x2140, 0x2145, 0x2500, 0x251E, 0x2540, 0x2545,
+       0x0D10, 0x0D17, 0x0D20, 0x0D23, 0x0D30, 0x0D30, 0x20C0, 0x20C0,
+       0x24C0, 0x24C0, 0x0E40, 0x0E43, 0x0E4A, 0x0E4A, 0x0E50, 0x0E57,
+       0x0E60, 0x0E7C, 0x0E80, 0x0E8E, 0x0E90, 0x0E96, 0x0EA0, 0x0EA8,
+       0x0EB0, 0x0EB2, 0xE140, 0xE147, 0xE150, 0xE187, 0xE1A0, 0xE1A9,
+       0xE1B0, 0xE1B6, 0xE1C0, 0xE1C7, 0xE1D0, 0xE1D1, 0xE200, 0xE201,
+       0xE210, 0xE21C, 0xE240, 0xE268, 0xE000, 0xE006, 0xE010, 0xE09A,
+       0xE0A0, 0xE0A4, 0xE0AA, 0xE0EB, 0xE100, 0xE105, 0xE380, 0xE38F,
+       0xE3B0, 0xE3B0, 0xE400, 0xE405, 0xE408, 0xE4E9, 0xE4F0, 0xE4F0,
+       0xE280, 0xE280, 0xE282, 0xE2A3, 0xE2A5, 0xE2C2, 0xE940, 0xE947,
+       0xE950, 0xE987, 0xE9A0, 0xE9A9, 0xE9B0, 0xE9B6, 0xE9C0, 0xE9C7,
+       0xE9D0, 0xE9D1, 0xEA00, 0xEA01, 0xEA10, 0xEA1C, 0xEA40, 0xEA68,
+       0xE800, 0xE806, 0xE810, 0xE89A, 0xE8A0, 0xE8A4, 0xE8AA, 0xE8EB,
+       0xE900, 0xE905, 0xEB80, 0xEB8F, 0xEBB0, 0xEBB0, 0xEC00, 0xEC05,
+       0xEC08, 0xECE9, 0xECF0, 0xECF0, 0xEA80, 0xEA80, 0xEA82, 0xEAA3,
+       0xEAA5, 0xEAC2, 0xA800, 0xA8FF, 0xAC60, 0xAC60, 0xB000, 0xB97F,
+       0xB9A0, 0xB9BF, ~0
 };
 
 static void a5xx_dump(struct msm_gpu *gpu)
@@ -1020,7 +964,14 @@ static void a5xx_show(struct msm_gpu *gpu, struct seq_file *m)
 {
        seq_printf(m, "status:   %08x\n",
                        gpu_read(gpu, REG_A5XX_RBBM_STATUS));
+
+       /*
+        * Temporarily disable hardware clock gating before going into
+        * adreno_show to avoid issues while reading the registers
+        */
+       a5xx_set_hwcg(gpu, false);
        adreno_show(gpu, m);
+       a5xx_set_hwcg(gpu, true);
 }
 #endif
 
index 6638bc85645dbad4adf3689bd7d9bae9441173c2..1137092241d593c34e4607e3c723acfb74861972 100644 (file)
@@ -36,8 +36,6 @@ struct a5xx_gpu {
        uint32_t gpmu_dwords;
 
        uint32_t lm_leakage;
-
-       struct device zap_dev;
 };
 
 #define to_a5xx_gpu(x) container_of(x, struct a5xx_gpu, base)
@@ -59,5 +57,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs,
 }
 
 bool a5xx_idle(struct msm_gpu *gpu);
+void a5xx_set_hwcg(struct msm_gpu *gpu, bool state);
 
 #endif /* __A5XX_GPU_H__ */
index f1ab2703674a2f5d4f533828bb6c8b49df24f571..7414c6bbd582e9597e502305885f0dec909859be 100644 (file)
@@ -48,8 +48,15 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
                *value = adreno_gpu->base.fast_rate;
                return 0;
        case MSM_PARAM_TIMESTAMP:
-               if (adreno_gpu->funcs->get_timestamp)
-                       return adreno_gpu->funcs->get_timestamp(gpu, value);
+               if (adreno_gpu->funcs->get_timestamp) {
+                       int ret;
+
+                       pm_runtime_get_sync(&gpu->pdev->dev);
+                       ret = adreno_gpu->funcs->get_timestamp(gpu, value);
+                       pm_runtime_put_autosuspend(&gpu->pdev->dev);
+
+                       return ret;
+               }
                return -EINVAL;
        default:
                DBG("%s: invalid param: %u", gpu->name, param);
index 9e9c5696bc03547b813ecf2ae56c535265e64bcd..c7b612c3d7717a02d8d64be21dea68f183163917 100644 (file)
@@ -2137,6 +2137,13 @@ void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
        struct msm_dsi_phy_clk_request *clk_req)
 {
        struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
+       int ret;
+
+       ret = dsi_calc_clk_rate(msm_host);
+       if (ret) {
+               pr_err("%s: unable to calc clk rate, %d\n", __func__, ret);
+               return;
+       }
 
        clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
        clk_req->escclk_rate = msm_host->esc_clk_rate;
@@ -2280,7 +2287,6 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
                                        struct drm_display_mode *mode)
 {
        struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
-       int ret;
 
        if (msm_host->mode) {
                drm_mode_destroy(msm_host->dev, msm_host->mode);
@@ -2293,12 +2299,6 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
                return -ENOMEM;
        }
 
-       ret = dsi_calc_clk_rate(msm_host);
-       if (ret) {
-               pr_err("%s: unable to calc clk rate, %d\n", __func__, ret);
-               return ret;
-       }
-
        return 0;
 }
 
index cb5415d6c04b7ab6e1e80503d26b32891a934dee..735a87a699fafafb99b179752e0e7f3c19491389 100644 (file)
@@ -221,8 +221,8 @@ static void blend_setup(struct drm_crtc *crtc)
        struct mdp5_ctl *ctl = mdp5_cstate->ctl;
        uint32_t blend_op, fg_alpha, bg_alpha, ctl_blend_flags = 0;
        unsigned long flags;
-       enum mdp5_pipe stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { SSPP_NONE };
-       enum mdp5_pipe r_stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { SSPP_NONE };
+       enum mdp5_pipe stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { { SSPP_NONE } };
+       enum mdp5_pipe r_stage[STAGE_MAX + 1][MAX_PIPE_STAGE] = { { SSPP_NONE } };
        int i, plane_cnt = 0;
        bool bg_alpha_enabled = false;
        u32 mixer_op_mode = 0;
@@ -753,6 +753,7 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,
        if (!handle) {
                DBG("Cursor off");
                cursor_enable = false;
+               mdp5_enable(mdp5_kms);
                goto set_cursor;
        }
 
@@ -776,6 +777,8 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,
 
        get_roi(crtc, &roi_w, &roi_h);
 
+       mdp5_enable(mdp5_kms);
+
        mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_STRIDE(lm), stride);
        mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_FORMAT(lm),
                        MDP5_LM_CURSOR_FORMAT_FORMAT(CURSOR_FMT_ARGB8888));
@@ -804,6 +807,7 @@ set_cursor:
        crtc_flush(crtc, flush_mask);
 
 end:
+       mdp5_disable(mdp5_kms);
        if (old_bo) {
                drm_flip_work_queue(&mdp5_crtc->unref_cursor_work, old_bo);
                /* enable vblank to complete cursor work: */
@@ -836,6 +840,8 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 
        get_roi(crtc, &roi_w, &roi_h);
 
+       mdp5_enable(mdp5_kms);
+
        spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags);
        mdp5_write(mdp5_kms, REG_MDP5_LM_CURSOR_SIZE(lm),
                        MDP5_LM_CURSOR_SIZE_ROI_H(roi_h) |
@@ -847,6 +853,8 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 
        crtc_flush(crtc, flush_mask);
 
+       mdp5_disable(mdp5_kms);
+
        return 0;
 }
 
index 97f3294fbfc6f9d26f453dac36d5dbb3cb00e93a..70bef51245af89d5bbb292f4495f2fd79dcc9e33 100644 (file)
@@ -299,7 +299,7 @@ static void mdp5_encoder_enable(struct drm_encoder *encoder)
        struct mdp5_interface *intf = mdp5_encoder->intf;
 
        if (intf->mode == MDP5_INTF_DSI_MODE_COMMAND)
-               mdp5_cmd_encoder_disable(encoder);
+               mdp5_cmd_encoder_enable(encoder);
        else
                mdp5_vid_encoder_enable(encoder);
 }
index 5d13fa5381ee37705a0c282bf023b4782fc19268..1c603aef3c59cdff286ce38e84c3e6a4745dd0c2 100644 (file)
@@ -502,7 +502,7 @@ static int get_clk(struct platform_device *pdev, struct clk **clkp,
                const char *name, bool mandatory)
 {
        struct device *dev = &pdev->dev;
-       struct clk *clk = devm_clk_get(dev, name);
+       struct clk *clk = msm_clk_get(pdev, name);
        if (IS_ERR(clk) && mandatory) {
                dev_err(dev, "failed to get %s (%ld)\n", name, PTR_ERR(clk));
                return PTR_ERR(clk);
@@ -887,21 +887,21 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
        }
 
        /* mandatory clocks: */
-       ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus_clk", true);
+       ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true);
        if (ret)
                goto fail;
-       ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface_clk", true);
+       ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true);
        if (ret)
                goto fail;
-       ret = get_clk(pdev, &mdp5_kms->core_clk, "core_clk", true);
+       ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true);
        if (ret)
                goto fail;
-       ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync_clk", true);
+       ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true);
        if (ret)
                goto fail;
 
        /* optional clocks: */
-       get_clk(pdev, &mdp5_kms->lut_clk, "lut_clk", false);
+       get_clk(pdev, &mdp5_kms->lut_clk, "lut", false);
 
        /* we need to set a default rate before enabling.  Set a safe
         * rate first, then figure out hw revision, and then set a
index fe3a4de1a4331ff86f0b4f0cc85a48b208bca3b5..61f39c86dd09e53a5860ce880b0f7955e5008c05 100644 (file)
@@ -890,8 +890,8 @@ static int mdp5_plane_mode_set(struct drm_plane *plane,
        struct mdp5_hw_pipe *right_hwpipe;
        const struct mdp_format *format;
        uint32_t nplanes, config = 0;
-       struct phase_step step = { 0 };
-       struct pixel_ext pe = { 0 };
+       struct phase_step step = { { 0 } };
+       struct pixel_ext pe = { { 0 } };
        uint32_t hdecm = 0, vdecm = 0;
        uint32_t pix_format;
        unsigned int rotation;
index 65f35544c1ec8859018c2afb713fa5120fc43272..a0c60e738db8d7be5e841311832e82f0b45bd7fa 100644 (file)
@@ -383,8 +383,10 @@ int msm_gem_get_iova(struct drm_gem_object *obj,
                struct page **pages;
 
                vma = add_vma(obj, aspace);
-               if (IS_ERR(vma))
-                       return PTR_ERR(vma);
+               if (IS_ERR(vma)) {
+                       ret = PTR_ERR(vma);
+                       goto unlock;
+               }
 
                pages = get_pages(obj);
                if (IS_ERR(pages)) {
@@ -405,7 +407,7 @@ int msm_gem_get_iova(struct drm_gem_object *obj,
 
 fail:
        del_vma(vma);
-
+unlock:
        mutex_unlock(&msm_obj->lock);
        return ret;
 }
@@ -928,8 +930,12 @@ static struct drm_gem_object *_msm_gem_new(struct drm_device *dev,
        if (use_vram) {
                struct msm_gem_vma *vma;
                struct page **pages;
+               struct msm_gem_object *msm_obj = to_msm_bo(obj);
+
+               mutex_lock(&msm_obj->lock);
 
                vma = add_vma(obj, NULL);
+               mutex_unlock(&msm_obj->lock);
                if (IS_ERR(vma)) {
                        ret = PTR_ERR(vma);
                        goto fail;
index 6bfca74701410050b20d1a136ae5cdc4454b1306..8a75c0bd8a78b1481e30fdab63f2d14bfc64536d 100644 (file)
@@ -34,8 +34,8 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
                struct msm_gpu *gpu, uint32_t nr_bos, uint32_t nr_cmds)
 {
        struct msm_gem_submit *submit;
-       uint64_t sz = sizeof(*submit) + (nr_bos * sizeof(submit->bos[0])) +
-               (nr_cmds * sizeof(submit->cmd[0]));
+       uint64_t sz = sizeof(*submit) + ((u64)nr_bos * sizeof(submit->bos[0])) +
+               ((u64)nr_cmds * sizeof(submit->cmd[0]));
 
        if (sz > SIZE_MAX)
                return NULL;
@@ -451,7 +451,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        if (ret)
                goto out;
 
-       if (!(args->fence & MSM_SUBMIT_NO_IMPLICIT)) {
+       if (!(args->flags & MSM_SUBMIT_NO_IMPLICIT)) {
                ret = submit_fence_sync(submit);
                if (ret)
                        goto out;
index c36321bc87148864db09bd0af4fc38a39cb182f9..d34e331554f3903eaded86cf12fdd4a4ef24507a 100644 (file)
@@ -42,7 +42,7 @@ void
 msm_gem_unmap_vma(struct msm_gem_address_space *aspace,
                struct msm_gem_vma *vma, struct sg_table *sgt)
 {
-       if (!vma->iova)
+       if (!aspace || !vma->iova)
                return;
 
        if (aspace->mmu) {
index c7c84d34d97e20308b926077e7ed4ce6e8d77281..88582af8bd89745b7c78332cf415dd0bc9f24e23 100644 (file)
@@ -267,6 +267,8 @@ nvkm_disp_oneinit(struct nvkm_engine *engine)
        /* Create output path objects for each VBIOS display path. */
        i = -1;
        while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) {
+               if (ver < 0x40) /* No support for chipsets prior to NV50. */
+                       break;
                if (dcbE.type == DCB_OUTPUT_UNUSED)
                        continue;
                if (dcbE.type == DCB_OUTPUT_EOL)
index c6b1b7f3a2a397740d5545671113def5bb2e5519..c16bc0a7115b1b41db4ccca2b74061e3e7ccceb2 100644 (file)
@@ -275,11 +275,15 @@ static void rockchip_drm_fb_resume(struct drm_device *drm)
 static int rockchip_drm_sys_suspend(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
-       struct rockchip_drm_private *priv = drm->dev_private;
+       struct rockchip_drm_private *priv;
+
+       if (!drm)
+               return 0;
 
        drm_kms_helper_poll_disable(drm);
        rockchip_drm_fb_suspend(drm);
 
+       priv = drm->dev_private;
        priv->state = drm_atomic_helper_suspend(drm);
        if (IS_ERR(priv->state)) {
                rockchip_drm_fb_resume(drm);
@@ -293,8 +297,12 @@ static int rockchip_drm_sys_suspend(struct device *dev)
 static int rockchip_drm_sys_resume(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
-       struct rockchip_drm_private *priv = drm->dev_private;
+       struct rockchip_drm_private *priv;
+
+       if (!drm)
+               return 0;
 
+       priv = drm->dev_private;
        drm_atomic_helper_resume(drm, priv->state);
        rockchip_drm_fb_resume(drm);
        drm_kms_helper_poll_enable(drm);
index 5d450332c2fd79fd8c1052aca84d7d15c5db3ef8..2900f1410d959bc9f4002a6f0c38a3aae5a9c59a 100644 (file)
@@ -500,7 +500,7 @@ static void vop_line_flag_irq_disable(struct vop *vop)
 static int vop_enable(struct drm_crtc *crtc)
 {
        struct vop *vop = to_vop(crtc);
-       int ret;
+       int ret, i;
 
        ret = pm_runtime_get_sync(vop->dev);
        if (ret < 0) {
@@ -533,6 +533,20 @@ static int vop_enable(struct drm_crtc *crtc)
        }
 
        memcpy(vop->regs, vop->regsbak, vop->len);
+       /*
+        * We need to make sure that all windows are disabled before we
+        * enable the crtc. Otherwise we might try to scan from a destroyed
+        * buffer later.
+        */
+       for (i = 0; i < vop->data->win_size; i++) {
+               struct vop_win *vop_win = &vop->win[i];
+               const struct vop_win_data *win = vop_win->data;
+
+               spin_lock(&vop->reg_lock);
+               VOP_WIN_SET(vop, win, enable, 0);
+               spin_unlock(&vop->reg_lock);
+       }
+
        vop_cfg_done(vop);
 
        /*
@@ -566,28 +580,11 @@ err_put_pm_runtime:
 static void vop_crtc_disable(struct drm_crtc *crtc)
 {
        struct vop *vop = to_vop(crtc);
-       int i;
 
        WARN_ON(vop->event);
 
        rockchip_drm_psr_deactivate(&vop->crtc);
 
-       /*
-        * We need to make sure that all windows are disabled before we
-        * disable that crtc. Otherwise we might try to scan from a destroyed
-        * buffer later.
-        */
-       for (i = 0; i < vop->data->win_size; i++) {
-               struct vop_win *vop_win = &vop->win[i];
-               const struct vop_win_data *win = vop_win->data;
-
-               spin_lock(&vop->reg_lock);
-               VOP_WIN_SET(vop, win, enable, 0);
-               spin_unlock(&vop->reg_lock);
-       }
-
-       vop_cfg_done(vop);
-
        drm_crtc_vblank_off(crtc);
 
        /*
@@ -682,8 +679,10 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
         * Src.x1 can be odd when do clip, but yuv plane start point
         * need align with 2 pixel.
         */
-       if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2))
+       if (is_yuv_support(fb->format->format) && ((state->src.x1 >> 16) % 2)) {
+               DRM_ERROR("Invalid Source: Yuv format not support odd xpos\n");
                return -EINVAL;
+       }
 
        return 0;
 }
@@ -764,7 +763,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
        spin_lock(&vop->reg_lock);
 
        VOP_WIN_SET(vop, win, format, format);
-       VOP_WIN_SET(vop, win, yrgb_vir, fb->pitches[0] >> 2);
+       VOP_WIN_SET(vop, win, yrgb_vir, DIV_ROUND_UP(fb->pitches[0], 4));
        VOP_WIN_SET(vop, win, yrgb_mst, dma_addr);
        if (is_yuv_support(fb->format->format)) {
                int hsub = drm_format_horz_chroma_subsampling(fb->format->format);
@@ -778,7 +777,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
                offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
 
                dma_addr = rk_uv_obj->dma_addr + offset + fb->offsets[1];
-               VOP_WIN_SET(vop, win, uv_vir, fb->pitches[1] >> 2);
+               VOP_WIN_SET(vop, win, uv_vir, DIV_ROUND_UP(fb->pitches[1], 4));
                VOP_WIN_SET(vop, win, uv_mst, dma_addr);
        }
 
index 9979fd0c22821d7efa3d7054468e0914619e0692..27eefbfcf3d05f3ad03e3b9f6fe2ae56f68e7684 100644 (file)
@@ -282,6 +282,9 @@ static inline uint16_t scl_get_bili_dn_vskip(int src_h, int dst_h,
 
        act_height = (src_h + vskiplines - 1) / vskiplines;
 
+       if (act_height == dst_h)
+               return GET_SCL_FT_BILI_DN(src_h, dst_h) / vskiplines;
+
        return GET_SCL_FT_BILI_DN(act_height, dst_h);
 }
 
index 2c4817fb08902427df09223b7ab4046241fc6c77..8fe5b184b4e8a945d68c201a3a29be531594e2d2 100644 (file)
@@ -7,7 +7,6 @@ config DRM_STM
        select DRM_PANEL
        select VIDEOMODE_HELPERS
        select FB_PROVIDE_GET_FB_UNMAPPED_AREA
-       default y
 
        help
          Enable support for the on-chip display controller on
index abc7d8fe06b450084bcd20ec560b62405415ff40..a45a627283a149c79693ec90dbd9da5fd8f42056 100644 (file)
 #include "sun4i_framebuffer.h"
 #include "sun4i_tcon.h"
 
+static void sun4i_drv_lastclose(struct drm_device *dev)
+{
+       struct sun4i_drv *drv = dev->dev_private;
+
+       drm_fbdev_cma_restore_mode(drv->fbdev);
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
 
 static struct drm_driver sun4i_drv_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
 
        /* Generic Operations */
+       .lastclose              = sun4i_drv_lastclose,
        .fops                   = &sun4i_drv_fops,
        .name                   = "sun4i-drm",
        .desc                   = "Allwinner sun4i Display Engine",
index 61e06f0e8cd3b43890e807a2ab2bb9037ac95e99..625ba24f143f22c3369cecde2abf4927ba6199f5 100644 (file)
@@ -1567,10 +1567,34 @@ vmw_kms_atomic_check_modeset(struct drm_device *dev,
 }
 
 
+/**
+ * vmw_kms_atomic_commit - Perform an atomic state commit
+ *
+ * @dev: DRM device
+ * @state: the driver state object
+ * @nonblock: Whether nonblocking behaviour is requested
+ *
+ * This is a simple wrapper around drm_atomic_helper_commit() for
+ * us to clear the nonblocking value.
+ *
+ * Nonblocking commits currently cause synchronization issues
+ * for vmwgfx.
+ *
+ * RETURNS
+ * Zero for success or negative error code on failure.
+ */
+int vmw_kms_atomic_commit(struct drm_device *dev,
+                         struct drm_atomic_state *state,
+                         bool nonblock)
+{
+       return drm_atomic_helper_commit(dev, state, false);
+}
+
+
 static const struct drm_mode_config_funcs vmw_kms_funcs = {
        .fb_create = vmw_kms_fb_create,
        .atomic_check = vmw_kms_atomic_check_modeset,
-       .atomic_commit = drm_atomic_helper_commit,
+       .atomic_commit = vmw_kms_atomic_commit,
 };
 
 static int vmw_kms_generic_present(struct vmw_private *dev_priv,
index 08766c6e7856b31f6183dba84f47c27980fb49c2..87a20b3dcf7a53a64fc464a3c8834d5c0a167781 100644 (file)
@@ -1,6 +1,7 @@
 config IMX_IPUV3_CORE
        tristate "IPUv3 core support"
        depends on SOC_IMX5 || SOC_IMX6Q || ARCH_MULTIPLATFORM
+       depends on DRM || !DRM # if DRM=m, this can't be 'y'
        select GENERIC_IRQ_CHIP
        help
          Choose this if you have a i.MX5/6 system and want to use the Image
index 1006b230b236f1c977d1c1a7d9bf32a268b7e263..65fa29591d21641fd1bd4e4484d8daeef56f9bdb 100644 (file)
@@ -983,7 +983,7 @@ config I2C_UNIPHIER_F
 
 config I2C_VERSATILE
        tristate "ARM Versatile/Realview I2C bus support"
-       depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || COMPILE_TEST
+       depends on ARCH_MPS2 || ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || COMPILE_TEST
        select I2C_ALGOBIT
        help
          Say yes if you want to support the I2C serial bus on ARMs Versatile
index f19348328a715580aa37043abed6d1ee6b061cf4..6fdf9231c23cb0a4f4c736d95662495c2237e24f 100644 (file)
@@ -410,10 +410,11 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus)
        }
 
        /* We are in an invalid state; reset bus to a known state. */
-       if (!bus->msgs && bus->master_state != ASPEED_I2C_MASTER_STOP) {
+       if (!bus->msgs) {
                dev_err(bus->dev, "bus in unknown state");
                bus->cmd_err = -EIO;
-               aspeed_i2c_do_stop(bus);
+               if (bus->master_state != ASPEED_I2C_MASTER_STOP)
+                       aspeed_i2c_do_stop(bus);
                goto out_no_complete;
        }
        msg = &bus->msgs[bus->msgs_index];
index 2ea6d0d25a01a33069bce293ab6858947a0cb01f..2b98a173136f2e53d729dfbe7fe314fe1eaf07fc 100644 (file)
@@ -198,8 +198,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
        dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY;
 
        dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
-                        DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED |
-                        DW_IC_CON_SPEED_FAST;
+                        DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED;
 
        dev->mode = DW_IC_SLAVE;
 
@@ -257,7 +256,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
        struct dw_i2c_dev *dev;
        u32 acpi_speed, ht = 0;
        struct resource *mem;
-       int irq, ret;
+       int i, irq, ret;
+       const int supported_speeds[] = { 0, 100000, 400000, 1000000, 3400000 };
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
@@ -298,6 +298,16 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
        }
 
        acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev);
+       /*
+        * Some DSTDs use a non standard speed, round down to the lowest
+        * standard speed.
+        */
+       for (i = 1; i < ARRAY_SIZE(supported_speeds); i++) {
+               if (acpi_speed < supported_speeds[i])
+                       break;
+       }
+       acpi_speed = supported_speeds[i - 1];
+
        /*
         * Find bus speed from the "clock-frequency" device property, ACPI
         * or by using fast mode if neither is set.
@@ -319,7 +329,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
        if (dev->clk_freq != 100000 && dev->clk_freq != 400000
            && dev->clk_freq != 1000000 && dev->clk_freq != 3400000) {
                dev_err(&pdev->dev,
-                       "Only 100kHz, 400kHz, 1MHz and 3.4MHz supported");
+                       "%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n",
+                       dev->clk_freq);
                ret = -EINVAL;
                goto exit_reset;
        }
@@ -426,7 +437,7 @@ static void dw_i2c_plat_complete(struct device *dev)
 #endif
 
 #ifdef CONFIG_PM
-static int dw_i2c_plat_suspend(struct device *dev)
+static int dw_i2c_plat_runtime_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
@@ -448,11 +459,21 @@ static int dw_i2c_plat_resume(struct device *dev)
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int dw_i2c_plat_suspend(struct device *dev)
+{
+       pm_runtime_resume(dev);
+       return dw_i2c_plat_runtime_suspend(dev);
+}
+#endif
+
 static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
        .prepare = dw_i2c_plat_prepare,
        .complete = dw_i2c_plat_complete,
        SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
-       SET_RUNTIME_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume, NULL)
+       SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend,
+                          dw_i2c_plat_resume,
+                          NULL)
 };
 
 #define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops)
index 0548c7ea578c9752f7c4cc1efebef37b41bca68a..78d8fb73927d853ebec3061685696db646236e36 100644 (file)
@@ -177,6 +177,8 @@ static int i2c_dw_reg_slave(struct i2c_client *slave)
                return -EBUSY;
        if (slave->flags & I2C_CLIENT_TEN)
                return -EAFNOSUPPORT;
+       pm_runtime_get_sync(dev->dev);
+
        /*
         * Set slave address in the IC_SAR register,
         * the address to which the DW_apb_i2c responds.
@@ -205,6 +207,7 @@ static int i2c_dw_unreg_slave(struct i2c_client *slave)
        dev->disable_int(dev);
        dev->disable(dev);
        dev->slave = NULL;
+       pm_runtime_put(dev->dev);
 
        return 0;
 }
@@ -272,7 +275,7 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
        slave_activity = ((dw_readl(dev, DW_IC_STATUS) &
                DW_IC_STATUS_SLAVE_ACTIVITY) >> 6);
 
-       if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY))
+       if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)
                return 0;
 
        dev_dbg(dev->dev,
@@ -382,7 +385,6 @@ int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
        ret = i2c_add_numbered_adapter(adap);
        if (ret)
                dev_err(dev->dev, "failure adding adapter: %d\n", ret);
-       pm_runtime_put_noidle(dev->dev);
 
        return ret;
 }
index e98e44e584a44a6e17dc3af00ae1f02ce50ae95b..22ffcb73c185f592d8b4e6bdbb1ede45cbeb4951 100644 (file)
@@ -341,8 +341,10 @@ static int ismt_process_desc(const struct ismt_desc *desc,
                        break;
                case I2C_SMBUS_BLOCK_DATA:
                case I2C_SMBUS_I2C_BLOCK_DATA:
-                       memcpy(&data->block[1], dma_buffer, desc->rxbytes);
-                       data->block[0] = desc->rxbytes;
+                       if (desc->rxbytes != dma_buffer[0] + 1)
+                               return -EMSGSIZE;
+
+                       memcpy(data->block, dma_buffer, desc->rxbytes);
                        break;
                }
                return 0;
index b4685bb9b5d7356f97067a80c1ff9bd0f2d92090..adca51a99487cfb4d2a6d8843047018265e3295a 100644 (file)
@@ -127,8 +127,7 @@ static int simtec_i2c_probe(struct platform_device *dev)
        iounmap(pd->reg);
 
  err_res:
-       release_resource(pd->ioarea);
-       kfree(pd->ioarea);
+       release_mem_region(pd->ioarea->start, size);
 
  err:
        kfree(pd);
@@ -142,8 +141,7 @@ static int simtec_i2c_remove(struct platform_device *dev)
        i2c_del_adapter(&pd->adap);
 
        iounmap(pd->reg);
-       release_resource(pd->ioarea);
-       kfree(pd->ioarea);
+       release_mem_region(pd->ioarea->start, resource_size(pd->ioarea));
        kfree(pd);
 
        return 0;
index 4842ec3a5451ed479446fc13352405aca45697d2..a9126b3cda61bc95f6a9d1282821ab7552484534 100644 (file)
@@ -230,6 +230,16 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)
                dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
 }
 
+const struct acpi_device_id *
+i2c_acpi_match_device(const struct acpi_device_id *matches,
+                     struct i2c_client *client)
+{
+       if (!(client && matches))
+               return NULL;
+
+       return acpi_match_device(matches, &client->dev);
+}
+
 static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level,
                                           void *data, void **return_value)
 {
@@ -289,7 +299,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
 
-static int i2c_acpi_match_adapter(struct device *dev, void *data)
+static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
 {
        struct i2c_adapter *adapter = i2c_verify_adapter(dev);
 
@@ -299,7 +309,7 @@ static int i2c_acpi_match_adapter(struct device *dev, void *data)
        return ACPI_HANDLE(dev) == (acpi_handle)data;
 }
 
-static int i2c_acpi_match_device(struct device *dev, void *data)
+static int i2c_acpi_find_match_device(struct device *dev, void *data)
 {
        return ACPI_COMPANION(dev) == data;
 }
@@ -309,7 +319,7 @@ static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
        struct device *dev;
 
        dev = bus_find_device(&i2c_bus_type, NULL, handle,
-                             i2c_acpi_match_adapter);
+                             i2c_acpi_find_match_adapter);
        return dev ? i2c_verify_adapter(dev) : NULL;
 }
 
@@ -317,7 +327,8 @@ static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
 {
        struct device *dev;
 
-       dev = bus_find_device(&i2c_bus_type, NULL, adev, i2c_acpi_match_device);
+       dev = bus_find_device(&i2c_bus_type, NULL, adev,
+                             i2c_acpi_find_match_device);
        return dev ? i2c_verify_client(dev) : NULL;
 }
 
index c89dac7fd2e7b793217119f2ccee849cf75ebcfe..56e46581b84bdb03eeb07ddaa8d83cec1aa76341 100644 (file)
@@ -353,10 +353,11 @@ static int i2c_device_probe(struct device *dev)
        }
 
        /*
-        * An I2C ID table is not mandatory, if and only if, a suitable Device
-        * Tree match table entry is supplied for the probing device.
+        * An I2C ID table is not mandatory, if and only if, a suitable OF
+        * or ACPI ID table is supplied for the probing device.
         */
        if (!driver->id_table &&
+           !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
            !i2c_of_match_device(dev->driver->of_match_table, client))
                return -ENODEV;
 
index 3b63f5e5b89cbda662a580c387bfa2d23e2ebcef..3d3d9bf02101bddf06fc6597f107cc3ac8e3beb8 100644 (file)
@@ -31,9 +31,18 @@ int i2c_check_addr_validity(unsigned addr, unsigned short flags);
 int i2c_check_7bit_addr_validity_strict(unsigned short addr);
 
 #ifdef CONFIG_ACPI
+const struct acpi_device_id *
+i2c_acpi_match_device(const struct acpi_device_id *matches,
+                     struct i2c_client *client);
 void i2c_acpi_register_devices(struct i2c_adapter *adap);
 #else /* CONFIG_ACPI */
 static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { }
+static inline const struct acpi_device_id *
+i2c_acpi_match_device(const struct acpi_device_id *matches,
+                     struct i2c_client *client)
+{
+       return NULL;
+}
 #endif /* CONFIG_ACPI */
 extern struct notifier_block i2c_acpi_notifier;
 
index 2c64d0e0740f0db0c4427af9d6602bc8aaa0ea24..17121329bb793a615e8969a15327e3f07035cdbb 100644 (file)
@@ -83,7 +83,7 @@ config I2C_MUX_PINCTRL
          different sets of pins at run-time.
 
          This driver can also be built as a module. If so, the module will be
-         called pinctrl-i2cmux.
+         called i2c-mux-pinctrl.
 
 config I2C_MUX_REG
        tristate "Register-based I2C multiplexer"
index 6b5d3be283c4e7e00f72bb32e550b52ab06e1526..807299dd45ebf0663fbc97b3831bd8f92148ec20 100644 (file)
@@ -193,7 +193,6 @@ struct bmc150_accel_data {
        struct regmap *regmap;
        int irq;
        struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
-       atomic_t active_intr;
        struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
        struct mutex mutex;
        u8 fifo_mode, watermark;
@@ -493,11 +492,6 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
                goto out_fix_power_state;
        }
 
-       if (state)
-               atomic_inc(&data->active_intr);
-       else
-               atomic_dec(&data->active_intr);
-
        return 0;
 
 out_fix_power_state:
@@ -1710,8 +1704,7 @@ static int bmc150_accel_resume(struct device *dev)
        struct bmc150_accel_data *data = iio_priv(indio_dev);
 
        mutex_lock(&data->mutex);
-       if (atomic_read(&data->active_intr))
-               bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
+       bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
        bmc150_accel_fifo_set_mode(data);
        mutex_unlock(&data->mutex);
 
index 07d1489cd457a6b5445b8b3ba35dad95b1792acc..e44f62bf9caa9f1a45c6699875b885d497bb0a7a 100644 (file)
@@ -166,6 +166,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .mask_ihl = 0x02,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
+               .sim = {
+                       .addr = 0x23,
+                       .value = BIT(0),
+               },
                .multi_read_bit = true,
                .bootime = 2,
        },
@@ -234,6 +238,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .mask_od = 0x40,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
+               .sim = {
+                       .addr = 0x23,
+                       .value = BIT(0),
+               },
                .multi_read_bit = true,
                .bootime = 2,
        },
@@ -316,6 +324,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                                .en_mask = 0x08,
                        },
                },
+               .sim = {
+                       .addr = 0x24,
+                       .value = BIT(0),
+               },
                .multi_read_bit = false,
                .bootime = 2,
        },
@@ -379,6 +391,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .mask_int1 = 0x04,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
+               .sim = {
+                       .addr = 0x21,
+                       .value = BIT(1),
+               },
                .multi_read_bit = true,
                .bootime = 2, /* guess */
        },
@@ -437,6 +453,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .mask_od = 0x40,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
+               .sim = {
+                       .addr = 0x21,
+                       .value = BIT(7),
+               },
                .multi_read_bit = false,
                .bootime = 2, /* guess */
        },
@@ -499,6 +519,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .addr_ihl = 0x22,
                        .mask_ihl = 0x80,
                },
+               .sim = {
+                       .addr = 0x23,
+                       .value = BIT(0),
+               },
                .multi_read_bit = true,
                .bootime = 2,
        },
@@ -547,6 +571,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .mask_int1 = 0x04,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
+               .sim = {
+                       .addr = 0x21,
+                       .value = BIT(1),
+               },
                .multi_read_bit = false,
                .bootime = 2,
        },
@@ -614,6 +642,10 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                        .mask_ihl = 0x02,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
+               .sim = {
+                       .addr = 0x23,
+                       .value = BIT(0),
+               },
                .multi_read_bit = true,
                .bootime = 2,
        },
index e0ea411a0b2df9563085c70552086946843ba2ca..c02b23d675cbc1540ec47769515da714c784cf67 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/iio/iio.h>
 #include <linux/iio/driver.h>
+#include <linux/iopoll.h>
 
 #define ASPEED_RESOLUTION_BITS         10
 #define ASPEED_CLOCKS_PER_SAMPLE       12
 
 #define ASPEED_ENGINE_ENABLE           BIT(0)
 
+#define ASPEED_ADC_CTRL_INIT_RDY       BIT(8)
+
+#define ASPEED_ADC_INIT_POLLING_TIME   500
+#define ASPEED_ADC_INIT_TIMEOUT                500000
+
 struct aspeed_adc_model_data {
        const char *model_name;
        unsigned int min_sampling_rate; // Hz
        unsigned int max_sampling_rate; // Hz
        unsigned int vref_voltage;      // mV
+       bool wait_init_sequence;
 };
 
 struct aspeed_adc_data {
@@ -211,6 +218,24 @@ static int aspeed_adc_probe(struct platform_device *pdev)
                goto scaler_error;
        }
 
+       model_data = of_device_get_match_data(&pdev->dev);
+
+       if (model_data->wait_init_sequence) {
+               /* Enable engine in normal mode. */
+               writel(ASPEED_OPERATION_MODE_NORMAL | ASPEED_ENGINE_ENABLE,
+                      data->base + ASPEED_REG_ENGINE_CONTROL);
+
+               /* Wait for initial sequence complete. */
+               ret = readl_poll_timeout(data->base + ASPEED_REG_ENGINE_CONTROL,
+                                        adc_engine_control_reg_val,
+                                        adc_engine_control_reg_val &
+                                        ASPEED_ADC_CTRL_INIT_RDY,
+                                        ASPEED_ADC_INIT_POLLING_TIME,
+                                        ASPEED_ADC_INIT_TIMEOUT);
+               if (ret)
+                       goto scaler_error;
+       }
+
        /* Start all channels in normal mode. */
        ret = clk_prepare_enable(data->clk_scaler->clk);
        if (ret)
@@ -274,6 +299,7 @@ static const struct aspeed_adc_model_data ast2500_model_data = {
        .vref_voltage = 1800, // mV
        .min_sampling_rate = 1,
        .max_sampling_rate = 1000000,
+       .wait_init_sequence = true,
 };
 
 static const struct of_device_id aspeed_adc_matches[] = {
index 64799ad7ebad02a797607470678aa500842ed99f..462a99c13e7a210a74f1d9b2a9c87de7ebc3fad6 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/iio/driver.h>
 
 #define AXP288_ADC_EN_MASK             0xF1
+#define AXP288_ADC_TS_PIN_GPADC                0xF2
+#define AXP288_ADC_TS_PIN_ON           0xF3
 
 enum axp288_adc_id {
        AXP288_ADC_TS,
@@ -121,6 +123,26 @@ static int axp288_adc_read_channel(int *val, unsigned long address,
        return IIO_VAL_INT;
 }
 
+static int axp288_adc_set_ts(struct regmap *regmap, unsigned int mode,
+                               unsigned long address)
+{
+       int ret;
+
+       /* channels other than GPADC do not need to switch TS pin */
+       if (address != AXP288_GP_ADC_H)
+               return 0;
+
+       ret = regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, mode);
+       if (ret)
+               return ret;
+
+       /* When switching to the GPADC pin give things some time to settle */
+       if (mode == AXP288_ADC_TS_PIN_GPADC)
+               usleep_range(6000, 10000);
+
+       return 0;
+}
+
 static int axp288_adc_read_raw(struct iio_dev *indio_dev,
                        struct iio_chan_spec const *chan,
                        int *val, int *val2, long mask)
@@ -131,7 +153,16 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
        mutex_lock(&indio_dev->mlock);
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
+               if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_GPADC,
+                                       chan->address)) {
+                       dev_err(&indio_dev->dev, "GPADC mode\n");
+                       ret = -EINVAL;
+                       break;
+               }
                ret = axp288_adc_read_channel(val, chan->address, info->regmap);
+               if (axp288_adc_set_ts(info->regmap, AXP288_ADC_TS_PIN_ON,
+                                               chan->address))
+                       dev_err(&indio_dev->dev, "TS pin restore\n");
                break;
        default:
                ret = -EINVAL;
@@ -141,6 +172,15 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev,
        return ret;
 }
 
+static int axp288_adc_set_state(struct regmap *regmap)
+{
+       /* ADC should be always enabled for internal FG to function */
+       if (regmap_write(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_PIN_ON))
+               return -EIO;
+
+       return regmap_write(regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
+}
+
 static const struct iio_info axp288_adc_iio_info = {
        .read_raw = &axp288_adc_read_raw,
        .driver_module = THIS_MODULE,
@@ -169,7 +209,7 @@ static int axp288_adc_probe(struct platform_device *pdev)
         * Set ADC to enabled state at all time, including system suspend.
         * otherwise internal fuel gauge functionality may be affected.
         */
-       ret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);
+       ret = axp288_adc_set_state(axp20x->regmap);
        if (ret) {
                dev_err(&pdev->dev, "unable to enable ADC device\n");
                return ret;
index 232c0b80d65893e497abe4e13c4b5273e3c9a7a0..c3f86138cb55eba108cb39ef5c10548ad13ff5a4 100644 (file)
@@ -644,7 +644,7 @@ static int ina2xx_capture_thread(void *data)
 {
        struct iio_dev *indio_dev = data;
        struct ina2xx_chip_info *chip = iio_priv(indio_dev);
-       unsigned int sampling_us = SAMPLING_PERIOD(chip);
+       int sampling_us = SAMPLING_PERIOD(chip);
        int buffer_us;
 
        /*
index e09233b03c055b01c1d3cab229b66e5d093c1c3d..609676384f5e779824e41100ba53906c3df92d13 100644 (file)
@@ -64,7 +64,7 @@
 #define STM32H7_CKMODE_MASK            GENMASK(17, 16)
 
 /* STM32 H7 maximum analog clock rate (from datasheet) */
-#define STM32H7_ADC_MAX_CLK_RATE       72000000
+#define STM32H7_ADC_MAX_CLK_RATE       36000000
 
 /**
  * stm32_adc_common_regs - stm32 common registers, compatible dependent data
@@ -148,14 +148,14 @@ static int stm32f4_adc_clk_sel(struct platform_device *pdev,
                return -EINVAL;
        }
 
-       priv->common.rate = rate;
+       priv->common.rate = rate / stm32f4_pclk_div[i];
        val = readl_relaxed(priv->common.base + STM32F4_ADC_CCR);
        val &= ~STM32F4_ADC_ADCPRE_MASK;
        val |= i << STM32F4_ADC_ADCPRE_SHIFT;
        writel_relaxed(val, priv->common.base + STM32F4_ADC_CCR);
 
        dev_dbg(&pdev->dev, "Using analog clock source at %ld kHz\n",
-               rate / (stm32f4_pclk_div[i] * 1000));
+               priv->common.rate / 1000);
 
        return 0;
 }
@@ -250,7 +250,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev,
 
 out:
        /* rate used later by each ADC instance to control BOOST mode */
-       priv->common.rate = rate;
+       priv->common.rate = rate / div;
 
        /* Set common clock mode and prescaler */
        val = readl_relaxed(priv->common.base + STM32H7_ADC_CCR);
@@ -260,7 +260,7 @@ out:
        writel_relaxed(val, priv->common.base + STM32H7_ADC_CCR);
 
        dev_dbg(&pdev->dev, "Using %s clock/%d source at %ld kHz\n",
-               ckmode ? "bus" : "adc", div, rate / (div * 1000));
+               ckmode ? "bus" : "adc", div, priv->common.rate / 1000);
 
        return 0;
 }
index 81d4c39e414a4da6b0f8df0ebd8922d371a909d7..137f577d94326a299e0f944edfd108bdc2db31fe 100644 (file)
@@ -256,6 +256,7 @@ static int sun4i_gpadc_read(struct iio_dev *indio_dev, int channel, int *val,
 
 err:
        pm_runtime_put_autosuspend(indio_dev->dev.parent);
+       disable_irq(irq);
        mutex_unlock(&info->mutex);
 
        return ret;
@@ -365,7 +366,6 @@ static irqreturn_t sun4i_gpadc_temp_data_irq_handler(int irq, void *dev_id)
                complete(&info->completion);
 
 out:
-       disable_irq_nosync(info->temp_data_irq);
        return IRQ_HANDLED;
 }
 
@@ -380,7 +380,6 @@ static irqreturn_t sun4i_gpadc_fifo_data_irq_handler(int irq, void *dev_id)
                complete(&info->completion);
 
 out:
-       disable_irq_nosync(info->fifo_data_irq);
        return IRQ_HANDLED;
 }
 
index 01fc76f7d6602c7b14c5f0cd4ea0c01090278087..c168e0db329ab49b6b59d720cc62cb2b37352088 100644 (file)
@@ -77,7 +77,7 @@
 #define VF610_ADC_ADSTS_MASK           0x300
 #define VF610_ADC_ADLPC_EN             0x80
 #define VF610_ADC_ADHSC_EN             0x400
-#define VF610_ADC_REFSEL_VALT          0x100
+#define VF610_ADC_REFSEL_VALT          0x800
 #define VF610_ADC_REFSEL_VBG           0x1000
 #define VF610_ADC_ADTRG_HARD           0x2000
 #define VF610_ADC_AVGS_8               0x4000
index 16ade0a0327bafbe478db6a3714549c455582a97..0e4b379ada4587e2fec367cb5a4beb8996cbe143 100644 (file)
@@ -111,8 +111,6 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
        s32 poll_value = 0;
 
        if (state) {
-               if (!atomic_read(&st->user_requested_state))
-                       return 0;
                if (sensor_hub_device_open(st->hsdev))
                        return -EIO;
 
@@ -161,6 +159,9 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
                                       &report_val);
        }
 
+       pr_debug("HID_SENSOR %s set power_state %d report_state %d\n",
+                st->pdev->name, state_val, report_val);
+
        sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
                               st->power_state.index,
                               sizeof(state_val), &state_val);
@@ -182,6 +183,7 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
                ret = pm_runtime_get_sync(&st->pdev->dev);
        else {
                pm_runtime_mark_last_busy(&st->pdev->dev);
+               pm_runtime_use_autosuspend(&st->pdev->dev);
                ret = pm_runtime_put_autosuspend(&st->pdev->dev);
        }
        if (ret < 0) {
@@ -285,8 +287,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
        /* Default to 3 seconds, but can be changed from sysfs */
        pm_runtime_set_autosuspend_delay(&attrb->pdev->dev,
                                         3000);
-       pm_runtime_use_autosuspend(&attrb->pdev->dev);
-
        return ret;
 error_unreg_trigger:
        iio_trigger_unregister(trig);
index 79c8c7cd70d5c6d74fc2e32cad372f8644233c6b..6e6a1ecc99ddf4b69252b6b4232c9cda6f00d4be 100644 (file)
@@ -550,6 +550,31 @@ out:
 }
 EXPORT_SYMBOL(st_sensors_read_info_raw);
 
+static int st_sensors_init_interface_mode(struct iio_dev *indio_dev,
+                       const struct st_sensor_settings *sensor_settings)
+{
+       struct st_sensor_data *sdata = iio_priv(indio_dev);
+       struct device_node *np = sdata->dev->of_node;
+       struct st_sensors_platform_data *pdata;
+
+       pdata = (struct st_sensors_platform_data *)sdata->dev->platform_data;
+       if (((np && of_property_read_bool(np, "spi-3wire")) ||
+            (pdata && pdata->spi_3wire)) && sensor_settings->sim.addr) {
+               int err;
+
+               err = sdata->tf->write_byte(&sdata->tb, sdata->dev,
+                                           sensor_settings->sim.addr,
+                                           sensor_settings->sim.value);
+               if (err < 0) {
+                       dev_err(&indio_dev->dev,
+                               "failed to init interface mode\n");
+                       return err;
+               }
+       }
+
+       return 0;
+}
+
 int st_sensors_check_device_support(struct iio_dev *indio_dev,
                        int num_sensors_list,
                        const struct st_sensor_settings *sensor_settings)
@@ -574,6 +599,10 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
                return -ENODEV;
        }
 
+       err = st_sensors_init_interface_mode(indio_dev, &sensor_settings[i]);
+       if (err < 0)
+               return err;
+
        if (sensor_settings[i].wai_addr) {
                err = sdata->tf->read_byte(&sdata->tb, sdata->dev,
                                           sensor_settings[i].wai_addr, &wai);
index 8cf84d3488b2650c0ca2f265e8dc58f1b10efc0b..12898424d8382f5953bcf2618e31f96c1874c56b 100644 (file)
@@ -696,7 +696,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
                .gyro_max_val = IIO_RAD_TO_DEGREE(22500),
                .gyro_max_scale = 450,
                .accel_max_val = IIO_M_S_2_TO_G(12500),
-               .accel_max_scale = 5,
+               .accel_max_scale = 10,
        },
        [ADIS16485] = {
                .channels = adis16485_channels,
index e7d4ea75e007c0bd82ef087812524258ec69f490..7599693f7fe9597cb750319ccb2635362c1dc9f0 100644 (file)
@@ -626,7 +626,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private)
        struct tsl2563_chip *chip = iio_priv(dev_info);
 
        iio_push_event(dev_info,
-                      IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
+                      IIO_UNMOD_EVENT_CODE(IIO_INTENSITY,
                                            0,
                                            IIO_EV_TYPE_THRESH,
                                            IIO_EV_DIR_EITHER),
index 8e1b0861fbe4a63b6b50466f320bd65e6e48f3c9..c3856369998498685aa1a516e11669fe8452aa2b 100644 (file)
@@ -356,9 +356,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
                .drdy_irq = {
                        .addr = 0x62,
                        .mask_int1 = 0x01,
-                       .addr_ihl = 0x63,
-                       .mask_ihl = 0x04,
-                       .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
+                       .addr_stat_drdy = 0x67,
                },
                .multi_read_bit = false,
                .bootime = 2,
index d82b788374b61ba617bc5a073e17d283e5e0cfc9..0d2ea3ee371b9fc8c0fff8c213f97ee3ab31b5a1 100644 (file)
@@ -282,6 +282,11 @@ static int bmp280_read_temp(struct bmp280_data *data,
        }
 
        adc_temp = be32_to_cpu(tmp) >> 12;
+       if (adc_temp == BMP280_TEMP_SKIPPED) {
+               /* reading was skipped */
+               dev_err(data->dev, "reading temperature skipped\n");
+               return -EIO;
+       }
        comp_temp = bmp280_compensate_temp(data, adc_temp);
 
        /*
@@ -317,6 +322,11 @@ static int bmp280_read_press(struct bmp280_data *data,
        }
 
        adc_press = be32_to_cpu(tmp) >> 12;
+       if (adc_press == BMP280_PRESS_SKIPPED) {
+               /* reading was skipped */
+               dev_err(data->dev, "reading pressure skipped\n");
+               return -EIO;
+       }
        comp_press = bmp280_compensate_press(data, adc_press);
 
        *val = comp_press;
@@ -345,6 +355,11 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
        }
 
        adc_humidity = be16_to_cpu(tmp);
+       if (adc_humidity == BMP280_HUMIDITY_SKIPPED) {
+               /* reading was skipped */
+               dev_err(data->dev, "reading humidity skipped\n");
+               return -EIO;
+       }
        comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
 
        *val = comp_humidity;
@@ -597,14 +612,20 @@ static const struct bmp280_chip_info bmp280_chip_info = {
 
 static int bme280_chip_config(struct bmp280_data *data)
 {
-       int ret = bmp280_chip_config(data);
+       int ret;
        u8 osrs = BMP280_OSRS_HUMIDITIY_X(data->oversampling_humid + 1);
 
+       /*
+        * Oversampling of humidity must be set before oversampling of
+        * temperature/pressure is set to become effective.
+        */
+       ret = regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY,
+                                 BMP280_OSRS_HUMIDITY_MASK, osrs);
+
        if (ret < 0)
                return ret;
 
-       return regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY,
-                                 BMP280_OSRS_HUMIDITY_MASK, osrs);
+       return bmp280_chip_config(data);
 }
 
 static const struct bmp280_chip_info bme280_chip_info = {
index 2c770e13be0e4ad0f4e884f5778d8b1e318b4a86..61347438b779e05f06f84b8c1a2ac8d50b9ddb1d 100644 (file)
 #define BME280_CHIP_ID                 0x60
 #define BMP280_SOFT_RESET_VAL          0xB6
 
+/* BMP280 register skipped special values */
+#define BMP280_TEMP_SKIPPED            0x80000
+#define BMP280_PRESS_SKIPPED           0x80000
+#define BMP280_HUMIDITY_SKIPPED                0x8000
+
 /* Regmap configurations */
 extern const struct regmap_config bmp180_regmap_config;
 extern const struct regmap_config bmp280_regmap_config;
index aa61ec15c1396ca3925ecf1a099fbf91a302dae7..f1bce05ffa135703792f24317db81375d3e4ebb3 100644 (file)
@@ -456,7 +456,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
                        .mask_od = 0x40,
                        .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR,
                },
-               .multi_read_bit = true,
+               .multi_read_bit = false,
                .bootime = 2,
        },
 };
index d22bc56dd9fc0ffffbd28eb30b3507e13fdfb50e..25ad6abfee22d0eeb77829ba623429ccbcbf343c 100644 (file)
@@ -366,34 +366,32 @@ static int stm32_counter_read_raw(struct iio_dev *indio_dev,
                                  int *val, int *val2, long mask)
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
+       u32 dat;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-       {
-               u32 cnt;
-
-               regmap_read(priv->regmap, TIM_CNT, &cnt);
-               *val = cnt;
+               regmap_read(priv->regmap, TIM_CNT, &dat);
+               *val = dat;
+               return IIO_VAL_INT;
 
+       case IIO_CHAN_INFO_ENABLE:
+               regmap_read(priv->regmap, TIM_CR1, &dat);
+               *val = (dat & TIM_CR1_CEN) ? 1 : 0;
                return IIO_VAL_INT;
-       }
-       case IIO_CHAN_INFO_SCALE:
-       {
-               u32 smcr;
 
-               regmap_read(priv->regmap, TIM_SMCR, &smcr);
-               smcr &= TIM_SMCR_SMS;
+       case IIO_CHAN_INFO_SCALE:
+               regmap_read(priv->regmap, TIM_SMCR, &dat);
+               dat &= TIM_SMCR_SMS;
 
                *val = 1;
                *val2 = 0;
 
                /* in quadrature case scale = 0.25 */
-               if (smcr == 3)
+               if (dat == 3)
                        *val2 = 2;
 
                return IIO_VAL_FRACTIONAL_LOG2;
        }
-       }
 
        return -EINVAL;
 }
@@ -403,15 +401,31 @@ static int stm32_counter_write_raw(struct iio_dev *indio_dev,
                                   int val, int val2, long mask)
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
+       u32 dat;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-               regmap_write(priv->regmap, TIM_CNT, val);
+               return regmap_write(priv->regmap, TIM_CNT, val);
 
-               return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
                /* fixed scale */
                return -EINVAL;
+
+       case IIO_CHAN_INFO_ENABLE:
+               if (val) {
+                       regmap_read(priv->regmap, TIM_CR1, &dat);
+                       if (!(dat & TIM_CR1_CEN))
+                               clk_enable(priv->clk);
+                       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
+                                          TIM_CR1_CEN);
+               } else {
+                       regmap_read(priv->regmap, TIM_CR1, &dat);
+                       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
+                                          0);
+                       if (dat & TIM_CR1_CEN)
+                               clk_disable(priv->clk);
+               }
+               return 0;
        }
 
        return -EINVAL;
@@ -471,7 +485,7 @@ static int stm32_get_trigger_mode(struct iio_dev *indio_dev,
 
        regmap_read(priv->regmap, TIM_SMCR, &smcr);
 
-       return smcr == TIM_SMCR_SMS ? 0 : -EINVAL;
+       return (smcr & TIM_SMCR_SMS) == TIM_SMCR_SMS ? 0 : -EINVAL;
 }
 
 static const struct iio_enum stm32_trigger_mode_enum = {
@@ -507,9 +521,19 @@ static int stm32_set_enable_mode(struct iio_dev *indio_dev,
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
        int sms = stm32_enable_mode2sms(mode);
+       u32 val;
 
        if (sms < 0)
                return sms;
+       /*
+        * Triggered mode sets CEN bit automatically by hardware. So, first
+        * enable counter clock, so it can use it. Keeps it in sync with CEN.
+        */
+       if (sms == 6) {
+               regmap_read(priv->regmap, TIM_CR1, &val);
+               if (!(val & TIM_CR1_CEN))
+                       clk_enable(priv->clk);
+       }
 
        regmap_update_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS, sms);
 
@@ -571,11 +595,14 @@ static int stm32_get_quadrature_mode(struct iio_dev *indio_dev,
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
        u32 smcr;
+       int mode;
 
        regmap_read(priv->regmap, TIM_SMCR, &smcr);
-       smcr &= TIM_SMCR_SMS;
+       mode = (smcr & TIM_SMCR_SMS) - 1;
+       if ((mode < 0) || (mode > ARRAY_SIZE(stm32_quadrature_modes)))
+               return -EINVAL;
 
-       return smcr - 1;
+       return mode;
 }
 
 static const struct iio_enum stm32_quadrature_mode_enum = {
@@ -592,13 +619,20 @@ static const char *const stm32_count_direction_states[] = {
 
 static int stm32_set_count_direction(struct iio_dev *indio_dev,
                                     const struct iio_chan_spec *chan,
-                                    unsigned int mode)
+                                    unsigned int dir)
 {
        struct stm32_timer_trigger *priv = iio_priv(indio_dev);
+       u32 val;
+       int mode;
 
-       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_DIR, mode);
+       /* In encoder mode, direction is RO (given by TI1/TI2 signals) */
+       regmap_read(priv->regmap, TIM_SMCR, &val);
+       mode = (val & TIM_SMCR_SMS) - 1;
+       if ((mode >= 0) || (mode < ARRAY_SIZE(stm32_quadrature_modes)))
+               return -EBUSY;
 
-       return 0;
+       return regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_DIR,
+                                 dir ? TIM_CR1_DIR : 0);
 }
 
 static int stm32_get_count_direction(struct iio_dev *indio_dev,
@@ -609,7 +643,7 @@ static int stm32_get_count_direction(struct iio_dev *indio_dev,
 
        regmap_read(priv->regmap, TIM_CR1, &cr1);
 
-       return (cr1 & TIM_CR1_DIR);
+       return ((cr1 & TIM_CR1_DIR) ? 1 : 0);
 }
 
 static const struct iio_enum stm32_count_direction_enum = {
@@ -672,7 +706,9 @@ static const struct iio_chan_spec_ext_info stm32_trigger_count_info[] = {
 static const struct iio_chan_spec stm32_trigger_channel = {
        .type = IIO_COUNT,
        .channel = 0,
-       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+                             BIT(IIO_CHAN_INFO_ENABLE) |
+                             BIT(IIO_CHAN_INFO_SCALE),
        .ext_info = stm32_trigger_count_info,
        .indexed = 1
 };
index 01236cef7bfb1affe07e4214cf6d8baf6ca2a2a1..437522ca97b4b62fd79b8e84fa643ff9c4751ccd 100644 (file)
@@ -61,6 +61,7 @@ struct addr_req {
        void (*callback)(int status, struct sockaddr *src_addr,
                         struct rdma_dev_addr *addr, void *context);
        unsigned long timeout;
+       struct delayed_work work;
        int status;
        u32 seq;
 };
@@ -295,7 +296,7 @@ int rdma_translate_ip(const struct sockaddr *addr,
 }
 EXPORT_SYMBOL(rdma_translate_ip);
 
-static void set_timeout(unsigned long time)
+static void set_timeout(struct delayed_work *delayed_work, unsigned long time)
 {
        unsigned long delay;
 
@@ -303,7 +304,7 @@ static void set_timeout(unsigned long time)
        if ((long)delay < 0)
                delay = 0;
 
-       mod_delayed_work(addr_wq, &work, delay);
+       mod_delayed_work(addr_wq, delayed_work, delay);
 }
 
 static void queue_req(struct addr_req *req)
@@ -318,8 +319,7 @@ static void queue_req(struct addr_req *req)
 
        list_add(&req->list, &temp_req->list);
 
-       if (req_list.next == &req->list)
-               set_timeout(req->timeout);
+       set_timeout(&req->work, req->timeout);
        mutex_unlock(&lock);
 }
 
@@ -574,6 +574,37 @@ static int addr_resolve(struct sockaddr *src_in,
        return ret;
 }
 
+static void process_one_req(struct work_struct *_work)
+{
+       struct addr_req *req;
+       struct sockaddr *src_in, *dst_in;
+
+       mutex_lock(&lock);
+       req = container_of(_work, struct addr_req, work.work);
+
+       if (req->status == -ENODATA) {
+               src_in = (struct sockaddr *)&req->src_addr;
+               dst_in = (struct sockaddr *)&req->dst_addr;
+               req->status = addr_resolve(src_in, dst_in, req->addr,
+                                          true, req->seq);
+               if (req->status && time_after_eq(jiffies, req->timeout)) {
+                       req->status = -ETIMEDOUT;
+               } else if (req->status == -ENODATA) {
+                       /* requeue the work for retrying again */
+                       set_timeout(&req->work, req->timeout);
+                       mutex_unlock(&lock);
+                       return;
+               }
+       }
+       list_del(&req->list);
+       mutex_unlock(&lock);
+
+       req->callback(req->status, (struct sockaddr *)&req->src_addr,
+               req->addr, req->context);
+       put_client(req->client);
+       kfree(req);
+}
+
 static void process_req(struct work_struct *work)
 {
        struct addr_req *req, *temp_req;
@@ -591,20 +622,23 @@ static void process_req(struct work_struct *work)
                                                   true, req->seq);
                        if (req->status && time_after_eq(jiffies, req->timeout))
                                req->status = -ETIMEDOUT;
-                       else if (req->status == -ENODATA)
+                       else if (req->status == -ENODATA) {
+                               set_timeout(&req->work, req->timeout);
                                continue;
+                       }
                }
                list_move_tail(&req->list, &done_list);
        }
 
-       if (!list_empty(&req_list)) {
-               req = list_entry(req_list.next, struct addr_req, list);
-               set_timeout(req->timeout);
-       }
        mutex_unlock(&lock);
 
        list_for_each_entry_safe(req, temp_req, &done_list, list) {
                list_del(&req->list);
+               /* It is safe to cancel other work items from this work item
+                * because at a time there can be only one work item running
+                * with this single threaded work queue.
+                */
+               cancel_delayed_work(&req->work);
                req->callback(req->status, (struct sockaddr *) &req->src_addr,
                        req->addr, req->context);
                put_client(req->client);
@@ -647,6 +681,7 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
        req->context = context;
        req->client = client;
        atomic_inc(&client->refcount);
+       INIT_DELAYED_WORK(&req->work, process_one_req);
        req->seq = (u32)atomic_inc_return(&ib_nl_addr_request_seq);
 
        req->status = addr_resolve(src_in, dst_in, addr, true, req->seq);
@@ -701,7 +736,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr)
                        req->status = -ECANCELED;
                        req->timeout = jiffies;
                        list_move(&req->list, &req_list);
-                       set_timeout(req->timeout);
+                       set_timeout(&req->work, req->timeout);
                        break;
                }
        }
@@ -807,9 +842,8 @@ static int netevent_callback(struct notifier_block *self, unsigned long event,
        if (event == NETEVENT_NEIGH_UPDATE) {
                struct neighbour *neigh = ctx;
 
-               if (neigh->nud_state & NUD_VALID) {
-                       set_timeout(jiffies);
-               }
+               if (neigh->nud_state & NUD_VALID)
+                       set_timeout(&work, jiffies);
        }
        return 0;
 }
@@ -820,7 +854,7 @@ static struct notifier_block nb = {
 
 int addr_init(void)
 {
-       addr_wq = alloc_workqueue("ib_addr", WQ_MEM_RECLAIM, 0);
+       addr_wq = alloc_ordered_workqueue("ib_addr", WQ_MEM_RECLAIM);
        if (!addr_wq)
                return -ENOMEM;
 
index a5dfab6adf495b88e846ee03b815536a7917bf48..221468f77128440acb2f5956d2ecf25bac7cc80d 100644 (file)
@@ -537,10 +537,11 @@ void ib_unregister_device(struct ib_device *device)
        }
        up_read(&lists_rwsem);
 
-       mutex_unlock(&device_mutex);
-
        ib_device_unregister_rdmacg(device);
        ib_device_unregister_sysfs(device);
+
+       mutex_unlock(&device_mutex);
+
        ib_cache_cleanup_one(device);
 
        ib_security_destroy_port_pkey_list(device);
index 8c4ec564e49583f6d05eab8df5e57e4378582f08..55e8f5ed8b3c69563033c50fc963446837284475 100644 (file)
@@ -166,24 +166,6 @@ static int invalidate_page_trampoline(struct ib_umem *item, u64 start,
        return 0;
 }
 
-static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
-                                            struct mm_struct *mm,
-                                            unsigned long address)
-{
-       struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
-
-       if (!context->invalidate_range)
-               return;
-
-       ib_ucontext_notifier_start_account(context);
-       down_read(&context->umem_rwsem);
-       rbt_ib_umem_for_each_in_range(&context->umem_tree, address,
-                                     address + PAGE_SIZE,
-                                     invalidate_page_trampoline, NULL);
-       up_read(&context->umem_rwsem);
-       ib_ucontext_notifier_end_account(context);
-}
-
 static int invalidate_range_start_trampoline(struct ib_umem *item, u64 start,
                                             u64 end, void *cookie)
 {
@@ -237,7 +219,6 @@ static void ib_umem_notifier_invalidate_range_end(struct mmu_notifier *mn,
 
 static const struct mmu_notifier_ops ib_umem_notifiers = {
        .release                    = ib_umem_notifier_release,
-       .invalidate_page            = ib_umem_notifier_invalidate_page,
        .invalidate_range_start     = ib_umem_notifier_invalidate_range_start,
        .invalidate_range_end       = ib_umem_notifier_invalidate_range_end,
 };
index 2c98533a0203b084fb198a3eb8088a0bac59522c..739bd69ef1d47fa163ea9f57cf86cbbf09f5fba7 100644 (file)
@@ -1015,7 +1015,7 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
        cq->uobject       = &obj->uobject;
        cq->comp_handler  = ib_uverbs_comp_handler;
        cq->event_handler = ib_uverbs_cq_event_handler;
-       cq->cq_context    = &ev_file->ev_queue;
+       cq->cq_context    = ev_file ? &ev_file->ev_queue : NULL;
        atomic_set(&cq->usecnt, 0);
 
        obj->uobject.object = cq;
@@ -1153,7 +1153,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
                            int out_len)
 {
        struct ib_uverbs_resize_cq      cmd;
-       struct ib_uverbs_resize_cq_resp resp;
+       struct ib_uverbs_resize_cq_resp resp = {};
        struct ib_udata                 udata;
        struct ib_cq                    *cq;
        int                             ret = -EINVAL;
@@ -1522,6 +1522,7 @@ static int create_qp(struct ib_uverbs_file *file,
                qp->qp_type       = attr.qp_type;
                atomic_set(&qp->usecnt, 0);
                atomic_inc(&pd->usecnt);
+               qp->port = 0;
                if (attr.send_cq)
                        atomic_inc(&attr.send_cq->usecnt);
                if (attr.recv_cq)
@@ -1962,8 +1963,9 @@ static int modify_qp(struct ib_uverbs_file *file,
        attr->alt_timeout         = cmd->base.alt_timeout;
        attr->rate_limit          = cmd->rate_limit;
 
-       attr->ah_attr.type = rdma_ah_find_type(qp->device,
-                                              cmd->base.dest.port_num);
+       if (cmd->base.attr_mask & IB_QP_AV)
+               attr->ah_attr.type = rdma_ah_find_type(qp->device,
+                                                      cmd->base.dest.port_num);
        if (cmd->base.dest.is_global) {
                rdma_ah_set_grh(&attr->ah_attr, NULL,
                                cmd->base.dest.flow_label,
@@ -1981,8 +1983,9 @@ static int modify_qp(struct ib_uverbs_file *file,
        rdma_ah_set_port_num(&attr->ah_attr,
                             cmd->base.dest.port_num);
 
-       attr->alt_ah_attr.type = rdma_ah_find_type(qp->device,
-                                                  cmd->base.dest.port_num);
+       if (cmd->base.attr_mask & IB_QP_ALT_PATH)
+               attr->alt_ah_attr.type =
+                       rdma_ah_find_type(qp->device, cmd->base.dest.port_num);
        if (cmd->base.alt_dest.is_global) {
                rdma_ah_set_grh(&attr->alt_ah_attr, NULL,
                                cmd->base.alt_dest.flow_label,
index 3d2609608f589625d0077167fa2e66a00430b89f..5e530d2bee4448ddcb68724199a5c93d36eec32a 100644 (file)
@@ -250,6 +250,7 @@ void ib_uverbs_release_file(struct kref *ref)
        if (atomic_dec_and_test(&file->device->refcount))
                ib_uverbs_comp_dev(file->device);
 
+       kobject_put(&file->device->kobj);
        kfree(file);
 }
 
@@ -917,7 +918,6 @@ err:
 static int ib_uverbs_close(struct inode *inode, struct file *filp)
 {
        struct ib_uverbs_file *file = filp->private_data;
-       struct ib_uverbs_device *dev = file->device;
 
        mutex_lock(&file->cleanup_mutex);
        if (file->ucontext) {
@@ -939,7 +939,6 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp)
                         ib_uverbs_release_async_event_file);
 
        kref_put(&file->ref, ib_uverbs_release_file);
-       kobject_put(&dev->kobj);
 
        return 0;
 }
@@ -1154,7 +1153,6 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
                kref_get(&file->ref);
                mutex_unlock(&uverbs_dev->lists_mutex);
 
-               ib_uverbs_event_handler(&file->event_handler, &event);
 
                mutex_lock(&file->cleanup_mutex);
                ucontext = file->ucontext;
@@ -1171,6 +1169,7 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
                         * for example due to freeing the resources
                         * (e.g mmput).
                         */
+                       ib_uverbs_event_handler(&file->event_handler, &event);
                        ib_dev->disassociate_ucontext(ucontext);
                        mutex_lock(&file->cleanup_mutex);
                        ib_uverbs_cleanup_ucontext(file, ucontext, true);
index fb98ed67d5bc684b8cc0b941d7140986b95aa99b..b456e3ca1876ae8db6bb5aeeb34dc8e7e48eab88 100644 (file)
@@ -838,6 +838,7 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd,
        spin_lock_init(&qp->mr_lock);
        INIT_LIST_HEAD(&qp->rdma_mrs);
        INIT_LIST_HEAD(&qp->sig_mrs);
+       qp->port = 0;
 
        if (qp_init_attr->qp_type == IB_QPT_XRC_TGT)
                return ib_create_xrc_qp(qp, qp_init_attr);
@@ -895,7 +896,6 @@ static const struct {
 } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
        [IB_QPS_RESET] = {
                [IB_QPS_RESET] = { .valid = 1 },
-               [IB_QPS_ERR] =   { .valid = 1 },
                [IB_QPS_INIT]  = {
                        .valid = 1,
                        .req_param = {
@@ -1298,7 +1298,11 @@ int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr,
                if (ret)
                        return ret;
        }
-       return ib_security_modify_qp(qp, attr, attr_mask, udata);
+       ret = ib_security_modify_qp(qp, attr, attr_mask, udata);
+       if (!ret && (attr_mask & IB_QP_PORT))
+               qp->port = attr->port_num;
+
+       return ret;
 }
 EXPORT_SYMBOL(ib_modify_qp_with_udata);
 
index 5332f06b99ba4cfa3ef404ec816d09fb68ec0ddf..c2fba76becd4e985a35b9ed3d1ec1314c955706b 100644 (file)
@@ -661,7 +661,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd,
        rhp = php->rhp;
 
        if (mr_type != IB_MR_TYPE_MEM_REG ||
-           max_num_sg > t4_max_fr_depth(&rhp->rdev.lldi.ulptx_memwrite_dsgl &&
+           max_num_sg > t4_max_fr_depth(rhp->rdev.lldi.ulptx_memwrite_dsgl &&
                                         use_dsgl))
                return ERR_PTR(-EINVAL);
 
index ccbf52c8ff6f037a485060e9d78f66c3b7fe79e6..e4b56a0dd6d08ec7eb36dac1e303353f3b0095f7 100644 (file)
@@ -67,8 +67,6 @@ struct mmu_rb_handler {
 
 static unsigned long mmu_node_start(struct mmu_rb_node *);
 static unsigned long mmu_node_last(struct mmu_rb_node *);
-static inline void mmu_notifier_page(struct mmu_notifier *, struct mm_struct *,
-                                    unsigned long);
 static inline void mmu_notifier_range_start(struct mmu_notifier *,
                                            struct mm_struct *,
                                            unsigned long, unsigned long);
@@ -82,7 +80,6 @@ static void do_remove(struct mmu_rb_handler *handler,
 static void handle_remove(struct work_struct *work);
 
 static const struct mmu_notifier_ops mn_opts = {
-       .invalidate_page = mmu_notifier_page,
        .invalidate_range_start = mmu_notifier_range_start,
 };
 
@@ -285,12 +282,6 @@ void hfi1_mmu_rb_remove(struct mmu_rb_handler *handler,
        handler->ops->remove(handler->ops_arg, node);
 }
 
-static inline void mmu_notifier_page(struct mmu_notifier *mn,
-                                    struct mm_struct *mm, unsigned long addr)
-{
-       mmu_notifier_mem_invalidate(mn, mm, addr, addr + PAGE_SIZE);
-}
-
 static inline void mmu_notifier_range_start(struct mmu_notifier *mn,
                                            struct mm_struct *mm,
                                            unsigned long start,
index f78a733a63ec7e1f884930a72e53ba2100ee888e..d545302b8ef8c520d4eceb630a39db06b7a584a4 100644 (file)
@@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
        } else {
                u8 *dmac = rdma_ah_retrieve_dmac(ah_attr);
 
-               if (!dmac)
+               if (!dmac) {
+                       kfree(ah);
                        return ERR_PTR(-EINVAL);
+               }
                memcpy(ah->av.mac, dmac, ETH_ALEN);
        }
 
index 23fad6d969440bd2bd50a0c8b0dbafe8a92f4ae9..2540b65e242cebcf5b7c9fd60f936bc35bbf019b 100644 (file)
@@ -733,7 +733,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev)
                        continue;
 
                free_mr->mr_free_qp[i] = hns_roce_v1_create_lp_qp(hr_dev, pd);
-               if (IS_ERR(free_mr->mr_free_qp[i])) {
+               if (!free_mr->mr_free_qp[i]) {
                        dev_err(dev, "Create loop qp failed!\n");
                        goto create_lp_qp_failed;
                }
index 9ec1ae9a82c9843878ea10266b0d5338d8862308..a49ff2eb6fb3bca54f40bc460238eeb4a5b4ba52 100644 (file)
@@ -130,20 +130,32 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf(
        u64 base = 0;
        u32 i, j;
        u32 k = 0;
-       u32 low;
 
        /* copy base values in obj_info */
-       for (i = I40IW_HMC_IW_QP, j = 0;
-                       i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
+       for (i = I40IW_HMC_IW_QP, j = 0; i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
+               if ((i == I40IW_HMC_IW_SRQ) ||
+                       (i == I40IW_HMC_IW_FSIMC) ||
+                       (i == I40IW_HMC_IW_FSIAV)) {
+                       info[i].base = 0;
+                       info[i].cnt = 0;
+                       continue;
+               }
                get_64bit_val(buf, j, &temp);
                info[i].base = RS_64_1(temp, 32) * 512;
                if (info[i].base > base) {
                        base = info[i].base;
                        k = i;
                }
-               low = (u32)(temp);
-               if (low)
-                       info[i].cnt = low;
+               if (i == I40IW_HMC_IW_APBVT_ENTRY) {
+                       info[i].cnt = 1;
+                       continue;
+               }
+               if (i == I40IW_HMC_IW_QP)
+                       info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
+               else if (i == I40IW_HMC_IW_CQ)
+                       info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
+               else
+                       info[i].cnt = (u32)(temp);
        }
        size = info[k].cnt * info[k].size + info[k].base;
        if (size & 0x1FFFFF)
@@ -154,6 +166,31 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf(
        return 0;
 }
 
+/**
+ * i40iw_sc_decode_fpm_query() - Decode a 64 bit value into max count and size
+ * @buf: ptr to fpm query buffer
+ * @buf_idx: index into buf
+ * @info: ptr to i40iw_hmc_obj_info struct
+ * @rsrc_idx: resource index into info
+ *
+ * Decode a 64 bit value from fpm query buffer into max count and size
+ */
+static u64 i40iw_sc_decode_fpm_query(u64 *buf,
+                                           u32 buf_idx,
+                                           struct i40iw_hmc_obj_info *obj_info,
+                                           u32 rsrc_idx)
+{
+       u64 temp;
+       u32 size;
+
+       get_64bit_val(buf, buf_idx, &temp);
+       obj_info[rsrc_idx].max_cnt = (u32)temp;
+       size = (u32)RS_64_1(temp, 32);
+       obj_info[rsrc_idx].size = LS_64_1(1, size);
+
+       return temp;
+}
+
 /**
  * i40iw_sc_parse_fpm_query_buf() - parses fpm query buffer
  * @buf: ptr to fpm query buffer
@@ -168,9 +205,9 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf(
                                struct i40iw_hmc_info *hmc_info,
                                struct i40iw_hmc_fpm_misc *hmc_fpm_misc)
 {
-       u64 temp;
        struct i40iw_hmc_obj_info *obj_info;
-       u32 i, j, size;
+       u64 temp;
+       u32 size;
        u16 max_pe_sds;
 
        obj_info = hmc_info->hmc_obj;
@@ -185,41 +222,52 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf(
        hmc_fpm_misc->max_sds = max_pe_sds;
        hmc_info->sd_table.sd_cnt = max_pe_sds + hmc_info->first_sd_index;
 
-       for (i = I40IW_HMC_IW_QP, j = 8;
-            i <= I40IW_HMC_IW_ARP; i++, j += 8) {
-               get_64bit_val(buf, j, &temp);
-               if (i == I40IW_HMC_IW_QP)
-                       obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
-               else if (i == I40IW_HMC_IW_CQ)
-                       obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
-               else
-                       obj_info[i].max_cnt = (u32)temp;
+       get_64bit_val(buf, 8, &temp);
+       obj_info[I40IW_HMC_IW_QP].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
+       size = (u32)RS_64_1(temp, 32);
+       obj_info[I40IW_HMC_IW_QP].size = LS_64_1(1, size);
 
-               size = (u32)RS_64_1(temp, 32);
-               obj_info[i].size = ((u64)1 << size);
-       }
-       for (i = I40IW_HMC_IW_MR, j = 48;
-                       i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
-               get_64bit_val(buf, j, &temp);
-               obj_info[i].max_cnt = (u32)temp;
-               size = (u32)RS_64_1(temp, 32);
-               obj_info[i].size = LS_64_1(1, size);
-       }
+       get_64bit_val(buf, 16, &temp);
+       obj_info[I40IW_HMC_IW_CQ].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
+       size = (u32)RS_64_1(temp, 32);
+       obj_info[I40IW_HMC_IW_CQ].size = LS_64_1(1, size);
+
+       i40iw_sc_decode_fpm_query(buf, 32, obj_info, I40IW_HMC_IW_HTE);
+       i40iw_sc_decode_fpm_query(buf, 40, obj_info, I40IW_HMC_IW_ARP);
+
+       obj_info[I40IW_HMC_IW_APBVT_ENTRY].size = 8192;
+       obj_info[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1;
+
+       i40iw_sc_decode_fpm_query(buf, 48, obj_info, I40IW_HMC_IW_MR);
+       i40iw_sc_decode_fpm_query(buf, 56, obj_info, I40IW_HMC_IW_XF);
 
-       get_64bit_val(buf, 120, &temp);
-       hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS);
-       get_64bit_val(buf, 120, &temp);
-       hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER);
-       get_64bit_val(buf, 120, &temp);
-       hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET);
        get_64bit_val(buf, 64, &temp);
+       obj_info[I40IW_HMC_IW_XFFL].max_cnt = (u32)temp;
+       obj_info[I40IW_HMC_IW_XFFL].size = 4;
        hmc_fpm_misc->xf_block_size = RS_64(temp, I40IW_QUERY_FPM_XFBLOCKSIZE);
        if (!hmc_fpm_misc->xf_block_size)
                return I40IW_ERR_INVALID_SIZE;
+
+       i40iw_sc_decode_fpm_query(buf, 72, obj_info, I40IW_HMC_IW_Q1);
+
        get_64bit_val(buf, 80, &temp);
+       obj_info[I40IW_HMC_IW_Q1FL].max_cnt = (u32)temp;
+       obj_info[I40IW_HMC_IW_Q1FL].size = 4;
        hmc_fpm_misc->q1_block_size = RS_64(temp, I40IW_QUERY_FPM_Q1BLOCKSIZE);
        if (!hmc_fpm_misc->q1_block_size)
                return I40IW_ERR_INVALID_SIZE;
+
+       i40iw_sc_decode_fpm_query(buf, 88, obj_info, I40IW_HMC_IW_TIMER);
+
+       get_64bit_val(buf, 112, &temp);
+       obj_info[I40IW_HMC_IW_PBLE].max_cnt = (u32)temp;
+       obj_info[I40IW_HMC_IW_PBLE].size = 8;
+
+       get_64bit_val(buf, 120, &temp);
+       hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS);
+       hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER);
+       hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET);
+
        return 0;
 }
 
@@ -3392,13 +3440,6 @@ enum i40iw_status_code i40iw_sc_init_iw_hmc(struct i40iw_sc_dev *dev, u8 hmc_fn_
                hmc_info->sd_table.sd_entry = virt_mem.va;
        }
 
-       /* fill size of objects which are fixed */
-       hmc_info->hmc_obj[I40IW_HMC_IW_XFFL].size = 4;
-       hmc_info->hmc_obj[I40IW_HMC_IW_Q1FL].size = 4;
-       hmc_info->hmc_obj[I40IW_HMC_IW_PBLE].size = 8;
-       hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].size = 8192;
-       hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1;
-
        return ret_code;
 }
 
@@ -4840,7 +4881,7 @@ void i40iw_vsi_stats_free(struct i40iw_sc_vsi *vsi)
 {
        u8 fcn_id = vsi->fcn_id;
 
-       if ((vsi->stats_fcn_id_alloc) && (fcn_id != I40IW_INVALID_FCN_ID))
+       if (vsi->stats_fcn_id_alloc && fcn_id < I40IW_MAX_STATS_COUNT)
                vsi->dev->fcn_id_array[fcn_id] = false;
        i40iw_hw_stats_stop_timer(vsi);
 }
index a39ac12b6a7e8430b80e42d9a38d7abd3b48d3b8..2ebaadbed379406e9d6c10f01fe0577ab515ebc9 100644 (file)
@@ -1507,8 +1507,8 @@ enum {
        I40IW_CQ0_ALIGNMENT_MASK =              (256 - 1),
        I40IW_HOST_CTX_ALIGNMENT_MASK =         (4 - 1),
        I40IW_SHADOWAREA_MASK =                 (128 - 1),
-       I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK =    0,
-       I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK =   0
+       I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK =    (4 - 1),
+       I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK =   (4 - 1)
 };
 
 enum i40iw_alignment {
index 71050c5d29a05f3f6cb9433aafd7e09fbb5695aa..7f5583d83622a57821d1d4718c6bbc49d84410d0 100644 (file)
@@ -685,7 +685,7 @@ static enum i40iw_status_code i40iw_puda_cq_create(struct i40iw_puda_rsrc *rsrc)
        cqsize = rsrc->cq_size * (sizeof(struct i40iw_cqe));
        tsize = cqsize + sizeof(struct i40iw_cq_shadow_area);
        ret = i40iw_allocate_dma_mem(dev->hw, &rsrc->cqmem, tsize,
-                                    I40IW_CQ0_ALIGNMENT_MASK);
+                                    I40IW_CQ0_ALIGNMENT);
        if (ret)
                return ret;
 
index 91c421762f06797be844f0834d7ff09ff36bb5f9..f7013f11d8085966bf6d9dab310f0f8d0f35422a 100644 (file)
@@ -62,7 +62,7 @@ enum i40iw_status_code {
        I40IW_ERR_INVALID_ALIGNMENT = -23,
        I40IW_ERR_FLUSHED_QUEUE = -24,
        I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25,
-       I40IW_ERR_INVALID_IMM_DATA_SIZE = -26,
+       I40IW_ERR_INVALID_INLINE_DATA_SIZE = -26,
        I40IW_ERR_TIMEOUT = -27,
        I40IW_ERR_OPCODE_MISMATCH = -28,
        I40IW_ERR_CQP_COMPL_ERROR = -29,
index b0d3a0e8a9b522a3549d63593a0af38f682e71ba..1060725d18bce852a108d6ce9e0b55cb460bfb0d 100644 (file)
@@ -435,7 +435,7 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp,
 
        op_info = &info->op.inline_rdma_write;
        if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
-               return I40IW_ERR_INVALID_IMM_DATA_SIZE;
+               return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
 
        ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size);
        if (ret_code)
@@ -511,7 +511,7 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp,
 
        op_info = &info->op.inline_send;
        if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
-               return I40IW_ERR_INVALID_IMM_DATA_SIZE;
+               return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
 
        ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size);
        if (ret_code)
@@ -784,7 +784,7 @@ static enum i40iw_status_code i40iw_cq_poll_completion(struct i40iw_cq_uk *cq,
        get_64bit_val(cqe, 0, &qword0);
        get_64bit_val(cqe, 16, &qword2);
 
-       info->tcp_seq_num = (u8)RS_64(qword0, I40IWCQ_TCPSEQNUM);
+       info->tcp_seq_num = (u32)RS_64(qword0, I40IWCQ_TCPSEQNUM);
 
        info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID);
 
@@ -1187,7 +1187,7 @@ enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size,
                                                         u8 *wqe_size)
 {
        if (data_size > I40IW_MAX_INLINE_DATA_SIZE)
-               return I40IW_ERR_INVALID_IMM_DATA_SIZE;
+               return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
 
        if (data_size <= 16)
                *wqe_size = I40IW_QP_WQE_MIN_SIZE;
index a7f2e60085c46c2300e3695029fbe1373cc0d480..f7fcde1ff0aae66fef09d6eaccf8f9de6b008ba1 100644 (file)
@@ -1085,6 +1085,12 @@ static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
        bool is_ib = (mlx5_ib_port_link_layer(ibdev, port) ==
                      IB_LINK_LAYER_INFINIBAND);
 
+       /* CM layer calls ib_modify_port() regardless of the link layer. For
+        * Ethernet ports, qkey violation and Port capabilities are meaningless.
+        */
+       if (!is_ib)
+               return 0;
+
        if (MLX5_CAP_GEN(dev->mdev, ib_virt) && is_ib) {
                change_mask = props->clr_port_cap_mask | props->set_port_cap_mask;
                value = ~props->clr_port_cap_mask | props->set_port_cap_mask;
index ae0746754008798fc0c4ab7e940f736c376a72f1..3d701c7a4c9140e488b7427d9d901a4ea77d2786 100644 (file)
@@ -939,7 +939,7 @@ static int mlx5_ib_mr_initiator_pfault_handler(
 
        if (qp->ibqp.qp_type != IB_QPT_RC) {
                av = *wqe;
-               if (av->dqp_dct & be32_to_cpu(MLX5_WQE_AV_EXT))
+               if (av->dqp_dct & cpu_to_be32(MLX5_EXTENDED_UD_AV))
                        *wqe += sizeof(struct mlx5_av);
                else
                        *wqe += sizeof(struct mlx5_base_av);
index 0889ff367c8625f694346136c22bd510d2dea2a7..f58f8f5f3ebe10e8270606327b58440efd70aae3 100644 (file)
@@ -1238,6 +1238,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
                        goto err_destroy_tis;
 
                sq->base.container_mibqp = qp;
+               sq->base.mqp.event = mlx5_ib_qp_event;
        }
 
        if (qp->rq.wqe_cnt) {
index 69bda611d31385044766915410ac72eb70cffac5..90aa326fd7c0974e0c5a70eb5d2b46f50d03c490 100644 (file)
@@ -65,13 +65,28 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
        struct pvrdma_dev *dev = to_vdev(ibcq->device);
        struct pvrdma_cq *cq = to_vcq(ibcq);
        u32 val = cq->cq_handle;
+       unsigned long flags;
+       int has_data = 0;
 
        val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
                PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
 
+       spin_lock_irqsave(&cq->cq_lock, flags);
+
        pvrdma_write_uar_cq(dev, val);
 
-       return 0;
+       if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
+               unsigned int head;
+
+               has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+                                                   cq->ibcq.cqe, &head);
+               if (unlikely(has_data == PVRDMA_INVALID_IDX))
+                       dev_err(&dev->pdev->dev, "CQ ring state invalid\n");
+       }
+
+       spin_unlock_irqrestore(&cq->cq_lock, flags);
+
+       return has_data;
 }
 
 /**
index ff50a7bd66d864506ec65aef1b63f45ce5d36e36..7ac25059c40f94aad951b28351cf425ebe573197 100644 (file)
@@ -336,6 +336,7 @@ struct ipoib_dev_priv {
        unsigned long flags;
 
        struct rw_semaphore vlan_rwsem;
+       struct mutex mcast_mutex;
 
        struct rb_root  path_tree;
        struct list_head path_list;
index f87d104837dcfab7f0e35b5b7fcae1e021599bfc..d69410c2ed97bdeceb17aedb2a7fe6049c59c310 100644 (file)
@@ -511,7 +511,6 @@ static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id,
        case IB_CM_REQ_RECEIVED:
                return ipoib_cm_req_handler(cm_id, event);
        case IB_CM_DREQ_RECEIVED:
-               p = cm_id->context;
                ib_send_cm_drep(cm_id, NULL, 0);
                /* Fall through */
        case IB_CM_REJ_RECEIVED:
index 7871379342f48fa77b2e6e8279ca774b4c49ad2f..184a22f4802773efc67131093f4ab4fcc89cd276 100644 (file)
@@ -52,7 +52,8 @@ static const struct ipoib_stats ipoib_gstrings_stats[] = {
        IPOIB_NETDEV_STAT(tx_bytes),
        IPOIB_NETDEV_STAT(tx_errors),
        IPOIB_NETDEV_STAT(rx_dropped),
-       IPOIB_NETDEV_STAT(tx_dropped)
+       IPOIB_NETDEV_STAT(tx_dropped),
+       IPOIB_NETDEV_STAT(multicast),
 };
 
 #define IPOIB_GLOBAL_STATS_LEN ARRAY_SIZE(ipoib_gstrings_stats)
index 57a9655e844deb1cc2eb57d9485f98e195368ac5..2e075377242e2baccc54cda5859d5b3ba7e768d0 100644 (file)
@@ -256,6 +256,8 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
 
        ++dev->stats.rx_packets;
        dev->stats.rx_bytes += skb->len;
+       if (skb->pkt_type == PACKET_MULTICAST)
+               dev->stats.multicast++;
 
        skb->dev = dev;
        if ((dev->features & NETIF_F_RXCSUM) &&
@@ -709,6 +711,27 @@ static int recvs_pending(struct net_device *dev)
        return pending;
 }
 
+static void check_qp_movement_and_print(struct ipoib_dev_priv *priv,
+                                       struct ib_qp *qp,
+                                       enum ib_qp_state new_state)
+{
+       struct ib_qp_attr qp_attr;
+       struct ib_qp_init_attr query_init_attr;
+       int ret;
+
+       ret = ib_query_qp(qp, &qp_attr, IB_QP_STATE, &query_init_attr);
+       if (ret) {
+               ipoib_warn(priv, "%s: Failed to query QP\n", __func__);
+               return;
+       }
+       /* print according to the new-state and the previous state.*/
+       if (new_state == IB_QPS_ERR && qp_attr.qp_state == IB_QPS_RESET)
+               ipoib_dbg(priv, "Failed modify QP, IB_QPS_RESET to IB_QPS_ERR, acceptable\n");
+       else
+               ipoib_warn(priv, "Failed to modify QP to state: %d from state: %d\n",
+                          new_state, qp_attr.qp_state);
+}
+
 int ipoib_ib_dev_stop_default(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = ipoib_priv(dev);
@@ -728,7 +751,7 @@ int ipoib_ib_dev_stop_default(struct net_device *dev)
         */
        qp_attr.qp_state = IB_QPS_ERR;
        if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
-               ipoib_warn(priv, "Failed to modify QP to ERROR state\n");
+               check_qp_movement_and_print(priv, priv->qp, IB_QPS_ERR);
 
        /* Wait for all sends and receives to complete */
        begin = jiffies;
index 4ce315c92b480fa705c30b33ffd7253b4cfded3b..6c77df34869dfb719d66787f6ccbb7637b042d36 100644 (file)
@@ -1560,6 +1560,7 @@ static void ipoib_flush_neighs(struct ipoib_dev_priv *priv)
        int i, wait_flushed = 0;
 
        init_completion(&priv->ntbl.flushed);
+       set_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags);
 
        spin_lock_irqsave(&priv->lock, flags);
 
@@ -1604,7 +1605,6 @@ static void ipoib_neigh_hash_uninit(struct net_device *dev)
 
        ipoib_dbg(priv, "ipoib_neigh_hash_uninit\n");
        init_completion(&priv->ntbl.deleted);
-       set_bit(IPOIB_NEIGH_TBL_FLUSH, &priv->flags);
 
        /* Stop GC if called at init fail need to cancel work */
        stopped = test_and_set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
@@ -1847,6 +1847,7 @@ static const struct net_device_ops ipoib_netdev_ops_vf = {
        .ndo_tx_timeout          = ipoib_timeout,
        .ndo_set_rx_mode         = ipoib_set_mcast_list,
        .ndo_get_iflink          = ipoib_get_iflink,
+       .ndo_get_stats64         = ipoib_get_stats,
 };
 
 void ipoib_setup_common(struct net_device *dev)
@@ -1877,6 +1878,7 @@ static void ipoib_build_priv(struct net_device *dev)
        priv->dev = dev;
        spin_lock_init(&priv->lock);
        init_rwsem(&priv->vlan_rwsem);
+       mutex_init(&priv->mcast_mutex);
 
        INIT_LIST_HEAD(&priv->path_list);
        INIT_LIST_HEAD(&priv->child_intfs);
@@ -2173,14 +2175,14 @@ static struct net_device *ipoib_add_port(const char *format,
        priv->dev->dev_id = port - 1;
 
        result = ib_query_port(hca, port, &attr);
-       if (!result)
-               priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
-       else {
+       if (result) {
                printk(KERN_WARNING "%s: ib_query_port %d failed\n",
                       hca->name, port);
                goto device_init_failed;
        }
 
+       priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
+
        /* MTU will be reset when mcast join happens */
        priv->dev->mtu  = IPOIB_UD_MTU(priv->max_ib_mtu);
        priv->mcast_mtu  = priv->admin_mtu = priv->dev->mtu;
@@ -2211,12 +2213,14 @@ static struct net_device *ipoib_add_port(const char *format,
                printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n",
                       hca->name, port, result);
                goto device_init_failed;
-       } else
-               memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid));
+       }
+
+       memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw,
+              sizeof(union ib_gid));
        set_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags);
 
        result = ipoib_dev_init(priv->dev, hca, port);
-       if (result < 0) {
+       if (result) {
                printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n",
                       hca->name, port, result);
                goto device_init_failed;
@@ -2365,6 +2369,7 @@ static int __init ipoib_init_module(void)
        ipoib_sendq_size = max3(ipoib_sendq_size, 2 * MAX_SEND_CQE, IPOIB_MIN_QUEUE_SIZE);
 #ifdef CONFIG_INFINIBAND_IPOIB_CM
        ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP);
+       ipoib_max_conn_qp = max(ipoib_max_conn_qp, 0);
 #endif
 
        /*
index 057f58e6afca249744f2d9013021e3c1c5d6417f..93e149efc1f5fc0382b61dcfc9f84d786d8b52ca 100644 (file)
@@ -684,15 +684,10 @@ void ipoib_mcast_start_thread(struct net_device *dev)
 int ipoib_mcast_stop_thread(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = ipoib_priv(dev);
-       unsigned long flags;
 
        ipoib_dbg_mcast(priv, "stopping multicast thread\n");
 
-       spin_lock_irqsave(&priv->lock, flags);
-       cancel_delayed_work(&priv->mcast_task);
-       spin_unlock_irqrestore(&priv->lock, flags);
-
-       flush_workqueue(priv->wq);
+       cancel_delayed_work_sync(&priv->mcast_task);
 
        return 0;
 }
@@ -748,6 +743,14 @@ void ipoib_mcast_remove_list(struct list_head *remove_list)
 {
        struct ipoib_mcast *mcast, *tmcast;
 
+       /*
+        * make sure the in-flight joins have finished before we attempt
+        * to leave
+        */
+       list_for_each_entry_safe(mcast, tmcast, remove_list, list)
+               if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
+                       wait_for_completion(&mcast->done);
+
        list_for_each_entry_safe(mcast, tmcast, remove_list, list) {
                ipoib_mcast_leave(mcast->dev, mcast);
                ipoib_mcast_free(mcast);
@@ -838,6 +841,7 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
        struct ipoib_mcast *mcast, *tmcast;
        unsigned long flags;
 
+       mutex_lock(&priv->mcast_mutex);
        ipoib_dbg_mcast(priv, "flushing multicast list\n");
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -856,15 +860,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
 
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       /*
-        * make sure the in-flight joins have finished before we attempt
-        * to leave
-        */
-       list_for_each_entry_safe(mcast, tmcast, &remove_list, list)
-               if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
-                       wait_for_completion(&mcast->done);
-
        ipoib_mcast_remove_list(&remove_list);
+       mutex_unlock(&priv->mcast_mutex);
 }
 
 static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
@@ -982,14 +979,6 @@ void ipoib_mcast_restart_task(struct work_struct *work)
        netif_addr_unlock(dev);
        local_irq_restore(flags);
 
-       /*
-        * make sure the in-flight joins have finished before we attempt
-        * to leave
-        */
-       list_for_each_entry_safe(mcast, tmcast, &remove_list, list)
-               if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
-                       wait_for_completion(&mcast->done);
-
        ipoib_mcast_remove_list(&remove_list);
 
        /*
index 298a6ba51411a2d68795f34b41c380df85fdfbc6..ca0e19ae7a90f0a2854938f926c5d7ece0675686 100644 (file)
@@ -476,10 +476,21 @@ static const u8 xboxone_hori_init[] = {
 };
 
 /*
- * A rumble packet is required for some PowerA pads to start
+ * A specific rumble packet is required for some PowerA pads to start
  * sending input reports. One of those pads is (0x24c6:0x543a).
  */
-static const u8 xboxone_zerorumble_init[] = {
+static const u8 xboxone_rumblebegin_init[] = {
+       0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
+       0x1D, 0x1D, 0xFF, 0x00, 0x00
+};
+
+/*
+ * A rumble packet with zero FF intensity will immediately
+ * terminate the rumbling required to init PowerA pads.
+ * This should happen fast enough that the motors don't
+ * spin up to enough speed to actually vibrate the gamepad.
+ */
+static const u8 xboxone_rumbleend_init[] = {
        0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00
 };
@@ -494,9 +505,12 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {
        XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
        XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
        XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
-       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_zerorumble_init),
-       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_zerorumble_init),
-       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_zerorumble_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumbleend_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumbleend_init),
+       XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumbleend_init),
 };
 
 struct xpad_output_packet {
index f600f3a7a3c685488e1ede36058439c59f0703dc..23520df7650f5bc9261c3b58cac22a8dfc27423f 100644 (file)
@@ -331,7 +331,7 @@ static int soc_button_probe(struct platform_device *pdev)
        error = gpiod_count(dev, NULL);
        if (error < 0) {
                dev_dbg(dev, "no GPIO attached, ignoring...\n");
-               return error;
+               return -ENODEV;
        }
 
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
index 262d1057c1da21ba7290c37c0379087d1ff5fa49..850b00e3ad8ecde13046449befa4fad95e308a60 100644 (file)
@@ -1215,14 +1215,24 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
 
        case SS4_PACKET_ID_TWO:
                if (priv->flags & ALPS_BUTTONPAD) {
-                       f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[0].x = SS4_BTL_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
+                       }
                        f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0);
-                       f->mt[1].x = SS4_BTL_MF_X_V2(p, 1);
                        f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1);
                } else {
-                       f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+                       }
                        f->mt[0].y = SS4_STD_MF_Y_V2(p, 0);
-                       f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
                        f->mt[1].y = SS4_STD_MF_Y_V2(p, 1);
                }
                f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0;
@@ -1239,16 +1249,27 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
 
        case SS4_PACKET_ID_MULTI:
                if (priv->flags & ALPS_BUTTONPAD) {
-                       f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[2].x = SS4_BTL_MF_X_V2(p, 0);
+                               f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
+                       }
+
                        f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0);
-                       f->mt[3].x = SS4_BTL_MF_X_V2(p, 1);
                        f->mt[3].y = SS4_BTL_MF_Y_V2(p, 1);
                        no_data_x = SS4_MFPACKET_NO_AX_BL;
                        no_data_y = SS4_MFPACKET_NO_AY_BL;
                } else {
-                       f->mt[2].x = SS4_STD_MF_X_V2(p, 0);
+                       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+                               f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1);
+                       } else {
+                               f->mt[0].x = SS4_STD_MF_X_V2(p, 0);
+                               f->mt[1].x = SS4_STD_MF_X_V2(p, 1);
+                       }
                        f->mt[2].y = SS4_STD_MF_Y_V2(p, 0);
-                       f->mt[3].x = SS4_STD_MF_X_V2(p, 1);
                        f->mt[3].y = SS4_STD_MF_Y_V2(p, 1);
                        no_data_x = SS4_MFPACKET_NO_AX;
                        no_data_y = SS4_MFPACKET_NO_AY;
@@ -2541,8 +2562,8 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
 
        memset(otp, 0, sizeof(otp));
 
-       if (alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]) ||
-           alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]))
+       if (alps_get_otp_values_ss4_v2(psmouse, 1, &otp[1][0]) ||
+           alps_get_otp_values_ss4_v2(psmouse, 0, &otp[0][0]))
                return -1;
 
        alps_update_device_area_ss4_v2(otp, priv);
index ed2d6879fa529aebc46d946e1b9c7341eee12b03..c80a7c76cb767187c13e18c5104042270886e736 100644 (file)
@@ -100,6 +100,10 @@ enum SS4_PACKET_ID {
                                 ((_b[1 + _i * 3]  << 5) & 0x1F00)      \
                                )
 
+#define SS4_PLUS_STD_MF_X_V2(_b, _i) (((_b[0 + (_i) * 3] << 4) & 0x0070) | \
+                                ((_b[1 + (_i) * 3]  << 4) & 0x0F80)    \
+                               )
+
 #define SS4_STD_MF_Y_V2(_b, _i)        (((_b[1 + (_i) * 3] << 3) & 0x0010) |   \
                                 ((_b[2 + (_i) * 3] << 5) & 0x01E0) |   \
                                 ((_b[2 + (_i) * 3] << 4) & 0x0E00)     \
@@ -109,6 +113,10 @@ enum SS4_PACKET_ID {
                                 ((_b[0 + (_i) * 3] >> 3) & 0x0010)     \
                                )
 
+#define SS4_PLUS_BTL_MF_X_V2(_b, _i) (SS4_PLUS_STD_MF_X_V2(_b, _i) |   \
+                                ((_b[0 + (_i) * 3] >> 4) & 0x0008)     \
+                               )
+
 #define SS4_BTL_MF_Y_V2(_b, _i)        (SS4_STD_MF_Y_V2(_b, _i) | \
                                 ((_b[0 + (_i) * 3] >> 3) & 0x0008)     \
                                )
index 3b616cb7c67f88512e82dbc8ba5f61e565cbd2a5..cfbc8ba4c96c7bedda89e1b79f8ee23b5cd36f47 100644 (file)
@@ -1247,7 +1247,12 @@ static const struct acpi_device_id elan_acpi_id[] = {
        { "ELAN0000", 0 },
        { "ELAN0100", 0 },
        { "ELAN0600", 0 },
+       { "ELAN0602", 0 },
        { "ELAN0605", 0 },
+       { "ELAN0608", 0 },
+       { "ELAN0605", 0 },
+       { "ELAN0609", 0 },
+       { "ELAN060B", 0 },
        { "ELAN1000", 0 },
        { }
 };
index 16c30460ef041b13686db7f6efe36860b725a4bd..5af0b7d200bc23ff0f2287d6e0b69a631fb8bb22 100644 (file)
@@ -535,16 +535,17 @@ static void synaptics_apply_quirks(struct psmouse *psmouse,
        }
 }
 
+static bool synaptics_has_agm(struct synaptics_data *priv)
+{
+       return (SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
+               SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c));
+}
+
 static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
 {
        static u8 param = 0xc8;
-       struct synaptics_data *priv = psmouse->private;
        int error;
 
-       if (!(SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
-             SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c)))
-               return 0;
-
        error = psmouse_sliced_command(psmouse, SYN_QUE_MODEL);
        if (error)
                return error;
@@ -553,9 +554,6 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
        if (error)
                return error;
 
-       /* Advanced gesture mode also sends multi finger data */
-       priv->info.capabilities |= BIT(1);
-
        return 0;
 }
 
@@ -578,7 +576,7 @@ static int synaptics_set_mode(struct psmouse *psmouse)
        if (error)
                return error;
 
-       if (priv->absolute_mode) {
+       if (priv->absolute_mode && synaptics_has_agm(priv)) {
                error = synaptics_set_advanced_gesture_mode(psmouse);
                if (error) {
                        psmouse_err(psmouse,
@@ -766,9 +764,7 @@ static int synaptics_parse_hw_state(const u8 buf[],
                         ((buf[0] & 0x04) >> 1) |
                         ((buf[3] & 0x04) >> 2));
 
-               if ((SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
-                       SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c)) &&
-                   hw->w == 2) {
+               if (synaptics_has_agm(priv) && hw->w == 2) {
                        synaptics_parse_agm(buf, priv, hw);
                        return 1;
                }
@@ -1033,6 +1029,15 @@ static void synaptics_image_sensor_process(struct psmouse *psmouse,
        synaptics_report_mt_data(psmouse, sgm, num_fingers);
 }
 
+static bool synaptics_has_multifinger(struct synaptics_data *priv)
+{
+       if (SYN_CAP_MULTIFINGER(priv->info.capabilities))
+               return true;
+
+       /* Advanced gesture mode also sends multi finger data */
+       return synaptics_has_agm(priv);
+}
+
 /*
  *  called for each full received packet from the touchpad
  */
@@ -1079,7 +1084,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
                if (SYN_CAP_EXTENDED(info->capabilities)) {
                        switch (hw.w) {
                        case 0 ... 1:
-                               if (SYN_CAP_MULTIFINGER(info->capabilities))
+                               if (synaptics_has_multifinger(priv))
                                        num_fingers = hw.w + 2;
                                break;
                        case 2:
@@ -1123,7 +1128,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
                input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
 
        input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
-       if (SYN_CAP_MULTIFINGER(info->capabilities)) {
+       if (synaptics_has_multifinger(priv)) {
                input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
                input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);
        }
@@ -1283,7 +1288,7 @@ static void set_input_params(struct psmouse *psmouse,
        __set_bit(BTN_TOUCH, dev->keybit);
        __set_bit(BTN_TOOL_FINGER, dev->keybit);
 
-       if (SYN_CAP_MULTIFINGER(info->capabilities)) {
+       if (synaptics_has_multifinger(priv)) {
                __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
                __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
        }
index 922ea02edcc3ef6c091b572275245e7d5fabd3f0..0871010f18d5f449e6440a5e41f71d24b8aecfd2 100644 (file)
@@ -265,7 +265,8 @@ static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *fir
        if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
                return -1;
 
-       if (param[0] != TP_MAGIC_IDENT)
+       /* add new TP ID. */
+       if (!(param[0] & TP_MAGIC_IDENT))
                return -1;
 
        if (firmware_id)
@@ -380,8 +381,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
                return 0;
 
        if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) {
-               psmouse_warn(psmouse, "failed to get extended button data\n");
-               button_info = 0;
+               psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n");
+               button_info = 0x33;
        }
 
        psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
index 5617ed3a7d7a15d0f9769086afb8c740b5739fcc..88055755f82e2304a5f7438bc59cb7f47f488823 100644 (file)
@@ -21,8 +21,9 @@
 #define TP_COMMAND             0xE2    /* Commands start with this */
 
 #define TP_READ_ID             0xE1    /* Sent for device identification */
-#define TP_MAGIC_IDENT         0x01    /* Sent after a TP_READ_ID followed */
+#define TP_MAGIC_IDENT         0x03    /* Sent after a TP_READ_ID followed */
                                        /* by the firmware ID */
+                                       /* Firmware ID includes 0x1, 0x2, 0x3 */
 
 
 /*
index 294a409e283b7ae4b52c59350756983711bba9d1..d6b873b57054b44d2f0227630798cda83a637256 100644 (file)
@@ -574,7 +574,9 @@ struct amd_iommu {
 
 static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)
 {
-       return container_of(dev, struct amd_iommu, iommu.dev);
+       struct iommu_device *iommu = dev_to_iommu_device(dev);
+
+       return container_of(iommu, struct amd_iommu, iommu);
 }
 
 #define ACPIHID_UID_LEN 256
index 6629c472eafd828bb45a9e7fe3a4260c2e199de2..dccf5b76eff24bc1bdd82397d2fd516c9226fae2 100644 (file)
@@ -391,13 +391,6 @@ static int mn_clear_flush_young(struct mmu_notifier *mn,
        return 0;
 }
 
-static void mn_invalidate_page(struct mmu_notifier *mn,
-                              struct mm_struct *mm,
-                              unsigned long address)
-{
-       __mn_flush_page(mn, address);
-}
-
 static void mn_invalidate_range(struct mmu_notifier *mn,
                                struct mm_struct *mm,
                                unsigned long start, unsigned long end)
@@ -436,7 +429,6 @@ static void mn_release(struct mmu_notifier *mn, struct mm_struct *mm)
 static const struct mmu_notifier_ops iommu_mn = {
        .release                = mn_release,
        .clear_flush_young      = mn_clear_flush_young,
-       .invalidate_page        = mn_invalidate_page,
        .invalidate_range       = mn_invalidate_range,
 };
 
index b97188acc4f1006185a5f8cb4fb3ee0e5cf735cf..2d80fa8a0634aba34b366609d8bcc50f432bb31c 100644 (file)
@@ -1519,6 +1519,13 @@ static int arm_smmu_add_device(struct device *dev)
 
        if (using_legacy_binding) {
                ret = arm_smmu_register_legacy_master(dev, &smmu);
+
+               /*
+                * If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master()
+                * will allocate/initialise a new one. Thus we need to update fwspec for
+                * later use.
+                */
+               fwspec = dev->iommu_fwspec;
                if (ret)
                        goto out_free;
        } else if (fwspec && fwspec->ops == &arm_smmu_ops) {
index 687f18f65cea58d2a5f22725a2c36c78621dd3cd..3e8636f1220ea9bdbcf668bac193e21cee408063 100644 (file)
@@ -4736,7 +4736,9 @@ static void intel_disable_iommus(void)
 
 static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev)
 {
-       return container_of(dev, struct intel_iommu, iommu.dev);
+       struct iommu_device *iommu_dev = dev_to_iommu_device(dev);
+
+       return container_of(iommu_dev, struct intel_iommu, iommu);
 }
 
 static ssize_t intel_iommu_show_version(struct device *dev,
index f167c0d84ebfb7f5937eb798c9cdbd8bd9abe6c6..f620dccec8ee3d9782b3c1322984e3b26078722a 100644 (file)
@@ -223,14 +223,6 @@ static void intel_change_pte(struct mmu_notifier *mn, struct mm_struct *mm,
        intel_flush_svm_range(svm, address, 1, 1, 0);
 }
 
-static void intel_invalidate_page(struct mmu_notifier *mn, struct mm_struct *mm,
-                                 unsigned long address)
-{
-       struct intel_svm *svm = container_of(mn, struct intel_svm, notifier);
-
-       intel_flush_svm_range(svm, address, 1, 1, 0);
-}
-
 /* Pages have been freed at this point */
 static void intel_invalidate_range(struct mmu_notifier *mn,
                                   struct mm_struct *mm,
@@ -285,7 +277,6 @@ static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm)
 static const struct mmu_notifier_ops intel_mmuops = {
        .release = intel_mm_release,
        .change_pte = intel_change_pte,
-       .invalidate_page = intel_invalidate_page,
        .invalidate_range = intel_invalidate_range,
 };
 
index c58351ed61c14309c7a72346bd56f659a7039637..36d1a7ce7fc4cc922cade9642b5d64c05e5d8e19 100644 (file)
@@ -62,32 +62,40 @@ int iommu_device_sysfs_add(struct iommu_device *iommu,
        va_list vargs;
        int ret;
 
-       device_initialize(&iommu->dev);
+       iommu->dev = kzalloc(sizeof(*iommu->dev), GFP_KERNEL);
+       if (!iommu->dev)
+               return -ENOMEM;
 
-       iommu->dev.class = &iommu_class;
-       iommu->dev.parent = parent;
-       iommu->dev.groups = groups;
+       device_initialize(iommu->dev);
+
+       iommu->dev->class = &iommu_class;
+       iommu->dev->parent = parent;
+       iommu->dev->groups = groups;
 
        va_start(vargs, fmt);
-       ret = kobject_set_name_vargs(&iommu->dev.kobj, fmt, vargs);
+       ret = kobject_set_name_vargs(&iommu->dev->kobj, fmt, vargs);
        va_end(vargs);
        if (ret)
                goto error;
 
-       ret = device_add(&iommu->dev);
+       ret = device_add(iommu->dev);
        if (ret)
                goto error;
 
+       dev_set_drvdata(iommu->dev, iommu);
+
        return 0;
 
 error:
-       put_device(&iommu->dev);
+       put_device(iommu->dev);
        return ret;
 }
 
 void iommu_device_sysfs_remove(struct iommu_device *iommu)
 {
-       device_unregister(&iommu->dev);
+       dev_set_drvdata(iommu->dev, NULL);
+       device_unregister(iommu->dev);
+       iommu->dev = NULL;
 }
 /*
  * IOMMU drivers can indicate a device is managed by a given IOMMU using
@@ -102,14 +110,14 @@ int iommu_device_link(struct iommu_device *iommu, struct device *link)
        if (!iommu || IS_ERR(iommu))
                return -ENODEV;
 
-       ret = sysfs_add_link_to_group(&iommu->dev.kobj, "devices",
+       ret = sysfs_add_link_to_group(&iommu->dev->kobj, "devices",
                                      &link->kobj, dev_name(link));
        if (ret)
                return ret;
 
-       ret = sysfs_create_link_nowarn(&link->kobj, &iommu->dev.kobj, "iommu");
+       ret = sysfs_create_link_nowarn(&link->kobj, &iommu->dev->kobj, "iommu");
        if (ret)
-               sysfs_remove_link_from_group(&iommu->dev.kobj, "devices",
+               sysfs_remove_link_from_group(&iommu->dev->kobj, "devices",
                                             dev_name(link));
 
        return ret;
@@ -121,5 +129,5 @@ void iommu_device_unlink(struct iommu_device *iommu, struct device *link)
                return;
 
        sysfs_remove_link(&link->kobj, "iommu");
-       sysfs_remove_link_from_group(&iommu->dev.kobj, "devices", dev_name(link));
+       sysfs_remove_link_from_group(&iommu->dev->kobj, "devices", dev_name(link));
 }
index 28b26c80f4cf937b8547328b5d724a69e51b7d05..072bd227b6c677b40fee80f99e1364d733e681a3 100644 (file)
@@ -137,14 +137,14 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
 #define AT91_RTC_IMR           0x28
 #define AT91_RTC_IRQ_MASK      0x1f
 
-void __init aic_common_rtc_irq_fixup(struct device_node *root)
+void __init aic_common_rtc_irq_fixup(void)
 {
        struct device_node *np;
        void __iomem *regs;
 
-       np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc");
+       np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-rtc");
        if (!np)
-               np = of_find_compatible_node(root, NULL,
+               np = of_find_compatible_node(NULL, NULL,
                                             "atmel,at91sam9x5-rtc");
 
        if (!np)
@@ -165,7 +165,7 @@ void __init aic_common_rtc_irq_fixup(struct device_node *root)
 #define AT91_RTT_ALMIEN                (1 << 16)               /* Alarm Interrupt Enable */
 #define AT91_RTT_RTTINCIEN     (1 << 17)               /* Real Time Timer Increment Interrupt Enable */
 
-void __init aic_common_rtt_irq_fixup(struct device_node *root)
+void __init aic_common_rtt_irq_fixup(void)
 {
        struct device_node *np;
        void __iomem *regs;
@@ -196,11 +196,10 @@ static void __init aic_common_irq_fixup(const struct of_device_id *matches)
                return;
 
        match = of_match_node(matches, root);
-       of_node_put(root);
 
        if (match) {
-               void (*fixup)(struct device_node *) = match->data;
-               fixup(root);
+               void (*fixup)(void) = match->data;
+               fixup();
        }
 
        of_node_put(root);
index af60376d50debe30132acd00c58254c4d1a7ab9a..242e62c1851ead9744442e0236fa84198f745d7f 100644 (file)
@@ -33,8 +33,8 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
                                             const char *name, int nirqs,
                                             const struct of_device_id *matches);
 
-void __init aic_common_rtc_irq_fixup(struct device_node *root);
+void __init aic_common_rtc_irq_fixup(void);
 
-void __init aic_common_rtt_irq_fixup(struct device_node *root);
+void __init aic_common_rtt_irq_fixup(void);
 
 #endif /* __IRQ_ATMEL_AIC_COMMON_H */
index 37f952dd9fc94bdc5faa6c2721822b8780dd46e1..bb1ad451392fd8b7a315a6b2c5bea523af04a62a 100644 (file)
@@ -209,20 +209,20 @@ static const struct irq_domain_ops aic_irq_ops = {
        .xlate  = aic_irq_domain_xlate,
 };
 
-static void __init at91rm9200_aic_irq_fixup(struct device_node *root)
+static void __init at91rm9200_aic_irq_fixup(void)
 {
-       aic_common_rtc_irq_fixup(root);
+       aic_common_rtc_irq_fixup();
 }
 
-static void __init at91sam9260_aic_irq_fixup(struct device_node *root)
+static void __init at91sam9260_aic_irq_fixup(void)
 {
-       aic_common_rtt_irq_fixup(root);
+       aic_common_rtt_irq_fixup();
 }
 
-static void __init at91sam9g45_aic_irq_fixup(struct device_node *root)
+static void __init at91sam9g45_aic_irq_fixup(void)
 {
-       aic_common_rtc_irq_fixup(root);
-       aic_common_rtt_irq_fixup(root);
+       aic_common_rtc_irq_fixup();
+       aic_common_rtt_irq_fixup();
 }
 
 static const struct of_device_id aic_irq_fixups[] __initconst = {
index c04ee9a23d094f9d6a9e0c95a7451cf73626727a..6acad2ea0fb3565a2604ecbb3fb5235395d62fad 100644 (file)
@@ -305,9 +305,9 @@ static const struct irq_domain_ops aic5_irq_ops = {
        .xlate  = aic5_irq_domain_xlate,
 };
 
-static void __init sama5d3_aic_irq_fixup(struct device_node *root)
+static void __init sama5d3_aic_irq_fixup(void)
 {
-       aic_common_rtc_irq_fixup(root);
+       aic_common_rtc_irq_fixup();
 }
 
 static const struct of_device_id aic5_irq_fixups[] __initconst = {
index bddf169c4b37b7c9d2a91518aa233480dbb52f5d..b009b916a2923504414aafe6961b404614770da5 100644 (file)
@@ -189,6 +189,7 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np,
 
        ct->chip.irq_suspend = brcmstb_l2_intc_suspend;
        ct->chip.irq_resume = brcmstb_l2_intc_resume;
+       ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend;
 
        if (data->can_wake) {
                /* This IRQ chip can wake the system, set all child interrupts
index 249240d9a4259eb72b7afb68c2e2723a72e7c9c5..833a90fe33aed839a81b781831027e677eef5581 100644 (file)
@@ -43,6 +43,7 @@ static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev,
                        *dev_id = args.args[0];
                        break;
                }
+               index++;
        } while (!ret);
 
        return ret;
index 68932873eebc0c3d14caa00b048d0c961e765a98..284738add89b3b94f77ad257fd314bc89a423cae 100644 (file)
@@ -1835,7 +1835,7 @@ static int __init its_of_probe(struct device_node *node)
 
 #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
 
-#if defined(CONFIG_ACPI_NUMA) && (ACPI_CA_VERSION >= 0x20170531)
+#ifdef CONFIG_ACPI_NUMA
 struct its_srat_map {
        /* numa node id */
        u32     numa_node;
@@ -1843,7 +1843,7 @@ struct its_srat_map {
        u32     its_id;
 };
 
-static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata;
+static struct its_srat_map *its_srat_maps __initdata;
 static int its_in_srat __initdata;
 
 static int __init acpi_get_its_numa_node(u32 its_id)
@@ -1857,6 +1857,12 @@ static int __init acpi_get_its_numa_node(u32 its_id)
        return NUMA_NO_NODE;
 }
 
+static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header,
+                                         const unsigned long end)
+{
+       return 0;
+}
+
 static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
                         const unsigned long end)
 {
@@ -1873,12 +1879,6 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
                return -EINVAL;
        }
 
-       if (its_in_srat >= MAX_NUMNODES) {
-               pr_err("SRAT: ITS affinity exceeding max count[%d]\n",
-                               MAX_NUMNODES);
-               return -EINVAL;
-       }
-
        node = acpi_map_pxm_to_node(its_affinity->proximity_domain);
 
        if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
@@ -1897,14 +1897,37 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
 
 static void __init acpi_table_parse_srat_its(void)
 {
+       int count;
+
+       count = acpi_table_parse_entries(ACPI_SIG_SRAT,
+                       sizeof(struct acpi_table_srat),
+                       ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
+                       gic_acpi_match_srat_its, 0);
+       if (count <= 0)
+               return;
+
+       its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
+                               GFP_KERNEL);
+       if (!its_srat_maps) {
+               pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
+               return;
+       }
+
        acpi_table_parse_entries(ACPI_SIG_SRAT,
                        sizeof(struct acpi_table_srat),
                        ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
                        gic_acpi_parse_srat_its, 0);
 }
+
+/* free the its_srat_maps after ITS probing */
+static void __init acpi_its_srat_maps_free(void)
+{
+       kfree(its_srat_maps);
+}
 #else
 static void __init acpi_table_parse_srat_its(void)     { }
 static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; }
+static void __init acpi_its_srat_maps_free(void) { }
 #endif
 
 static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
@@ -1951,6 +1974,7 @@ static void __init its_acpi_probe(void)
        acpi_table_parse_srat_its();
        acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
                              gic_acpi_parse_madt_its, 0);
+       acpi_its_srat_maps_free();
 }
 #else
 static void __init its_acpi_probe(void) { }
index dbffb7ab62033b346ca7fc3b3468d6bcb3a19a63..984c3ecfd22c21aff59b3cad177c676348d86dd4 100644 (file)
@@ -353,6 +353,8 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
 
                        if (static_key_true(&supports_deactivate))
                                gic_write_eoir(irqnr);
+                       else
+                               isb();
 
                        err = handle_domain_irq(gic_data.domain, irqnr, regs);
                        if (err) {
@@ -640,11 +642,16 @@ static void gic_smp_init(void)
 static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
                            bool force)
 {
-       unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
+       unsigned int cpu;
        void __iomem *reg;
        int enabled;
        u64 val;
 
+       if (force)
+               cpu = cpumask_first(mask_val);
+       else
+               cpu = cpumask_any_and(mask_val, cpu_online_mask);
+
        if (cpu >= nr_cpu_ids)
                return -EINVAL;
 
@@ -831,8 +838,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
        if (ret)
                return ret;
 
-       for (i = 0; i < nr_irqs; i++)
-               gic_irq_domain_map(domain, virq + i, hwirq + i);
+       for (i = 0; i < nr_irqs; i++) {
+               ret = gic_irq_domain_map(domain, virq + i, hwirq + i);
+               if (ret)
+                       return ret;
+       }
 
        return 0;
 }
index 1b1df4f770bdefe0a16e0109624801f8af90f1f7..d3e7c43718b82b9e7fb2191dedadab1950c3ac7d 100644 (file)
@@ -361,6 +361,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
                if (likely(irqnr > 15 && irqnr < 1020)) {
                        if (static_key_true(&supports_deactivate))
                                writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
+                       isb();
                        handle_domain_irq(gic->domain, irqnr, regs);
                        continue;
                }
@@ -401,10 +402,12 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
                goto out;
 
        cascade_irq = irq_find_mapping(chip_data->domain, gic_irq);
-       if (unlikely(gic_irq < 32 || gic_irq > 1020))
+       if (unlikely(gic_irq < 32 || gic_irq > 1020)) {
                handle_bad_irq(desc);
-       else
+       } else {
+               isb();
                generic_handle_irq(cascade_irq);
+       }
 
  out:
        chained_irq_exit(chip, desc);
@@ -1027,8 +1030,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
        if (ret)
                return ret;
 
-       for (i = 0; i < nr_irqs; i++)
-               gic_irq_domain_map(domain, virq + i, hwirq + i);
+       for (i = 0; i < nr_irqs; i++) {
+               ret = gic_irq_domain_map(domain, virq + i, hwirq + i);
+               if (ret)
+                       return ret;
+       }
 
        return 0;
 }
index 7b5fd8fb1761d1912be615ee14571e420dc4c92b..aaca0b3d662eb18bda0848652c309985d5f6ad0e 100644 (file)
@@ -44,7 +44,6 @@ struct procdata {
        char log_name[15];      /* log filename */
        struct log_data *log_head, *log_tail;   /* head and tail for queue */
        int if_used;            /* open count for interface */
-       int volatile del_lock;  /* lock for delete operations */
        unsigned char logtmp[LOG_MAX_LINELEN];
        wait_queue_head_t rd_queue;
 };
@@ -102,7 +101,6 @@ put_log_buffer(hysdn_card *card, char *cp)
 {
        struct log_data *ib;
        struct procdata *pd = card->proclog;
-       int i;
        unsigned long flags;
 
        if (!pd)
@@ -126,21 +124,21 @@ put_log_buffer(hysdn_card *card, char *cp)
        else
                pd->log_tail->next = ib;        /* follows existing messages */
        pd->log_tail = ib;      /* new tail */
-       i = pd->del_lock++;     /* get lock state */
-       spin_unlock_irqrestore(&card->hysdn_lock, flags);
 
        /* delete old entrys */
-       if (!i)
-               while (pd->log_head->next) {
-                       if ((pd->log_head->usage_cnt <= 0) &&
-                           (pd->log_head->next->usage_cnt <= 0)) {
-                               ib = pd->log_head;
-                               pd->log_head = pd->log_head->next;
-                               kfree(ib);
-                       } else
-                               break;
-               }               /* pd->log_head->next */
-       pd->del_lock--;         /* release lock level */
+       while (pd->log_head->next) {
+               if ((pd->log_head->usage_cnt <= 0) &&
+                   (pd->log_head->next->usage_cnt <= 0)) {
+                       ib = pd->log_head;
+                       pd->log_head = pd->log_head->next;
+                       kfree(ib);
+               } else {
+                       break;
+               }
+       }               /* pd->log_head->next */
+
+       spin_unlock_irqrestore(&card->hysdn_lock, flags);
+
        wake_up_interruptible(&(pd->rd_queue));         /* announce new entry */
 }                              /* put_log_buffer */
 
index 78fc5d5e90514353b258658da350a85c408b89db..92e6570b11435e7e4dade7aa433231008c82b294 100644 (file)
@@ -26,7 +26,7 @@
 
 #define FSM_TIMER_DEBUG 0
 
-void
+int
 mISDN_FsmNew(struct Fsm *fsm,
             struct FsmNode *fnlist, int fncount)
 {
@@ -34,6 +34,8 @@ mISDN_FsmNew(struct Fsm *fsm,
 
        fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count *
                                  fsm->event_count, GFP_KERNEL);
+       if (fsm->jumpmatrix == NULL)
+               return -ENOMEM;
 
        for (i = 0; i < fncount; i++)
                if ((fnlist[i].state >= fsm->state_count) ||
@@ -45,6 +47,7 @@ mISDN_FsmNew(struct Fsm *fsm,
                } else
                        fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
                                        fnlist[i].state] = (FSMFNPTR) fnlist[i].routine;
+       return 0;
 }
 EXPORT_SYMBOL(mISDN_FsmNew);
 
index 928f5be192c1fd4a5c8197160efb9dad21e1141d..e1def84902212e1637cf96f0c9cefb8c3950edbd 100644 (file)
@@ -55,7 +55,7 @@ struct FsmTimer {
        void *arg;
 };
 
-extern void mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
+extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
 extern void mISDN_FsmFree(struct Fsm *);
 extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
 extern void mISDN_FsmChangeState(struct FsmInst *, int);
index bebc57b72138e721aa5a290482ae46e748aac2d2..3192b0eb39445435d7b38c0f914bded7c93b2fac 100644 (file)
@@ -414,8 +414,7 @@ l1_init(u_int *deb)
        l1fsm_s.event_count = L1_EVENT_COUNT;
        l1fsm_s.strEvent = strL1Event;
        l1fsm_s.strState = strL1SState;
-       mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
-       return 0;
+       return mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
 }
 
 void
index 7243a6746f8b099d79d3221def6dcfcf138a6f51..9ff0903a0e89fb2f4f7373e1ef4d1d1663934b36 100644 (file)
@@ -2247,15 +2247,26 @@ static struct Bprotocol X75SLP = {
 int
 Isdnl2_Init(u_int *deb)
 {
+       int res;
        debug = deb;
        mISDN_register_Bprotocol(&X75SLP);
        l2fsm.state_count = L2_STATE_COUNT;
        l2fsm.event_count = L2_EVENT_COUNT;
        l2fsm.strEvent = strL2Event;
        l2fsm.strState = strL2State;
-       mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList));
-       TEIInit(deb);
+       res = mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList));
+       if (res)
+               goto error;
+       res = TEIInit(deb);
+       if (res)
+               goto error_fsm;
        return 0;
+
+error_fsm:
+       mISDN_FsmFree(&l2fsm);
+error:
+       mISDN_unregister_Bprotocol(&X75SLP);
+       return res;
 }
 
 void
index 908127efccf8ceb94ef2ab1ed7df4b17b26ce5b9..12d9e5f4beb1f81c5aa5e5af81bc9aca61c21668 100644 (file)
@@ -1387,23 +1387,37 @@ create_teimanager(struct mISDNdevice *dev)
 
 int TEIInit(u_int *deb)
 {
+       int res;
        debug = deb;
        teifsmu.state_count = TEI_STATE_COUNT;
        teifsmu.event_count = TEI_EVENT_COUNT;
        teifsmu.strEvent = strTeiEvent;
        teifsmu.strState = strTeiState;
-       mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser));
+       res = mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser));
+       if (res)
+               goto error;
        teifsmn.state_count = TEI_STATE_COUNT;
        teifsmn.event_count = TEI_EVENT_COUNT;
        teifsmn.strEvent = strTeiEvent;
        teifsmn.strState = strTeiState;
-       mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet));
+       res = mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet));
+       if (res)
+               goto error_smn;
        deactfsm.state_count =  DEACT_STATE_COUNT;
        deactfsm.event_count = DEACT_EVENT_COUNT;
        deactfsm.strEvent = strDeactEvent;
        deactfsm.strState = strDeactState;
-       mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList));
+       res = mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList));
+       if (res)
+               goto error_deact;
        return 0;
+
+error_deact:
+       mISDN_FsmFree(&teifsmn);
+error_smn:
+       mISDN_FsmFree(&teifsmu);
+error:
+       return res;
 }
 
 void TEIFree(void)
index 0e8ab5bb3575fccf24a5734d1f5fe8149210b6aa..d24e4b05f5dacefe5c0528b0ff3b75444bb216e6 100644 (file)
@@ -504,7 +504,6 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
                if (queue_dying) {
                        atomic_inc(&m->pg_init_in_progress);
                        activate_or_offline_path(pgpath);
-                       return DM_MAPIO_REQUEUE;
                }
                return DM_MAPIO_DELAY_REQUEUE;
        }
@@ -1458,7 +1457,6 @@ static int noretry_error(blk_status_t error)
        case BLK_STS_TARGET:
        case BLK_STS_NEXUS:
        case BLK_STS_MEDIUM:
-       case BLK_STS_RESOURCE:
                return 1;
        }
 
index 2edbcc2d7d3f6274b689447859470d2773ea4e3b..d669fddd9290d027a39fa2e65b01b0a1b24afc0a 100644 (file)
 
 #define DM_MSG_PREFIX "core"
 
-#ifdef CONFIG_PRINTK
-/*
- * ratelimit state to be used in DMXXX_LIMIT().
- */
-DEFINE_RATELIMIT_STATE(dm_ratelimit_state,
-                      DEFAULT_RATELIMIT_INTERVAL,
-                      DEFAULT_RATELIMIT_BURST);
-EXPORT_SYMBOL(dm_ratelimit_state);
-#endif
-
 /*
  * Cookies are numeric values sent with CHANGE and REMOVE
  * uevents while resuming, removing or renaming the device.
@@ -1523,7 +1513,7 @@ static void __split_and_process_bio(struct mapped_device *md,
        }
 
        /* drop the extra reference count */
-       dec_pending(ci.io, error);
+       dec_pending(ci.io, errno_to_blk_status(error));
 }
 /*-----------------------------------------------------------------
  * CRUD END
index c99634612fc408fbc97df9c7c8ef8e028efe2fad..b01e458d31e94ce9eba98b9300366121de550619 100644 (file)
@@ -7996,7 +7996,7 @@ bool md_write_start(struct mddev *mddev, struct bio *bi)
        if (mddev->safemode == 1)
                mddev->safemode = 0;
        /* sync_checkers is always 0 when writes_pending is in per-cpu mode */
-       if (mddev->in_sync || !mddev->sync_checkers) {
+       if (mddev->in_sync || mddev->sync_checkers) {
                spin_lock(&mddev->lock);
                if (mddev->in_sync) {
                        mddev->in_sync = 0;
@@ -8656,6 +8656,9 @@ void md_check_recovery(struct mddev *mddev)
        if (mddev_trylock(mddev)) {
                int spares = 0;
 
+               if (!mddev->external && mddev->safemode == 1)
+                       mddev->safemode = 0;
+
                if (mddev->ro) {
                        struct md_rdev *rdev;
                        if (!mddev->external && mddev->in_sync)
index bfa1e907c472e49855f9e0abb4c307cd45514d4d..2dcbafa8e66ca7f5418fce8434fe9674977f0832 100644 (file)
@@ -236,9 +236,10 @@ struct r5l_io_unit {
        bool need_split_bio;
        struct bio *split_bio;
 
-       unsigned int has_flush:1;      /* include flush request */
-       unsigned int has_fua:1;        /* include fua request */
-       unsigned int has_null_flush:1; /* include empty flush request */
+       unsigned int has_flush:1;               /* include flush request */
+       unsigned int has_fua:1;                 /* include fua request */
+       unsigned int has_null_flush:1;          /* include null flush request */
+       unsigned int has_flush_payload:1;       /* include flush payload  */
        /*
         * io isn't sent yet, flush/fua request can only be submitted till it's
         * the first IO in running_ios list
@@ -571,6 +572,8 @@ static void r5l_log_endio(struct bio *bio)
        struct r5l_io_unit *io_deferred;
        struct r5l_log *log = io->log;
        unsigned long flags;
+       bool has_null_flush;
+       bool has_flush_payload;
 
        if (bio->bi_status)
                md_error(log->rdev->mddev, log->rdev);
@@ -580,6 +583,16 @@ static void r5l_log_endio(struct bio *bio)
 
        spin_lock_irqsave(&log->io_list_lock, flags);
        __r5l_set_io_unit_state(io, IO_UNIT_IO_END);
+
+       /*
+        * if the io doesn't not have null_flush or flush payload,
+        * it is not safe to access it after releasing io_list_lock.
+        * Therefore, it is necessary to check the condition with
+        * the lock held.
+        */
+       has_null_flush = io->has_null_flush;
+       has_flush_payload = io->has_flush_payload;
+
        if (log->need_cache_flush && !list_empty(&io->stripe_list))
                r5l_move_to_end_ios(log);
        else
@@ -600,19 +613,23 @@ static void r5l_log_endio(struct bio *bio)
        if (log->need_cache_flush)
                md_wakeup_thread(log->rdev->mddev->thread);
 
-       if (io->has_null_flush) {
+       /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */
+       if (has_null_flush) {
                struct bio *bi;
 
                WARN_ON(bio_list_empty(&io->flush_barriers));
                while ((bi = bio_list_pop(&io->flush_barriers)) != NULL) {
                        bio_endio(bi);
-                       atomic_dec(&io->pending_stripe);
+                       if (atomic_dec_and_test(&io->pending_stripe)) {
+                               __r5l_stripe_write_finished(io);
+                               return;
+                       }
                }
        }
-
-       /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */
-       if (atomic_read(&io->pending_stripe) == 0)
-               __r5l_stripe_write_finished(io);
+       /* decrease pending_stripe for flush payload */
+       if (has_flush_payload)
+               if (atomic_dec_and_test(&io->pending_stripe))
+                       __r5l_stripe_write_finished(io);
 }
 
 static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io)
@@ -881,6 +898,11 @@ static void r5l_append_flush_payload(struct r5l_log *log, sector_t sect)
        payload->size = cpu_to_le32(sizeof(__le64));
        payload->flush_stripes[0] = cpu_to_le64(sect);
        io->meta_offset += meta_size;
+       /* multiple flush payloads count as one pending_stripe */
+       if (!io->has_flush_payload) {
+               io->has_flush_payload = 1;
+               atomic_inc(&io->pending_stripe);
+       }
        mutex_unlock(&log->io_mutex);
 }
 
@@ -2540,23 +2562,32 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
  */
 int r5c_journal_mode_set(struct mddev *mddev, int mode)
 {
-       struct r5conf *conf = mddev->private;
-       struct r5l_log *log = conf->log;
-
-       if (!log)
-               return -ENODEV;
+       struct r5conf *conf;
+       int err;
 
        if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH ||
            mode > R5C_JOURNAL_MODE_WRITE_BACK)
                return -EINVAL;
 
+       err = mddev_lock(mddev);
+       if (err)
+               return err;
+       conf = mddev->private;
+       if (!conf || !conf->log) {
+               mddev_unlock(mddev);
+               return -ENODEV;
+       }
+
        if (raid5_calc_degraded(conf) > 0 &&
-           mode == R5C_JOURNAL_MODE_WRITE_BACK)
+           mode == R5C_JOURNAL_MODE_WRITE_BACK) {
+               mddev_unlock(mddev);
                return -EINVAL;
+       }
 
        mddev_suspend(mddev);
        conf->log->r5c_journal_mode = mode;
        mddev_resume(mddev);
+       mddev_unlock(mddev);
 
        pr_debug("md/raid:%s: setting r5c cache mode to %d: %s\n",
                 mdname(mddev), mode, r5c_journal_mode_str[mode]);
index fbe0f245ce8ee50943340de1c05d6490a3a13ced..fe1811523e4a7aac70e0498e7cd70fac55e2046b 100644 (file)
@@ -644,6 +644,9 @@ static const struct regmap_range da9062_aa_readable_ranges[] = {
        }, {
                .range_min = DA9062AA_VLDO1_B,
                .range_max = DA9062AA_VLDO4_B,
+       }, {
+               .range_min = DA9062AA_BBAT_CONT,
+               .range_max = DA9062AA_BBAT_CONT,
        }, {
                .range_min = DA9062AA_INTERFACE,
                .range_max = DA9062AA_CONFIG_E,
@@ -720,6 +723,9 @@ static const struct regmap_range da9062_aa_writeable_ranges[] = {
        }, {
                .range_min = DA9062AA_VLDO1_B,
                .range_max = DA9062AA_VLDO4_B,
+       }, {
+               .range_min = DA9062AA_BBAT_CONT,
+               .range_max = DA9062AA_BBAT_CONT,
        }, {
                .range_min = DA9062AA_GP_ID_0,
                .range_max = DA9062AA_GP_ID_19,
index 8621a198a2ce3eae317e4007cd6c533b56cfecc4..bac33311f55a6d7a6699b362c39730fae9c4f107 100644 (file)
@@ -215,6 +215,12 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_drvdata(pdev, dev);
 
+       /*
+        * MEI requires to resume from runtime suspend mode
+        * in order to perform link reset flow upon system suspend.
+        */
+       pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME;
+
        /*
        * For not wake-able HW runtime pm framework
        * can't be used on pci device level.
index f811cd52446852beecfedf02b7100f4bb6789169..e38a5f144373451fc87007ffc1cf4292059c5408 100644 (file)
@@ -137,6 +137,12 @@ static int mei_txe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_drvdata(pdev, dev);
 
+       /*
+        * MEI requires to resume from runtime suspend mode
+        * in order to perform link reset flow upon system suspend.
+        */
+       pdev->dev_flags |= PCI_DEV_FLAGS_NEEDS_RESUME;
+
        /*
        * For not wake-able HW runtime pm framework
        * can't be used on pci device level.
index 64d5760d069ab3887682e5358f009c9a4767b374..63d6246d6dff3caf8b6f7099257f902d50d2de20 100644 (file)
@@ -200,16 +200,6 @@ static void scif_mmu_notifier_release(struct mmu_notifier *mn,
        schedule_work(&scif_info.misc_work);
 }
 
-static void scif_mmu_notifier_invalidate_page(struct mmu_notifier *mn,
-                                             struct mm_struct *mm,
-                                             unsigned long address)
-{
-       struct scif_mmu_notif   *mmn;
-
-       mmn = container_of(mn, struct scif_mmu_notif, ep_mmu_notifier);
-       scif_rma_destroy_tcw(mmn, address, PAGE_SIZE);
-}
-
 static void scif_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
                                                     struct mm_struct *mm,
                                                     unsigned long start,
@@ -235,7 +225,6 @@ static void scif_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
 static const struct mmu_notifier_ops scif_mmu_notifier_ops = {
        .release = scif_mmu_notifier_release,
        .clear_flush_young = NULL,
-       .invalidate_page = scif_mmu_notifier_invalidate_page,
        .invalidate_range_start = scif_mmu_notifier_invalidate_range_start,
        .invalidate_range_end = scif_mmu_notifier_invalidate_range_end};
 
index e936d43895d2579965c9a8d6127cc9111c9cc716..9918eda0e05f649882b8db5f0828db2e3bcfe31e 100644 (file)
@@ -247,17 +247,6 @@ static void gru_invalidate_range_end(struct mmu_notifier *mn,
        gru_dbg(grudev, "gms %p, start 0x%lx, end 0x%lx\n", gms, start, end);
 }
 
-static void gru_invalidate_page(struct mmu_notifier *mn, struct mm_struct *mm,
-                               unsigned long address)
-{
-       struct gru_mm_struct *gms = container_of(mn, struct gru_mm_struct,
-                                                ms_notifier);
-
-       STAT(mmu_invalidate_page);
-       gru_flush_tlb_range(gms, address, PAGE_SIZE);
-       gru_dbg(grudev, "gms %p, address 0x%lx\n", gms, address);
-}
-
 static void gru_release(struct mmu_notifier *mn, struct mm_struct *mm)
 {
        struct gru_mm_struct *gms = container_of(mn, struct gru_mm_struct,
@@ -269,7 +258,6 @@ static void gru_release(struct mmu_notifier *mn, struct mm_struct *mm)
 
 
 static const struct mmu_notifier_ops gru_mmuops = {
-       .invalidate_page        = gru_invalidate_page,
        .invalidate_range_start = gru_invalidate_range_start,
        .invalidate_range_end   = gru_invalidate_range_end,
        .release                = gru_release,
index e5938c791330c9be1203c2698bc511e4f98aaea4..8bd7aba811e969a3b7cfdc6cf12e685f25e8c37e 100644 (file)
@@ -1213,7 +1213,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
                break;
        }
        mq_rq->drv_op_result = ret;
-       blk_end_request_all(req, ret);
+       blk_end_request_all(req, ret ? BLK_STS_IOERR : BLK_STS_OK);
 }
 
 static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
@@ -1371,12 +1371,46 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
         R1_CC_ERROR |          /* Card controller error */             \
         R1_ERROR)              /* General/unknown error */
 
-static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
+static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq)
 {
-       if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
-               cmd->error = -EIO;
+       u32 val;
+
+       /*
+        * Per the SD specification(physical layer version 4.10)[1],
+        * section 4.3.3, it explicitly states that "When the last
+        * block of user area is read using CMD18, the host should
+        * ignore OUT_OF_RANGE error that may occur even the sequence
+        * is correct". And JESD84-B51 for eMMC also has a similar
+        * statement on section 6.8.3.
+        *
+        * Multiple block read/write could be done by either predefined
+        * method, namely CMD23, or open-ending mode. For open-ending mode,
+        * we should ignore the OUT_OF_RANGE error as it's normal behaviour.
+        *
+        * However the spec[1] doesn't tell us whether we should also
+        * ignore that for predefined method. But per the spec[1], section
+        * 4.15 Set Block Count Command, it says"If illegal block count
+        * is set, out of range error will be indicated during read/write
+        * operation (For example, data transfer is stopped at user area
+        * boundary)." In another word, we could expect a out of range error
+        * in the response for the following CMD18/25. And if argument of
+        * CMD23 + the argument of CMD18/25 exceed the max number of blocks,
+        * we could also expect to get a -ETIMEDOUT or any error number from
+        * the host drivers due to missing data response(for write)/data(for
+        * read), as the cards will stop the data transfer by itself per the
+        * spec. So we only need to check R1_OUT_OF_RANGE for open-ending mode.
+        */
 
-       return cmd->error;
+       if (!brq->stop.error) {
+               bool oor_with_open_end;
+               /* If there is no error yet, check R1 response */
+
+               val = brq->stop.resp[0] & CMD_ERRORS;
+               oor_with_open_end = val & R1_OUT_OF_RANGE && !brq->mrq.sbc;
+
+               if (val && !oor_with_open_end)
+                       brq->stop.error = -EIO;
+       }
 }
 
 static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
@@ -1400,8 +1434,11 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
         * stop.error indicates a problem with the stop command.  Data
         * may have been transferred, or may still be transferring.
         */
-       if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) ||
-           brq->data.error) {
+
+       mmc_blk_eval_resp_error(brq);
+
+       if (brq->sbc.error || brq->cmd.error ||
+           brq->stop.error || brq->data.error) {
                switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
                case ERR_RETRY:
                        return MMC_BLK_RETRY;
@@ -1681,9 +1718,9 @@ static bool mmc_blk_rw_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,
                if (err)
                        req_pending = old_req_pending;
                else
-                       req_pending = blk_end_request(req, 0, blocks << 9);
+                       req_pending = blk_end_request(req, BLK_STS_OK, blocks << 9);
        } else {
-               req_pending = blk_end_request(req, 0, brq->data.bytes_xfered);
+               req_pending = blk_end_request(req, BLK_STS_OK, brq->data.bytes_xfered);
        }
        return req_pending;
 }
@@ -2170,7 +2207,9 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)
                 * from being accepted.
                 */
                card = md->queue.card;
+               spin_lock_irq(md->queue.queue->queue_lock);
                queue_flag_set(QUEUE_FLAG_BYPASS, md->queue.queue);
+               spin_unlock_irq(md->queue.queue->queue_lock);
                blk_set_queue_dying(md->queue.queue);
                mmc_cleanup_queue(&md->queue);
                if (md->disk->flags & GENHD_FL_UP) {
index 4ffea14b7eb645d92a91d62907d64c97cf8a9998..2bae69e39544452dc323a9a3bd15ae9b3e7de1b9 100644 (file)
@@ -1289,7 +1289,7 @@ out_err:
 static int mmc_select_hs400es(struct mmc_card *card)
 {
        struct mmc_host *host = card->host;
-       int err = 0;
+       int err = -EINVAL;
        u8 val;
 
        if (!(host->caps & MMC_CAP_8_BIT_DATA)) {
index 04ff3c97a535143933acec93caa8483a43f633c6..2ab4788d021f0512082c6bd67d1edaa57ba61379 100644 (file)
@@ -2086,7 +2086,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
        mmc->max_seg_size = mmc->max_req_size;
 
        mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
-                    MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE;
+                    MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE | MMC_CAP_CMD23;
 
        mmc->caps |= mmc_pdata(host)->caps;
        if (mmc->caps & MMC_CAP_8_BIT_DATA)
index bc1781bb070b7b8b83c0132abb114f6905ffddfb..c580af05b033a1f596f4335d90a1e56f84c6903e 100644 (file)
@@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host,
        sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
 }
 
+static void xenon_set_power(struct sdhci_host *host, unsigned char mode,
+               unsigned short vdd)
+{
+       struct mmc_host *mmc = host->mmc;
+       u8 pwr = host->pwr;
+
+       sdhci_set_power_noreg(host, mode, vdd);
+
+       if (host->pwr == pwr)
+               return;
+
+       if (host->pwr == 0)
+               vdd = 0;
+
+       if (!IS_ERR(mmc->supply.vmmc))
+               mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
+}
+
 static const struct sdhci_ops sdhci_xenon_ops = {
        .set_clock              = sdhci_set_clock,
+       .set_power              = xenon_set_power,
        .set_bus_width          = sdhci_set_bus_width,
        .reset                  = xenon_reset,
        .set_uhs_signaling      = xenon_set_uhs_signaling,
index f336a9b855765e5ea236fddf9564f5f084793597..9ec8f033ac5f077b05fdfc32a7f97f1747339ca8 100644 (file)
@@ -113,6 +113,7 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,
                for (; nsect > 0; nsect--, block++, buf += tr->blksize)
                        if (tr->writesect(dev, block, buf))
                                return BLK_STS_IOERR;
+               return BLK_STS_OK;
        default:
                return BLK_STS_IOERR;
        }
index d922a88e407f119bbf52aae494c632e08d113e7f..ceec21bd30c4fc5c49ad4c4bdbfe9bd031005809 100644 (file)
@@ -1201,7 +1201,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
         * tRC < 30ns implies EDO mode. This controller does not support this
         * mode.
         */
-       if (conf->timings.sdr.tRC_min < 30)
+       if (conf->timings.sdr.tRC_min < 30000)
                return -ENOTSUPP;
 
        atmel_smc_cs_conf_init(smcconf);
@@ -1364,7 +1364,18 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand,
        ret = atmel_smc_cs_conf_set_timing(smcconf,
                                           ATMEL_HSMC_TIMINGS_TADL_SHIFT,
                                           ncycles);
-       if (ret)
+       /*
+        * Version 4 of the ONFI spec mandates that tADL be at least 400
+        * nanoseconds, but, depending on the master clock rate, 400 ns may not
+        * fit in the tADL field of the SMC reg. We need to relax the check and
+        * accept the -ERANGE return code.
+        *
+        * Note that previous versions of the ONFI spec had a lower tADL_min
+        * (100 or 200 ns). It's not clear why this timing constraint got
+        * increased but it seems most NANDs are fine with values lower than
+        * 400ns, so we should be safe.
+        */
+       if (ret && ret != -ERANGE)
                return ret;
 
        ncycles = DIV_ROUND_UP(conf->timings.sdr.tAR_min, mckperiodps);
index 55a8ee5306ea992f39bbcd0c2cbaa5e40ad90214..8c210a5776bcbea1677e422dc3f06397c831d9cc 100644 (file)
@@ -945,6 +945,7 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev)
                 */
                struct platform_device *pdev = to_platform_device(userdev);
                const struct atmel_pmecc_caps *caps;
+               const struct of_device_id *match;
 
                /* No PMECC engine available. */
                if (!of_property_read_bool(userdev->of_node,
@@ -953,21 +954,11 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev)
 
                caps = &at91sam9g45_caps;
 
-               /*
-                * Try to find the NFC subnode and extract the associated caps
-                * from there.
-                */
-               np = of_find_compatible_node(userdev->of_node, NULL,
-                                            "atmel,sama5d3-nfc");
-               if (np) {
-                       const struct of_device_id *match;
-
-                       match = of_match_node(atmel_pmecc_legacy_match, np);
-                       if (match && match->data)
-                               caps = match->data;
-
-                       of_node_put(np);
-               }
+               /* Find the caps associated to the NAND dev node. */
+               match = of_match_node(atmel_pmecc_legacy_match,
+                                     userdev->of_node);
+               if (match && match->data)
+                       caps = match->data;
 
                pmecc = atmel_pmecc_create(pdev, caps, 1, 2);
        }
index 5fa5ddc94834d0a27a8add0125ed27310601af09..c6c18b82f8f4eade18561edb24439a9d4737efa5 100644 (file)
@@ -65,8 +65,14 @@ static int nand_ooblayout_ecc_sp(struct mtd_info *mtd, int section,
 
        if (!section) {
                oobregion->offset = 0;
-               oobregion->length = 4;
+               if (mtd->oobsize == 16)
+                       oobregion->length = 4;
+               else
+                       oobregion->length = 3;
        } else {
+               if (mtd->oobsize == 8)
+                       return -ERANGE;
+
                oobregion->offset = 6;
                oobregion->length = ecc->total - 4;
        }
@@ -1125,7 +1131,9 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
         * Ensure the timing mode has been changed on the chip side
         * before changing timings on the controller side.
         */
-       if (chip->onfi_version) {
+       if (chip->onfi_version &&
+           (le16_to_cpu(chip->onfi_params.opt_cmd) &
+            ONFI_OPT_CMD_SET_GET_FEATURES)) {
                u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
                        chip->onfi_timing_mode_default,
                };
@@ -2741,7 +2749,6 @@ static int nand_write_page_syndrome(struct mtd_info *mtd,
  * @buf: the data to write
  * @oob_required: must write chip->oob_poi to OOB
  * @page: page number to write
- * @cached: cached programming
  * @raw: use _raw version of write_page
  */
 static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
index f06312df3669c18cb788fc033acf6b5811db8d0a..7e36d7d13c268fc2317c330f7688e188e81d6bdc 100644 (file)
@@ -311,9 +311,9 @@ int onfi_init_data_interface(struct nand_chip *chip,
                struct nand_sdr_timings *timings = &iface->timings.sdr;
 
                /* microseconds -> picoseconds */
-               timings->tPROG_max = 1000000UL * le16_to_cpu(params->t_prog);
-               timings->tBERS_max = 1000000UL * le16_to_cpu(params->t_bers);
-               timings->tR_max = 1000000UL * le16_to_cpu(params->t_r);
+               timings->tPROG_max = 1000000ULL * le16_to_cpu(params->t_prog);
+               timings->tBERS_max = 1000000ULL * le16_to_cpu(params->t_bers);
+               timings->tR_max = 1000000ULL * le16_to_cpu(params->t_r);
 
                /* nanoseconds -> picoseconds */
                timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs);
index 03a0d057bf2f80b3ea4c3f397eb1f607697aad3c..e4211c3cc49b2ac054a080fd34d83db56f9556da 100644 (file)
@@ -2373,6 +2373,7 @@ static int __init ns_init_module(void)
         return 0;
 
 err_exit:
+       nandsim_debugfs_remove(nand);
        free_nandsim(nand);
        nand_release(nsmtd);
        for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)
index d0b6f8f9f297ab89f355a727c333de1c5a2f7fc8..6abd142b13246f1189e189c03d3ff499665c1b0b 100644 (file)
@@ -1728,6 +1728,10 @@ static int sunxi_nfc_setup_data_interface(struct mtd_info *mtd, int csline,
         */
        chip->clk_rate = NSEC_PER_SEC / min_clk_period;
        real_clk_rate = clk_round_rate(nfc->mod_clk, chip->clk_rate);
+       if (real_clk_rate <= 0) {
+               dev_err(nfc->dev, "Unable to round clk %lu\n", chip->clk_rate);
+               return -EINVAL;
+       }
 
        /*
         * ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data
index 9bee6c1c70cca33941ae8db8002d69e760693bac..fc63992ab0e0ad3300aa9a8d991fc107788ae780 100644 (file)
@@ -1569,7 +1569,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        new_slave->delay = 0;
        new_slave->link_failure_count = 0;
 
-       if (bond_update_speed_duplex(new_slave))
+       if (bond_update_speed_duplex(new_slave) &&
+           bond_needs_speed_duplex(bond))
                new_slave->link = BOND_LINK_DOWN;
 
        new_slave->last_rx = jiffies -
@@ -2140,11 +2141,13 @@ static void bond_miimon_commit(struct bonding *bond)
                        continue;
 
                case BOND_LINK_UP:
-                       if (bond_update_speed_duplex(slave)) {
+                       if (bond_update_speed_duplex(slave) &&
+                           bond_needs_speed_duplex(bond)) {
                                slave->link = BOND_LINK_DOWN;
-                               netdev_warn(bond->dev,
-                                           "failed to get link speed/duplex for %s\n",
-                                           slave->dev->name);
+                               if (net_ratelimit())
+                                       netdev_warn(bond->dev,
+                                                   "failed to get link speed/duplex for %s\n",
+                                                   slave->dev->name);
                                continue;
                        }
                        bond_set_slave_link_state(slave, BOND_LINK_UP,
index 648f91b58d1e260a71de7db12dc39627bc40a35c..9b6ce7c3f6c3228c88fced286a31c3be0c19900f 100644 (file)
@@ -1048,6 +1048,7 @@ struct bcm_sf2_of_data {
        u32 type;
        const u16 *reg_offsets;
        unsigned int core_reg_align;
+       unsigned int num_cfp_rules;
 };
 
 /* Register offsets for the SWITCH_REG_* block */
@@ -1071,6 +1072,7 @@ static const struct bcm_sf2_of_data bcm_sf2_7445_data = {
        .type           = BCM7445_DEVICE_ID,
        .core_reg_align = 0,
        .reg_offsets    = bcm_sf2_7445_reg_offsets,
+       .num_cfp_rules  = 256,
 };
 
 static const u16 bcm_sf2_7278_reg_offsets[] = {
@@ -1093,6 +1095,7 @@ static const struct bcm_sf2_of_data bcm_sf2_7278_data = {
        .type           = BCM7278_DEVICE_ID,
        .core_reg_align = 1,
        .reg_offsets    = bcm_sf2_7278_reg_offsets,
+       .num_cfp_rules  = 128,
 };
 
 static const struct of_device_id bcm_sf2_of_match[] = {
@@ -1149,6 +1152,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
        priv->type = data->type;
        priv->reg_offsets = data->reg_offsets;
        priv->core_reg_align = data->core_reg_align;
+       priv->num_cfp_rules = data->num_cfp_rules;
 
        /* Auto-detection using standard registers will not work, so
         * provide an indication of what kind of device we are for
index 7d3030e04f1127bcfd8e98d32d0b0837093f52da..7f9125eef3df42038fdce368d4a5fe2690d3276c 100644 (file)
@@ -72,6 +72,7 @@ struct bcm_sf2_priv {
        u32                             type;
        const u16                       *reg_offsets;
        unsigned int                    core_reg_align;
+       unsigned int                    num_cfp_rules;
 
        /* spinlock protecting access to the indirect registers */
        spinlock_t                      indir_lock;
index 2fb32d67065f8aa164b3ea03d5cb914120c4e0c6..8a1da7e677070d33571748c2b511d4e38169324f 100644 (file)
@@ -98,7 +98,7 @@ static inline void bcm_sf2_cfp_rule_addr_set(struct bcm_sf2_priv *priv,
 {
        u32 reg;
 
-       WARN_ON(addr >= CFP_NUM_RULES);
+       WARN_ON(addr >= priv->num_cfp_rules);
 
        reg = core_readl(priv, CORE_CFP_ACC);
        reg &= ~(XCESS_ADDR_MASK << XCESS_ADDR_SHIFT);
@@ -109,7 +109,7 @@ static inline void bcm_sf2_cfp_rule_addr_set(struct bcm_sf2_priv *priv,
 static inline unsigned int bcm_sf2_cfp_rule_size(struct bcm_sf2_priv *priv)
 {
        /* Entry #0 is reserved */
-       return CFP_NUM_RULES - 1;
+       return priv->num_cfp_rules - 1;
 }
 
 static int bcm_sf2_cfp_rule_set(struct dsa_switch *ds, int port,
@@ -523,7 +523,7 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv,
                if (!(reg & OP_STR_DONE))
                        break;
 
-       } while (index < CFP_NUM_RULES);
+       } while (index < priv->num_cfp_rules);
 
        /* Put the TCAM size here */
        nfc->data = bcm_sf2_cfp_rule_size(priv);
@@ -544,7 +544,7 @@ int bcm_sf2_get_rxnfc(struct dsa_switch *ds, int port,
        case ETHTOOL_GRXCLSRLCNT:
                /* Subtract the default, unusable rule */
                nfc->rule_cnt = bitmap_weight(priv->cfp.used,
-                                             CFP_NUM_RULES) - 1;
+                                             priv->num_cfp_rules) - 1;
                /* We support specifying rule locations */
                nfc->data |= RX_CLS_LOC_SPECIAL;
                break;
index 1e46418a3b74c3f351068fd6d1a3b3b5168e8ab2..264b281eb86bf1b52abb88ef67c2ce7143ba6024 100644 (file)
@@ -625,6 +625,44 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int port,
                 * all finished.
                 */
                mt7623_pad_clk_setup(ds);
+       } else {
+               u16 lcl_adv = 0, rmt_adv = 0;
+               u8 flowctrl;
+               u32 mcr = PMCR_USERP_LINK | PMCR_FORCE_MODE;
+
+               switch (phydev->speed) {
+               case SPEED_1000:
+                       mcr |= PMCR_FORCE_SPEED_1000;
+                       break;
+               case SPEED_100:
+                       mcr |= PMCR_FORCE_SPEED_100;
+                       break;
+               };
+
+               if (phydev->link)
+                       mcr |= PMCR_FORCE_LNK;
+
+               if (phydev->duplex) {
+                       mcr |= PMCR_FORCE_FDX;
+
+                       if (phydev->pause)
+                               rmt_adv = LPA_PAUSE_CAP;
+                       if (phydev->asym_pause)
+                               rmt_adv |= LPA_PAUSE_ASYM;
+
+                       if (phydev->advertising & ADVERTISED_Pause)
+                               lcl_adv |= ADVERTISE_PAUSE_CAP;
+                       if (phydev->advertising & ADVERTISED_Asym_Pause)
+                               lcl_adv |= ADVERTISE_PAUSE_ASYM;
+
+                       flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
+
+                       if (flowctrl & FLOW_CTRL_TX)
+                               mcr |= PMCR_TX_FC_EN;
+                       if (flowctrl & FLOW_CTRL_RX)
+                               mcr |= PMCR_RX_FC_EN;
+               }
+               mt7530_write(priv, MT7530_PMCR_P(port), mcr);
        }
 }
 
index b83d76b998023c38c9e67b90ca73e393f7d29fc4..74db9822eb40437a92bc21ace75971df48c1bfa4 100644 (file)
@@ -151,6 +151,7 @@ enum mt7530_stp_state {
 #define  PMCR_TX_FC_EN                 BIT(5)
 #define  PMCR_RX_FC_EN                 BIT(4)
 #define  PMCR_FORCE_SPEED_1000         BIT(3)
+#define  PMCR_FORCE_SPEED_100          BIT(2)
 #define  PMCR_FORCE_FDX                        BIT(1)
 #define  PMCR_FORCE_LNK                        BIT(0)
 #define  PMCR_COMMON_LINK              (PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | \
index 86058a9f3417bc59613cb9c019638dc8a85a9731..6e253d913fe29df271ebae8726bbd5062d41ccb3 100644 (file)
@@ -1661,21 +1661,21 @@ static int xgene_enet_get_irqs(struct xgene_enet_pdata *pdata)
        return 0;
 }
 
-static int xgene_enet_check_phy_handle(struct xgene_enet_pdata *pdata)
+static void xgene_enet_check_phy_handle(struct xgene_enet_pdata *pdata)
 {
        int ret;
 
        if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII)
-               return 0;
+               return;
 
        if (!IS_ENABLED(CONFIG_MDIO_XGENE))
-               return 0;
+               return;
 
        ret = xgene_enet_phy_connect(pdata->ndev);
        if (!ret)
                pdata->mdio_driver = true;
 
-       return 0;
+       return;
 }
 
 static void xgene_enet_gpiod_get(struct xgene_enet_pdata *pdata)
@@ -1779,15 +1779,11 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
        if (ret)
                return ret;
 
-       ret = xgene_enet_check_phy_handle(pdata);
-       if (ret)
-               return ret;
-
        xgene_enet_gpiod_get(pdata);
 
-       if (pdata->phy_mode != PHY_INTERFACE_MODE_SGMII) {
-               pdata->clk = devm_clk_get(&pdev->dev, NULL);
-               if (IS_ERR(pdata->clk)) {
+       pdata->clk = devm_clk_get(&pdev->dev, NULL);
+       if (IS_ERR(pdata->clk)) {
+               if (pdata->phy_mode != PHY_INTERFACE_MODE_SGMII) {
                        /* Abort if the clock is defined but couldn't be
                         * retrived. Always abort if the clock is missing on
                         * DT system as the driver can't cope with this case.
@@ -2097,9 +2093,11 @@ static int xgene_enet_probe(struct platform_device *pdev)
                goto err;
        }
 
+       xgene_enet_check_phy_handle(pdata);
+
        ret = xgene_enet_init_hw(pdata);
        if (ret)
-               goto err;
+               goto err2;
 
        link_state = pdata->mac_ops->link_state;
        if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) {
@@ -2117,29 +2115,30 @@ static int xgene_enet_probe(struct platform_device *pdev)
        spin_lock_init(&pdata->stats_lock);
        ret = xgene_extd_stats_init(pdata);
        if (ret)
-               goto err2;
+               goto err1;
 
        xgene_enet_napi_add(pdata);
        ret = register_netdev(ndev);
        if (ret) {
                netdev_err(ndev, "Failed to register netdev\n");
-               goto err2;
+               goto err1;
        }
 
        return 0;
 
-err2:
+err1:
        /*
         * If necessary, free_netdev() will call netif_napi_del() and undo
         * the effects of xgene_enet_napi_add()'s calls to netif_napi_add().
         */
 
+       xgene_enet_delete_desc_rings(pdata);
+
+err2:
        if (pdata->mdio_driver)
                xgene_enet_phy_disconnect(pdata);
        else if (phy_interface_mode_is_rgmii(pdata->phy_mode))
                xgene_enet_mdio_remove(pdata);
-err1:
-       xgene_enet_delete_desc_rings(pdata);
 err:
        free_netdev(ndev);
        return ret;
index fce0fd3f23ff251ae60392575f1c51bee4d88681..bf9b3f020e106cb07fd7630073f146d7f54ccfa9 100644 (file)
@@ -105,8 +105,7 @@ struct aq_hw_ops {
 
        int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
 
-       int (*hw_get_link_status)(struct aq_hw_s *self,
-                                 struct aq_hw_link_status_s *link_status);
+       int (*hw_get_link_status)(struct aq_hw_s *self);
 
        int (*hw_set_link_speed)(struct aq_hw_s *self, u32 speed);
 
index 9ee1c501678409719f460912c6316b803c2dc7fc..6ac9e2602d6d8ea1fefd0de613ee633b905cbd8b 100644 (file)
@@ -103,6 +103,8 @@ int aq_nic_cfg_start(struct aq_nic_s *self)
        else
                cfg->vecs = 1U;
 
+       cfg->num_rss_queues = min(cfg->vecs, AQ_CFG_NUM_RSS_QUEUES_DEF);
+
        cfg->irq_type = aq_pci_func_get_irq_type(self->aq_pci_func);
 
        if ((cfg->irq_type == AQ_HW_IRQ_LEGACY) ||
@@ -123,33 +125,30 @@ static void aq_nic_service_timer_cb(unsigned long param)
        struct net_device *ndev = aq_nic_get_ndev(self);
        int err = 0;
        unsigned int i = 0U;
-       struct aq_hw_link_status_s link_status;
        struct aq_ring_stats_rx_s stats_rx;
        struct aq_ring_stats_tx_s stats_tx;
 
        if (aq_utils_obj_test(&self->header.flags, AQ_NIC_FLAGS_IS_NOT_READY))
                goto err_exit;
 
-       err = self->aq_hw_ops.hw_get_link_status(self->aq_hw, &link_status);
+       err = self->aq_hw_ops.hw_get_link_status(self->aq_hw);
        if (err < 0)
                goto err_exit;
 
-       self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw,
-                           self->aq_nic_cfg.is_interrupt_moderation);
-
-       if (memcmp(&link_status, &self->link_status, sizeof(link_status))) {
-               if (link_status.mbps) {
-                       aq_utils_obj_set(&self->header.flags,
-                                        AQ_NIC_FLAG_STARTED);
-                       aq_utils_obj_clear(&self->header.flags,
-                                          AQ_NIC_LINK_DOWN);
-                       netif_carrier_on(self->ndev);
-               } else {
-                       netif_carrier_off(self->ndev);
-                       aq_utils_obj_set(&self->header.flags, AQ_NIC_LINK_DOWN);
-               }
+       self->link_status = self->aq_hw->aq_link_status;
 
-               self->link_status = link_status;
+       self->aq_hw_ops.hw_interrupt_moderation_set(self->aq_hw,
+                   self->aq_nic_cfg.is_interrupt_moderation);
+
+       if (self->link_status.mbps) {
+               aq_utils_obj_set(&self->header.flags,
+                                AQ_NIC_FLAG_STARTED);
+               aq_utils_obj_clear(&self->header.flags,
+                                  AQ_NIC_LINK_DOWN);
+               netif_carrier_on(self->ndev);
+       } else {
+               netif_carrier_off(self->ndev);
+               aq_utils_obj_set(&self->header.flags, AQ_NIC_LINK_DOWN);
        }
 
        memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s));
@@ -597,14 +596,11 @@ exit:
 }
 
 int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb)
-__releases(&ring->lock)
-__acquires(&ring->lock)
 {
        struct aq_ring_s *ring = NULL;
        unsigned int frags = 0U;
        unsigned int vec = skb->queue_mapping % self->aq_nic_cfg.vecs;
        unsigned int tc = 0U;
-       unsigned int trys = AQ_CFG_LOCK_TRYS;
        int err = NETDEV_TX_OK;
        bool is_nic_in_bad_state;
 
@@ -628,36 +624,21 @@ __acquires(&ring->lock)
                goto err_exit;
        }
 
-       do {
-               if (spin_trylock(&ring->header.lock)) {
-                       frags = aq_nic_map_skb(self, skb, ring);
-
-                       if (likely(frags)) {
-                               err = self->aq_hw_ops.hw_ring_tx_xmit(
-                                                               self->aq_hw,
-                                                               ring, frags);
-                               if (err >= 0) {
-                                       if (aq_ring_avail_dx(ring) <
-                                           AQ_CFG_SKB_FRAGS_MAX + 1)
-                                               aq_nic_ndev_queue_stop(
-                                                               self,
-                                                               ring->idx);
-
-                                       ++ring->stats.tx.packets;
-                                       ring->stats.tx.bytes += skb->len;
-                               }
-                       } else {
-                               err = NETDEV_TX_BUSY;
-                       }
+       frags = aq_nic_map_skb(self, skb, ring);
 
-                       spin_unlock(&ring->header.lock);
-                       break;
-               }
-       } while (--trys);
+       if (likely(frags)) {
+               err = self->aq_hw_ops.hw_ring_tx_xmit(self->aq_hw,
+                                                     ring,
+                                                     frags);
+               if (err >= 0) {
+                       if (aq_ring_avail_dx(ring) < AQ_CFG_SKB_FRAGS_MAX + 1)
+                               aq_nic_ndev_queue_stop(self, ring->idx);
 
-       if (!trys) {
+                       ++ring->stats.tx.packets;
+                       ring->stats.tx.bytes += skb->len;
+               }
+       } else {
                err = NETDEV_TX_BUSY;
-               goto err_exit;
        }
 
 err_exit:
@@ -688,11 +669,26 @@ int aq_nic_set_multicast_list(struct aq_nic_s *self, struct net_device *ndev)
        netdev_for_each_mc_addr(ha, ndev) {
                ether_addr_copy(self->mc_list.ar[i++], ha->addr);
                ++self->mc_list.count;
+
+               if (i >= AQ_CFG_MULTICAST_ADDRESS_MAX)
+                       break;
        }
 
-       return self->aq_hw_ops.hw_multicast_list_set(self->aq_hw,
+       if (i >= AQ_CFG_MULTICAST_ADDRESS_MAX) {
+               /* Number of filters is too big: atlantic does not support this.
+                * Force all multi filter to support this.
+                * With this we disable all UC filters and setup "all pass"
+                * multicast mask
+                */
+               self->packet_filter |= IFF_ALLMULTI;
+               self->aq_hw->aq_nic_cfg->mc_list_count = 0;
+               return self->aq_hw_ops.hw_packet_filter_set(self->aq_hw,
+                                                       self->packet_filter);
+       } else {
+               return self->aq_hw_ops.hw_multicast_list_set(self->aq_hw,
                                                    self->mc_list.ar,
                                                    self->mc_list.count);
+       }
 }
 
 int aq_nic_set_mtu(struct aq_nic_s *self, int new_mtu)
index 9a0817938eca38526e4c746680efe2845e9b1e51..ec5579fb8268b29c6040f524fe20495b43fa617d 100644 (file)
@@ -101,7 +101,6 @@ int aq_ring_init(struct aq_ring_s *self)
        self->hw_head = 0;
        self->sw_head = 0;
        self->sw_tail = 0;
-       spin_lock_init(&self->header.lock);
        return 0;
 }
 
index f6012b34abe690471e3e317ccf3731e3f45506fc..e12bcdfb874a4409f8ccec886f626b19b48b2b52 100644 (file)
@@ -17,7 +17,6 @@
 #define AQ_DIMOF(_ARY_)  ARRAY_SIZE(_ARY_)
 
 struct aq_obj_s {
-       spinlock_t lock; /* spinlock for nic/rings processing */
        atomic_t flags;
 };
 
index ad5b4d4dac7f6c7a5626ce5b86b9ca6d1a37f012..fee446af748ff1a64a984cf4b5ec12dce46471d1 100644 (file)
@@ -34,8 +34,6 @@ struct aq_vec_s {
 #define AQ_VEC_RX_ID 1
 
 static int aq_vec_poll(struct napi_struct *napi, int budget)
-__releases(&self->lock)
-__acquires(&self->lock)
 {
        struct aq_vec_s *self = container_of(napi, struct aq_vec_s, napi);
        struct aq_ring_s *ring = NULL;
@@ -47,7 +45,7 @@ __acquires(&self->lock)
 
        if (!self) {
                err = -EINVAL;
-       } else if (spin_trylock(&self->header.lock)) {
+       } else {
                for (i = 0U, ring = self->ring[0];
                        self->tx_rings > i; ++i, ring = self->ring[i]) {
                        if (self->aq_hw_ops->hw_ring_tx_head_update) {
@@ -105,11 +103,8 @@ __acquires(&self->lock)
                        self->aq_hw_ops->hw_irq_enable(self->aq_hw,
                                        1U << self->aq_ring_param.vec_idx);
                }
-
-err_exit:
-               spin_unlock(&self->header.lock);
        }
-
+err_exit:
        return work_done;
 }
 
@@ -185,8 +180,6 @@ int aq_vec_init(struct aq_vec_s *self, struct aq_hw_ops *aq_hw_ops,
        self->aq_hw_ops = aq_hw_ops;
        self->aq_hw = aq_hw;
 
-       spin_lock_init(&self->header.lock);
-
        for (i = 0U, ring = self->ring[0];
                self->tx_rings > i; ++i, ring = self->ring[i]) {
                err = aq_ring_init(&ring[AQ_VEC_TX_ID]);
index faeb4935ef3e3af5c998ef701e1e7cd2f5d739c8..c5a02df7a48b719a65b169938746d777f3f0b5a0 100644 (file)
@@ -629,6 +629,12 @@ static int hw_atl_a0_hw_ring_rx_receive(struct aq_hw_s *self,
                                buff->is_udp_cso = (is_err & 0x10U) ? 0 : 1;
                        else if (0x0U == (pkt_type & 0x1CU))
                                buff->is_tcp_cso = (is_err & 0x10U) ? 0 : 1;
+
+                       /* Checksum offload workaround for small packets */
+                       if (rxd_wb->pkt_len <= 60) {
+                               buff->is_ip_cso = 0U;
+                               buff->is_cso_err = 0U;
+                       }
                }
 
                is_err &= ~0x18U;
index 1bceb7358e5ca3a4455badf55bc091d3705dc89d..21784cc39dabdb9005a0c4bff26c64b0ac7a5286 100644 (file)
@@ -645,6 +645,12 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self,
                                buff->is_udp_cso = buff->is_cso_err ? 0U : 1U;
                        else if (0x0U == (pkt_type & 0x1CU))
                                buff->is_tcp_cso = buff->is_cso_err ? 0U : 1U;
+
+                       /* Checksum offload workaround for small packets */
+                       if (rxd_wb->pkt_len <= 60) {
+                               buff->is_ip_cso = 0U;
+                               buff->is_cso_err = 0U;
+                       }
                }
 
                is_err &= ~0x18U;
index 8d6d8f5804daf2f431f0c93fcc8e4a2a7a1983ee..4f5ec9a0fbfb82b7bcf25fb234c5d6c3180c544a 100644 (file)
@@ -141,6 +141,12 @@ static int hw_atl_utils_init_ucp(struct aq_hw_s *self,
 
        err = hw_atl_utils_ver_match(aq_hw_caps->fw_ver_expected,
                                     aq_hw_read_reg(self, 0x18U));
+
+       if (err < 0)
+               pr_err("%s: Bad FW version detected: expected=%x, actual=%x\n",
+                      AQ_CFG_DRV_NAME,
+                      aq_hw_caps->fw_ver_expected,
+                      aq_hw_read_reg(self, 0x18U));
        return err;
 }
 
@@ -313,11 +319,11 @@ void hw_atl_utils_mpi_set(struct aq_hw_s *self,
 err_exit:;
 }
 
-int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self,
-                                    struct aq_hw_link_status_s *link_status)
+int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self)
 {
        u32 cp0x036C = aq_hw_read_reg(self, HW_ATL_MPI_STATE_ADR);
        u32 link_speed_mask = cp0x036C >> HW_ATL_MPI_SPEED_SHIFT;
+       struct aq_hw_link_status_s *link_status = &self->aq_link_status;
 
        if (!link_speed_mask) {
                link_status->mbps = 0U;
index a66aee51ab5b049c4e9f6367aebdd57cbbf5fc5a..e0360a6b2202ef5b4ac683a44edcde9bf20ebedc 100644 (file)
@@ -180,8 +180,7 @@ void hw_atl_utils_mpi_set(struct aq_hw_s *self,
 int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed,
                               enum hal_atl_utils_fw_state_e state);
 
-int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self,
-                                    struct aq_hw_link_status_s *link_status);
+int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self);
 
 int hw_atl_utils_get_mac_permanent(struct aq_hw_s *self,
                                   struct aq_hw_caps_s *aq_hw_caps,
index f411936b744cb1fa4d331f7b439a181916fa118e..a1125d10c8255f6eb8fbb6046b09473c35ba52b8 100644 (file)
@@ -2368,6 +2368,7 @@ static int b44_init_one(struct ssb_device *sdev,
        bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);
 
        spin_lock_init(&bp->lock);
+       u64_stats_init(&bp->hw_stats.syncp);
 
        bp->rx_pending = B44_DEF_RX_RING_PENDING;
        bp->tx_pending = B44_DEF_TX_RING_PENDING;
index 5333601f855f88529c04e003eae5e3d19aa59f6d..c28fa5a8734cbc769adc16dfc5e36a8cd13b35cb 100644 (file)
@@ -449,6 +449,10 @@ static void bcm_sysport_get_stats(struct net_device *dev,
                        p = (char *)&dev->stats;
                else
                        p = (char *)priv;
+
+               if (priv->is_lite && !bcm_sysport_lite_stat_valid(s->type))
+                       continue;
+
                p += s->stat_offset;
                data[j] = *(unsigned long *)p;
                j++;
@@ -593,7 +597,7 @@ static int bcm_sysport_set_coalesce(struct net_device *dev,
 
 static void bcm_sysport_free_cb(struct bcm_sysport_cb *cb)
 {
-       dev_kfree_skb_any(cb->skb);
+       dev_consume_skb_any(cb->skb);
        cb->skb = NULL;
        dma_unmap_addr_set(cb, dma_addr, 0);
 }
@@ -1342,6 +1346,8 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,
 
        ring->cbs = kcalloc(size, sizeof(struct bcm_sysport_cb), GFP_KERNEL);
        if (!ring->cbs) {
+               dma_free_coherent(kdev, sizeof(struct dma_desc),
+                                 ring->desc_cpu, ring->desc_dma);
                netif_err(priv, hw, priv->netdev, "CB allocation failed\n");
                return -ENOMEM;
        }
index e7c8539cbddf6704720a4a11f5e09aebec066066..f20b3d2a4c2330543f64eee1334ae4e543317f9c 100644 (file)
@@ -4647,7 +4647,6 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
                pf->port_id = le16_to_cpu(resp->port_id);
                bp->dev->dev_port = pf->port_id;
                memcpy(pf->mac_addr, resp->mac_address, ETH_ALEN);
-               memcpy(bp->dev->dev_addr, pf->mac_addr, ETH_ALEN);
                pf->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx);
                pf->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings);
                pf->max_tx_rings = le16_to_cpu(resp->max_tx_rings);
@@ -4687,16 +4686,6 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)
                vf->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx);
 
                memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN);
-               mutex_unlock(&bp->hwrm_cmd_lock);
-
-               if (is_valid_ether_addr(vf->mac_addr)) {
-                       /* overwrite netdev dev_adr with admin VF MAC */
-                       memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
-               } else {
-                       eth_hw_addr_random(bp->dev);
-                       rc = bnxt_approve_mac(bp, bp->dev->dev_addr);
-               }
-               return rc;
 #endif
        }
 
@@ -7152,6 +7141,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
                bp->tx_nr_rings = bp->tx_nr_rings_per_tc;
                netdev_reset_tc(dev);
        }
+       bp->tx_nr_rings += bp->tx_nr_rings_xdp;
        bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
                               bp->tx_nr_rings + bp->rx_nr_rings;
        bp->num_stat_ctxs = bp->cp_nr_rings;
@@ -7661,6 +7651,28 @@ void bnxt_restore_pf_fw_resources(struct bnxt *bp)
        bnxt_subtract_ulp_resources(bp, BNXT_ROCE_ULP);
 }
 
+static int bnxt_init_mac_addr(struct bnxt *bp)
+{
+       int rc = 0;
+
+       if (BNXT_PF(bp)) {
+               memcpy(bp->dev->dev_addr, bp->pf.mac_addr, ETH_ALEN);
+       } else {
+#ifdef CONFIG_BNXT_SRIOV
+               struct bnxt_vf_info *vf = &bp->vf;
+
+               if (is_valid_ether_addr(vf->mac_addr)) {
+                       /* overwrite netdev dev_adr with admin VF MAC */
+                       memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
+               } else {
+                       eth_hw_addr_random(bp->dev);
+                       rc = bnxt_approve_mac(bp, bp->dev->dev_addr);
+               }
+#endif
+       }
+       return rc;
+}
+
 static void bnxt_parse_log_pcie_link(struct bnxt *bp)
 {
        enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
@@ -7789,7 +7801,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                rc = -1;
                goto init_err_pci_clean;
        }
-
+       rc = bnxt_init_mac_addr(bp);
+       if (rc) {
+               dev_err(&pdev->dev, "Unable to initialize mac address.\n");
+               rc = -EADDRNOTAVAIL;
+               goto init_err_pci_clean;
+       }
        rc = bnxt_hwrm_queue_qportcfg(bp);
        if (rc) {
                netdev_err(bp->dev, "hwrm query qportcfg failure rc: %x\n",
index 77da75a55c0200edf5229d1dd88939473f85194c..997e10e8b863cc74387016d9de9fbe9bbba5b9b3 100644 (file)
@@ -84,6 +84,8 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, int ulp_id)
 
                max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
                bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs + 1);
+               if (ulp->msix_requested)
+                       edev->en_ops->bnxt_free_msix(edev, ulp_id);
        }
        if (ulp->max_async_event_id)
                bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0);
index a981c4ee9d72deab705231088043e8690853d563..fea3f9a5fb2d37221cbf9abed77cdcdcf906a00c 100644 (file)
@@ -1360,7 +1360,7 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev,
                if (skb) {
                        pkts_compl++;
                        bytes_compl += GENET_CB(skb)->bytes_sent;
-                       dev_kfree_skb_any(skb);
+                       dev_consume_skb_any(skb);
                }
 
                txbds_processed++;
@@ -1875,7 +1875,7 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv,
                cb = ring->cbs + i;
                skb = bcmgenet_rx_refill(priv, cb);
                if (skb)
-                       dev_kfree_skb_any(skb);
+                       dev_consume_skb_any(skb);
                if (!cb->skb)
                        return -ENOMEM;
        }
@@ -1894,7 +1894,7 @@ static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv)
 
                skb = bcmgenet_free_rx_cb(&priv->pdev->dev, cb);
                if (skb)
-                       dev_kfree_skb_any(skb);
+                       dev_consume_skb_any(skb);
        }
 }
 
index ef4be781fd054696edac7c494cf713f0dd5f3d4e..09ea62ee96d38b3d99bb48cbd0f72dcc715f8315 100644 (file)
@@ -529,6 +529,7 @@ enum {                                 /* adapter flags */
        USING_SOFT_PARAMS  = (1 << 6),
        MASTER_PF          = (1 << 7),
        FW_OFLD_CONN       = (1 << 9),
+       ROOT_NO_RELAXED_ORDERING = (1 << 10),
 };
 
 enum {
index e403fa18f1b15e570748b2136ae1bf8b54d14afb..33bb8678833adc6f83551d992f201f6314e68762 100644 (file)
@@ -4654,11 +4654,6 @@ static void print_port_info(const struct net_device *dev)
                    dev->name, adap->params.vpd.id, adap->name, buf);
 }
 
-static void enable_pcie_relaxed_ordering(struct pci_dev *dev)
-{
-       pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN);
-}
-
 /*
  * Free the following resources:
  * - memory used for tables
@@ -4908,7 +4903,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        pci_enable_pcie_error_reporting(pdev);
-       enable_pcie_relaxed_ordering(pdev);
        pci_set_master(pdev);
        pci_save_state(pdev);
 
@@ -4947,6 +4941,23 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        adapter->msg_enable = DFLT_MSG_ENABLE;
        memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
 
+       /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
+        * Ingress Packet Data to Free List Buffers in order to allow for
+        * chipset performance optimizations between the Root Complex and
+        * Memory Controllers.  (Messages to the associated Ingress Queue
+        * notifying new Packet Placement in the Free Lists Buffers will be
+        * send without the Relaxed Ordering Attribute thus guaranteeing that
+        * all preceding PCIe Transaction Layer Packets will be processed
+        * first.)  But some Root Complexes have various issues with Upstream
+        * Transaction Layer Packets with the Relaxed Ordering Attribute set.
+        * The PCIe devices which under the Root Complexes will be cleared the
+        * Relaxed Ordering bit in the configuration space, So we check our
+        * PCIe configuration space to see if it's flagged with advice against
+        * using Relaxed Ordering.
+        */
+       if (!pcie_relaxed_ordering_enabled(pdev))
+               adapter->flags |= ROOT_NO_RELAXED_ORDERING;
+
        spin_lock_init(&adapter->stats_lock);
        spin_lock_init(&adapter->tid_release_lock);
        spin_lock_init(&adapter->win0_lock);
index ede12209f20be4573a5464de9e7f7a0da0088c31..4ef68f69b58c45322d65f414e06d068ade4ab22d 100644 (file)
@@ -2719,6 +2719,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
        struct fw_iq_cmd c;
        struct sge *s = &adap->sge;
        struct port_info *pi = netdev_priv(dev);
+       int relaxed = !(adap->flags & ROOT_NO_RELAXED_ORDERING);
 
        /* Size needs to be multiple of 16, including status entry. */
        iq->size = roundup(iq->size, 16);
@@ -2772,8 +2773,8 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 
                flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc);
                c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F |
-                                            FW_IQ_CMD_FL0FETCHRO_F |
-                                            FW_IQ_CMD_FL0DATARO_F |
+                                            FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
+                                            FW_IQ_CMD_FL0DATARO_V(relaxed) |
                                             FW_IQ_CMD_FL0PADEN_F);
                if (cong >= 0)
                        c.iqns_to_fl0congen |=
index 82bf7aac6cdbda6431d1bfdd715ce1a56b2763af..0293b41171a5d90070c2ff9a954e1dd0e42aea4d 100644 (file)
@@ -369,12 +369,12 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
                list_del(&entry.list);
                spin_unlock(&adap->mbox_lock);
                ret = (v == MBOX_OWNER_FW) ? -EBUSY : -ETIMEDOUT;
-               t4_record_mbox(adap, cmd, MBOX_LEN, access, ret);
+               t4_record_mbox(adap, cmd, size, access, ret);
                return ret;
        }
 
        /* Copy in the new mailbox command and send it on its way ... */
-       t4_record_mbox(adap, cmd, MBOX_LEN, access, 0);
+       t4_record_mbox(adap, cmd, size, access, 0);
        for (i = 0; i < size; i += 8)
                t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p++));
 
@@ -426,7 +426,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
        }
 
        ret = (pcie_fw & PCIE_FW_ERR_F) ? -ENXIO : -ETIMEDOUT;
-       t4_record_mbox(adap, cmd, MBOX_LEN, access, ret);
+       t4_record_mbox(adap, cmd, size, access, ret);
        dev_err(adap->pdev_dev, "command %#x in mailbox %d timed out\n",
                *(const u8 *)cmd, mbox);
        t4_report_fw_error(adap);
index 109bc630408b65b1dc67cedbaab00ce0601d2574..08c6ddb84a049ecc75f414a968dba78974d5837f 100644 (file)
@@ -408,6 +408,7 @@ enum { /* adapter flags */
        USING_MSI          = (1UL << 1),
        USING_MSIX         = (1UL << 2),
        QUEUES_BOUND       = (1UL << 3),
+       ROOT_NO_RELAXED_ORDERING = (1UL << 4),
 };
 
 /*
index ac7a150c54e9b4e93b751821eb09d80669eecc69..2b85b874fd0d2c96fadb4888b0bd4695628bf611 100644 (file)
@@ -2888,6 +2888,24 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
         */
        adapter->name = pci_name(pdev);
        adapter->msg_enable = DFLT_MSG_ENABLE;
+
+       /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
+        * Ingress Packet Data to Free List Buffers in order to allow for
+        * chipset performance optimizations between the Root Complex and
+        * Memory Controllers.  (Messages to the associated Ingress Queue
+        * notifying new Packet Placement in the Free Lists Buffers will be
+        * send without the Relaxed Ordering Attribute thus guaranteeing that
+        * all preceding PCIe Transaction Layer Packets will be processed
+        * first.)  But some Root Complexes have various issues with Upstream
+        * Transaction Layer Packets with the Relaxed Ordering Attribute set.
+        * The PCIe devices which under the Root Complexes will be cleared the
+        * Relaxed Ordering bit in the configuration space, So we check our
+        * PCIe configuration space to see if it's flagged with advice against
+        * using Relaxed Ordering.
+        */
+       if (!pcie_relaxed_ordering_enabled(pdev))
+               adapter->flags |= ROOT_NO_RELAXED_ORDERING;
+
        err = adap_init0(adapter);
        if (err)
                goto err_unmap_bar;
index e37dde2ba97f6d529177d475be2a6d001071de0b..05498e7f284034d86a8f8531de95cf7f59ec4890 100644 (file)
@@ -2205,6 +2205,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
        struct port_info *pi = netdev_priv(dev);
        struct fw_iq_cmd cmd, rpl;
        int ret, iqandst, flsz = 0;
+       int relaxed = !(adapter->flags & ROOT_NO_RELAXED_ORDERING);
 
        /*
         * If we're using MSI interrupts and we're not initializing the
@@ -2300,6 +2301,8 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
                        cpu_to_be32(
                                FW_IQ_CMD_FL0HOSTFCMODE_V(SGE_HOSTFCMODE_NONE) |
                                FW_IQ_CMD_FL0PACKEN_F |
+                               FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
+                               FW_IQ_CMD_FL0DATARO_V(relaxed) |
                                FW_IQ_CMD_FL0PADEN_F);
 
                /* In T6, for egress queue type FL there is internal overhead
index 34dae51effd45a19c9a2b8b607dafeaec3aa0456..59da7ac3c1087c03f52b514c3fc9b81074284a5e 100644 (file)
@@ -1863,7 +1863,6 @@ err_setup_mdio:
 err_ioremap:
        release_resource(priv->res);
 err_req_mem:
-       netif_napi_del(&priv->napi);
        free_netdev(netdev);
 err_alloc_etherdev:
        return err;
index 6e67d22fd0d54f69e5ee3358717e7ed539fad952..1c7da16ad0ffe5de0bbed64f027ed765daec7464 100644 (file)
@@ -623,6 +623,8 @@ static struct platform_device *dpaa_eth_add_device(int fman_id,
                goto no_mem;
        }
 
+       pdev->dev.of_node = node;
+       pdev->dev.parent = priv->dev;
        set_dma_ops(&pdev->dev, get_dma_ops(priv->dev));
 
        ret = platform_device_add_data(pdev, &data, sizeof(data));
index a3e6946796350d0a3bb79410d1f354a844ab7f60..c45e8e3b82d38da950a7cf1ca72022d120b7947e 100644 (file)
@@ -111,6 +111,7 @@ static void send_request_map(struct ibmvnic_adapter *, dma_addr_t, __be32, u8);
 static void send_request_unmap(struct ibmvnic_adapter *, u8);
 static void send_login(struct ibmvnic_adapter *adapter);
 static void send_cap_queries(struct ibmvnic_adapter *adapter);
+static int init_sub_crqs(struct ibmvnic_adapter *);
 static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter);
 static int ibmvnic_init(struct ibmvnic_adapter *);
 static void release_crq_queue(struct ibmvnic_adapter *);
@@ -651,6 +652,7 @@ static int ibmvnic_login(struct net_device *netdev)
        struct ibmvnic_adapter *adapter = netdev_priv(netdev);
        unsigned long timeout = msecs_to_jiffies(30000);
        struct device *dev = &adapter->vdev->dev;
+       int rc;
 
        do {
                if (adapter->renegotiate) {
@@ -664,6 +666,18 @@ static int ibmvnic_login(struct net_device *netdev)
                                dev_err(dev, "Capabilities query timeout\n");
                                return -1;
                        }
+                       rc = init_sub_crqs(adapter);
+                       if (rc) {
+                               dev_err(dev,
+                                       "Initialization of SCRQ's failed\n");
+                               return -1;
+                       }
+                       rc = init_sub_crq_irqs(adapter);
+                       if (rc) {
+                               dev_err(dev,
+                                       "Initialization of SCRQ's irqs failed\n");
+                               return -1;
+                       }
                }
 
                reinit_completion(&adapter->init_done);
@@ -3004,7 +3018,6 @@ static void handle_request_cap_rsp(union ibmvnic_crq *crq,
                         *req_value,
                         (long int)be64_to_cpu(crq->request_capability_rsp.
                                               number), name);
-               release_sub_crqs(adapter);
                *req_value = be64_to_cpu(crq->request_capability_rsp.number);
                ibmvnic_send_req_caps(adapter, 1);
                return;
index b936febc315a17b3d8db0af05f60938d478edefd..2194960d5855c6576ec03c870479344b099ce12b 100644 (file)
@@ -1113,6 +1113,8 @@ int i40e_setup_tx_descriptors(struct i40e_ring *tx_ring)
        if (!tx_ring->tx_bi)
                goto err;
 
+       u64_stats_init(&tx_ring->syncp);
+
        /* round up to nearest 4K */
        tx_ring->size = tx_ring->count * sizeof(struct i40e_tx_desc);
        /* add u32 for head writeback, align after this takes care of
index 084c5358279319ed6d826aa00f135adb98b7631b..032f8ac06357aefa7a695c6685b8bbbbf7a8949e 100644 (file)
@@ -2988,6 +2988,8 @@ int ixgbevf_setup_tx_resources(struct ixgbevf_ring *tx_ring)
        if (!tx_ring->tx_buffer_info)
                goto err;
 
+       u64_stats_init(&tx_ring->syncp);
+
        /* round up to nearest 4K */
        tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);
        tx_ring->size = ALIGN(tx_ring->size, 4096);
@@ -3046,6 +3048,8 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_ring *rx_ring)
        if (!rx_ring->rx_buffer_info)
                goto err;
 
+       u64_stats_init(&rx_ring->syncp);
+
        /* Round up to nearest 4K */
        rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
        rx_ring->size = ALIGN(rx_ring->size, 4096);
index 48d21c1e09f27b74c67179a82ec3ab5af9b41d6b..4d598ca8503a50952576354ae35f1b3b6a574b6e 100644 (file)
@@ -6504,7 +6504,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
        struct resource *res;
        const char *dt_mac_addr;
        const char *mac_from;
-       char hw_mac_addr[ETH_ALEN];
+       char hw_mac_addr[ETH_ALEN] = {0};
        u32 id;
        int features;
        int phy_mode;
index c751a1d434ad7167e6b65a62f46b7295044860f8..3d4e4a5d00d1c5f81267c4a4a9675bc667709211 100644 (file)
@@ -223,6 +223,7 @@ static void mlx4_en_get_wol(struct net_device *netdev,
                            struct ethtool_wolinfo *wol)
 {
        struct mlx4_en_priv *priv = netdev_priv(netdev);
+       struct mlx4_caps *caps = &priv->mdev->dev->caps;
        int err = 0;
        u64 config = 0;
        u64 mask;
@@ -235,24 +236,24 @@ static void mlx4_en_get_wol(struct net_device *netdev,
        mask = (priv->port == 1) ? MLX4_DEV_CAP_FLAG_WOL_PORT1 :
                MLX4_DEV_CAP_FLAG_WOL_PORT2;
 
-       if (!(priv->mdev->dev->caps.flags & mask)) {
+       if (!(caps->flags & mask)) {
                wol->supported = 0;
                wol->wolopts = 0;
                return;
        }
 
+       if (caps->wol_port[priv->port])
+               wol->supported = WAKE_MAGIC;
+       else
+               wol->supported = 0;
+
        err = mlx4_wol_read(priv->mdev->dev, &config, priv->port);
        if (err) {
                en_err(priv, "Failed to get WoL information\n");
                return;
        }
 
-       if (config & MLX4_EN_WOL_MAGIC)
-               wol->supported = WAKE_MAGIC;
-       else
-               wol->supported = 0;
-
-       if (config & MLX4_EN_WOL_ENABLED)
+       if ((config & MLX4_EN_WOL_ENABLED) && (config & MLX4_EN_WOL_MAGIC))
                wol->wolopts = WAKE_MAGIC;
        else
                wol->wolopts = 0;
index 436f7689a03212943d5ea70a2214774d2c940d97..bf1638044a7a89b6e911b3f5786c75597f89f2ba 100644 (file)
@@ -574,16 +574,21 @@ static inline __wsum get_fixed_vlan_csum(__wsum hw_checksum,
  * header, the HW adds it. To address that, we are subtracting the pseudo
  * header checksum from the checksum value provided by the HW.
  */
-static void get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
-                               struct iphdr *iph)
+static int get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
+                              struct iphdr *iph)
 {
        __u16 length_for_csum = 0;
        __wsum csum_pseudo_header = 0;
+       __u8 ipproto = iph->protocol;
+
+       if (unlikely(ipproto == IPPROTO_SCTP))
+               return -1;
 
        length_for_csum = (be16_to_cpu(iph->tot_len) - (iph->ihl << 2));
        csum_pseudo_header = csum_tcpudp_nofold(iph->saddr, iph->daddr,
-                                               length_for_csum, iph->protocol, 0);
+                                               length_for_csum, ipproto, 0);
        skb->csum = csum_sub(hw_checksum, csum_pseudo_header);
+       return 0;
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
@@ -594,17 +599,20 @@ static void get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
 static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
                               struct ipv6hdr *ipv6h)
 {
+       __u8 nexthdr = ipv6h->nexthdr;
        __wsum csum_pseudo_hdr = 0;
 
-       if (unlikely(ipv6h->nexthdr == IPPROTO_FRAGMENT ||
-                    ipv6h->nexthdr == IPPROTO_HOPOPTS))
+       if (unlikely(nexthdr == IPPROTO_FRAGMENT ||
+                    nexthdr == IPPROTO_HOPOPTS ||
+                    nexthdr == IPPROTO_SCTP))
                return -1;
-       hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(ipv6h->nexthdr));
+       hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(nexthdr));
 
        csum_pseudo_hdr = csum_partial(&ipv6h->saddr,
                                       sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0);
        csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ipv6h->payload_len);
-       csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ntohs(ipv6h->nexthdr));
+       csum_pseudo_hdr = csum_add(csum_pseudo_hdr,
+                                  (__force __wsum)htons(nexthdr));
 
        skb->csum = csum_sub(hw_checksum, csum_pseudo_hdr);
        skb->csum = csum_add(skb->csum, csum_partial(ipv6h, sizeof(struct ipv6hdr), 0));
@@ -627,11 +635,10 @@ static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va,
        }
 
        if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV4))
-               get_fixed_ipv4_csum(hw_checksum, skb, hdr);
+               return get_fixed_ipv4_csum(hw_checksum, skb, hdr);
 #if IS_ENABLED(CONFIG_IPV6)
-       else if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV6))
-               if (unlikely(get_fixed_ipv6_csum(hw_checksum, skb, hdr)))
-                       return -1;
+       if (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPV6))
+               return get_fixed_ipv6_csum(hw_checksum, skb, hdr);
 #endif
        return 0;
 }
index 37e84a59e751d8ad44c34f5a0c7b16337a207c9e..041c0ed6592909a2d7b99cbaa51fc6cc59b7096b 100644 (file)
@@ -159,8 +159,9 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
                [32] = "Loopback source checks support",
                [33] = "RoCEv2 support",
                [34] = "DMFS Sniffer support (UC & MC)",
-               [35] = "QinQ VST mode support",
-               [36] = "sl to vl mapping table change event support"
+               [35] = "Diag counters per port",
+               [36] = "QinQ VST mode support",
+               [37] = "sl to vl mapping table change event support",
        };
        int i;
 
@@ -764,6 +765,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 #define QUERY_DEV_CAP_CQ_TS_SUPPORT_OFFSET     0x3e
 #define QUERY_DEV_CAP_MAX_PKEY_OFFSET          0x3f
 #define QUERY_DEV_CAP_EXT_FLAGS_OFFSET         0x40
+#define QUERY_DEV_CAP_WOL_OFFSET               0x43
 #define QUERY_DEV_CAP_FLAGS_OFFSET             0x44
 #define QUERY_DEV_CAP_RSVD_UAR_OFFSET          0x48
 #define QUERY_DEV_CAP_UAR_SZ_OFFSET            0x49
@@ -920,6 +922,9 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        MLX4_GET(ext_flags, outbox, QUERY_DEV_CAP_EXT_FLAGS_OFFSET);
        MLX4_GET(flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET);
        dev_cap->flags = flags | (u64)ext_flags << 32;
+       MLX4_GET(field, outbox, QUERY_DEV_CAP_WOL_OFFSET);
+       dev_cap->wol_port[1] = !!(field & 0x20);
+       dev_cap->wol_port[2] = !!(field & 0x40);
        MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_UAR_OFFSET);
        dev_cap->reserved_uars = field >> 4;
        MLX4_GET(field, outbox, QUERY_DEV_CAP_UAR_SZ_OFFSET);
index 5343a0599253b98d6f2b9b77b65210a4e1e0abf9..b52ba01aa486a0b492cdb623cbe253c7a2e583d0 100644 (file)
@@ -129,6 +129,7 @@ struct mlx4_dev_cap {
        u32 dmfs_high_rate_qpn_range;
        struct mlx4_rate_limit_caps rl_caps;
        struct mlx4_port_cap port_cap[MLX4_MAX_PORTS + 1];
+       bool wol_port[MLX4_MAX_PORTS + 1];
 };
 
 struct mlx4_func_cap {
index a27c9c13a36ed11d577e7cd9cff1e2a9daec137d..5fe5cdc5135776abb8fd4df748b0948520504b48 100644 (file)
@@ -424,13 +424,15 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        dev->caps.stat_rate_support  = dev_cap->stat_rate_support;
        dev->caps.max_gso_sz         = dev_cap->max_gso_sz;
        dev->caps.max_rss_tbl_sz     = dev_cap->max_rss_tbl_sz;
+       dev->caps.wol_port[1]          = dev_cap->wol_port[1];
+       dev->caps.wol_port[2]          = dev_cap->wol_port[2];
 
        /* Save uar page shift */
        if (!mlx4_is_slave(dev)) {
                /* Virtual PCI function needs to determine UAR page size from
                 * firmware. Only master PCI function can set the uar page size
                 */
-               if (enable_4k_uar)
+               if (enable_4k_uar || !dev->persist->num_vfs)
                        dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT;
                else
                        dev->uar_page_shift = PAGE_SHIFT;
@@ -2275,7 +2277,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
 
                dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1;
 
-               if (enable_4k_uar) {
+               if (enable_4k_uar || !dev->persist->num_vfs) {
                        init_hca.log_uar_sz = ilog2(dev->caps.num_uars) +
                                                    PAGE_SHIFT - DEFAULT_UAR_PAGE_SHIFT;
                        init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12;
index 0039b4725405fcf0a961fa53eab250adc2d51f3c..2f26fb34d7416b88ee8bf7a3464e40837ab90c3c 100644 (file)
@@ -263,6 +263,7 @@ struct mlx5e_dcbx {
 
        /* The only setting that cannot be read from FW */
        u8                         tc_tsa[IEEE_8021QAZ_MAX_TCS];
+       u8                         cap;
 };
 #endif
 
index 2eb54d36e16eac77e3a9d0387758d66b51584bd3..c1d384fca4dc1195a1d0b76677176b7dfcbad538 100644 (file)
@@ -288,13 +288,8 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev,
 static u8 mlx5e_dcbnl_getdcbx(struct net_device *dev)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
-       struct mlx5e_dcbx *dcbx = &priv->dcbx;
-       u8 mode = DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_VER_CEE;
-
-       if (dcbx->mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
-               mode |= DCB_CAP_DCBX_HOST;
 
-       return mode;
+       return priv->dcbx.cap;
 }
 
 static u8 mlx5e_dcbnl_setdcbx(struct net_device *dev, u8 mode)
@@ -312,6 +307,7 @@ static u8 mlx5e_dcbnl_setdcbx(struct net_device *dev, u8 mode)
                /* set dcbx to fw controlled */
                if (!mlx5e_dcbnl_set_dcbx_mode(priv, MLX5E_DCBX_PARAM_VER_OPER_AUTO)) {
                        dcbx->mode = MLX5E_DCBX_PARAM_VER_OPER_AUTO;
+                       dcbx->cap &= ~DCB_CAP_DCBX_HOST;
                        return 0;
                }
 
@@ -324,6 +320,8 @@ static u8 mlx5e_dcbnl_setdcbx(struct net_device *dev, u8 mode)
        if (mlx5e_dcbnl_switch_to_host_mode(netdev_priv(dev)))
                return 1;
 
+       dcbx->cap = mode;
+
        return 0;
 }
 
@@ -628,9 +626,9 @@ static u8 mlx5e_dcbnl_getcap(struct net_device *netdev,
                *cap = false;
                break;
        case DCB_CAP_ATTR_DCBX:
-               *cap = (DCB_CAP_DCBX_LLD_MANAGED |
-                       DCB_CAP_DCBX_VER_CEE |
-                       DCB_CAP_DCBX_STATIC);
+               *cap = priv->dcbx.cap |
+                      DCB_CAP_DCBX_VER_CEE |
+                      DCB_CAP_DCBX_VER_IEEE;
                break;
        default:
                *cap = 0;
@@ -754,8 +752,16 @@ void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv)
 {
        struct mlx5e_dcbx *dcbx = &priv->dcbx;
 
+       if (!MLX5_CAP_GEN(priv->mdev, qos))
+               return;
+
        if (MLX5_CAP_GEN(priv->mdev, dcbx))
                mlx5e_dcbnl_query_dcbx_mode(priv, &dcbx->mode);
 
+       priv->dcbx.cap = DCB_CAP_DCBX_VER_CEE |
+                        DCB_CAP_DCBX_VER_IEEE;
+       if (priv->dcbx.mode == MLX5E_DCBX_PARAM_VER_OPER_HOST)
+               priv->dcbx.cap |= DCB_CAP_DCBX_HOST;
+
        mlx5e_ets_init(priv);
 }
index 917fade5f5d55aa1a89c5abaadf73d9e5f37d612..f5594014715bbbd1c281f95ecd871408b4949e06 100644 (file)
@@ -641,8 +641,10 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
 
        new_channels.params = priv->channels.params;
        new_channels.params.num_channels = count;
-       mlx5e_build_default_indir_rqt(priv->mdev, new_channels.params.indirection_rqt,
-                                     MLX5E_INDIR_RQT_SIZE, count);
+       if (!netif_is_rxfh_configured(priv->netdev))
+               mlx5e_build_default_indir_rqt(priv->mdev,
+                                             new_channels.params.indirection_rqt,
+                                             MLX5E_INDIR_RQT_SIZE, count);
 
        if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) {
                priv->channels.params = new_channels.params;
index 57f31fa478ceee5b83a3b4041cfef12457acbd03..6ad7f07e7861d9c8d6922b0c115fc950e0126dfc 100644 (file)
@@ -1969,6 +1969,7 @@ static void mlx5e_build_rx_cq_param(struct mlx5e_priv *priv,
        }
 
        mlx5e_build_common_cq_param(priv, param);
+       param->cq_period_mode = params->rx_cq_period_mode;
 }
 
 static void mlx5e_build_tx_cq_param(struct mlx5e_priv *priv,
index 325b2c8c1c6d18c8d8544ee15d0fcf0a347f6ee8..7344433259fca32fe288ba4c63dff6c64ab2d126 100644 (file)
@@ -222,13 +222,13 @@ static inline int mlx5e_page_alloc_mapped(struct mlx5e_rq *rq,
        if (unlikely(!page))
                return -ENOMEM;
 
-       dma_info->page = page;
        dma_info->addr = dma_map_page(rq->pdev, page, 0,
                                      RQ_PAGE_SIZE(rq), rq->buff.map_dir);
        if (unlikely(dma_mapping_error(rq->pdev, dma_info->addr))) {
                put_page(page);
                return -ENOMEM;
        }
+       dma_info->page = page;
 
        return 0;
 }
index 3c536f560dd2b529607ddf30de70d979efd0c59b..7f282e8f4e7fee460e1140dacc8f86ece6b1ea9e 100644 (file)
@@ -1443,12 +1443,10 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
        struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
        int ret;
 
-       dst = ip6_route_output(dev_net(mirred_dev), NULL, fl6);
-       ret = dst->error;
-       if (ret) {
-               dst_release(dst);
+       ret = ipv6_stub->ipv6_dst_lookup(dev_net(mirred_dev), NULL, &dst,
+                                        fl6);
+       if (ret < 0)
                return ret;
-       }
 
        *out_ttl = ip6_dst_hoplimit(dst);
 
index aaa0f4ebba9aee5229cfd7cd22088bfc3ac3027c..31353e5c3c783c2b6c5789fa46e66f4955535be7 100644 (file)
@@ -128,10 +128,10 @@ static inline int mlx5e_skb_l3_header_offset(struct sk_buff *skb)
                return mlx5e_skb_l2_header_offset(skb);
 }
 
-static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
-                                                struct sk_buff *skb)
+static inline u16 mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
+                                       struct sk_buff *skb)
 {
-       int hlen;
+       u16 hlen;
 
        switch (mode) {
        case MLX5_INLINE_MODE_NONE:
@@ -140,19 +140,22 @@ static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
                hlen = eth_get_headlen(skb->data, skb_headlen(skb));
                if (hlen == ETH_HLEN && !skb_vlan_tag_present(skb))
                        hlen += VLAN_HLEN;
-               return hlen;
+               break;
        case MLX5_INLINE_MODE_IP:
                /* When transport header is set to zero, it means no transport
                 * header. When transport header is set to 0xff's, it means
                 * transport header wasn't set.
                 */
-               if (skb_transport_offset(skb))
-                       return mlx5e_skb_l3_header_offset(skb);
+               if (skb_transport_offset(skb)) {
+                       hlen = mlx5e_skb_l3_header_offset(skb);
+                       break;
+               }
                /* fall through */
        case MLX5_INLINE_MODE_L2:
        default:
-               return mlx5e_skb_l2_header_offset(skb);
+               hlen = mlx5e_skb_l2_header_offset(skb);
        }
+       return min_t(u16, hlen, skb->len);
 }
 
 static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data,
index 95b64025ce36f74681a69cc8812dc8fa6da79261..5bc0593bd76e706e2b5c38a0a767af0324e67685 100644 (file)
@@ -815,7 +815,7 @@ void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports)
        struct mlx5_eswitch_rep *rep;
        int vport;
 
-       for (vport = 0; vport < nvports; vport++) {
+       for (vport = nvports - 1; vport >= 0; vport--) {
                rep = &esw->offloads.vport_reps[vport];
                if (!rep->valid)
                        continue;
index c065132b956d6ba772f812bff21a190d5759bf13..16885827367bfd9153f96faaf7c2afedc6c6a5b0 100644 (file)
@@ -1186,7 +1186,6 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
                }
        }
 
-       clear_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state);
        set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
 out:
        mutex_unlock(&dev->intf_state_mutex);
@@ -1261,7 +1260,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
                mlx5_drain_health_recovery(dev);
 
        mutex_lock(&dev->intf_state_mutex);
-       if (test_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state)) {
+       if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
                dev_warn(&dev->pdev->dev, "%s: interface is down, NOP\n",
                         __func__);
                if (cleanup)
@@ -1270,7 +1269,6 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
        }
 
        clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
-       set_bit(MLX5_INTERFACE_STATE_DOWN, &dev->intf_state);
 
        if (mlx5_device_registered(dev))
                mlx5_detach_device(dev);
@@ -1565,8 +1563,6 @@ static void shutdown(struct pci_dev *pdev)
        int err;
 
        dev_info(&pdev->dev, "Shutdown was called\n");
-       /* Notify mlx5 clients that the kernel is being shut down */
-       set_bit(MLX5_INTERFACE_STATE_SHUTDOWN, &dev->intf_state);
        err = mlx5_try_fast_unload(dev);
        if (err)
                mlx5_unload_one(dev, priv, false);
index f774de6f5fcb4b88bbe0e491ca7a2e2c2fb432ea..520f6382dfdeceac61ffa383afd12a6de99daf54 100644 (file)
@@ -201,13 +201,13 @@ static int destroy_srq_cmd(struct mlx5_core_dev *dev,
 static int arm_srq_cmd(struct mlx5_core_dev *dev, struct mlx5_core_srq *srq,
                       u16 lwm, int is_srq)
 {
-       /* arm_srq structs missing using identical xrc ones */
-       u32 srq_in[MLX5_ST_SZ_DW(arm_xrc_srq_in)] = {0};
-       u32 srq_out[MLX5_ST_SZ_DW(arm_xrc_srq_out)] = {0};
+       u32 srq_in[MLX5_ST_SZ_DW(arm_rq_in)] = {0};
+       u32 srq_out[MLX5_ST_SZ_DW(arm_rq_out)] = {0};
 
-       MLX5_SET(arm_xrc_srq_in, srq_in, opcode,   MLX5_CMD_OP_ARM_XRC_SRQ);
-       MLX5_SET(arm_xrc_srq_in, srq_in, xrc_srqn, srq->srqn);
-       MLX5_SET(arm_xrc_srq_in, srq_in, lwm,      lwm);
+       MLX5_SET(arm_rq_in, srq_in, opcode, MLX5_CMD_OP_ARM_RQ);
+       MLX5_SET(arm_rq_in, srq_in, op_mod, MLX5_ARM_RQ_IN_OP_MOD_SRQ);
+       MLX5_SET(arm_rq_in, srq_in, srq_number, srq->srqn);
+       MLX5_SET(arm_rq_in, srq_in, lwm,      lwm);
 
        return  mlx5_cmd_exec(dev, srq_in, sizeof(srq_in),
                              srq_out, sizeof(srq_out));
index 60bf8f27cc00ecc6bbed3685a14dd3aa8a96fd78..c6a3e61b53bdbf0c32212a6415f4a1d2da769bf8 100644 (file)
@@ -4139,6 +4139,8 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev,
                        return -EINVAL;
                if (!info->linking)
                        break;
+               if (netdev_has_any_upper_dev(upper_dev))
+                       return -EINVAL;
                if (netif_is_lag_master(upper_dev) &&
                    !mlxsw_sp_master_lag_check(mlxsw_sp, upper_dev,
                                               info->upper_info))
@@ -4258,6 +4260,10 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev,
                upper_dev = info->upper_dev;
                if (!netif_is_bridge_master(upper_dev))
                        return -EINVAL;
+               if (!info->linking)
+                       break;
+               if (netdev_has_any_upper_dev(upper_dev))
+                       return -EINVAL;
                break;
        case NETDEV_CHANGEUPPER:
                upper_dev = info->upper_dev;
index 656b2d3f1bee0e8aa5b1f328d5066d60f5e96099..d39ffbfcc436fdb4343b391f2ac6bbdd48dd14af 100644 (file)
@@ -626,8 +626,8 @@ static int mlxsw_sp_port_attr_br_flags_set(struct mlxsw_sp_port *mlxsw_sp_port,
 
        bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp_port->mlxsw_sp->bridge,
                                                orig_dev);
-       if (WARN_ON(!bridge_port))
-               return -EINVAL;
+       if (!bridge_port)
+               return 0;
 
        err = mlxsw_sp_bridge_port_flood_table_set(mlxsw_sp_port, bridge_port,
                                                   MLXSW_SP_FLOOD_TYPE_UC,
@@ -705,21 +705,28 @@ static int mlxsw_sp_port_attr_mc_router_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                            bool is_port_mc_router)
 {
        struct mlxsw_sp_bridge_port *bridge_port;
+       int err;
 
        if (switchdev_trans_ph_prepare(trans))
                return 0;
 
        bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp_port->mlxsw_sp->bridge,
                                                orig_dev);
-       if (WARN_ON(!bridge_port))
-               return -EINVAL;
+       if (!bridge_port)
+               return 0;
 
        if (!bridge_port->bridge_device->multicast_enabled)
-               return 0;
+               goto out;
 
-       return mlxsw_sp_bridge_port_flood_table_set(mlxsw_sp_port, bridge_port,
-                                                   MLXSW_SP_FLOOD_TYPE_MC,
-                                                   is_port_mc_router);
+       err = mlxsw_sp_bridge_port_flood_table_set(mlxsw_sp_port, bridge_port,
+                                                  MLXSW_SP_FLOOD_TYPE_MC,
+                                                  is_port_mc_router);
+       if (err)
+               return err;
+
+out:
+       bridge_port->mrouter = is_port_mc_router;
+       return 0;
 }
 
 static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,
@@ -1283,15 +1290,15 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port,
                return 0;
 
        bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp->bridge, orig_dev);
-       if (WARN_ON(!bridge_port))
-               return -EINVAL;
+       if (!bridge_port)
+               return 0;
 
        bridge_device = bridge_port->bridge_device;
        mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_bridge(mlxsw_sp_port,
                                                               bridge_device,
                                                               mdb->vid);
-       if (WARN_ON(!mlxsw_sp_port_vlan))
-               return -EINVAL;
+       if (!mlxsw_sp_port_vlan)
+               return 0;
 
        fid_index = mlxsw_sp_fid_index(mlxsw_sp_port_vlan->fid);
 
@@ -1407,15 +1414,15 @@ static int mlxsw_sp_port_mdb_del(struct mlxsw_sp_port *mlxsw_sp_port,
        int err = 0;
 
        bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp->bridge, orig_dev);
-       if (WARN_ON(!bridge_port))
-               return -EINVAL;
+       if (!bridge_port)
+               return 0;
 
        bridge_device = bridge_port->bridge_device;
        mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_bridge(mlxsw_sp_port,
                                                               bridge_device,
                                                               mdb->vid);
-       if (WARN_ON(!mlxsw_sp_port_vlan))
-               return -EINVAL;
+       if (!mlxsw_sp_port_vlan)
+               return 0;
 
        fid_index = mlxsw_sp_fid_index(mlxsw_sp_port_vlan->fid);
 
@@ -1974,6 +1981,17 @@ static void mlxsw_sp_fdb_fini(struct mlxsw_sp *mlxsw_sp)
 
 }
 
+static void mlxsw_sp_mids_fini(struct mlxsw_sp *mlxsw_sp)
+{
+       struct mlxsw_sp_mid *mid, *tmp;
+
+       list_for_each_entry_safe(mid, tmp, &mlxsw_sp->bridge->mids_list, list) {
+               list_del(&mid->list);
+               clear_bit(mid->mid, mlxsw_sp->bridge->mids_bitmap);
+               kfree(mid);
+       }
+}
+
 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp)
 {
        struct mlxsw_sp_bridge *bridge;
@@ -1996,7 +2014,7 @@ int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp)
 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp)
 {
        mlxsw_sp_fdb_fini(mlxsw_sp);
-       WARN_ON(!list_empty(&mlxsw_sp->bridge->mids_list));
+       mlxsw_sp_mids_fini(mlxsw_sp);
        WARN_ON(!list_empty(&mlxsw_sp->bridge->bridges_list));
        kfree(mlxsw_sp->bridge);
 }
index dd7fa9cf225ff3c9e60d6f62e3f7f17317f2ea52..b0837b58c3a1084e8261ff3bf6d6057c4d8e7f54 100644 (file)
@@ -115,14 +115,10 @@ nfp_flower_cmsg_portmod_rx(struct nfp_app *app, struct sk_buff *skb)
                return;
        }
 
-       if (link) {
+       if (link)
                netif_carrier_on(netdev);
-               rtnl_lock();
-               dev_set_mtu(netdev, be16_to_cpu(msg->mtu));
-               rtnl_unlock();
-       } else {
+       else
                netif_carrier_off(netdev);
-       }
        rcu_read_unlock();
 }
 
index 0e08404480efb7863e2be9a67109b0068b7aaf1a..d25b5038c3a269c316611512d3880597f534550f 100644 (file)
@@ -42,33 +42,29 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_two *frame,
                            struct tc_cls_flower_offload *flow, u8 key_type,
                            bool mask_version)
 {
+       struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
        struct flow_dissector_key_vlan *flow_vlan;
        u16 tmp_tci;
 
+       memset(frame, 0, sizeof(struct nfp_flower_meta_two));
        /* Populate the metadata frame. */
        frame->nfp_flow_key_layer = key_type;
        frame->mask_id = ~0;
 
-       if (mask_version) {
-               frame->tci = cpu_to_be16(~0);
-               return;
-       }
-
-       flow_vlan = skb_flow_dissector_target(flow->dissector,
-                                             FLOW_DISSECTOR_KEY_VLAN,
-                                             flow->key);
-
-       /* Populate the tci field. */
-       if (!flow_vlan->vlan_id) {
-               tmp_tci = 0;
-       } else {
-               tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO,
-                                    flow_vlan->vlan_priority) |
-                         FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID,
-                                    flow_vlan->vlan_id) |
-                         NFP_FLOWER_MASK_VLAN_CFI;
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
+               flow_vlan = skb_flow_dissector_target(flow->dissector,
+                                                     FLOW_DISSECTOR_KEY_VLAN,
+                                                     target);
+               /* Populate the tci field. */
+               if (flow_vlan->vlan_id) {
+                       tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO,
+                                            flow_vlan->vlan_priority) |
+                                 FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID,
+                                            flow_vlan->vlan_id) |
+                                 NFP_FLOWER_MASK_VLAN_CFI;
+                       frame->tci = cpu_to_be16(tmp_tci);
+               }
        }
-       frame->tci = cpu_to_be16(tmp_tci);
 }
 
 static void
@@ -99,17 +95,18 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *frame,
                       bool mask_version)
 {
        struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
-       struct flow_dissector_key_eth_addrs *flow_mac;
-
-       flow_mac = skb_flow_dissector_target(flow->dissector,
-                                            FLOW_DISSECTOR_KEY_ETH_ADDRS,
-                                            target);
+       struct flow_dissector_key_eth_addrs *addr;
 
        memset(frame, 0, sizeof(struct nfp_flower_mac_mpls));
 
-       /* Populate mac frame. */
-       ether_addr_copy(frame->mac_dst, &flow_mac->dst[0]);
-       ether_addr_copy(frame->mac_src, &flow_mac->src[0]);
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
+               addr = skb_flow_dissector_target(flow->dissector,
+                                                FLOW_DISSECTOR_KEY_ETH_ADDRS,
+                                                target);
+               /* Populate mac frame. */
+               ether_addr_copy(frame->mac_dst, &addr->dst[0]);
+               ether_addr_copy(frame->mac_src, &addr->src[0]);
+       }
 
        if (mask_version)
                frame->mpls_lse = cpu_to_be32(~0);
@@ -121,14 +118,17 @@ nfp_flower_compile_tport(struct nfp_flower_tp_ports *frame,
                         bool mask_version)
 {
        struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
-       struct flow_dissector_key_ports *flow_tp;
+       struct flow_dissector_key_ports *tp;
 
-       flow_tp = skb_flow_dissector_target(flow->dissector,
-                                           FLOW_DISSECTOR_KEY_PORTS,
-                                           target);
+       memset(frame, 0, sizeof(struct nfp_flower_tp_ports));
 
-       frame->port_src = flow_tp->src;
-       frame->port_dst = flow_tp->dst;
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_PORTS)) {
+               tp = skb_flow_dissector_target(flow->dissector,
+                                              FLOW_DISSECTOR_KEY_PORTS,
+                                              target);
+               frame->port_src = tp->src;
+               frame->port_dst = tp->dst;
+       }
 }
 
 static void
@@ -137,25 +137,27 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame,
                        bool mask_version)
 {
        struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
-       struct flow_dissector_key_ipv4_addrs *flow_ipv4;
-       struct flow_dissector_key_basic *flow_basic;
-
-       flow_ipv4 = skb_flow_dissector_target(flow->dissector,
-                                             FLOW_DISSECTOR_KEY_IPV4_ADDRS,
-                                             target);
-
-       flow_basic = skb_flow_dissector_target(flow->dissector,
-                                              FLOW_DISSECTOR_KEY_BASIC,
-                                              target);
+       struct flow_dissector_key_ipv4_addrs *addr;
+       struct flow_dissector_key_basic *basic;
 
-       /* Populate IPv4 frame. */
-       frame->reserved = 0;
-       frame->ipv4_src = flow_ipv4->src;
-       frame->ipv4_dst = flow_ipv4->dst;
-       frame->proto = flow_basic->ip_proto;
        /* Wildcard TOS/TTL for now. */
-       frame->tos = 0;
-       frame->ttl = 0;
+       memset(frame, 0, sizeof(struct nfp_flower_ipv4));
+
+       if (dissector_uses_key(flow->dissector,
+                              FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
+               addr = skb_flow_dissector_target(flow->dissector,
+                                                FLOW_DISSECTOR_KEY_IPV4_ADDRS,
+                                                target);
+               frame->ipv4_src = addr->src;
+               frame->ipv4_dst = addr->dst;
+       }
+
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
+               basic = skb_flow_dissector_target(flow->dissector,
+                                                 FLOW_DISSECTOR_KEY_BASIC,
+                                                 target);
+               frame->proto = basic->ip_proto;
+       }
 }
 
 static void
@@ -164,26 +166,27 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *frame,
                        bool mask_version)
 {
        struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
-       struct flow_dissector_key_ipv6_addrs *flow_ipv6;
-       struct flow_dissector_key_basic *flow_basic;
-
-       flow_ipv6 = skb_flow_dissector_target(flow->dissector,
-                                             FLOW_DISSECTOR_KEY_IPV6_ADDRS,
-                                             target);
+       struct flow_dissector_key_ipv6_addrs *addr;
+       struct flow_dissector_key_basic *basic;
 
-       flow_basic = skb_flow_dissector_target(flow->dissector,
-                                              FLOW_DISSECTOR_KEY_BASIC,
-                                              target);
-
-       /* Populate IPv6 frame. */
-       frame->reserved = 0;
-       frame->ipv6_src = flow_ipv6->src;
-       frame->ipv6_dst = flow_ipv6->dst;
-       frame->proto = flow_basic->ip_proto;
        /* Wildcard LABEL/TOS/TTL for now. */
-       frame->ipv6_flow_label_exthdr = 0;
-       frame->tos = 0;
-       frame->ttl = 0;
+       memset(frame, 0, sizeof(struct nfp_flower_ipv6));
+
+       if (dissector_uses_key(flow->dissector,
+                              FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {
+               addr = skb_flow_dissector_target(flow->dissector,
+                                                FLOW_DISSECTOR_KEY_IPV6_ADDRS,
+                                                target);
+               frame->ipv6_src = addr->src;
+               frame->ipv6_dst = addr->dst;
+       }
+
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
+               basic = skb_flow_dissector_target(flow->dissector,
+                                                 FLOW_DISSECTOR_KEY_BASIC,
+                                                 target);
+               frame->proto = basic->ip_proto;
+       }
 }
 
 int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow,
index 4ad10bd5e139402dc452d90be81f1384bb5a6785..74a96d6bb05ce1c4b3a64d03d18016327b697a84 100644 (file)
@@ -105,43 +105,62 @@ static int
 nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
                                struct tc_cls_flower_offload *flow)
 {
-       struct flow_dissector_key_control *mask_enc_ctl;
-       struct flow_dissector_key_basic *mask_basic;
-       struct flow_dissector_key_basic *key_basic;
+       struct flow_dissector_key_basic *mask_basic = NULL;
+       struct flow_dissector_key_basic *key_basic = NULL;
+       struct flow_dissector_key_ip *mask_ip = NULL;
        u32 key_layer_two;
        u8 key_layer;
        int key_size;
 
-       mask_enc_ctl = skb_flow_dissector_target(flow->dissector,
-                                                FLOW_DISSECTOR_KEY_ENC_CONTROL,
-                                                flow->mask);
+       if (dissector_uses_key(flow->dissector,
+                              FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
+               struct flow_dissector_key_control *mask_enc_ctl =
+                       skb_flow_dissector_target(flow->dissector,
+                                                 FLOW_DISSECTOR_KEY_ENC_CONTROL,
+                                                 flow->mask);
+               /* We are expecting a tunnel. For now we ignore offloading. */
+               if (mask_enc_ctl->addr_type)
+                       return -EOPNOTSUPP;
+       }
 
-       mask_basic = skb_flow_dissector_target(flow->dissector,
-                                              FLOW_DISSECTOR_KEY_BASIC,
-                                              flow->mask);
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
+               mask_basic = skb_flow_dissector_target(flow->dissector,
+                                                      FLOW_DISSECTOR_KEY_BASIC,
+                                                      flow->mask);
+
+               key_basic = skb_flow_dissector_target(flow->dissector,
+                                                     FLOW_DISSECTOR_KEY_BASIC,
+                                                     flow->key);
+       }
+
+       if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_IP))
+               mask_ip = skb_flow_dissector_target(flow->dissector,
+                                                   FLOW_DISSECTOR_KEY_IP,
+                                                   flow->mask);
 
-       key_basic = skb_flow_dissector_target(flow->dissector,
-                                             FLOW_DISSECTOR_KEY_BASIC,
-                                             flow->key);
        key_layer_two = 0;
        key_layer = NFP_FLOWER_LAYER_PORT | NFP_FLOWER_LAYER_MAC;
        key_size = sizeof(struct nfp_flower_meta_one) +
                   sizeof(struct nfp_flower_in_port) +
                   sizeof(struct nfp_flower_mac_mpls);
 
-       /* We are expecting a tunnel. For now we ignore offloading. */
-       if (mask_enc_ctl->addr_type)
-               return -EOPNOTSUPP;
-
-       if (mask_basic->n_proto) {
+       if (mask_basic && mask_basic->n_proto) {
                /* Ethernet type is present in the key. */
                switch (key_basic->n_proto) {
                case cpu_to_be16(ETH_P_IP):
+                       if (mask_ip && mask_ip->tos)
+                               return -EOPNOTSUPP;
+                       if (mask_ip && mask_ip->ttl)
+                               return -EOPNOTSUPP;
                        key_layer |= NFP_FLOWER_LAYER_IPV4;
                        key_size += sizeof(struct nfp_flower_ipv4);
                        break;
 
                case cpu_to_be16(ETH_P_IPV6):
+                       if (mask_ip && mask_ip->tos)
+                               return -EOPNOTSUPP;
+                       if (mask_ip && mask_ip->ttl)
+                               return -EOPNOTSUPP;
                        key_layer |= NFP_FLOWER_LAYER_IPV6;
                        key_size += sizeof(struct nfp_flower_ipv6);
                        break;
@@ -152,6 +171,11 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
                case cpu_to_be16(ETH_P_ARP):
                        return -EOPNOTSUPP;
 
+               /* Currently we do not offload MPLS. */
+               case cpu_to_be16(ETH_P_MPLS_UC):
+               case cpu_to_be16(ETH_P_MPLS_MC):
+                       return -EOPNOTSUPP;
+
                /* Will be included in layer 2. */
                case cpu_to_be16(ETH_P_8021Q):
                        break;
@@ -166,7 +190,7 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
                }
        }
 
-       if (mask_basic->ip_proto) {
+       if (mask_basic && mask_basic->ip_proto) {
                /* Ethernet type is present in the key. */
                switch (key_basic->ip_proto) {
                case IPPROTO_TCP:
index d67969d3e484682c102a965c4abf5908dc1fc6fc..3f199db2002e5ce1c4a0dabc1475647426f6c876 100644 (file)
@@ -98,21 +98,20 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)
        struct nfp_pf *pf = pci_get_drvdata(pdev);
        int err;
 
-       mutex_lock(&pf->lock);
-
        if (num_vfs > pf->limit_vfs) {
                nfp_info(pf->cpp, "Firmware limits number of VFs to %u\n",
                         pf->limit_vfs);
-               err = -EINVAL;
-               goto err_unlock;
+               return -EINVAL;
        }
 
        err = pci_enable_sriov(pdev, num_vfs);
        if (err) {
                dev_warn(&pdev->dev, "Failed to enable PCI SR-IOV: %d\n", err);
-               goto err_unlock;
+               return err;
        }
 
+       mutex_lock(&pf->lock);
+
        err = nfp_app_sriov_enable(pf->app, num_vfs);
        if (err) {
                dev_warn(&pdev->dev,
@@ -129,9 +128,8 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs)
        return num_vfs;
 
 err_sriov_disable:
-       pci_disable_sriov(pdev);
-err_unlock:
        mutex_unlock(&pf->lock);
+       pci_disable_sriov(pdev);
        return err;
 #endif
        return 0;
@@ -158,10 +156,10 @@ static int nfp_pcie_sriov_disable(struct pci_dev *pdev)
 
        pf->num_vfs = 0;
 
+       mutex_unlock(&pf->lock);
+
        pci_disable_sriov(pdev);
        dev_dbg(&pdev->dev, "Removed VFs.\n");
-
-       mutex_unlock(&pf->lock);
 #endif
        return 0;
 }
index 18750ff0ede6262d1a5fd50b8acc808c12a50756..66a09e490cf5a5f2ce19193653910e0fcbe5632e 100644 (file)
@@ -513,6 +513,7 @@ nfp_net_tx_ring_init(struct nfp_net_tx_ring *tx_ring,
        tx_ring->idx = idx;
        tx_ring->r_vec = r_vec;
        tx_ring->is_xdp = is_xdp;
+       u64_stats_init(&tx_ring->r_vec->tx_sync);
 
        tx_ring->qcidx = tx_ring->idx * nn->stride_tx;
        tx_ring->qcp_q = nn->tx_bar + NFP_QCP_QUEUE_OFF(tx_ring->qcidx);
@@ -532,6 +533,7 @@ nfp_net_rx_ring_init(struct nfp_net_rx_ring *rx_ring,
 
        rx_ring->idx = idx;
        rx_ring->r_vec = r_vec;
+       u64_stats_init(&rx_ring->r_vec->rx_sync);
 
        rx_ring->fl_qcidx = rx_ring->idx * nn->stride_rx;
        rx_ring->qcp_fl = nn->rx_bar + NFP_QCP_QUEUE_OFF(rx_ring->fl_qcidx);
@@ -893,6 +895,8 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
 
        netdev_tx_sent_queue(nd_q, txbuf->real_len);
 
+       skb_tx_timestamp(skb);
+
        tx_ring->wr_p += nr_frags + 1;
        if (nfp_net_tx_ring_should_stop(tx_ring))
                nfp_net_tx_ring_stop(nd_q, tx_ring);
@@ -901,13 +905,10 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
        if (!skb->xmit_more || netif_xmit_stopped(nd_q))
                nfp_net_tx_xmit_more_flush(tx_ring);
 
-       skb_tx_timestamp(skb);
-
        return NETDEV_TX_OK;
 
 err_unmap:
-       --f;
-       while (f >= 0) {
+       while (--f >= 0) {
                frag = &skb_shinfo(skb)->frags[f];
                dma_unmap_page(dp->dev, tx_ring->txbufs[wr_idx].dma_addr,
                               skb_frag_size(frag), DMA_TO_DEVICE);
@@ -1750,6 +1751,10 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
                        continue;
                }
 
+               nfp_net_dma_unmap_rx(dp, rxbuf->dma_addr);
+
+               nfp_net_rx_give_one(dp, rx_ring, new_frag, new_dma_addr);
+
                if (likely(!meta.portid)) {
                        netdev = dp->netdev;
                } else {
@@ -1758,16 +1763,12 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
                        nn = netdev_priv(dp->netdev);
                        netdev = nfp_app_repr_get(nn->app, meta.portid);
                        if (unlikely(!netdev)) {
-                               nfp_net_rx_drop(dp, r_vec, rx_ring, rxbuf, skb);
+                               nfp_net_rx_drop(dp, r_vec, rx_ring, NULL, skb);
                                continue;
                        }
                        nfp_repr_inc_rx_stats(netdev, pkt_len);
                }
 
-               nfp_net_dma_unmap_rx(dp, rxbuf->dma_addr);
-
-               nfp_net_rx_give_one(dp, rx_ring, new_frag, new_dma_addr);
-
                skb_reserve(skb, pkt_off);
                skb_put(skb, pkt_len);
 
index 5797dbf2b50779583e0a27e1fee02ce85b8feebb..34b985384d26129435686dca6c86b3e6e092cde2 100644 (file)
@@ -456,13 +456,9 @@ static int nfp_net_pf_app_start(struct nfp_pf *pf)
 {
        int err;
 
-       err = nfp_net_pf_app_start_ctrl(pf);
-       if (err)
-               return err;
-
        err = nfp_app_start(pf->app, pf->ctrl_vnic);
        if (err)
-               goto err_ctrl_stop;
+               return err;
 
        if (pf->num_vfs) {
                err = nfp_app_sriov_enable(pf->app, pf->num_vfs);
@@ -474,8 +470,6 @@ static int nfp_net_pf_app_start(struct nfp_pf *pf)
 
 err_app_stop:
        nfp_app_stop(pf->app);
-err_ctrl_stop:
-       nfp_net_pf_app_stop_ctrl(pf);
        return err;
 }
 
@@ -484,7 +478,6 @@ static void nfp_net_pf_app_stop(struct nfp_pf *pf)
        if (pf->num_vfs)
                nfp_app_sriov_disable(pf->app);
        nfp_app_stop(pf->app);
-       nfp_net_pf_app_stop_ctrl(pf);
 }
 
 static void nfp_net_pci_unmap_mem(struct nfp_pf *pf)
@@ -559,7 +552,7 @@ err_unmap_ctrl:
 
 static void nfp_net_pci_remove_finish(struct nfp_pf *pf)
 {
-       nfp_net_pf_app_stop(pf);
+       nfp_net_pf_app_stop_ctrl(pf);
        /* stop app first, to avoid double free of ctrl vNIC's ddir */
        nfp_net_debugfs_dir_clean(&pf->ddir);
 
@@ -690,6 +683,7 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
 {
        struct nfp_net_fw_version fw_ver;
        u8 __iomem *ctrl_bar, *qc_bar;
+       struct nfp_net *nn;
        int stride;
        int err;
 
@@ -766,7 +760,7 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
        if (err)
                goto err_free_vnics;
 
-       err = nfp_net_pf_app_start(pf);
+       err = nfp_net_pf_app_start_ctrl(pf);
        if (err)
                goto err_free_irqs;
 
@@ -774,12 +768,20 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
        if (err)
                goto err_stop_app;
 
+       err = nfp_net_pf_app_start(pf);
+       if (err)
+               goto err_clean_vnics;
+
        mutex_unlock(&pf->lock);
 
        return 0;
 
+err_clean_vnics:
+       list_for_each_entry(nn, &pf->vnics, vnic_list)
+               if (nfp_net_is_data_vnic(nn))
+                       nfp_net_pf_clean_vnic(pf, nn);
 err_stop_app:
-       nfp_net_pf_app_stop(pf);
+       nfp_net_pf_app_stop_ctrl(pf);
 err_free_irqs:
        nfp_net_pf_free_irqs(pf);
 err_free_vnics:
@@ -803,6 +805,8 @@ void nfp_net_pci_remove(struct nfp_pf *pf)
        if (list_empty(&pf->vnics))
                goto out;
 
+       nfp_net_pf_app_stop(pf);
+
        list_for_each_entry(nn, &pf->vnics, vnic_list)
                if (nfp_net_is_data_vnic(nn))
                        nfp_net_pf_clean_vnic(pf, nn);
index 66ff15d08bad4eb0a12e30e69547905789d15336..0a66389c06c2522a95ed8d6d8fdd04ce1762cf4d 100644 (file)
@@ -2311,7 +2311,7 @@ netxen_md_rdqueue(struct netxen_adapter *adapter,
                                 loop_cnt++) {
                NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id);
                read_addr = queueEntry->read_addr;
-               for (k = 0; k < read_cnt; k--) {
+               for (k = 0; k < read_cnt; k++) {
                        NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0,
                                                        &read_value);
                        *data_buff++ = read_value;
index 9da91045d167b095ad2bb45f5bd3fa1a89255012..3eb241657368e33cb6bc7b25afcecee931a24366 100644 (file)
@@ -253,7 +253,7 @@ int qed_mcp_cmd_init(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
        size = MFW_DRV_MSG_MAX_DWORDS(p_info->mfw_mb_length) * sizeof(u32);
        p_info->mfw_mb_cur = kzalloc(size, GFP_KERNEL);
        p_info->mfw_mb_shadow = kzalloc(size, GFP_KERNEL);
-       if (!p_info->mfw_mb_shadow || !p_info->mfw_mb_addr)
+       if (!p_info->mfw_mb_cur || !p_info->mfw_mb_shadow)
                goto err;
 
        return 0;
index 28ea0af89aefeb2a733801af03a21b20d269cb37..e3223f2fe2ffc9d4b186a42e0cac87fc37021afd 100644 (file)
@@ -724,7 +724,7 @@ static void ql_build_coredump_seg_header(
        seg_hdr->cookie = MPI_COREDUMP_COOKIE;
        seg_hdr->segNum = seg_number;
        seg_hdr->segSize = seg_size;
-       memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
+       strncpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1);
 }
 
 /*
index bd07a15d3b7c09886de55af99a45975ac3401219..e03fcf914690c9a9e8fae548c4702f402d698f47 100644 (file)
@@ -6863,8 +6863,7 @@ static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
                        rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
                                             tp->TxDescArray + entry);
                        if (skb) {
-                               tp->dev->stats.tx_dropped++;
-                               dev_kfree_skb_any(skb);
+                               dev_consume_skb_any(skb);
                                tx_skb->skb = NULL;
                        }
                }
@@ -7319,7 +7318,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
                        tp->tx_stats.packets++;
                        tp->tx_stats.bytes += tx_skb->skb->len;
                        u64_stats_update_end(&tp->tx_stats.syncp);
-                       dev_kfree_skb_any(tx_skb->skb);
+                       dev_consume_skb_any(tx_skb->skb);
                        tx_skb->skb = NULL;
                }
                dirty_tx++;
index 73427e29df2afb808a0b525ebb1978df4d76a996..fbd00cb0cb7d7204e97b9b11d8ae058c95148834 100644 (file)
@@ -47,6 +47,8 @@ static int sxgbe_probe_config_dt(struct platform_device *pdev,
        plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
                                           sizeof(*plat->mdio_bus_data),
                                           GFP_KERNEL);
+       if (!plat->mdio_bus_data)
+               return -ENOMEM;
 
        dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), GFP_KERNEL);
        if (!dma_cfg)
index c905971c5f3a2849262dcf3ce220de93e32e4bd2..990a63d7fcb7213fa5c5d6e40a10ec5102af892a 100644 (file)
@@ -938,7 +938,6 @@ enum efx_stats_action {
 static int efx_mcdi_mac_stats(struct efx_nic *efx,
                              enum efx_stats_action action, int clear)
 {
-       struct efx_ef10_nic_data *nic_data = efx->nic_data;
        MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
        int rc;
        int change = action == EFX_STATS_PULL ? 0 : 1;
@@ -960,7 +959,12 @@ static int efx_mcdi_mac_stats(struct efx_nic *efx,
                              MAC_STATS_IN_PERIODIC_NOEVENT, 1,
                              MAC_STATS_IN_PERIOD_MS, period);
        MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
-       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id);
+
+       if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) {
+               struct efx_ef10_nic_data *nic_data = efx->nic_data;
+
+               MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id);
+       }
 
        rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
                                NULL, 0, NULL);
index 17d4bbaeb65cd7e8711c6cb541bc36713695235a..6e359572b9f0ea53ed46b553fb1cb51273415f57 100644 (file)
@@ -269,7 +269,10 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
        ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
        ctrl |= val << reg_shift;
 
-       if (dwmac->f2h_ptp_ref_clk) {
+       if (dwmac->f2h_ptp_ref_clk ||
+           phymode == PHY_INTERFACE_MODE_MII ||
+           phymode == PHY_INTERFACE_MODE_GMII ||
+           phymode == PHY_INTERFACE_MODE_SGMII) {
                ctrl |= SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2);
                regmap_read(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG,
                            &module);
index fffd6d5fc907b01d2277370f80b23af5a9288e8d..39c2122a4f26947ff564b773df454ce8fa05ec75 100644 (file)
@@ -979,14 +979,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id sun8i_dwmac_match[] = {
-       { .compatible = "allwinner,sun8i-h3-emac",
-               .data = &emac_variant_h3 },
-       { .compatible = "allwinner,sun8i-v3s-emac",
-               .data = &emac_variant_v3s },
-       { .compatible = "allwinner,sun8i-a83t-emac",
-               .data = &emac_variant_a83t },
-       { .compatible = "allwinner,sun50i-a64-emac",
-               .data = &emac_variant_a64 },
        { }
 };
 MODULE_DEVICE_TABLE(of, sun8i_dwmac_match);
index db157a47000c65fb588d3f1c5dfe21bbd20983fb..72ec711fcba242775feea3064bdcb69de6c1812e 100644 (file)
@@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev)
        struct stmmac_priv *priv = netdev_priv(ndev);
        struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
        struct device_node *mdio_node = priv->plat->mdio_node;
+       struct device *dev = ndev->dev.parent;
        int addr, found;
 
        if (!mdio_bus_data)
@@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev)
        else
                err = mdiobus_register(new_bus);
        if (err != 0) {
-               netdev_err(ndev, "Cannot register the MDIO bus\n");
+               dev_err(dev, "Cannot register the MDIO bus\n");
                goto bus_register_fail;
        }
 
@@ -285,14 +286,12 @@ int stmmac_mdio_register(struct net_device *ndev)
                        irq_str = irq_num;
                        break;
                }
-               netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n",
-                           phydev->phy_id, addr, irq_str, phydev_name(phydev),
-                           act ? " active" : "");
+               phy_attached_info(phydev);
                found = 1;
        }
 
        if (!found && !mdio_node) {
-               netdev_warn(ndev, "No PHY found\n");
+               dev_warn(dev, "No PHY found\n");
                mdiobus_unregister(new_bus);
                mdiobus_free(new_bus);
                return -ENODEV;
index 56ba411421f0a77bae5b4568fb273464472741f5..38d1cc557c116b1047e27daa7923a654a438d52e 100644 (file)
@@ -96,7 +96,7 @@ int ti_cm_get_macid(struct device *dev, int slave, u8 *mac_addr)
        if (of_machine_is_compatible("ti,dra7"))
                return davinci_emac_3517_get_macid(dev, 0x514, slave, mac_addr);
 
-       dev_err(dev, "incompatible machine/device type for reading mac address\n");
+       dev_info(dev, "incompatible machine/device type for reading mac address\n");
        return -ENOENT;
 }
 EXPORT_SYMBOL_GPL(ti_cm_get_macid);
index 32279d21c8363d4976c6d313599fbc0e015e6a36..c2121d214f089eb1fe59af4ceb4b2b358abb8f0c 100644 (file)
 
 #include "cpts.h"
 
+#define CPTS_SKB_TX_WORK_TIMEOUT 1 /* jiffies */
+
+struct cpts_skb_cb_data {
+       unsigned long tmo;
+};
+
 #define cpts_read32(c, r)      readl_relaxed(&c->reg->r)
 #define cpts_write32(c, v, r)  writel_relaxed(v, &c->reg->r)
 
+static int cpts_match(struct sk_buff *skb, unsigned int ptp_class,
+                     u16 ts_seqid, u8 ts_msgtype);
+
 static int event_expired(struct cpts_event *event)
 {
        return time_after(jiffies, event->tmo);
@@ -77,6 +86,47 @@ static int cpts_purge_events(struct cpts *cpts)
        return removed ? 0 : -1;
 }
 
+static bool cpts_match_tx_ts(struct cpts *cpts, struct cpts_event *event)
+{
+       struct sk_buff *skb, *tmp;
+       u16 seqid;
+       u8 mtype;
+       bool found = false;
+
+       mtype = (event->high >> MESSAGE_TYPE_SHIFT) & MESSAGE_TYPE_MASK;
+       seqid = (event->high >> SEQUENCE_ID_SHIFT) & SEQUENCE_ID_MASK;
+
+       /* no need to grab txq.lock as access is always done under cpts->lock */
+       skb_queue_walk_safe(&cpts->txq, skb, tmp) {
+               struct skb_shared_hwtstamps ssh;
+               unsigned int class = ptp_classify_raw(skb);
+               struct cpts_skb_cb_data *skb_cb =
+                                       (struct cpts_skb_cb_data *)skb->cb;
+
+               if (cpts_match(skb, class, seqid, mtype)) {
+                       u64 ns = timecounter_cyc2time(&cpts->tc, event->low);
+
+                       memset(&ssh, 0, sizeof(ssh));
+                       ssh.hwtstamp = ns_to_ktime(ns);
+                       skb_tstamp_tx(skb, &ssh);
+                       found = true;
+                       __skb_unlink(skb, &cpts->txq);
+                       dev_consume_skb_any(skb);
+                       dev_dbg(cpts->dev, "match tx timestamp mtype %u seqid %04x\n",
+                               mtype, seqid);
+               } else if (time_after(jiffies, skb_cb->tmo)) {
+                       /* timeout any expired skbs over 1s */
+                       dev_dbg(cpts->dev,
+                               "expiring tx timestamp mtype %u seqid %04x\n",
+                               mtype, seqid);
+                       __skb_unlink(skb, &cpts->txq);
+                       dev_consume_skb_any(skb);
+               }
+       }
+
+       return found;
+}
+
 /*
  * Returns zero if matching event type was found.
  */
@@ -101,9 +151,15 @@ static int cpts_fifo_read(struct cpts *cpts, int match)
                event->low = lo;
                type = event_type(event);
                switch (type) {
+               case CPTS_EV_TX:
+                       if (cpts_match_tx_ts(cpts, event)) {
+                               /* if the new event matches an existing skb,
+                                * then don't queue it
+                                */
+                               break;
+                       }
                case CPTS_EV_PUSH:
                case CPTS_EV_RX:
-               case CPTS_EV_TX:
                        list_del_init(&event->list);
                        list_add_tail(&event->list, &cpts->events);
                        break;
@@ -224,6 +280,24 @@ static int cpts_ptp_enable(struct ptp_clock_info *ptp,
        return -EOPNOTSUPP;
 }
 
+static long cpts_overflow_check(struct ptp_clock_info *ptp)
+{
+       struct cpts *cpts = container_of(ptp, struct cpts, info);
+       unsigned long delay = cpts->ov_check_period;
+       struct timespec64 ts;
+       unsigned long flags;
+
+       spin_lock_irqsave(&cpts->lock, flags);
+       ts = ns_to_timespec64(timecounter_read(&cpts->tc));
+
+       if (!skb_queue_empty(&cpts->txq))
+               delay = CPTS_SKB_TX_WORK_TIMEOUT;
+       spin_unlock_irqrestore(&cpts->lock, flags);
+
+       pr_debug("cpts overflow check at %lld.%09lu\n", ts.tv_sec, ts.tv_nsec);
+       return (long)delay;
+}
+
 static struct ptp_clock_info cpts_info = {
        .owner          = THIS_MODULE,
        .name           = "CTPS timer",
@@ -236,18 +310,9 @@ static struct ptp_clock_info cpts_info = {
        .gettime64      = cpts_ptp_gettime,
        .settime64      = cpts_ptp_settime,
        .enable         = cpts_ptp_enable,
+       .do_aux_work    = cpts_overflow_check,
 };
 
-static void cpts_overflow_check(struct work_struct *work)
-{
-       struct timespec64 ts;
-       struct cpts *cpts = container_of(work, struct cpts, overflow_work.work);
-
-       cpts_ptp_gettime(&cpts->info, &ts);
-       pr_debug("cpts overflow check at %lld.%09lu\n", ts.tv_sec, ts.tv_nsec);
-       schedule_delayed_work(&cpts->overflow_work, cpts->ov_check_period);
-}
-
 static int cpts_match(struct sk_buff *skb, unsigned int ptp_class,
                      u16 ts_seqid, u8 ts_msgtype)
 {
@@ -299,7 +364,7 @@ static u64 cpts_find_ts(struct cpts *cpts, struct sk_buff *skb, int ev_type)
                return 0;
 
        spin_lock_irqsave(&cpts->lock, flags);
-       cpts_fifo_read(cpts, CPTS_EV_PUSH);
+       cpts_fifo_read(cpts, -1);
        list_for_each_safe(this, next, &cpts->events) {
                event = list_entry(this, struct cpts_event, list);
                if (event_expired(event)) {
@@ -317,6 +382,19 @@ static u64 cpts_find_ts(struct cpts *cpts, struct sk_buff *skb, int ev_type)
                        break;
                }
        }
+
+       if (ev_type == CPTS_EV_TX && !ns) {
+               struct cpts_skb_cb_data *skb_cb =
+                               (struct cpts_skb_cb_data *)skb->cb;
+               /* Not found, add frame to queue for processing later.
+                * The periodic FIFO check will handle this.
+                */
+               skb_get(skb);
+               /* get the timestamp for timeouts */
+               skb_cb->tmo = jiffies + msecs_to_jiffies(100);
+               __skb_queue_tail(&cpts->txq, skb);
+               ptp_schedule_worker(cpts->clock, 0);
+       }
        spin_unlock_irqrestore(&cpts->lock, flags);
 
        return ns;
@@ -358,6 +436,7 @@ int cpts_register(struct cpts *cpts)
 {
        int err, i;
 
+       skb_queue_head_init(&cpts->txq);
        INIT_LIST_HEAD(&cpts->events);
        INIT_LIST_HEAD(&cpts->pool);
        for (i = 0; i < CPTS_MAX_EVENTS; i++)
@@ -378,7 +457,7 @@ int cpts_register(struct cpts *cpts)
        }
        cpts->phc_index = ptp_clock_index(cpts->clock);
 
-       schedule_delayed_work(&cpts->overflow_work, cpts->ov_check_period);
+       ptp_schedule_worker(cpts->clock, cpts->ov_check_period);
        return 0;
 
 err_ptp:
@@ -392,14 +471,15 @@ void cpts_unregister(struct cpts *cpts)
        if (WARN_ON(!cpts->clock))
                return;
 
-       cancel_delayed_work_sync(&cpts->overflow_work);
-
        ptp_clock_unregister(cpts->clock);
        cpts->clock = NULL;
 
        cpts_write32(cpts, 0, int_enable);
        cpts_write32(cpts, 0, control);
 
+       /* Drop all packet */
+       skb_queue_purge(&cpts->txq);
+
        clk_disable(cpts->refclk);
 }
 EXPORT_SYMBOL_GPL(cpts_unregister);
@@ -476,7 +556,6 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
        cpts->dev = dev;
        cpts->reg = (struct cpsw_cpts __iomem *)regs;
        spin_lock_init(&cpts->lock);
-       INIT_DELAYED_WORK(&cpts->overflow_work, cpts_overflow_check);
 
        ret = cpts_of_parse(cpts, node);
        if (ret)
index 01ea82ba9cdca7e83a03f36d9ef1f43ec4267bc0..73d73faf0f38748327cf5ca241f7a5c685f10275 100644 (file)
@@ -119,13 +119,13 @@ struct cpts {
        u32 cc_mult; /* for the nominal frequency */
        struct cyclecounter cc;
        struct timecounter tc;
-       struct delayed_work overflow_work;
        int phc_index;
        struct clk *refclk;
        struct list_head events;
        struct list_head pool;
        struct cpts_event pool_data[CPTS_MAX_EVENTS];
        unsigned long ov_check_period;
+       struct sk_buff_head txq;
 };
 
 void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
index de8156c6b2925741534a45a6c3a28a3afe9d1ad6..2bbda71818adb022853964dd6d51a14c26f7cd19 100644 (file)
@@ -1091,7 +1091,7 @@ static int geneve_validate(struct nlattr *tb[], struct nlattr *data[],
        if (data[IFLA_GENEVE_ID]) {
                __u32 vni =  nla_get_u32(data[IFLA_GENEVE_ID]);
 
-               if (vni >= GENEVE_VID_MASK)
+               if (vni >= GENEVE_N_VID)
                        return -ERANGE;
        }
 
index 1542e837fdfa777e96155f041bc6d2072946d0cc..f38e32a7ec9c979ac4524c31e09da375a6e0606c 100644 (file)
@@ -364,7 +364,7 @@ static int gtp_dev_init(struct net_device *dev)
 
        gtp->dev = dev;
 
-       dev->tstats = alloc_percpu(struct pcpu_sw_netstats);
+       dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
        if (!dev->tstats)
                return -ENOMEM;
 
index d6c25580f8dd636dc43fe464adb339f597fdbcee..12cc64bfcff83c3c28c1bf97033dfd0162848b0e 100644 (file)
@@ -765,7 +765,8 @@ struct netvsc_device {
        u32 max_chn;
        u32 num_chn;
 
-       refcount_t sc_offered;
+       atomic_t open_chn;
+       wait_queue_head_t subchan_open;
 
        struct rndis_device *extension;
 
index 0a9167dd72fb94e50692fa70ec9bc50fd99f733e..d18c3326a1f782b403de4a10ef057196beb3aaa5 100644 (file)
@@ -78,6 +78,7 @@ static struct netvsc_device *alloc_net_device(void)
        net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
        net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
        init_completion(&net_device->channel_init_wait);
+       init_waitqueue_head(&net_device->subchan_open);
 
        return net_device;
 }
@@ -1302,6 +1303,8 @@ int netvsc_device_add(struct hv_device *device,
                struct netvsc_channel *nvchan = &net_device->chan_table[i];
 
                nvchan->channel = device->channel;
+               u64_stats_init(&nvchan->tx_stats.syncp);
+               u64_stats_init(&nvchan->rx_stats.syncp);
        }
 
        /* Enable NAPI handler before init callbacks */
index 0d78727f1a14dd9c4ae301f053769437cbe4eb3b..d91cbc6c3ca4eee43090bccc70c76b9a9d1fbb85 100644 (file)
@@ -1269,7 +1269,12 @@ static void netvsc_link_change(struct work_struct *w)
        bool notify = false, reschedule = false;
        unsigned long flags, next_reconfig, delay;
 
-       rtnl_lock();
+       /* if changes are happening, comeback later */
+       if (!rtnl_trylock()) {
+               schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
+               return;
+       }
+
        net_device = rtnl_dereference(ndev_ctx->nvdev);
        if (!net_device)
                goto out_unlock;
index 85c00e1c52b6aa9309e782df639e03f444ffc1be..d6308ffda53ec797acf5f9e6038bf0a230008b55 100644 (file)
@@ -1048,8 +1048,8 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
        else
                netif_napi_del(&nvchan->napi);
 
-       if (refcount_dec_and_test(&nvscdev->sc_offered))
-               complete(&nvscdev->channel_init_wait);
+       atomic_inc(&nvscdev->open_chn);
+       wake_up(&nvscdev->subchan_open);
 }
 
 int rndis_filter_device_add(struct hv_device *dev,
@@ -1090,8 +1090,6 @@ int rndis_filter_device_add(struct hv_device *dev,
        net_device->max_chn = 1;
        net_device->num_chn = 1;
 
-       refcount_set(&net_device->sc_offered, 0);
-
        net_device->extension = rndis_device;
        rndis_device->ndev = net;
 
@@ -1221,11 +1219,11 @@ int rndis_filter_device_add(struct hv_device *dev,
                rndis_device->ind_table[i] = ethtool_rxfh_indir_default(i,
                                                        net_device->num_chn);
 
+       atomic_set(&net_device->open_chn, 1);
        num_rss_qs = net_device->num_chn - 1;
        if (num_rss_qs == 0)
                return 0;
 
-       refcount_set(&net_device->sc_offered, num_rss_qs);
        vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open);
 
        init_packet = &net_device->channel_init_pkt;
@@ -1242,15 +1240,19 @@ int rndis_filter_device_add(struct hv_device *dev,
        if (ret)
                goto out;
 
+       wait_for_completion(&net_device->channel_init_wait);
        if (init_packet->msg.v5_msg.subchn_comp.status != NVSP_STAT_SUCCESS) {
                ret = -ENODEV;
                goto out;
        }
-       wait_for_completion(&net_device->channel_init_wait);
 
        net_device->num_chn = 1 +
                init_packet->msg.v5_msg.subchn_comp.num_subchannels;
 
+       /* wait for all sub channels to open */
+       wait_event(net_device->subchan_open,
+                  atomic_read(&net_device->open_chn) == net_device->num_chn);
+
        /* ignore failues from setting rss parameters, still have channels */
        rndis_filter_set_rss_param(rndis_device, netvsc_hash_key,
                                   net_device->num_chn);
index f37e3c1fd4e73f27e46564a6ef2739ff658523df..8dab74a81303277aed5cf24844941bdcadfcef1a 100644 (file)
@@ -192,7 +192,7 @@ static int ipvlan_init(struct net_device *dev)
 
        netdev_lockdep_set_classes(dev);
 
-       ipvlan->pcpu_stats = alloc_percpu(struct ipvl_pcpu_stats);
+       ipvlan->pcpu_stats = netdev_alloc_pcpu_stats(struct ipvl_pcpu_stats);
        if (!ipvlan->pcpu_stats)
                return -ENOMEM;
 
index 5e1ab11608560799bb6d956b213d06f58b8fc45e..98e4deaa3a6a1c2f89d55e8f2db54b6fc93380be 100644 (file)
@@ -3521,6 +3521,7 @@ module_init(macsec_init);
 module_exit(macsec_exit);
 
 MODULE_ALIAS_RTNL_LINK("macsec");
+MODULE_ALIAS_GENL_FAMILY("macsec");
 
 MODULE_DESCRIPTION("MACsec IEEE 802.1AE");
 MODULE_LICENSE("GPL v2");
index 5068c582d502c6944a01a2ee87062d7ffb409034..d0626bf5c540911b0d15bdbab1b960145b6d124c 100644 (file)
@@ -749,9 +749,6 @@ void phy_stop_machine(struct phy_device *phydev)
        if (phydev->state > PHY_UP && phydev->state != PHY_HALTED)
                phydev->state = PHY_UP;
        mutex_unlock(&phydev->lock);
-
-       /* Now we can run the state machine synchronously */
-       phy_state_machine(&phydev->state_queue.work);
 }
 
 /**
index 1790f7fec12573fe21d088f9865126784efc0c08..2f742ae5b92ee7d7be080ec60fca7958f722e576 100644 (file)
@@ -864,15 +864,17 @@ EXPORT_SYMBOL(phy_attached_info);
 #define ATTACHED_FMT "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)"
 void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
 {
+       const char *drv_name = phydev->drv ? phydev->drv->name : "unbound";
+
        if (!fmt) {
                dev_info(&phydev->mdio.dev, ATTACHED_FMT "\n",
-                        phydev->drv->name, phydev_name(phydev),
+                        drv_name, phydev_name(phydev),
                         phydev->irq);
        } else {
                va_list ap;
 
                dev_info(&phydev->mdio.dev, ATTACHED_FMT,
-                        phydev->drv->name, phydev_name(phydev),
+                        drv_name, phydev_name(phydev),
                         phydev->irq);
 
                va_start(ap, fmt);
index bd4303944e4405d543a399f6fc529df9ffd41e02..a404552555d488c832e7758293d7d4c1e229e679 100644 (file)
@@ -1915,21 +1915,23 @@ static void __ppp_channel_push(struct channel *pch)
        spin_unlock(&pch->downl);
        /* see if there is anything from the attached unit to be sent */
        if (skb_queue_empty(&pch->file.xq)) {
-               read_lock(&pch->upl);
                ppp = pch->ppp;
                if (ppp)
-                       ppp_xmit_process(ppp);
-               read_unlock(&pch->upl);
+                       __ppp_xmit_process(ppp);
        }
 }
 
 static void ppp_channel_push(struct channel *pch)
 {
-       local_bh_disable();
-
-       __ppp_channel_push(pch);
-
-       local_bh_enable();
+       read_lock_bh(&pch->upl);
+       if (pch->ppp) {
+               (*this_cpu_ptr(pch->ppp->xmit_recursion))++;
+               __ppp_channel_push(pch);
+               (*this_cpu_ptr(pch->ppp->xmit_recursion))--;
+       } else {
+               __ppp_channel_push(pch);
+       }
+       read_unlock_bh(&pch->upl);
 }
 
 /*
index 32ad87345f5798498584d8dcfbda2f9ac993e619..0a2c0a42283f780b947fcf52fcb4220e73f0fa2f 100644 (file)
@@ -1879,6 +1879,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 
 err_detach:
        tun_detach_all(dev);
+       /* register_netdevice() already called tun_free_netdev() */
+       goto err_free_dev;
+
 err_free_flow:
        tun_flow_uninit(tun);
        security_tun_dev_free_security(tun->security);
index d1092421aaa7e7b69ba926d508155574f072ba61..9a4171b9094760871cf4396c99b2236bccd15193 100644 (file)
@@ -209,6 +209,7 @@ void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
 int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
                           struct asix_rx_fixup_info *rx);
 int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb);
+void asix_rx_fixup_common_free(struct asix_common_private *dp);
 
 struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
                              gfp_t flags);
index 7847436c441e3c16b91fb0d72c3f07061d4e772d..522d2900cd1dd942ae58c407920289e95f0ae5e3 100644 (file)
@@ -75,6 +75,27 @@ void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
                               value, index, data, size);
 }
 
+static void reset_asix_rx_fixup_info(struct asix_rx_fixup_info *rx)
+{
+       /* Reset the variables that have a lifetime outside of
+        * asix_rx_fixup_internal() so that future processing starts from a
+        * known set of initial conditions.
+        */
+
+       if (rx->ax_skb) {
+               /* Discard any incomplete Ethernet frame in the netdev buffer */
+               kfree_skb(rx->ax_skb);
+               rx->ax_skb = NULL;
+       }
+
+       /* Assume the Data header 32-bit word is at the start of the current
+        * or next URB socket buffer so reset all the state variables.
+        */
+       rx->remaining = 0;
+       rx->split_head = false;
+       rx->header = 0;
+}
+
 int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
                           struct asix_rx_fixup_info *rx)
 {
@@ -99,15 +120,7 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
                if (size != ((~rx->header >> 16) & 0x7ff)) {
                        netdev_err(dev->net, "asix_rx_fixup() Data Header synchronisation was lost, remaining %d\n",
                                   rx->remaining);
-                       if (rx->ax_skb) {
-                               kfree_skb(rx->ax_skb);
-                               rx->ax_skb = NULL;
-                               /* Discard the incomplete netdev Ethernet frame
-                                * and assume the Data header is at the start of
-                                * the current URB socket buffer.
-                                */
-                       }
-                       rx->remaining = 0;
+                       reset_asix_rx_fixup_info(rx);
                }
        }
 
@@ -139,11 +152,13 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
                        if (size != ((~rx->header >> 16) & 0x7ff)) {
                                netdev_err(dev->net, "asix_rx_fixup() Bad Header Length 0x%x, offset %d\n",
                                           rx->header, offset);
+                               reset_asix_rx_fixup_info(rx);
                                return 0;
                        }
                        if (size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) {
                                netdev_dbg(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
                                           size);
+                               reset_asix_rx_fixup_info(rx);
                                return 0;
                        }
 
@@ -168,8 +183,10 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
                if (rx->ax_skb) {
                        skb_put_data(rx->ax_skb, skb->data + offset,
                                     copy_length);
-                       if (!rx->remaining)
+                       if (!rx->remaining) {
                                usbnet_skb_return(dev, rx->ax_skb);
+                               rx->ax_skb = NULL;
+                       }
                }
 
                offset += (copy_length + 1) & 0xfffe;
@@ -178,6 +195,7 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
        if (skb->len != offset) {
                netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d, %d\n",
                           skb->len, offset);
+               reset_asix_rx_fixup_info(rx);
                return 0;
        }
 
@@ -192,6 +210,21 @@ int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb)
        return asix_rx_fixup_internal(dev, skb, rx);
 }
 
+void asix_rx_fixup_common_free(struct asix_common_private *dp)
+{
+       struct asix_rx_fixup_info *rx;
+
+       if (!dp)
+               return;
+
+       rx = &dp->rx_fixup_info;
+
+       if (rx->ax_skb) {
+               kfree_skb(rx->ax_skb);
+               rx->ax_skb = NULL;
+       }
+}
+
 struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
                              gfp_t flags)
 {
index a3aa0a27dfe56b22121a0571cc4eaca1b2bbee03..b2ff88e69a819cc3098a720ece238d8847d6be57 100644 (file)
@@ -764,6 +764,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
+       asix_rx_fixup_common_free(dev->driver_priv);
        kfree(dev->driver_priv);
 }
 
index 8f572b9f362555b55dc2e3cccfc5761140664616..9c80e80c5493b4f5a5d56c06f0d188debe53eca1 100644 (file)
@@ -1758,6 +1758,13 @@ static const struct usb_device_id cdc_devs[] = {
          .driver_info = (unsigned long)&wwan_noarp_info,
        },
 
+       /* u-blox TOBY-L4 */
+       { USB_DEVICE_AND_INTERFACE_INFO(0x1546, 0x1010,
+               USB_CLASS_COMM,
+               USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
+         .driver_info = (unsigned long)&wwan_info,
+       },
+
        /* Generic CDC-NCM devices */
        { USB_INTERFACE_INFO(USB_CLASS_COMM,
                USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
index 5833f7e2a127811aa2298ded2bc62b1d06ae1e9d..b99a7fb09f8e31827a725151b415967699cdfa27 100644 (file)
@@ -2367,9 +2367,6 @@ static int lan78xx_reset(struct lan78xx_net *dev)
        /* Init LTM */
        lan78xx_init_ltm(dev);
 
-       dev->net->hard_header_len += TX_OVERHEAD;
-       dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
-
        if (dev->udev->speed == USB_SPEED_SUPER) {
                buf = DEFAULT_BURST_CAP_SIZE / SS_USB_PKT_SIZE;
                dev->rx_urb_size = DEFAULT_BURST_CAP_SIZE;
@@ -2855,16 +2852,19 @@ static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf)
                return ret;
        }
 
+       dev->net->hard_header_len += TX_OVERHEAD;
+       dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
+
        /* Init all registers */
        ret = lan78xx_reset(dev);
 
-       lan78xx_mdio_init(dev);
+       ret = lan78xx_mdio_init(dev);
 
        dev->net->flags |= IFF_MULTICAST;
 
        pdata->wol = WAKE_MAGIC;
 
-       return 0;
+       return ret;
 }
 
 static void lan78xx_unbind(struct lan78xx_net *dev, struct usb_interface *intf)
@@ -3525,11 +3525,11 @@ static int lan78xx_probe(struct usb_interface *intf,
        udev = interface_to_usbdev(intf);
        udev = usb_get_dev(udev);
 
-       ret = -ENOMEM;
        netdev = alloc_etherdev(sizeof(struct lan78xx_net));
        if (!netdev) {
-                       dev_err(&intf->dev, "Error: OOM\n");
-                       goto out1;
+               dev_err(&intf->dev, "Error: OOM\n");
+               ret = -ENOMEM;
+               goto out1;
        }
 
        /* netdev_printk() needs this */
@@ -3610,7 +3610,7 @@ static int lan78xx_probe(struct usb_interface *intf,
        ret = register_netdev(netdev);
        if (ret != 0) {
                netif_err(dev, probe, netdev, "couldn't register the device\n");
-               goto out2;
+               goto out3;
        }
 
        usb_set_intfdata(intf, dev);
index 5894e3c9468f590e6b50144901b3f3b606e4ee69..8c373360827108855717f6d139034ff9f264bf0b 100644 (file)
@@ -1175,6 +1175,7 @@ static const struct usb_device_id products[] = {
        {QMI_FIXED_INTF(0x19d2, 0x1428, 2)},    /* Telewell TW-LTE 4G v2 */
        {QMI_FIXED_INTF(0x19d2, 0x2002, 4)},    /* ZTE (Vodafone) K3765-Z */
        {QMI_FIXED_INTF(0x2001, 0x7e19, 4)},    /* D-Link DWM-221 B1 */
+       {QMI_FIXED_INTF(0x2001, 0x7e35, 4)},    /* D-Link DWM-222 */
        {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
        {QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
        {QMI_FIXED_INTF(0x1199, 0x68a2, 8)},    /* Sierra Wireless MC7710 in QMI mode */
@@ -1340,10 +1341,14 @@ static int qmi_wwan_probe(struct usb_interface *intf,
 static void qmi_wwan_disconnect(struct usb_interface *intf)
 {
        struct usbnet *dev = usb_get_intfdata(intf);
-       struct qmi_wwan_state *info = (void *)&dev->data;
+       struct qmi_wwan_state *info;
        struct list_head *iter;
        struct net_device *ldev;
 
+       /* called twice if separate control and data intf */
+       if (!dev)
+               return;
+       info = (void *)&dev->data;
        if (info->flags & QMI_WWAN_FLAG_MUX) {
                if (!rtnl_trylock()) {
                        restart_syscall();
index 98f17b05c68b745276ecbe67d2934918eaf340bd..b06169ea60dc9d519f9a7673e9aea809539dbd5c 100644 (file)
@@ -1058,7 +1058,7 @@ static void free_old_xmit_skbs(struct send_queue *sq)
                bytes += skb->len;
                packets++;
 
-               dev_kfree_skb_any(skb);
+               dev_consume_skb_any(skb);
        }
 
        /* Avoid overhead when no packets have been processed
index 96aa7e6cf214cc332eba6d54fcd626bee917c633..e17baac70f439f86c723732cc0298eaa5eee15de 100644 (file)
@@ -623,6 +623,7 @@ static struct sk_buff **vxlan_gro_receive(struct sock *sk,
 
 out:
        skb_gro_remcsum_cleanup(skb, &grc);
+       skb->remcsum_offload = 0;
        NAPI_GRO_CB(skb)->flush |= flush;
 
        return pp;
index d21258d277ce4bca965e588e537df507d4e23892..f1b60740e02080261d998686a28e27c9ee4ea8a2 100644 (file)
@@ -159,8 +159,10 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
 
        brcmf_feat_firmware_capabilities(ifp);
        memset(&gscan_cfg, 0, sizeof(gscan_cfg));
-       brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, "pfn_gscan_cfg",
-                                 &gscan_cfg, sizeof(gscan_cfg));
+       if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID)
+               brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN,
+                                         "pfn_gscan_cfg",
+                                         &gscan_cfg, sizeof(gscan_cfg));
        brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn");
        if (drvr->bus_if->wowl_supported)
                brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl");
index b4ecd1fe137489617ab477608e0152712db0f784..97208ce19f927685ce79b2b2321ee5b3086f7a3c 100644 (file)
@@ -154,7 +154,7 @@ static const struct iwl_tt_params iwl9000_tt_params = {
 const struct iwl_cfg iwl9160_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9160",
        .fw_name_pre = IWL9260A_FW_PRE,
-       .fw_name_pre_next_step = IWL9260B_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -165,7 +165,7 @@ const struct iwl_cfg iwl9160_2ac_cfg = {
 const struct iwl_cfg iwl9260_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9260",
        .fw_name_pre = IWL9260A_FW_PRE,
-       .fw_name_pre_next_step = IWL9260B_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -176,7 +176,7 @@ const struct iwl_cfg iwl9260_2ac_cfg = {
 const struct iwl_cfg iwl9270_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9270",
        .fw_name_pre = IWL9260A_FW_PRE,
-       .fw_name_pre_next_step = IWL9260B_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -186,8 +186,8 @@ const struct iwl_cfg iwl9270_2ac_cfg = {
 
 const struct iwl_cfg iwl9460_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9460",
-       .fw_name_pre = IWL9000_FW_PRE,
-       .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
+       .fw_name_pre = IWL9260A_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
@@ -198,8 +198,8 @@ const struct iwl_cfg iwl9460_2ac_cfg = {
 
 const struct iwl_cfg iwl9560_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 9560",
-       .fw_name_pre = IWL9000_FW_PRE,
-       .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE,
+       .fw_name_pre = IWL9260A_FW_PRE,
+       .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
        IWL_DEVICE_9000,
        .ht_params = &iwl9000_ht_params,
        .nvm_ver = IWL9000_NVM_VERSION,
index 0fa8c473f1e2738b8490e2555af1ae95319d96dd..c73a6438ce8fbcd12a8e12e359c5f7d25e66a76f 100644 (file)
@@ -328,6 +328,7 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
  * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger
  *     command size (command version 4) that supports toggling ACK TX
  *     power reduction.
+ * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload
  *
  * @NUM_IWL_UCODE_TLV_CAPA: number of bits used
  */
@@ -373,6 +374,7 @@ enum iwl_ucode_tlv_capa {
        IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG        = (__force iwl_ucode_tlv_capa_t)80,
        IWL_UCODE_TLV_CAPA_LQM_SUPPORT                  = (__force iwl_ucode_tlv_capa_t)81,
        IWL_UCODE_TLV_CAPA_TX_POWER_ACK                 = (__force iwl_ucode_tlv_capa_t)84,
+       IWL_UCODE_TLV_CAPA_MLME_OFFLOAD                 = (__force iwl_ucode_tlv_capa_t)96,
 
        NUM_IWL_UCODE_TLV_CAPA
 #ifdef __CHECKER__
index c52623cb7c2a1bc89d635f4406df70bc3101f340..d19c74827fbb6094147ab48fc266cd6dbbb15e28 100644 (file)
@@ -276,10 +276,10 @@ struct iwl_pwr_tx_backoff {
  * @fw_name_pre: Firmware filename prefix. The api version and extension
  *     (.ucode) will be added to filename before loading from disk. The
  *     filename is constructed as fw_name_pre<api>.ucode.
- * @fw_name_pre_next_step: same as @fw_name_pre, only for next step
+ * @fw_name_pre_b_or_c_step: same as @fw_name_pre, only for b or c steps
  *     (if supported)
- * @fw_name_pre_rf_next_step: same as @fw_name_pre_next_step, only for rf next
- *     step. Supported only in integrated solutions.
+ * @fw_name_pre_rf_next_step: same as @fw_name_pre_b_or_c_step, only for rf
+ *     next step. Supported only in integrated solutions.
  * @ucode_api_max: Highest version of uCode API supported by driver.
  * @ucode_api_min: Lowest version of uCode API supported by driver.
  * @max_inst_size: The maximal length of the fw inst section
@@ -330,7 +330,7 @@ struct iwl_cfg {
        /* params specific to an individual device within a device family */
        const char *name;
        const char *fw_name_pre;
-       const char *fw_name_pre_next_step;
+       const char *fw_name_pre_b_or_c_step;
        const char *fw_name_pre_rf_next_step;
        /* params not likely to change within a device family */
        const struct iwl_base_params *base_params;
index 6fdb5921e17f41846db6a4c7302d9248247d1c03..4e0f86fe0a6f0874a96d41ae257c9621a2f035ee 100644 (file)
@@ -216,8 +216,9 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
        const char *fw_pre_name;
 
        if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
-           CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP)
-               fw_pre_name = cfg->fw_name_pre_next_step;
+           (CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP ||
+            CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_C_STEP))
+               fw_pre_name = cfg->fw_name_pre_b_or_c_step;
        else if (drv->trans->cfg->integrated &&
                 CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP &&
                 cfg->fw_name_pre_rf_next_step)
index 5c08f4d40f6ac78fbdeb575e152742c9c0a3cef5..3ee6767392b61151efc774610223e2f6216d22f3 100644 (file)
@@ -785,7 +785,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                       int num_of_ch, __le32 *channels, u16 fw_mcc)
 {
        int ch_idx;
-       u16 ch_flags, prev_ch_flags = 0;
+       u16 ch_flags;
+       u32 reg_rule_flags, prev_reg_rule_flags = 0;
        const u8 *nvm_chan = cfg->ext_nvm ?
                             iwl_ext_nvm_channels : iwl_nvm_channels;
        struct ieee80211_regdomain *regd;
@@ -834,8 +835,11 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                        continue;
                }
 
+               reg_rule_flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx,
+                                                            ch_flags, cfg);
+
                /* we can't continue the same rule */
-               if (ch_idx == 0 || prev_ch_flags != ch_flags ||
+               if (ch_idx == 0 || prev_reg_rule_flags != reg_rule_flags ||
                    center_freq - prev_center_freq > 20) {
                        valid_rules++;
                        new_rule = true;
@@ -854,18 +858,17 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                rule->power_rule.max_eirp =
                        DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER);
 
-               rule->flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx,
-                                                         ch_flags, cfg);
+               rule->flags = reg_rule_flags;
 
                /* rely on auto-calculation to merge BW of contiguous chans */
                rule->flags |= NL80211_RRF_AUTO_BW;
                rule->freq_range.max_bandwidth_khz = 0;
 
-               prev_ch_flags = ch_flags;
                prev_center_freq = center_freq;
+               prev_reg_rule_flags = reg_rule_flags;
 
                IWL_DEBUG_DEV(dev, IWL_DL_LAR,
-                             "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x): Ad-Hoc %ssupported\n",
+                             "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x) reg_flags 0x%x: %s\n",
                              center_freq,
                              band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
                              CHECK_AND_PRINT_I(VALID),
@@ -877,10 +880,10 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                              CHECK_AND_PRINT_I(160MHZ),
                              CHECK_AND_PRINT_I(INDOOR_ONLY),
                              CHECK_AND_PRINT_I(GO_CONCURRENT),
-                             ch_flags,
+                             ch_flags, reg_rule_flags,
                              ((ch_flags & NVM_CHANNEL_ACTIVE) &&
                               !(ch_flags & NVM_CHANNEL_RADAR))
-                                        ? "" : "not ");
+                                        ? "Ad-Hoc" : "");
        }
 
        regd->n_reg_rules = valid_rules;
index 79e7a7a285dc960597e945ce7b80f96e729a86ad..82863e9273eb66ce9058a5974d2f35988290e1dc 100644 (file)
@@ -1275,8 +1275,10 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
 
                        entry = &wifi_pkg->package.elements[idx++];
                        if ((entry->type != ACPI_TYPE_INTEGER) ||
-                           (entry->integer.value > U8_MAX))
-                               return -EINVAL;
+                           (entry->integer.value > U8_MAX)) {
+                               ret = -EINVAL;
+                               goto out_free;
+                       }
 
                        mvm->geo_profiles[i].values[j] = entry->integer.value;
                }
index c7b1e58e33847a8250ab708695373a0817f85874..ce901be5fba87e3674f06b030cfae8759e063c3b 100644 (file)
@@ -2597,8 +2597,18 @@ static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm *mvm,
        spin_lock_bh(&mvm_sta->lock);
        for (i = 0; i <= IWL_MAX_TID_COUNT; i++) {
                tid_data = &mvm_sta->tid_data[i];
-               while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames)))
+
+               while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) {
+                       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+
+                       /*
+                        * The first deferred frame should've stopped the MAC
+                        * queues, so we should never get a second deferred
+                        * frame for the RA/TID.
+                        */
+                       iwl_mvm_start_mac_queues(mvm, info->hw_queue);
                        ieee80211_free_txskb(mvm->hw, skb);
+               }
        }
        spin_unlock_bh(&mvm_sta->lock);
 }
index 65beca3a457a19d2dcd804d01a590f7404e04f65..8999a1199d60d27bdec88d6c638feb85403c3ced 100644 (file)
@@ -1291,7 +1291,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
         * first index into rate scale table.
         */
        if (info->flags & IEEE80211_TX_STAT_AMPDU) {
-               rs_collect_tpc_data(mvm, lq_sta, curr_tbl, lq_rate.index,
+               rs_collect_tpc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index,
                                    info->status.ampdu_len,
                                    info->status.ampdu_ack_len,
                                    reduced_txp);
@@ -1312,7 +1312,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
                if (info->status.ampdu_ack_len == 0)
                        info->status.ampdu_len = 1;
 
-               rs_collect_tlc_data(mvm, lq_sta, curr_tbl, lq_rate.index,
+               rs_collect_tlc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index,
                                    info->status.ampdu_len,
                                    info->status.ampdu_ack_len);
 
@@ -1348,11 +1348,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
                                continue;
 
                        rs_collect_tpc_data(mvm, lq_sta, tmp_tbl,
-                                           lq_rate.index, 1,
+                                           tx_resp_rate.index, 1,
                                            i < retries ? 0 : legacy_success,
                                            reduced_txp);
                        rs_collect_tlc_data(mvm, lq_sta, tmp_tbl,
-                                           lq_rate.index, 1,
+                                           tx_resp_rate.index, 1,
                                            i < retries ? 0 : legacy_success);
                }
 
index f3e608196369a3885804b42331f442a16623e388..71c8b800ffa99874bd4120e59e2aa7f51212d2da 100644 (file)
@@ -636,9 +636,9 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
 
        baid_data = rcu_dereference(mvm->baid_map[baid]);
        if (!baid_data) {
-               WARN(!(reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN),
-                    "Received baid %d, but no data exists for this BAID\n",
-                    baid);
+               IWL_DEBUG_RX(mvm,
+                            "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
+                             baid, reorder);
                return false;
        }
 
@@ -759,7 +759,9 @@ static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm,
 
        data = rcu_dereference(mvm->baid_map[baid]);
        if (!data) {
-               WARN_ON(!(reorder_data & IWL_RX_MPDU_REORDER_BA_OLD_SN));
+               IWL_DEBUG_RX(mvm,
+                            "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
+                             baid, reorder_data);
                goto out;
        }
 
index ab66b4394dfc8ca2afc0cf1321f93f28f186d1cb..027ee5e72172c85f9eaa98f1fd1a26489ab74820 100644 (file)
@@ -121,7 +121,8 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
                .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color),
                .add_modify = update ? 1 : 0,
                .station_flags_msk = cpu_to_le32(STA_FLG_FAT_EN_MSK |
-                                                STA_FLG_MIMO_EN_MSK),
+                                                STA_FLG_MIMO_EN_MSK |
+                                                STA_FLG_RTS_MIMO_PROT),
                .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg),
        };
        int ret;
@@ -290,8 +291,8 @@ static void iwl_mvm_rx_agg_session_expired(unsigned long data)
                goto unlock;
 
        mvm_sta = iwl_mvm_sta_from_mac80211(sta);
-       ieee80211_stop_rx_ba_session_offl(mvm_sta->vif,
-                                         sta->addr, ba_data->tid);
+       ieee80211_rx_ba_timer_expired(mvm_sta->vif,
+                                     sta->addr, ba_data->tid);
 unlock:
        rcu_read_unlock();
 }
index 60360ed73f26165c890d0af3bac742b5669fb8d9..5fcc9dd6be56de52fa0a063969cf58011b8eb3d8 100644 (file)
@@ -185,8 +185,14 @@ static u16 iwl_mvm_tx_csum(struct iwl_mvm *mvm, struct sk_buff *skb,
        else
                udp_hdr(skb)->check = 0;
 
-       /* mac header len should include IV, size is in words */
-       if (info->control.hw_key)
+       /*
+        * mac header len should include IV, size is in words unless
+        * the IV is added by the firmware like in WEP.
+        * In new Tx API, the IV is always added by the firmware.
+        */
+       if (!iwl_mvm_has_new_tx_api(mvm) && info->control.hw_key &&
+           info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP40 &&
+           info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP104)
                mh_len += info->control.hw_key->iv_len;
        mh_len /= 2;
        offload_assist |= mh_len << TX_CMD_OFFLD_MH_SIZE;
@@ -1815,6 +1821,8 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
        struct iwl_mvm_tid_data *tid_data;
        struct iwl_mvm_sta *mvmsta;
 
+       ba_info.flags = IEEE80211_TX_STAT_AMPDU;
+
        if (iwl_mvm_has_new_tx_api(mvm)) {
                struct iwl_mvm_compressed_ba_notif *ba_res =
                        (void *)pkt->data;
index f16c1bb9bf94b6bef6bfb6ce2ff36c3faf771c00..84f4ba01e14fa2e84878dc75fda5d050e3500880 100644 (file)
@@ -510,9 +510,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
 
 /* 9000 Series */
        {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9460_2ac_cfg)},
@@ -527,10 +535,22 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
        {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)},
        {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)},
+       {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)},
        {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)},
        {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)},
        {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)},
index fa315d84e98eacdf4f58bf47863f9f0aa3cce712..a1ea9ef97ed97adc31e7c399b66123cbab8058e1 100644 (file)
@@ -787,6 +787,8 @@ int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans);
 
 void iwl_pcie_enable_rx_wake(struct iwl_trans *trans, bool enable);
 
+void iwl_pcie_rx_allocator_work(struct work_struct *data);
+
 /* common functions that are used by gen2 transport */
 void iwl_pcie_apm_config(struct iwl_trans *trans);
 int iwl_pcie_prepare_card_hw(struct iwl_trans *trans);
index 351c4423125a219cc88b4dc0846d5b573526afbb..942736d3fa75521018580aed3518dd2fea251fc6 100644 (file)
@@ -597,7 +597,7 @@ static void iwl_pcie_rx_allocator_get(struct iwl_trans *trans,
        rxq->free_count += RX_CLAIM_REQ_ALLOC;
 }
 
-static void iwl_pcie_rx_allocator_work(struct work_struct *data)
+void iwl_pcie_rx_allocator_work(struct work_struct *data)
 {
        struct iwl_rb_allocator *rba_p =
                container_of(data, struct iwl_rb_allocator, rx_alloc);
@@ -900,10 +900,6 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
                        return err;
        }
        def_rxq = trans_pcie->rxq;
-       if (!rba->alloc_wq)
-               rba->alloc_wq = alloc_workqueue("rb_allocator",
-                                               WQ_HIGHPRI | WQ_UNBOUND, 1);
-       INIT_WORK(&rba->rx_alloc, iwl_pcie_rx_allocator_work);
 
        spin_lock(&rba->lock);
        atomic_set(&rba->req_pending, 0);
@@ -1017,10 +1013,6 @@ void iwl_pcie_rx_free(struct iwl_trans *trans)
        }
 
        cancel_work_sync(&rba->rx_alloc);
-       if (rba->alloc_wq) {
-               destroy_workqueue(rba->alloc_wq);
-               rba->alloc_wq = NULL;
-       }
 
        iwl_pcie_free_rbs_pool(trans);
 
index f95eec52508e9bc4784f5cda71548bbd7d761b0b..3927bbf04f727d5e0b9a9c0a9d1c78cee42e3d94 100644 (file)
@@ -1786,6 +1786,11 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)
                iwl_pcie_tx_free(trans);
        iwl_pcie_rx_free(trans);
 
+       if (trans_pcie->rba.alloc_wq) {
+               destroy_workqueue(trans_pcie->rba.alloc_wq);
+               trans_pcie->rba.alloc_wq = NULL;
+       }
+
        if (trans_pcie->msix_enabled) {
                for (i = 0; i < trans_pcie->alloc_vecs; i++) {
                        irq_set_affinity_hint(
@@ -3169,6 +3174,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
                trans_pcie->inta_mask = CSR_INI_SET_MASK;
         }
 
+       trans_pcie->rba.alloc_wq = alloc_workqueue("rb_allocator",
+                                                  WQ_HIGHPRI | WQ_UNBOUND, 1);
+       INIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work);
+
 #ifdef CONFIG_IWLWIFI_PCIE_RTPM
        trans->runtime_pm_mode = IWL_PLAT_PM_MODE_D0I3;
 #else
index 08f0477f78d93d102b11524cffeb982d7ac29c82..9915d83a4a30550816fafbc741471e00fb694942 100644 (file)
@@ -1571,6 +1571,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 
        wl->state = WL1251_STATE_OFF;
        mutex_init(&wl->mutex);
+       spin_lock_init(&wl->wl_lock);
 
        wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
        wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
index 9a03c5871efe675015418e6f5e1ebd1745faaac0..f58d8e3053236ad4608e5552052214b0694a3a95 100644 (file)
@@ -924,10 +924,8 @@ out1:
                ntb_free_mw(nt, i);
 
        /* if there's an actual failure, we should just bail */
-       if (rc < 0) {
-               ntb_link_disable(ndev);
+       if (rc < 0)
                return;
-       }
 
 out:
        if (ntb_link_is_up(ndev, NULL, NULL) == 1)
@@ -1059,7 +1057,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
        int node;
        int rc, i;
 
-       mw_count = ntb_mw_count(ndev, PIDX);
+       mw_count = ntb_peer_mw_count(ndev);
 
        if (!ndev->ops->mw_set_trans) {
                dev_err(&ndev->dev, "Inbound MW based NTB API is required\n");
index f002bf48a08dbefd0602532bc6d2f1dbf4f68a3a..a69815c45ce6f2137d9f409bad0b8742fa530df4 100644 (file)
@@ -959,7 +959,7 @@ static int tool_probe(struct ntb_client *self, struct ntb_dev *ntb)
        tc->ntb = ntb;
        init_waitqueue_head(&tc->link_wq);
 
-       tc->mw_count = min(ntb_mw_count(tc->ntb, PIDX), MAX_MWS);
+       tc->mw_count = min(ntb_peer_mw_count(tc->ntb), MAX_MWS);
        for (i = 0; i < tc->mw_count; i++) {
                rc = tool_init_mw(tc, i);
                if (rc)
index c49f1f8b2e57459deb2605f242c9324e8960a95b..37046ac2c4413a51b9a77864cdf9e434a6ac7bd6 100644 (file)
@@ -336,7 +336,7 @@ static int nvme_get_stream_params(struct nvme_ctrl *ctrl,
 
        c.directive.opcode = nvme_admin_directive_recv;
        c.directive.nsid = cpu_to_le32(nsid);
-       c.directive.numd = cpu_to_le32(sizeof(*s));
+       c.directive.numd = cpu_to_le32((sizeof(*s) >> 2) - 1);
        c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM;
        c.directive.dtype = NVME_DIR_STREAMS;
 
@@ -1509,7 +1509,7 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
        blk_queue_write_cache(q, vwc, vwc);
 }
 
-static void nvme_configure_apst(struct nvme_ctrl *ctrl)
+static int nvme_configure_apst(struct nvme_ctrl *ctrl)
 {
        /*
         * APST (Autonomous Power State Transition) lets us program a
@@ -1538,16 +1538,16 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
         * then don't do anything.
         */
        if (!ctrl->apsta)
-               return;
+               return 0;
 
        if (ctrl->npss > 31) {
                dev_warn(ctrl->device, "NPSS is invalid; not using APST\n");
-               return;
+               return 0;
        }
 
        table = kzalloc(sizeof(*table), GFP_KERNEL);
        if (!table)
-               return;
+               return 0;
 
        if (!ctrl->apst_enabled || ctrl->ps_max_latency_us == 0) {
                /* Turn off APST. */
@@ -1629,6 +1629,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
                dev_err(ctrl->device, "failed to set APST feature (%d)\n", ret);
 
        kfree(table);
+       return ret;
 }
 
 static void nvme_set_latency_tolerance(struct device *dev, s32 val)
@@ -1835,13 +1836,16 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
                 * In fabrics we need to verify the cntlid matches the
                 * admin connect
                 */
-               if (ctrl->cntlid != le16_to_cpu(id->cntlid))
+               if (ctrl->cntlid != le16_to_cpu(id->cntlid)) {
                        ret = -EINVAL;
+                       goto out_free;
+               }
 
                if (!ctrl->opts->discovery_nqn && !ctrl->kas) {
                        dev_err(ctrl->device,
                                "keep-alive support is mandatory for fabrics\n");
                        ret = -EINVAL;
+                       goto out_free;
                }
        } else {
                ctrl->cntlid = le16_to_cpu(id->cntlid);
@@ -1856,11 +1860,20 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
        else if (!ctrl->apst_enabled && prev_apst_enabled)
                dev_pm_qos_hide_latency_tolerance(ctrl->device);
 
-       nvme_configure_apst(ctrl);
-       nvme_configure_directives(ctrl);
+       ret = nvme_configure_apst(ctrl);
+       if (ret < 0)
+               return ret;
+
+       ret = nvme_configure_directives(ctrl);
+       if (ret < 0)
+               return ret;
 
        ctrl->identified = true;
 
+       return 0;
+
+out_free:
+       kfree(id);
        return ret;
 }
 EXPORT_SYMBOL_GPL(nvme_init_identify);
@@ -2004,9 +2017,11 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
        if (memchr_inv(ns->eui, 0, sizeof(ns->eui)))
                return sprintf(buf, "eui.%8phN\n", ns->eui);
 
-       while (ctrl->serial[serial_len - 1] == ' ')
+       while (serial_len > 0 && (ctrl->serial[serial_len - 1] == ' ' ||
+                                 ctrl->serial[serial_len - 1] == '\0'))
                serial_len--;
-       while (ctrl->model[model_len - 1] == ' ')
+       while (model_len > 0 && (ctrl->model[model_len - 1] == ' ' ||
+                                ctrl->model[model_len - 1] == '\0'))
                model_len--;
 
        return sprintf(buf, "nvme.%04x-%*phN-%*phN-%08x\n", ctrl->vid,
index 2e582a2409437bca7d603598290d023bd988c577..5f5cd306f76d05e8cb7351cb91403d7f9a554d9a 100644 (file)
@@ -794,7 +794,8 @@ static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts,
                int i;
 
                for (i = 0; i < ARRAY_SIZE(opt_tokens); i++) {
-                       if (opt_tokens[i].token & ~allowed_opts) {
+                       if ((opt_tokens[i].token & opts->mask) &&
+                           (opt_tokens[i].token & ~allowed_opts)) {
                                pr_warn("invalid parameter '%s'\n",
                                        opt_tokens[i].pattern);
                        }
index cd888a47d0fccb728b155f75aa85f0836ec4eac3..ea892e732268fe37bd4ea0c52b6d89fa055b691d 100644 (file)
@@ -109,6 +109,7 @@ struct nvme_dev {
        /* host memory buffer support: */
        u64 host_mem_size;
        u32 nr_host_mem_descs;
+       dma_addr_t host_mem_descs_dma;
        struct nvme_host_mem_buf_desc *host_mem_descs;
        void **host_mem_desc_bufs;
 };
@@ -801,6 +802,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
                return;
        }
 
+       nvmeq->cqe_seen = 1;
        req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id);
        nvme_end_request(req, cqe->status, cqe->result);
 }
@@ -830,10 +832,8 @@ static void nvme_process_cq(struct nvme_queue *nvmeq)
                consumed++;
        }
 
-       if (consumed) {
+       if (consumed)
                nvme_ring_cq_doorbell(nvmeq);
-               nvmeq->cqe_seen = 1;
-       }
 }
 
 static irqreturn_t nvme_irq(int irq, void *data)
@@ -1558,26 +1558,18 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)
        if (dev->cmb) {
                iounmap(dev->cmb);
                dev->cmb = NULL;
-               if (dev->cmbsz) {
-                       sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
-                                                    &dev_attr_cmb.attr, NULL);
-                       dev->cmbsz = 0;
-               }
+               sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
+                                            &dev_attr_cmb.attr, NULL);
+               dev->cmbsz = 0;
        }
 }
 
 static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
 {
-       size_t len = dev->nr_host_mem_descs * sizeof(*dev->host_mem_descs);
+       u64 dma_addr = dev->host_mem_descs_dma;
        struct nvme_command c;
-       u64 dma_addr;
        int ret;
 
-       dma_addr = dma_map_single(dev->dev, dev->host_mem_descs, len,
-                       DMA_TO_DEVICE);
-       if (dma_mapping_error(dev->dev, dma_addr))
-               return -ENOMEM;
-
        memset(&c, 0, sizeof(c));
        c.features.opcode       = nvme_admin_set_features;
        c.features.fid          = cpu_to_le32(NVME_FEAT_HOST_MEM_BUF);
@@ -1594,7 +1586,6 @@ static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
                         "failed to set host mem (err %d, flags %#x).\n",
                         ret, bits);
        }
-       dma_unmap_single(dev->dev, dma_addr, len, DMA_TO_DEVICE);
        return ret;
 }
 
@@ -1612,7 +1603,9 @@ static void nvme_free_host_mem(struct nvme_dev *dev)
 
        kfree(dev->host_mem_desc_bufs);
        dev->host_mem_desc_bufs = NULL;
-       kfree(dev->host_mem_descs);
+       dma_free_coherent(dev->dev,
+                       dev->nr_host_mem_descs * sizeof(*dev->host_mem_descs),
+                       dev->host_mem_descs, dev->host_mem_descs_dma);
        dev->host_mem_descs = NULL;
 }
 
@@ -1620,6 +1613,7 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
 {
        struct nvme_host_mem_buf_desc *descs;
        u32 chunk_size, max_entries, len;
+       dma_addr_t descs_dma;
        int i = 0;
        void **bufs;
        u64 size = 0, tmp;
@@ -1630,7 +1624,8 @@ retry:
        tmp = (preferred + chunk_size - 1);
        do_div(tmp, chunk_size);
        max_entries = tmp;
-       descs = kcalloc(max_entries, sizeof(*descs), GFP_KERNEL);
+       descs = dma_zalloc_coherent(dev->dev, max_entries * sizeof(*descs),
+                       &descs_dma, GFP_KERNEL);
        if (!descs)
                goto out;
 
@@ -1664,6 +1659,7 @@ retry:
        dev->nr_host_mem_descs = i;
        dev->host_mem_size = size;
        dev->host_mem_descs = descs;
+       dev->host_mem_descs_dma = descs_dma;
        dev->host_mem_desc_bufs = bufs;
        return 0;
 
@@ -1677,7 +1673,8 @@ out_free_bufs:
 
        kfree(bufs);
 out_free_descs:
-       kfree(descs);
+       dma_free_coherent(dev->dev, max_entries * sizeof(*descs), descs,
+                       descs_dma);
 out:
        /* try a smaller chunk size if we failed early */
        if (chunk_size >= PAGE_SIZE * 2 && (i == 0 || size < min)) {
@@ -1953,16 +1950,14 @@ static int nvme_pci_enable(struct nvme_dev *dev)
 
        /*
         * CMBs can currently only exist on >=1.2 PCIe devices. We only
-        * populate sysfs if a CMB is implemented. Note that we add the
-        * CMB attribute to the nvme_ctrl kobj which removes the need to remove
-        * it on exit. Since nvme_dev_attrs_group has no name we can pass
-        * NULL as final argument to sysfs_add_file_to_group.
+        * populate sysfs if a CMB is implemented. Since nvme_dev_attrs_group
+        * has no name we can pass NULL as final argument to
+        * sysfs_add_file_to_group.
         */
 
        if (readl(dev->bar + NVME_REG_VS) >= NVME_VS(1, 2, 0)) {
                dev->cmb = nvme_map_cmb(dev);
-
-               if (dev->cmbsz) {
+               if (dev->cmb) {
                        if (sysfs_add_file_to_group(&dev->ctrl.device->kobj,
                                                    &dev_attr_cmb.attr, NULL))
                                dev_warn(dev->ctrl.device,
index da04df1af231758cb4965735c417a215d736ec94..a03299d779229de271eb28704a73515f1020ffe1 100644 (file)
@@ -920,7 +920,11 @@ static int nvme_rdma_map_sg_fr(struct nvme_rdma_queue *queue,
        struct nvme_keyed_sgl_desc *sg = &c->common.dptr.ksgl;
        int nr;
 
-       nr = ib_map_mr_sg(req->mr, req->sg_table.sgl, count, NULL, PAGE_SIZE);
+       /*
+        * Align the MR to a 4K page size to match the ctrl page size and
+        * the block virtual boundary.
+        */
+       nr = ib_map_mr_sg(req->mr, req->sg_table.sgl, count, NULL, SZ_4K);
        if (nr < count) {
                if (nr < 0)
                        return nr;
@@ -1583,7 +1587,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl)
                goto out_cleanup_queue;
 
        ctrl->ctrl.max_hw_sectors =
-               (ctrl->max_fr_pages - 1) << (PAGE_SHIFT - 9);
+               (ctrl->max_fr_pages - 1) << (ilog2(SZ_4K) - 9);
 
        error = nvme_init_identify(&ctrl->ctrl);
        if (error)
index 2d7a98ab53fbf2de131990b753b929fe31cd154b..a53bb6635b8378d00f7fb4d367a16170d81a846e 100644 (file)
@@ -199,12 +199,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
        copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1);
        copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE));
 
-       memset(id->mn, ' ', sizeof(id->mn));
-       strncpy((char *)id->mn, "Linux", sizeof(id->mn));
-
-       memset(id->fr, ' ', sizeof(id->fr));
-       strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr));
-
        id->rab = 6;
 
        /*
index 31ca55dfcb1d49f3a1d88f7c6f5d0e7f0ee1e1ea..309c84aa7595b9b2ffab72c8a632c97f29def6d1 100644 (file)
@@ -114,6 +114,11 @@ struct nvmet_fc_tgtport {
        struct kref                     ref;
 };
 
+struct nvmet_fc_defer_fcp_req {
+       struct list_head                req_list;
+       struct nvmefc_tgt_fcp_req       *fcp_req;
+};
+
 struct nvmet_fc_tgt_queue {
        bool                            ninetypercent;
        u16                             qid;
@@ -132,6 +137,8 @@ struct nvmet_fc_tgt_queue {
        struct nvmet_fc_tgt_assoc       *assoc;
        struct nvmet_fc_fcp_iod         *fod;           /* array of fcp_iods */
        struct list_head                fod_list;
+       struct list_head                pending_cmd_list;
+       struct list_head                avail_defer_list;
        struct workqueue_struct         *work_q;
        struct kref                     ref;
 } __aligned(sizeof(unsigned long long));
@@ -223,6 +230,8 @@ static void nvmet_fc_tgt_q_put(struct nvmet_fc_tgt_queue *queue);
 static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue);
 static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport);
 static int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport);
+static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
+                                       struct nvmet_fc_fcp_iod *fod);
 
 
 /* *********************** FC-NVME DMA Handling **************************** */
@@ -385,7 +394,7 @@ nvmet_fc_free_ls_iodlist(struct nvmet_fc_tgtport *tgtport)
 static struct nvmet_fc_ls_iod *
 nvmet_fc_alloc_ls_iod(struct nvmet_fc_tgtport *tgtport)
 {
-       static struct nvmet_fc_ls_iod *iod;
+       struct nvmet_fc_ls_iod *iod;
        unsigned long flags;
 
        spin_lock_irqsave(&tgtport->lock, flags);
@@ -462,10 +471,10 @@ nvmet_fc_destroy_fcp_iodlist(struct nvmet_fc_tgtport *tgtport,
 static struct nvmet_fc_fcp_iod *
 nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue)
 {
-       static struct nvmet_fc_fcp_iod *fod;
-       unsigned long flags;
+       struct nvmet_fc_fcp_iod *fod;
+
+       lockdep_assert_held(&queue->qlock);
 
-       spin_lock_irqsave(&queue->qlock, flags);
        fod = list_first_entry_or_null(&queue->fod_list,
                                        struct nvmet_fc_fcp_iod, fcp_list);
        if (fod) {
@@ -477,17 +486,37 @@ nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue)
                 * will "inherit" that reference.
                 */
        }
-       spin_unlock_irqrestore(&queue->qlock, flags);
        return fod;
 }
 
 
+static void
+nvmet_fc_queue_fcp_req(struct nvmet_fc_tgtport *tgtport,
+                      struct nvmet_fc_tgt_queue *queue,
+                      struct nvmefc_tgt_fcp_req *fcpreq)
+{
+       struct nvmet_fc_fcp_iod *fod = fcpreq->nvmet_fc_private;
+
+       /*
+        * put all admin cmds on hw queue id 0. All io commands go to
+        * the respective hw queue based on a modulo basis
+        */
+       fcpreq->hwqid = queue->qid ?
+                       ((queue->qid - 1) % tgtport->ops->max_hw_queues) : 0;
+
+       if (tgtport->ops->target_features & NVMET_FCTGTFEAT_CMD_IN_ISR)
+               queue_work_on(queue->cpu, queue->work_q, &fod->work);
+       else
+               nvmet_fc_handle_fcp_rqst(tgtport, fod);
+}
+
 static void
 nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue,
                        struct nvmet_fc_fcp_iod *fod)
 {
        struct nvmefc_tgt_fcp_req *fcpreq = fod->fcpreq;
        struct nvmet_fc_tgtport *tgtport = fod->tgtport;
+       struct nvmet_fc_defer_fcp_req *deferfcp;
        unsigned long flags;
 
        fc_dma_sync_single_for_cpu(tgtport->dev, fod->rspdma,
@@ -495,21 +524,56 @@ nvmet_fc_free_fcp_iod(struct nvmet_fc_tgt_queue *queue,
 
        fcpreq->nvmet_fc_private = NULL;
 
-       spin_lock_irqsave(&queue->qlock, flags);
-       list_add_tail(&fod->fcp_list, &fod->queue->fod_list);
        fod->active = false;
        fod->abort = false;
        fod->aborted = false;
        fod->writedataactive = false;
        fod->fcpreq = NULL;
+
+       tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq);
+
+       spin_lock_irqsave(&queue->qlock, flags);
+       deferfcp = list_first_entry_or_null(&queue->pending_cmd_list,
+                               struct nvmet_fc_defer_fcp_req, req_list);
+       if (!deferfcp) {
+               list_add_tail(&fod->fcp_list, &fod->queue->fod_list);
+               spin_unlock_irqrestore(&queue->qlock, flags);
+
+               /* Release reference taken at queue lookup and fod allocation */
+               nvmet_fc_tgt_q_put(queue);
+               return;
+       }
+
+       /* Re-use the fod for the next pending cmd that was deferred */
+       list_del(&deferfcp->req_list);
+
+       fcpreq = deferfcp->fcp_req;
+
+       /* deferfcp can be reused for another IO at a later date */
+       list_add_tail(&deferfcp->req_list, &queue->avail_defer_list);
+
        spin_unlock_irqrestore(&queue->qlock, flags);
 
+       /* Save NVME CMD IO in fod */
+       memcpy(&fod->cmdiubuf, fcpreq->rspaddr, fcpreq->rsplen);
+
+       /* Setup new fcpreq to be processed */
+       fcpreq->rspaddr = NULL;
+       fcpreq->rsplen  = 0;
+       fcpreq->nvmet_fc_private = fod;
+       fod->fcpreq = fcpreq;
+       fod->active = true;
+
+       /* inform LLDD IO is now being processed */
+       tgtport->ops->defer_rcv(&tgtport->fc_target_port, fcpreq);
+
+       /* Submit deferred IO for processing */
+       nvmet_fc_queue_fcp_req(tgtport, queue, fcpreq);
+
        /*
-        * release the reference taken at queue lookup and fod allocation
+        * Leave the queue lookup get reference taken when
+        * fod was originally allocated.
         */
-       nvmet_fc_tgt_q_put(queue);
-
-       tgtport->ops->fcp_req_release(&tgtport->fc_target_port, fcpreq);
 }
 
 static int
@@ -569,6 +633,8 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc,
        queue->port = assoc->tgtport->port;
        queue->cpu = nvmet_fc_queue_to_cpu(assoc->tgtport, qid);
        INIT_LIST_HEAD(&queue->fod_list);
+       INIT_LIST_HEAD(&queue->avail_defer_list);
+       INIT_LIST_HEAD(&queue->pending_cmd_list);
        atomic_set(&queue->connected, 0);
        atomic_set(&queue->sqtail, 0);
        atomic_set(&queue->rsn, 1);
@@ -638,6 +704,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
 {
        struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport;
        struct nvmet_fc_fcp_iod *fod = queue->fod;
+       struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr;
        unsigned long flags;
        int i, writedataactive;
        bool disconnect;
@@ -666,6 +733,36 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
                        }
                }
        }
+
+       /* Cleanup defer'ed IOs in queue */
+       list_for_each_entry_safe(deferfcp, tempptr, &queue->avail_defer_list,
+                               req_list) {
+               list_del(&deferfcp->req_list);
+               kfree(deferfcp);
+       }
+
+       for (;;) {
+               deferfcp = list_first_entry_or_null(&queue->pending_cmd_list,
+                               struct nvmet_fc_defer_fcp_req, req_list);
+               if (!deferfcp)
+                       break;
+
+               list_del(&deferfcp->req_list);
+               spin_unlock_irqrestore(&queue->qlock, flags);
+
+               tgtport->ops->defer_rcv(&tgtport->fc_target_port,
+                               deferfcp->fcp_req);
+
+               tgtport->ops->fcp_abort(&tgtport->fc_target_port,
+                               deferfcp->fcp_req);
+
+               tgtport->ops->fcp_req_release(&tgtport->fc_target_port,
+                               deferfcp->fcp_req);
+
+               kfree(deferfcp);
+
+               spin_lock_irqsave(&queue->qlock, flags);
+       }
        spin_unlock_irqrestore(&queue->qlock, flags);
 
        flush_workqueue(queue->work_q);
@@ -2172,11 +2269,38 @@ nvmet_fc_handle_fcp_rqst_work(struct work_struct *work)
  * Pass a FC-NVME FCP CMD IU received from the FC link to the nvmet-fc
  * layer for processing.
  *
- * The nvmet-fc layer will copy cmd payload to an internal structure for
- * processing.  As such, upon completion of the routine, the LLDD may
- * immediately free/reuse the CMD IU buffer passed in the call.
+ * The nvmet_fc layer allocates a local job structure (struct
+ * nvmet_fc_fcp_iod) from the queue for the io and copies the
+ * CMD IU buffer to the job structure. As such, on a successful
+ * completion (returns 0), the LLDD may immediately free/reuse
+ * the CMD IU buffer passed in the call.
  *
- * If this routine returns error, the lldd should abort the exchange.
+ * However, in some circumstances, due to the packetized nature of FC
+ * and the api of the FC LLDD which may issue a hw command to send the
+ * response, but the LLDD may not get the hw completion for that command
+ * and upcall the nvmet_fc layer before a new command may be
+ * asynchronously received - its possible for a command to be received
+ * before the LLDD and nvmet_fc have recycled the job structure. It gives
+ * the appearance of more commands received than fits in the sq.
+ * To alleviate this scenario, a temporary queue is maintained in the
+ * transport for pending LLDD requests waiting for a queue job structure.
+ * In these "overrun" cases, a temporary queue element is allocated
+ * the LLDD request and CMD iu buffer information remembered, and the
+ * routine returns a -EOVERFLOW status. Subsequently, when a queue job
+ * structure is freed, it is immediately reallocated for anything on the
+ * pending request list. The LLDDs defer_rcv() callback is called,
+ * informing the LLDD that it may reuse the CMD IU buffer, and the io
+ * is then started normally with the transport.
+ *
+ * The LLDD, when receiving an -EOVERFLOW completion status, is to treat
+ * the completion as successful but must not reuse the CMD IU buffer
+ * until the LLDD's defer_rcv() callback has been called for the
+ * corresponding struct nvmefc_tgt_fcp_req pointer.
+ *
+ * If there is any other condition in which an error occurs, the
+ * transport will return a non-zero status indicating the error.
+ * In all cases other than -EOVERFLOW, the transport has not accepted the
+ * request and the LLDD should abort the exchange.
  *
  * @target_port: pointer to the (registered) target port the FCP CMD IU
  *              was received on.
@@ -2194,6 +2318,8 @@ nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *target_port,
        struct nvme_fc_cmd_iu *cmdiu = cmdiubuf;
        struct nvmet_fc_tgt_queue *queue;
        struct nvmet_fc_fcp_iod *fod;
+       struct nvmet_fc_defer_fcp_req *deferfcp;
+       unsigned long flags;
 
        /* validate iu, so the connection id can be used to find the queue */
        if ((cmdiubuf_len != sizeof(*cmdiu)) ||
@@ -2214,29 +2340,60 @@ nvmet_fc_rcv_fcp_req(struct nvmet_fc_target_port *target_port,
         * when the fod is freed.
         */
 
+       spin_lock_irqsave(&queue->qlock, flags);
+
        fod = nvmet_fc_alloc_fcp_iod(queue);
-       if (!fod) {
+       if (fod) {
+               spin_unlock_irqrestore(&queue->qlock, flags);
+
+               fcpreq->nvmet_fc_private = fod;
+               fod->fcpreq = fcpreq;
+
+               memcpy(&fod->cmdiubuf, cmdiubuf, cmdiubuf_len);
+
+               nvmet_fc_queue_fcp_req(tgtport, queue, fcpreq);
+
+               return 0;
+       }
+
+       if (!tgtport->ops->defer_rcv) {
+               spin_unlock_irqrestore(&queue->qlock, flags);
                /* release the queue lookup reference */
                nvmet_fc_tgt_q_put(queue);
                return -ENOENT;
        }
 
-       fcpreq->nvmet_fc_private = fod;
-       fod->fcpreq = fcpreq;
-       /*
-        * put all admin cmds on hw queue id 0. All io commands go to
-        * the respective hw queue based on a modulo basis
-        */
-       fcpreq->hwqid = queue->qid ?
-                       ((queue->qid - 1) % tgtport->ops->max_hw_queues) : 0;
-       memcpy(&fod->cmdiubuf, cmdiubuf, cmdiubuf_len);
+       deferfcp = list_first_entry_or_null(&queue->avail_defer_list,
+                       struct nvmet_fc_defer_fcp_req, req_list);
+       if (deferfcp) {
+               /* Just re-use one that was previously allocated */
+               list_del(&deferfcp->req_list);
+       } else {
+               spin_unlock_irqrestore(&queue->qlock, flags);
 
-       if (tgtport->ops->target_features & NVMET_FCTGTFEAT_CMD_IN_ISR)
-               queue_work_on(queue->cpu, queue->work_q, &fod->work);
-       else
-               nvmet_fc_handle_fcp_rqst(tgtport, fod);
+               /* Now we need to dynamically allocate one */
+               deferfcp = kmalloc(sizeof(*deferfcp), GFP_KERNEL);
+               if (!deferfcp) {
+                       /* release the queue lookup reference */
+                       nvmet_fc_tgt_q_put(queue);
+                       return -ENOMEM;
+               }
+               spin_lock_irqsave(&queue->qlock, flags);
+       }
 
-       return 0;
+       /* For now, use rspaddr / rsplen to save payload information */
+       fcpreq->rspaddr = cmdiubuf;
+       fcpreq->rsplen  = cmdiubuf_len;
+       deferfcp->fcp_req = fcpreq;
+
+       /* defer processing till a fod becomes available */
+       list_add_tail(&deferfcp->req_list, &queue->pending_cmd_list);
+
+       /* NOTE: the queue lookup reference is still valid */
+
+       spin_unlock_irqrestore(&queue->qlock, flags);
+
+       return -EOVERFLOW;
 }
 EXPORT_SYMBOL_GPL(nvmet_fc_rcv_fcp_req);
 
index 28c38c756f92858906ca2aee54a9c922522f9253..e0a28ea341fe95e84a866559dad8e317c8056401 100644 (file)
@@ -89,6 +89,7 @@ int of_dma_configure(struct device *dev, struct device_node *np)
        bool coherent;
        unsigned long offset;
        const struct iommu_ops *iommu;
+       u64 mask;
 
        /*
         * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
@@ -134,10 +135,9 @@ int of_dma_configure(struct device *dev, struct device_node *np)
         * Limit coherent and dma mask based on size and default mask
         * set by the driver.
         */
-       dev->coherent_dma_mask = min(dev->coherent_dma_mask,
-                                    DMA_BIT_MASK(ilog2(dma_addr + size)));
-       *dev->dma_mask = min((*dev->dma_mask),
-                            DMA_BIT_MASK(ilog2(dma_addr + size)));
+       mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1);
+       dev->coherent_dma_mask &= mask;
+       *dev->dma_mask &= mask;
 
        coherent = of_dma_is_coherent(np);
        dev_dbg(dev, "device is%sdma coherent\n",
index 5c63b920b4713eaf41954c4e8f0d041472c78b6d..ed92c1254cff473113f9b24e25a598a72871891d 100644 (file)
@@ -956,7 +956,7 @@ static int __init dino_probe(struct parisc_device *dev)
 
        dino_dev->hba.dev = dev;
        dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096);
-       dino_dev->hba.lmmio_space_offset = 0;   /* CPU addrs == bus addrs */
+       dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND;
        spin_lock_init(&dino_dev->dinosaur_pen);
        dino_dev->hba.iommu = ccio_get_iommu(dev);
 
index 253d92409bb3930b3348fd91037aa0df2355ce9c..2225afc1cbbb76a39c516230a58c8e8752b568f9 100644 (file)
@@ -538,12 +538,9 @@ msi_setup_entry(struct pci_dev *dev, int nvec, const struct irq_affinity *affd)
        struct msi_desc *entry;
        u16 control;
 
-       if (affd) {
+       if (affd)
                masks = irq_create_affinity_masks(nvec, affd);
-               if (!masks)
-                       dev_err(&dev->dev, "can't allocate MSI affinity masks for %d vectors\n",
-                               nvec);
-       }
+
 
        /* MSI Entry Initialization */
        entry = alloc_msi_entry(&dev->dev, nvec, masks);
@@ -679,12 +676,8 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base,
        struct msi_desc *entry;
        int ret, i;
 
-       if (affd) {
+       if (affd)
                masks = irq_create_affinity_masks(nvec, affd);
-               if (!masks)
-                       dev_err(&dev->dev, "can't allocate MSI-X affinity masks for %d vectors\n",
-                               nvec);
-       }
 
        for (i = 0, curmsk = masks; i < nvec; i++) {
                entry = alloc_msi_entry(&dev->dev, 1, curmsk);
index af0cc3456dc1b48b1325c06c5edd2ca8cc22a640..fdf65a6c13f62558e887cd001f4c61ca2daef989 100644 (file)
@@ -514,7 +514,7 @@ EXPORT_SYMBOL(pci_find_resource);
  */
 struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev)
 {
-       struct pci_dev *bridge, *highest_pcie_bridge = NULL;
+       struct pci_dev *bridge, *highest_pcie_bridge = dev;
 
        bridge = pci_upstream_bridge(dev);
        while (bridge && pci_is_pcie(bridge)) {
@@ -4259,6 +4259,41 @@ int pci_reset_function(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_reset_function);
 
+/**
+ * pci_reset_function_locked - quiesce and reset a PCI device function
+ * @dev: PCI device to reset
+ *
+ * Some devices allow an individual function to be reset without affecting
+ * other functions in the same device.  The PCI device must be responsive
+ * to PCI config space in order to use this function.
+ *
+ * This function does not just reset the PCI portion of a device, but
+ * clears all the state associated with the device.  This function differs
+ * from __pci_reset_function() in that it saves and restores device state
+ * over the reset.  It also differs from pci_reset_function() in that it
+ * requires the PCI device lock to be held.
+ *
+ * Returns 0 if the device function was successfully reset or negative if the
+ * device doesn't support resetting a single function.
+ */
+int pci_reset_function_locked(struct pci_dev *dev)
+{
+       int rc;
+
+       rc = pci_probe_reset_function(dev);
+       if (rc)
+               return rc;
+
+       pci_dev_save_and_disable(dev);
+
+       rc = __pci_reset_function_locked(dev);
+
+       pci_dev_restore(dev);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(pci_reset_function_locked);
+
 /**
  * pci_try_reset_function - quiesce and reset a PCI device function
  * @dev: PCI device to reset
index c31310db04047367c44b96ff6afa41a6b991bc28..e6a917b4acd3f3c63dff5d57b905ab093d7d0487 100644 (file)
@@ -1762,6 +1762,48 @@ static void pci_configure_extended_tags(struct pci_dev *dev)
                                         PCI_EXP_DEVCTL_EXT_TAG);
 }
 
+/**
+ * pcie_relaxed_ordering_enabled - Probe for PCIe relaxed ordering enable
+ * @dev: PCI device to query
+ *
+ * Returns true if the device has enabled relaxed ordering attribute.
+ */
+bool pcie_relaxed_ordering_enabled(struct pci_dev *dev)
+{
+       u16 v;
+
+       pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &v);
+
+       return !!(v & PCI_EXP_DEVCTL_RELAX_EN);
+}
+EXPORT_SYMBOL(pcie_relaxed_ordering_enabled);
+
+static void pci_configure_relaxed_ordering(struct pci_dev *dev)
+{
+       struct pci_dev *root;
+
+       /* PCI_EXP_DEVICE_RELAX_EN is RsvdP in VFs */
+       if (dev->is_virtfn)
+               return;
+
+       if (!pcie_relaxed_ordering_enabled(dev))
+               return;
+
+       /*
+        * For now, we only deal with Relaxed Ordering issues with Root
+        * Ports. Peer-to-Peer DMA is another can of worms.
+        */
+       root = pci_find_pcie_root_port(dev);
+       if (!root)
+               return;
+
+       if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) {
+               pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
+                                          PCI_EXP_DEVCTL_RELAX_EN);
+               dev_info(&dev->dev, "Disable Relaxed Ordering because the Root Port didn't support it\n");
+       }
+}
+
 static void pci_configure_device(struct pci_dev *dev)
 {
        struct hotplug_params hpp;
@@ -1769,6 +1811,7 @@ static void pci_configure_device(struct pci_dev *dev)
 
        pci_configure_mps(dev);
        pci_configure_extended_tags(dev);
+       pci_configure_relaxed_ordering(dev);
 
        memset(&hpp, 0, sizeof(hpp));
        ret = pci_get_hp_params(dev, &hpp);
index 6967c6b4cf6b017170619c285ee58feaa5975a5a..140760403f36a932b7d39eb73ae3eb96d76cab37 100644 (file)
@@ -4015,6 +4015,95 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6868, PCI_CLASS_NOT_DEFINED, 8,
 DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6869, PCI_CLASS_NOT_DEFINED, 8,
                              quirk_tw686x_class);
 
+/*
+ * Some devices have problems with Transaction Layer Packets with the Relaxed
+ * Ordering Attribute set.  Such devices should mark themselves and other
+ * Device Drivers should check before sending TLPs with RO set.
+ */
+static void quirk_relaxedordering_disable(struct pci_dev *dev)
+{
+       dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING;
+       dev_info(&dev->dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n");
+}
+
+/*
+ * Intel Xeon processors based on Broadwell/Haswell microarchitecture Root
+ * Complex has a Flow Control Credit issue which can cause performance
+ * problems with Upstream Transaction Layer Packets with Relaxed Ordering set.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f01, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f03, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f05, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f06, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f07, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f09, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0a, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0b, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0c, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0d, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0e, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f01, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f02, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f03, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f04, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f05, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f06, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f07, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f08, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f09, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0a, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0b, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0c, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0d, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0e, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+
+/*
+ * The AMD ARM A1100 (AKA "SEATTLE") SoC has a bug in its PCIe Root Complex
+ * where Upstream Transaction Layer Packets with the Relaxed Ordering
+ * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering
+ * set.  This is a violation of the PCIe 3.0 Transaction Ordering Rules
+ * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0
+ * November 10, 2010).  As a result, on this platform we can't use Relaxed
+ * Ordering for Upstream TLPs.
+ */
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, PCI_CLASS_NOT_DEFINED, 8,
+                             quirk_relaxedordering_disable);
+
 /*
  * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same
  * values for the Attribute as were supplied in the header of the
index 20f1b44939944614ff270c757fc7152f901e9f09..04e929fd0ffee494cc744cf495e5acd9e437ea6b 100644 (file)
@@ -1547,6 +1547,13 @@ static const struct dmi_system_id chv_no_valid_mask[] = {
                        DMI_MATCH(DMI_PRODUCT_FAMILY, "Intel_Strago"),
                },
        },
+       {
+               .ident = "HP Chromebook 11 G5 (Setzer)",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Setzer"),
+               },
+       },
        {
                .ident = "Acer Chromebook R11 (Cyan)",
                .matches = {
index 4d4ef42a39b5faaa1969d20a5aeeedffef90074c..86c4b3fab7b0ea8f0abfdf36e5a2b035e024ec66 100644 (file)
@@ -343,9 +343,9 @@ static const struct pinctrl_pin_desc mrfld_pins[] = {
 
 static const unsigned int mrfld_sdio_pins[] = { 50, 51, 52, 53, 54, 55, 56 };
 static const unsigned int mrfld_spi5_pins[] = { 90, 91, 92, 93, 94, 95, 96 };
-static const unsigned int mrfld_uart0_pins[] = { 124, 125, 126, 127 };
-static const unsigned int mrfld_uart1_pins[] = { 128, 129, 130, 131 };
-static const unsigned int mrfld_uart2_pins[] = { 132, 133, 134, 135 };
+static const unsigned int mrfld_uart0_pins[] = { 115, 116, 117, 118 };
+static const unsigned int mrfld_uart1_pins[] = { 119, 120, 121, 122 };
+static const unsigned int mrfld_uart2_pins[] = { 123, 124, 125, 126 };
 static const unsigned int mrfld_pwm0_pins[] = { 144 };
 static const unsigned int mrfld_pwm1_pins[] = { 145 };
 static const unsigned int mrfld_pwm2_pins[] = { 132 };
index f024e25787fc603c3469ea75de53452743d6af16..0c6d7812d6fd981b95f9d526cb9d6645e4b7855d 100644 (file)
@@ -37,7 +37,7 @@
 #define IRQ_STATUS     0x10
 #define IRQ_WKUP       0x18
 
-#define NB_FUNCS 2
+#define NB_FUNCS 3
 #define GPIO_PER_REG   32
 
 /**
@@ -126,6 +126,16 @@ struct armada_37xx_pinctrl {
                .funcs = {_func1, "gpio"}       \
        }
 
+#define PIN_GRP_GPIO_3(_name, _start, _nr, _mask, _v1, _v2, _v3, _f1, _f2) \
+       {                                       \
+               .name = _name,                  \
+               .start_pin = _start,            \
+               .npins = _nr,                   \
+               .reg_mask = _mask,              \
+               .val = {_v1, _v2, _v3}, \
+               .funcs = {_f1, _f2, "gpio"}     \
+       }
+
 #define PIN_GRP_EXTRA(_name, _start, _nr, _mask, _v1, _v2, _start2, _nr2, \
                      _f1, _f2)                         \
        {                                               \
@@ -171,12 +181,13 @@ static struct armada_37xx_pin_group armada_37xx_sb_groups[] = {
        PIN_GRP_GPIO("usb32_drvvbus0", 0, 1, BIT(0), "drvbus"),
        PIN_GRP_GPIO("usb2_drvvbus1", 1, 1, BIT(1), "drvbus"),
        PIN_GRP_GPIO("sdio_sb", 24, 6, BIT(2), "sdio"),
-       PIN_GRP_EXTRA("rgmii", 6, 12, BIT(3), 0, BIT(3), 23, 1, "mii", "gpio"),
+       PIN_GRP_GPIO("rgmii", 6, 12, BIT(3), "mii"),
        PIN_GRP_GPIO("pcie1", 3, 2, BIT(4), "pcie"),
        PIN_GRP_GPIO("ptp", 20, 3, BIT(5), "ptp"),
        PIN_GRP("ptp_clk", 21, 1, BIT(6), "ptp", "mii"),
        PIN_GRP("ptp_trig", 22, 1, BIT(7), "ptp", "mii"),
-       PIN_GRP("mii_col", 23, 1, BIT(8), "mii", "mii_err"),
+       PIN_GRP_GPIO_3("mii_col", 23, 1, BIT(8) | BIT(14), 0, BIT(8), BIT(14),
+                      "mii", "mii_err"),
 };
 
 const struct armada_37xx_pin_data armada_37xx_pin_nb = {
@@ -187,7 +198,7 @@ const struct armada_37xx_pin_data armada_37xx_pin_nb = {
 };
 
 const struct armada_37xx_pin_data armada_37xx_pin_sb = {
-       .nr_pins = 29,
+       .nr_pins = 30,
        .name = "GPIO2",
        .groups = armada_37xx_sb_groups,
        .ngroups = ARRAY_SIZE(armada_37xx_sb_groups),
@@ -208,7 +219,7 @@ static int armada_37xx_get_func_reg(struct armada_37xx_pin_group *grp,
 {
        int f;
 
-       for (f = 0; f < NB_FUNCS; f++)
+       for (f = 0; (f < NB_FUNCS) && grp->funcs[f]; f++)
                if (!strcmp(grp->funcs[f], func))
                        return f;
 
@@ -795,7 +806,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
                for (j = 0; j < grp->extra_npins; j++)
                        grp->pins[i+j] = grp->extra_pin + j;
 
-               for (f = 0; f < NB_FUNCS; f++) {
+               for (f = 0; (f < NB_FUNCS) && grp->funcs[f]; f++) {
                        int ret;
                        /* check for unique functions and count groups */
                        ret = armada_37xx_add_function(info->funcs, &funcsize,
@@ -847,7 +858,7 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
                        struct armada_37xx_pin_group *gp = &info->groups[g];
                        int f;
 
-                       for (f = 0; f < NB_FUNCS; f++) {
+                       for (f = 0; (f < NB_FUNCS) && gp->funcs[f]; f++) {
                                if (strcmp(gp->funcs[f], name) == 0) {
                                        *groups = gp->name;
                                        groups++;
index 159580c04b14b138c5ec78b6768db2224d63fb58..47a392bc73c821203abe1c7cb1e966db9a40a3ba 100644 (file)
@@ -918,6 +918,7 @@ static const struct sunxi_desc_pin sun4i_a10_pins[] = {
                  SUNXI_FUNCTION_VARIANT(0x3, "emac",   /* ETXD1 */
                                         PINCTRL_SUN7I_A20),
                  SUNXI_FUNCTION(0x4, "keypad"),        /* IN6 */
+                 SUNXI_FUNCTION(0x5, "sim"),           /* DET */
                  SUNXI_FUNCTION_IRQ(0x6, 16),          /* EINT16 */
                  SUNXI_FUNCTION(0x7, "csi1")),         /* D16 */
        SUNXI_PIN(SUNXI_PINCTRL_PIN(H, 17),
index a433a306a2d06ae11dd2a8c61830e0c76c4e7862..c75e094b2d90779f92570a534fd1c8d53e6a9e97 100644 (file)
@@ -1084,7 +1084,7 @@ static const unsigned usb1_pins[] = {182, 183};
 static const int usb1_muxvals[] = {0, 0};
 static const unsigned usb2_pins[] = {184, 185};
 static const int usb2_muxvals[] = {0, 0};
-static const unsigned usb3_pins[] = {186, 187};
+static const unsigned usb3_pins[] = {187, 188};
 static const int usb3_muxvals[] = {0, 0};
 static const unsigned port_range0_pins[] = {
        300, 301, 302, 303, 304, 305, 306, 307,         /* PORT0x */
index 787e3967bd5c5741aeb7a2cb96c18e38901092ed..f828ee340a98238052448d15a5f7604c286926dd 100644 (file)
@@ -64,10 +64,8 @@ static int zx_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector,
        struct zx_pinctrl_soc_info *info = zpctl->info;
        const struct pinctrl_pin_desc *pindesc = info->pins + group_selector;
        struct zx_pin_data *data = pindesc->drv_data;
-       struct zx_mux_desc *mux = data->muxes;
-       u32 mask = (1 << data->width) - 1;
-       u32 offset = data->offset;
-       u32 bitpos = data->bitpos;
+       struct zx_mux_desc *mux;
+       u32 mask, offset, bitpos;
        struct function_desc *func;
        unsigned long flags;
        u32 val, mval;
@@ -76,6 +74,11 @@ static int zx_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector,
        if (!data)
                return -EINVAL;
 
+       mux = data->muxes;
+       mask = (1 << data->width) - 1;
+       offset = data->offset;
+       bitpos = data->bitpos;
+
        func = pinmux_generic_get_function(pctldev, func_selector);
        if (!func)
                return -EINVAL;
index b77435783ef332c30963f84e280cefbedbdb8e3b..7eacc1c4b3b10e1103e6e9c895112eb176245faa 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
+#include <uapi/linux/sched/types.h>
 
 #include "ptp_private.h"
 
@@ -184,6 +185,19 @@ static void delete_ptp_clock(struct posix_clock *pc)
        kfree(ptp);
 }
 
+static void ptp_aux_kworker(struct kthread_work *work)
+{
+       struct ptp_clock *ptp = container_of(work, struct ptp_clock,
+                                            aux_work.work);
+       struct ptp_clock_info *info = ptp->info;
+       long delay;
+
+       delay = info->do_aux_work(info);
+
+       if (delay >= 0)
+               kthread_queue_delayed_work(ptp->kworker, &ptp->aux_work, delay);
+}
+
 /* public interface */
 
 struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
@@ -217,6 +231,20 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
        mutex_init(&ptp->pincfg_mux);
        init_waitqueue_head(&ptp->tsev_wq);
 
+       if (ptp->info->do_aux_work) {
+               char *worker_name = kasprintf(GFP_KERNEL, "ptp%d", ptp->index);
+
+               kthread_init_delayed_work(&ptp->aux_work, ptp_aux_kworker);
+               ptp->kworker = kthread_create_worker(0, worker_name ?
+                                                    worker_name : info->name);
+               kfree(worker_name);
+               if (IS_ERR(ptp->kworker)) {
+                       err = PTR_ERR(ptp->kworker);
+                       pr_err("failed to create ptp aux_worker %d\n", err);
+                       goto kworker_err;
+               }
+       }
+
        err = ptp_populate_pin_groups(ptp);
        if (err)
                goto no_pin_groups;
@@ -259,6 +287,9 @@ no_pps:
 no_device:
        ptp_cleanup_pin_groups(ptp);
 no_pin_groups:
+       if (ptp->kworker)
+               kthread_destroy_worker(ptp->kworker);
+kworker_err:
        mutex_destroy(&ptp->tsevq_mux);
        mutex_destroy(&ptp->pincfg_mux);
        ida_simple_remove(&ptp_clocks_map, index);
@@ -274,6 +305,11 @@ int ptp_clock_unregister(struct ptp_clock *ptp)
        ptp->defunct = 1;
        wake_up_interruptible(&ptp->tsev_wq);
 
+       if (ptp->kworker) {
+               kthread_cancel_delayed_work_sync(&ptp->aux_work);
+               kthread_destroy_worker(ptp->kworker);
+       }
+
        /* Release the clock's resources. */
        if (ptp->pps_source)
                pps_unregister_source(ptp->pps_source);
@@ -339,6 +375,12 @@ int ptp_find_pin(struct ptp_clock *ptp,
 }
 EXPORT_SYMBOL(ptp_find_pin);
 
+int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay)
+{
+       return kthread_mod_delayed_work(ptp->kworker, &ptp->aux_work, delay);
+}
+EXPORT_SYMBOL(ptp_schedule_worker);
+
 /* module operations */
 
 static void __exit ptp_exit(void)
index d95888974d0c67f1e4cf4d3c2229ba4e901a2d87..b86f1bfecd6f2329cdd19c16da49c562e9e86fc6 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/cdev.h>
 #include <linux/device.h>
+#include <linux/kthread.h>
 #include <linux/mutex.h>
 #include <linux/posix-clock.h>
 #include <linux/ptp_clock.h>
@@ -56,6 +57,8 @@ struct ptp_clock {
        struct attribute_group pin_attr_group;
        /* 1st entry is a pointer to the real group, 2nd is NULL terminator */
        const struct attribute_group *pin_attr_groups[2];
+       struct kthread_worker *kworker;
+       struct kthread_delayed_work aux_work;
 };
 
 /*
index 4fac49e55d473e80c87eb932698a33383ffca04b..4b43aa62fbc789b049ecf05b3be7ec393dfa868d 100644 (file)
@@ -1301,7 +1301,6 @@ static void ds1307_clks_register(struct ds1307 *ds1307)
 static const struct regmap_config regmap_config = {
        .reg_bits = 8,
        .val_bits = 8,
-       .max_register = 0x12,
 };
 
 static int ds1307_probe(struct i2c_client *client,
index ba6ac83a6c2500c874f6a64518e72398bf5d52cb..5ccfdc80d0ec942d2e4dde4113830ab9eb2ba735 100644 (file)
@@ -481,7 +481,7 @@ static int ccwchain_fetch_tic(struct ccwchain *chain,
                ccw_tail = ccw_head + (iter->ch_len - 1) * sizeof(struct ccw1);
 
                if ((ccw_head <= ccw->cda) && (ccw->cda <= ccw_tail)) {
-                       ccw->cda = (__u32) (addr_t) (iter->ch_ccw +
+                       ccw->cda = (__u32) (addr_t) (((char *)iter->ch_ccw) +
                                                     (ccw->cda - ccw_head));
                        return 0;
                }
index 8975cd32139047cf03afe9a93544cc919eaed661..d42e758518ed92e33dfd6c6aaf2a4ee2ec198ff0 100644 (file)
@@ -2512,7 +2512,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
                struct rtable *rt = (struct rtable *) dst;
                __be32 *pkey = &ip_hdr(skb)->daddr;
 
-               if (rt->rt_gateway)
+               if (rt && rt->rt_gateway)
                        pkey = &rt->rt_gateway;
 
                /* IPv4 */
@@ -2523,7 +2523,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
                struct rt6_info *rt = (struct rt6_info *) dst;
                struct in6_addr *pkey = &ipv6_hdr(skb)->daddr;
 
-               if (!ipv6_addr_any(&rt->rt6i_gateway))
+               if (rt && !ipv6_addr_any(&rt->rt6i_gateway))
                        pkey = &rt->rt6i_gateway;
 
                /* IPv6 */
index f4538d7a3016e2b1514df38c9e6e9b48939d6ce7..d145e0d9022755d476f8f48c22ea9c3a62377e28 100644 (file)
@@ -47,6 +47,17 @@ config SCSI_NETLINK
        default n
        depends on NET
 
+config SCSI_MQ_DEFAULT
+       bool "SCSI: use blk-mq I/O path by default"
+       depends on SCSI
+       ---help---
+         This option enables the new blk-mq based I/O path for SCSI
+         devices by default.  With the option the scsi_mod.use_blk_mq
+         module/boot option defaults to Y, without it to N, but it can
+         still be overridden either way.
+
+         If unsure say N.
+
 config SCSI_PROC_FS
        bool "legacy /proc/scsi/ support"
        depends on SCSI && PROC_FS
index 707ee2f5954d0ac0890c6f05967f7acd24157704..a1a2c71e162651f93d499c56e024e7073cc7fc79 100644 (file)
@@ -549,7 +549,9 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
        if ((le32_to_cpu(get_name_reply->status) == CT_OK)
         && (get_name_reply->data[0] != '\0')) {
                char *sp = get_name_reply->data;
-               sp[sizeof(((struct aac_get_name_resp *)NULL)->data)] = '\0';
+               int data_size = FIELD_SIZEOF(struct aac_get_name_resp, data);
+
+               sp[data_size - 1] = '\0';
                while (*sp == ' ')
                        ++sp;
                if (*sp) {
@@ -579,12 +581,15 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
 static int aac_get_container_name(struct scsi_cmnd * scsicmd)
 {
        int status;
+       int data_size;
        struct aac_get_name *dinfo;
        struct fib * cmd_fibcontext;
        struct aac_dev * dev;
 
        dev = (struct aac_dev *)scsicmd->device->host->hostdata;
 
+       data_size = FIELD_SIZEOF(struct aac_get_name_resp, data);
+
        cmd_fibcontext = aac_fib_alloc_tag(dev, scsicmd);
 
        aac_fib_init(cmd_fibcontext);
@@ -593,7 +598,7 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
        dinfo->command = cpu_to_le32(VM_ContainerConfig);
        dinfo->type = cpu_to_le32(CT_READ_NAME);
        dinfo->cid = cpu_to_le32(scmd_id(scsicmd));
-       dinfo->count = cpu_to_le32(sizeof(((struct aac_get_name_resp *)NULL)->data));
+       dinfo->count = cpu_to_le32(data_size - 1);
 
        status = aac_fib_send(ContainerCommand,
                  cmd_fibcontext,
@@ -3198,10 +3203,11 @@ static int query_disk(struct aac_dev *dev, void __user *arg)
                return -EBUSY;
        if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
                return -EFAULT;
-       if (qd.cnum == -1)
+       if (qd.cnum == -1) {
+               if (qd.id < 0 || qd.id >= dev->maximum_num_containers)
+                       return -EINVAL;
                qd.cnum = qd.id;
-       else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
-       {
+       } else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) {
                if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
                        return -EINVAL;
                qd.instance = dev->scsi_host_ptr->host_no;
index d31a9bc2ba69abdcf6cd6c6c8e6d99229ae50e4a..ee2667e20e4239f9129ebe21e7983a2428065b88 100644 (file)
@@ -2274,7 +2274,7 @@ struct aac_get_name_resp {
        __le32          parm3;
        __le32          parm4;
        __le32          parm5;
-       u8              data[16];
+       u8              data[17];
 };
 
 #define CT_CID_TO_32BITS_UID 165
index 7dfe709a713837b075cd2021c00ee6a5fb44d978..6844ba36161638d995f3d5d5135c160fc54bc9ed 100644 (file)
@@ -2624,12 +2624,11 @@ static struct fcoe_transport bnx2fc_transport = {
 };
 
 /**
- * bnx2fc_percpu_thread_create - Create a receive thread for an
- *                              online CPU
+ * bnx2fc_cpu_online - Create a receive thread for an  online CPU
  *
  * @cpu: cpu index for the online cpu
  */
-static void bnx2fc_percpu_thread_create(unsigned int cpu)
+static int bnx2fc_cpu_online(unsigned int cpu)
 {
        struct bnx2fc_percpu_s *p;
        struct task_struct *thread;
@@ -2639,15 +2638,17 @@ static void bnx2fc_percpu_thread_create(unsigned int cpu)
        thread = kthread_create_on_node(bnx2fc_percpu_io_thread,
                                        (void *)p, cpu_to_node(cpu),
                                        "bnx2fc_thread/%d", cpu);
+       if (IS_ERR(thread))
+               return PTR_ERR(thread);
+
        /* bind thread to the cpu */
-       if (likely(!IS_ERR(thread))) {
-               kthread_bind(thread, cpu);
-               p->iothread = thread;
-               wake_up_process(thread);
-       }
+       kthread_bind(thread, cpu);
+       p->iothread = thread;
+       wake_up_process(thread);
+       return 0;
 }
 
-static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
+static int bnx2fc_cpu_offline(unsigned int cpu)
 {
        struct bnx2fc_percpu_s *p;
        struct task_struct *thread;
@@ -2661,7 +2662,6 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
        thread = p->iothread;
        p->iothread = NULL;
 
-
        /* Free all work in the list */
        list_for_each_entry_safe(work, tmp, &p->work_list, list) {
                list_del_init(&work->list);
@@ -2673,20 +2673,6 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
 
        if (thread)
                kthread_stop(thread);
-}
-
-
-static int bnx2fc_cpu_online(unsigned int cpu)
-{
-       printk(PFX "CPU %x online: Create Rx thread\n", cpu);
-       bnx2fc_percpu_thread_create(cpu);
-       return 0;
-}
-
-static int bnx2fc_cpu_dead(unsigned int cpu)
-{
-       printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
-       bnx2fc_percpu_thread_destroy(cpu);
        return 0;
 }
 
@@ -2761,30 +2747,16 @@ static int __init bnx2fc_mod_init(void)
                spin_lock_init(&p->fp_work_lock);
        }
 
-       get_online_cpus();
-
-       for_each_online_cpu(cpu)
-               bnx2fc_percpu_thread_create(cpu);
-
-       rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
-                                      "scsi/bnx2fc:online",
-                                      bnx2fc_cpu_online, NULL);
+       rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "scsi/bnx2fc:online",
+                              bnx2fc_cpu_online, bnx2fc_cpu_offline);
        if (rc < 0)
-               goto stop_threads;
+               goto stop_thread;
        bnx2fc_online_state = rc;
 
-       cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD, "scsi/bnx2fc:dead",
-                                 NULL, bnx2fc_cpu_dead);
-       put_online_cpus();
-
        cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb);
-
        return 0;
 
-stop_threads:
-       for_each_online_cpu(cpu)
-               bnx2fc_percpu_thread_destroy(cpu);
-       put_online_cpus();
+stop_thread:
        kthread_stop(l2_thread);
 free_wq:
        destroy_workqueue(bnx2fc_wq);
@@ -2803,7 +2775,6 @@ static void __exit bnx2fc_mod_exit(void)
        struct fcoe_percpu_s *bg;
        struct task_struct *l2_thread;
        struct sk_buff *skb;
-       unsigned int cpu = 0;
 
        /*
         * NOTE: Since cnic calls register_driver routine rtnl_lock,
@@ -2844,16 +2815,7 @@ static void __exit bnx2fc_mod_exit(void)
        if (l2_thread)
                kthread_stop(l2_thread);
 
-       get_online_cpus();
-       /* Destroy per cpu threads */
-       for_each_online_cpu(cpu) {
-               bnx2fc_percpu_thread_destroy(cpu);
-       }
-
-       cpuhp_remove_state_nocalls(bnx2fc_online_state);
-       cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD);
-
-       put_online_cpus();
+       cpuhp_remove_state(bnx2fc_online_state);
 
        destroy_workqueue(bnx2fc_wq);
        /*
index 913c750205ce2a3f1a90f5d255d98d3b39f90145..26de61d65a4d259fa41e7e070648f775031a9662 100644 (file)
@@ -1008,6 +1008,28 @@ static struct bnx2fc_work *bnx2fc_alloc_work(struct bnx2fc_rport *tgt, u16 wqe)
        return work;
 }
 
+/* Pending work request completion */
+static void bnx2fc_pending_work(struct bnx2fc_rport *tgt, unsigned int wqe)
+{
+       unsigned int cpu = wqe % num_possible_cpus();
+       struct bnx2fc_percpu_s *fps;
+       struct bnx2fc_work *work;
+
+       fps = &per_cpu(bnx2fc_percpu, cpu);
+       spin_lock_bh(&fps->fp_work_lock);
+       if (fps->iothread) {
+               work = bnx2fc_alloc_work(tgt, wqe);
+               if (work) {
+                       list_add_tail(&work->list, &fps->work_list);
+                       wake_up_process(fps->iothread);
+                       spin_unlock_bh(&fps->fp_work_lock);
+                       return;
+               }
+       }
+       spin_unlock_bh(&fps->fp_work_lock);
+       bnx2fc_process_cq_compl(tgt, wqe);
+}
+
 int bnx2fc_process_new_cqes(struct bnx2fc_rport *tgt)
 {
        struct fcoe_cqe *cq;
@@ -1042,28 +1064,7 @@ int bnx2fc_process_new_cqes(struct bnx2fc_rport *tgt)
                        /* Unsolicited event notification */
                        bnx2fc_process_unsol_compl(tgt, wqe);
                } else {
-                       /* Pending work request completion */
-                       struct bnx2fc_work *work = NULL;
-                       struct bnx2fc_percpu_s *fps = NULL;
-                       unsigned int cpu = wqe % num_possible_cpus();
-
-                       fps = &per_cpu(bnx2fc_percpu, cpu);
-                       spin_lock_bh(&fps->fp_work_lock);
-                       if (unlikely(!fps->iothread))
-                               goto unlock;
-
-                       work = bnx2fc_alloc_work(tgt, wqe);
-                       if (work)
-                               list_add_tail(&work->list,
-                                             &fps->work_list);
-unlock:
-                       spin_unlock_bh(&fps->fp_work_lock);
-
-                       /* Pending work request completion */
-                       if (fps->iothread && work)
-                               wake_up_process(fps->iothread);
-                       else
-                               bnx2fc_process_cq_compl(tgt, wqe);
+                       bnx2fc_pending_work(tgt, wqe);
                        num_free_sqes++;
                }
                cqe++;
index 86afc002814cd07bbc3b55b64ca31201208a514b..4ebcda8d9500439941bd630f8b1187875a7beac5 100644 (file)
@@ -404,12 +404,11 @@ int bnx2i_get_stats(void *handle)
 
 
 /**
- * bnx2i_percpu_thread_create - Create a receive thread for an
- *                             online CPU
+ * bnx2i_cpu_online - Create a receive thread for an online CPU
  *
  * @cpu:       cpu index for the online cpu
  */
-static void bnx2i_percpu_thread_create(unsigned int cpu)
+static int bnx2i_cpu_online(unsigned int cpu)
 {
        struct bnx2i_percpu_s *p;
        struct task_struct *thread;
@@ -419,16 +418,17 @@ static void bnx2i_percpu_thread_create(unsigned int cpu)
        thread = kthread_create_on_node(bnx2i_percpu_io_thread, (void *)p,
                                        cpu_to_node(cpu),
                                        "bnx2i_thread/%d", cpu);
+       if (IS_ERR(thread))
+               return PTR_ERR(thread);
+
        /* bind thread to the cpu */
-       if (likely(!IS_ERR(thread))) {
-               kthread_bind(thread, cpu);
-               p->iothread = thread;
-               wake_up_process(thread);
-       }
+       kthread_bind(thread, cpu);
+       p->iothread = thread;
+       wake_up_process(thread);
+       return 0;
 }
 
-
-static void bnx2i_percpu_thread_destroy(unsigned int cpu)
+static int bnx2i_cpu_offline(unsigned int cpu)
 {
        struct bnx2i_percpu_s *p;
        struct task_struct *thread;
@@ -451,19 +451,6 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu)
        spin_unlock_bh(&p->p_work_lock);
        if (thread)
                kthread_stop(thread);
-}
-
-static int bnx2i_cpu_online(unsigned int cpu)
-{
-       pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu);
-       bnx2i_percpu_thread_create(cpu);
-       return 0;
-}
-
-static int bnx2i_cpu_dead(unsigned int cpu)
-{
-       pr_info("CPU %x offline: Remove Rx thread\n", cpu);
-       bnx2i_percpu_thread_destroy(cpu);
        return 0;
 }
 
@@ -511,27 +498,14 @@ static int __init bnx2i_mod_init(void)
                p->iothread = NULL;
        }
 
-       get_online_cpus();
-
-       for_each_online_cpu(cpu)
-               bnx2i_percpu_thread_create(cpu);
-
-       err = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
-                                      "scsi/bnx2i:online",
-                                      bnx2i_cpu_online, NULL);
+       err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "scsi/bnx2i:online",
+                               bnx2i_cpu_online, bnx2i_cpu_offline);
        if (err < 0)
-               goto remove_threads;
+               goto unreg_driver;
        bnx2i_online_state = err;
-
-       cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead",
-                                 NULL, bnx2i_cpu_dead);
-       put_online_cpus();
        return 0;
 
-remove_threads:
-       for_each_online_cpu(cpu)
-               bnx2i_percpu_thread_destroy(cpu);
-       put_online_cpus();
+unreg_driver:
        cnic_unregister_driver(CNIC_ULP_ISCSI);
 unreg_xport:
        iscsi_unregister_transport(&bnx2i_iscsi_transport);
@@ -551,7 +525,6 @@ out:
 static void __exit bnx2i_mod_exit(void)
 {
        struct bnx2i_hba *hba;
-       unsigned cpu = 0;
 
        mutex_lock(&bnx2i_dev_lock);
        while (!list_empty(&adapter_list)) {
@@ -569,14 +542,7 @@ static void __exit bnx2i_mod_exit(void)
        }
        mutex_unlock(&bnx2i_dev_lock);
 
-       get_online_cpus();
-
-       for_each_online_cpu(cpu)
-               bnx2i_percpu_thread_destroy(cpu);
-
-       cpuhp_remove_state_nocalls(bnx2i_online_state);
-       cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD);
-       put_online_cpus();
+       cpuhp_remove_state(bnx2i_online_state);
 
        iscsi_unregister_transport(&bnx2i_iscsi_transport);
        cnic_unregister_driver(CNIC_ULP_ISCSI);
index 2029ad225121162bddfec4ffcce7e38a940385f3..5be0086142cac6991598cd9099522212709a216c 100644 (file)
@@ -3845,8 +3845,10 @@ csio_hw_start(struct csio_hw *hw)
 
        if (csio_is_hw_ready(hw))
                return 0;
-       else
+       else if (csio_match_state(hw, csio_hws_uninit))
                return -EINVAL;
+       else
+               return -ENODEV;
 }
 
 int
index ea0c31086cc6b8b44517c8fcd34a44fb6c93fad9..dcd074169aa9b7794850c7034a1208353ba17266 100644 (file)
@@ -969,10 +969,14 @@ static int csio_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        pci_set_drvdata(pdev, hw);
 
-       if (csio_hw_start(hw) != 0) {
-               dev_err(&pdev->dev,
-                       "Failed to start FW, continuing in debug mode.\n");
-               return 0;
+       rv = csio_hw_start(hw);
+       if (rv) {
+               if (rv == -EINVAL) {
+                       dev_err(&pdev->dev,
+                               "Failed to start FW, continuing in debug mode.\n");
+                       return 0;
+               }
+               goto err_lnode_exit;
        }
 
        sprintf(hw->fwrev_str, "%u.%u.%u.%u\n",
index a69a9ac836f5d13c37d5220ecbb2711d588c4c35..1d02cf9fe06c5e941e5d1a76254f86ce658fc04b 100644 (file)
@@ -1635,6 +1635,9 @@ static int init_act_open(struct cxgbi_sock *csk)
                goto rel_resource;
        }
 
+       if (!(n->nud_state & NUD_VALID))
+               neigh_event_send(n, NULL);
+
        csk->atid = cxgb4_alloc_atid(lldi->tids, csk);
        if (csk->atid < 0) {
                pr_err("%s, NO atid available.\n", ndev->name);
index b0c68d24db011ba9465dd31a41c05acd4f13c283..f838bd73befa8f3b2fe915b8bbbe1990c563de1f 100644 (file)
@@ -3351,6 +3351,16 @@ static void ipr_worker_thread(struct work_struct *work)
                return;
        }
 
+       if (ioa_cfg->scsi_unblock) {
+               ioa_cfg->scsi_unblock = 0;
+               ioa_cfg->scsi_blocked = 0;
+               spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
+               scsi_unblock_requests(ioa_cfg->host);
+               spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
+               if (ioa_cfg->scsi_blocked)
+                       scsi_block_requests(ioa_cfg->host);
+       }
+
        if (!ioa_cfg->scan_enabled) {
                spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
                return;
@@ -4935,6 +4945,7 @@ static int ipr_slave_configure(struct scsi_device *sdev)
                }
                if (ipr_is_vset_device(res)) {
                        sdev->scsi_level = SCSI_SPC_3;
+                       sdev->no_report_opcodes = 1;
                        blk_queue_rq_timeout(sdev->request_queue,
                                             IPR_VSET_RW_TIMEOUT);
                        blk_queue_max_hw_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS);
@@ -7211,9 +7222,8 @@ static int ipr_ioa_bringdown_done(struct ipr_cmnd *ipr_cmd)
        ENTER;
        if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
                ipr_trace;
-               spin_unlock_irq(ioa_cfg->host->host_lock);
-               scsi_unblock_requests(ioa_cfg->host);
-               spin_lock_irq(ioa_cfg->host->host_lock);
+               ioa_cfg->scsi_unblock = 1;
+               schedule_work(&ioa_cfg->work_q);
        }
 
        ioa_cfg->in_reset_reload = 0;
@@ -7287,13 +7297,7 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd)
        list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
        wake_up_all(&ioa_cfg->reset_wait_q);
 
-       spin_unlock(ioa_cfg->host->host_lock);
-       scsi_unblock_requests(ioa_cfg->host);
-       spin_lock(ioa_cfg->host->host_lock);
-
-       if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds)
-               scsi_block_requests(ioa_cfg->host);
-
+       ioa_cfg->scsi_unblock = 1;
        schedule_work(&ioa_cfg->work_q);
        LEAVE;
        return IPR_RC_JOB_RETURN;
@@ -9249,8 +9253,11 @@ static void _ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
                spin_unlock(&ioa_cfg->hrrq[i]._lock);
        }
        wmb();
-       if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa)
+       if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
+               ioa_cfg->scsi_unblock = 0;
+               ioa_cfg->scsi_blocked = 1;
                scsi_block_requests(ioa_cfg->host);
+       }
 
        ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
        ioa_cfg->reset_cmd = ipr_cmd;
@@ -9306,9 +9313,8 @@ static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
                        wake_up_all(&ioa_cfg->reset_wait_q);
 
                        if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
-                               spin_unlock_irq(ioa_cfg->host->host_lock);
-                               scsi_unblock_requests(ioa_cfg->host);
-                               spin_lock_irq(ioa_cfg->host->host_lock);
+                               ioa_cfg->scsi_unblock = 1;
+                               schedule_work(&ioa_cfg->work_q);
                        }
                        return;
                } else {
index e98a87a653357b54996326d6f422d2ffa7923bee..c7f0e9e3cd7d4986c1341c3b7e115e65de551723 100644 (file)
@@ -1488,6 +1488,8 @@ struct ipr_ioa_cfg {
        u8 cfg_locked:1;
        u8 clear_isr:1;
        u8 probe_done:1;
+       u8 scsi_unblock:1;
+       u8 scsi_blocked:1;
 
        u8 revid;
 
index 4ed48ed38e79316f02ca1e299e56f66eea84ba8e..7ee1a94c0b33eefd57a6889df66649477ad4713b 100644 (file)
@@ -205,8 +205,10 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
                                atomic_read(&tgtp->xmt_ls_rsp_error));
 
                len += snprintf(buf+len, PAGE_SIZE-len,
-                               "FCP: Rcv %08x Release %08x Drop %08x\n",
+                               "FCP: Rcv %08x Defer %08x Release %08x "
+                               "Drop %08x\n",
                                atomic_read(&tgtp->rcv_fcp_cmd_in),
+                               atomic_read(&tgtp->rcv_fcp_cmd_defer),
                                atomic_read(&tgtp->xmt_fcp_release),
                                atomic_read(&tgtp->rcv_fcp_cmd_drop));
 
index 5cc8b0f7d885fb0dfd5a00342f6ca72c72a40129..744f3f395b64852a294a9300adb64a496087aed7 100644 (file)
@@ -782,8 +782,11 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
                                atomic_read(&tgtp->xmt_ls_rsp_error));
 
                len += snprintf(buf + len, size - len,
-                               "FCP: Rcv %08x Drop %08x\n",
+                               "FCP: Rcv %08x Defer %08x Release %08x "
+                               "Drop %08x\n",
                                atomic_read(&tgtp->rcv_fcp_cmd_in),
+                               atomic_read(&tgtp->rcv_fcp_cmd_defer),
+                               atomic_read(&tgtp->xmt_fcp_release),
                                atomic_read(&tgtp->rcv_fcp_cmd_drop));
 
                if (atomic_read(&tgtp->rcv_fcp_cmd_in) !=
index fbeec344c6cc3be0bdd878db6bafda7353dcf901..bbbd0f84160d36563008a212afd8252f86ef15c8 100644 (file)
@@ -841,12 +841,31 @@ lpfc_nvmet_xmt_fcp_release(struct nvmet_fc_target_port *tgtport,
        lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf);
 }
 
+static void
+lpfc_nvmet_defer_rcv(struct nvmet_fc_target_port *tgtport,
+                    struct nvmefc_tgt_fcp_req *rsp)
+{
+       struct lpfc_nvmet_tgtport *tgtp;
+       struct lpfc_nvmet_rcv_ctx *ctxp =
+               container_of(rsp, struct lpfc_nvmet_rcv_ctx, ctx.fcp_req);
+       struct rqb_dmabuf *nvmebuf = ctxp->rqb_buffer;
+       struct lpfc_hba *phba = ctxp->phba;
+
+       lpfc_nvmeio_data(phba, "NVMET DEFERRCV: xri x%x sz %d CPU %02x\n",
+                        ctxp->oxid, ctxp->size, smp_processor_id());
+
+       tgtp = phba->targetport->private;
+       atomic_inc(&tgtp->rcv_fcp_cmd_defer);
+       lpfc_rq_buf_free(phba, &nvmebuf->hbuf); /* repost */
+}
+
 static struct nvmet_fc_target_template lpfc_tgttemplate = {
        .targetport_delete = lpfc_nvmet_targetport_delete,
        .xmt_ls_rsp     = lpfc_nvmet_xmt_ls_rsp,
        .fcp_op         = lpfc_nvmet_xmt_fcp_op,
        .fcp_abort      = lpfc_nvmet_xmt_fcp_abort,
        .fcp_req_release = lpfc_nvmet_xmt_fcp_release,
+       .defer_rcv      = lpfc_nvmet_defer_rcv,
 
        .max_hw_queues  = 1,
        .max_sgl_segments = LPFC_NVMET_DEFAULT_SEGS,
@@ -1504,6 +1523,17 @@ lpfc_nvmet_unsol_fcp_buffer(struct lpfc_hba *phba,
                return;
        }
 
+       /* Processing of FCP command is deferred */
+       if (rc == -EOVERFLOW) {
+               lpfc_nvmeio_data(phba,
+                                "NVMET RCV BUSY: xri x%x sz %d from %06x\n",
+                                oxid, size, sid);
+               /* defer reposting rcv buffer till .defer_rcv callback */
+               ctxp->rqb_buffer = nvmebuf;
+               atomic_inc(&tgtp->rcv_fcp_cmd_out);
+               return;
+       }
+
        atomic_inc(&tgtp->rcv_fcp_cmd_drop);
        lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
                        "6159 FCP Drop IO x%x: err x%x: x%x x%x x%x\n",
index e675ef17be08a0f67dd76f9d33a2ab831f961ce8..48a76788b003cb746afa45376272af362c4446ce 100644 (file)
@@ -49,6 +49,7 @@ struct lpfc_nvmet_tgtport {
        atomic_t rcv_fcp_cmd_in;
        atomic_t rcv_fcp_cmd_out;
        atomic_t rcv_fcp_cmd_drop;
+       atomic_t rcv_fcp_cmd_defer;
        atomic_t xmt_fcp_release;
 
        /* Stats counters - lpfc_nvmet_xmt_fcp_op */
index 316c3df0c3fd80f9689499f0351082703772707f..71c4746341ea379e3881d32cf3078f135d15f999 100644 (file)
@@ -6228,8 +6228,8 @@ static int megasas_probe_one(struct pci_dev *pdev,
 fail_start_aen:
 fail_io_attach:
        megasas_mgmt_info.count--;
-       megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
        megasas_mgmt_info.max_index--;
+       megasas_mgmt_info.instance[megasas_mgmt_info.max_index] = NULL;
 
        instance->instancet->disable_intr(instance);
        megasas_destroy_irqs(instance);
index 4d038926a4558c45b8685ca08c4976233a7ed5e7..351f06dfc5a0dac7bf4f7606166611848876d477 100644 (file)
@@ -528,7 +528,8 @@ struct fip_vlan {
 #define QEDF_WRITE                    (1 << 0)
 #define MAX_FIBRE_LUNS                 0xffffffff
 
-#define QEDF_MAX_NUM_CQS               8
+#define MIN_NUM_CPUS_MSIX(x)   min_t(u32, x->dev_info.num_cqs, \
+                                       num_online_cpus())
 
 /*
  * PCI function probe defines
index eb07f1de8afa5316be9c038b881d076327c36bb3..59c18ca4cda98e59285853d14e93c1a79a80f3f0 100644 (file)
@@ -489,7 +489,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
 
        /* If a SRR times out, simply free resources */
        if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO)
-               goto out_free;
+               goto out_put;
 
        /* Normalize response data into struct fc_frame */
        mp_req = &(srr_req->mp_req);
@@ -501,7 +501,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
        if (!fp) {
                QEDF_ERR(&(qedf->dbg_ctx),
                    "fc_frame_alloc failure.\n");
-               goto out_free;
+               goto out_put;
        }
 
        /* Copy frame header from firmware into fp */
@@ -526,9 +526,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
        }
 
        fc_frame_free(fp);
-out_free:
+out_put:
        /* Put reference for original command since SRR completed */
        kref_put(&orig_io_req->refcount, qedf_release_cmd);
+out_free:
        kfree(cb_arg);
 }
 
@@ -780,7 +781,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
 
        /* If a REC times out, free resources */
        if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO)
-               goto out_free;
+               goto out_put;
 
        /* Normalize response data into struct fc_frame */
        mp_req = &(rec_req->mp_req);
@@ -792,7 +793,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
        if (!fp) {
                QEDF_ERR(&(qedf->dbg_ctx),
                    "fc_frame_alloc failure.\n");
-               goto out_free;
+               goto out_put;
        }
 
        /* Copy frame header from firmware into fp */
@@ -884,9 +885,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
 
 out_free_frame:
        fc_frame_free(fp);
-out_free:
+out_put:
        /* Put reference for original command since REC completed */
        kref_put(&orig_io_req->refcount, qedf_release_cmd);
+out_free:
        kfree(cb_arg);
 }
 
index 7786c97e033fdcdd9643a41dd1d0bb928036d65b..1d13c9ca517de7e2cec033bdf050498fafbfeccc 100644 (file)
@@ -2760,11 +2760,9 @@ static int qedf_set_fcoe_pf_param(struct qedf_ctx *qedf)
         * we allocation is the minimum off:
         *
         * Number of CPUs
-        * Number of MSI-X vectors
-        * Max number allocated in hardware (QEDF_MAX_NUM_CQS)
+        * Number allocated by qed for our PCI function
         */
-       qedf->num_queues = min((unsigned int)QEDF_MAX_NUM_CQS,
-           num_online_cpus());
+       qedf->num_queues = MIN_NUM_CPUS_MSIX(qedf);
 
        QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, "Number of CQs is %d.\n",
                   qedf->num_queues);
@@ -2962,6 +2960,13 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
                goto err1;
        }
 
+       /* Learn information crucial for qedf to progress */
+       rc = qed_ops->fill_dev_info(qedf->cdev, &qedf->dev_info);
+       if (rc) {
+               QEDF_ERR(&(qedf->dbg_ctx), "Failed to dev info.\n");
+               goto err1;
+       }
+
        /* queue allocation code should come here
         * order should be
         *      slowpath_start
@@ -2977,13 +2982,6 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
        }
        qed_ops->common->update_pf_params(qedf->cdev, &qedf->pf_params);
 
-       /* Learn information crucial for qedf to progress */
-       rc = qed_ops->fill_dev_info(qedf->cdev, &qedf->dev_info);
-       if (rc) {
-               QEDF_ERR(&(qedf->dbg_ctx), "Failed to dev info.\n");
-               goto err1;
-       }
-
        /* Record BDQ producer doorbell addresses */
        qedf->bdq_primary_prod = qedf->dev_info.primary_dbq_rq_addr;
        qedf->bdq_secondary_prod = qedf->dev_info.secondary_bdq_rq_addr;
index 33142610882f4d9bedce93076160180513ca5f82..b18646d6057f476e70d59137a0450e5f90d4b3fc 100644 (file)
@@ -401,9 +401,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_req_queues; i++) {
                        struct req_que *req = vha->hw->req_q_map[i];
 
-                       if (!test_bit(i, vha->hw->req_qid_map))
-                               continue;
-
                        if (req || !buf) {
                                length = req ?
                                    req->length : REQUEST_ENTRY_CNT_24XX;
@@ -418,9 +415,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_rsp_queues; i++) {
                        struct rsp_que *rsp = vha->hw->rsp_q_map[i];
 
-                       if (!test_bit(i, vha->hw->rsp_qid_map))
-                               continue;
-
                        if (rsp || !buf) {
                                length = rsp ?
                                    rsp->length : RESPONSE_ENTRY_CNT_MQ;
@@ -660,9 +654,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_req_queues; i++) {
                        struct req_que *req = vha->hw->req_q_map[i];
 
-                       if (!test_bit(i, vha->hw->req_qid_map))
-                               continue;
-
                        if (req || !buf) {
                                qla27xx_insert16(i, buf, len);
                                qla27xx_insert16(1, buf, len);
@@ -675,9 +666,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
                for (i = 0; i < vha->hw->max_rsp_queues; i++) {
                        struct rsp_que *rsp = vha->hw->rsp_q_map[i];
 
-                       if (!test_bit(i, vha->hw->rsp_qid_map))
-                               continue;
-
                        if (rsp || !buf) {
                                qla27xx_insert16(i, buf, len);
                                qla27xx_insert16(1, buf, len);
index b20da0d27ad78494bc9a0172d428dc176cbcb852..3f82ea1b72dc8739283992b4f425d77692b51e7b 100644 (file)
@@ -500,7 +500,6 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
 static void tcm_qla2xxx_handle_data_work(struct work_struct *work)
 {
        struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
-       unsigned long flags;
 
        /*
         * Ensure that the complete FCP WRITE payload has been received.
@@ -508,17 +507,6 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work)
         */
        cmd->cmd_in_wq = 0;
 
-       spin_lock_irqsave(&cmd->cmd_lock, flags);
-       cmd->data_work = 1;
-       if (cmd->aborted) {
-               cmd->data_work_free = 1;
-               spin_unlock_irqrestore(&cmd->cmd_lock, flags);
-
-               tcm_qla2xxx_free_cmd(cmd);
-               return;
-       }
-       spin_unlock_irqrestore(&cmd->cmd_lock, flags);
-
        cmd->qpair->tgt_counters.qla_core_ret_ctio++;
        if (!cmd->write_data_transferred) {
                /*
@@ -765,31 +753,13 @@ static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
        qlt_xmit_tm_rsp(mcmd);
 }
 
-#define DATA_WORK_NOT_FREE(_cmd) (_cmd->data_work && !_cmd->data_work_free)
 static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
 {
        struct qla_tgt_cmd *cmd = container_of(se_cmd,
                                struct qla_tgt_cmd, se_cmd);
-       unsigned long flags;
 
        if (qlt_abort_cmd(cmd))
                return;
-
-       spin_lock_irqsave(&cmd->cmd_lock, flags);
-       if ((cmd->state == QLA_TGT_STATE_NEW)||
-           ((cmd->state == QLA_TGT_STATE_DATA_IN) &&
-               DATA_WORK_NOT_FREE(cmd))) {
-               cmd->data_work_free = 1;
-               spin_unlock_irqrestore(&cmd->cmd_lock, flags);
-               /*
-                * cmd has not reached fw, Use this trigger to free it.
-                */
-               tcm_qla2xxx_free_cmd(cmd);
-               return;
-       }
-       spin_unlock_irqrestore(&cmd->cmd_lock, flags);
-       return;
-
 }
 
 static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *,
index 3d38c6d463b810f19fe2cbdd3dc69801465cd05a..1bf274e3b2b614b5331f4a082668e660ceba74e7 100644 (file)
@@ -800,7 +800,11 @@ MODULE_LICENSE("GPL");
 module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
 
+#ifdef CONFIG_SCSI_MQ_DEFAULT
 bool scsi_use_blk_mq = true;
+#else
+bool scsi_use_blk_mq = false;
+#endif
 module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO);
 
 static int __init init_scsi(void)
index bea36adeee178ab57bced3591b0969bc2d973264..e2647f2d44304b0ded65ebb0f55d629c7289d0b7 100644 (file)
@@ -1277,6 +1277,9 @@ static void sd_uninit_command(struct scsi_cmnd *SCpnt)
 {
        struct request *rq = SCpnt->request;
 
+       if (SCpnt->flags & SCMD_ZONE_WRITE_LOCK)
+               sd_zbc_write_unlock_zone(SCpnt);
+
        if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
                __free_page(rq->special_vec.bv_page);
 
index 96855df9f49ddf3756b8fc6ee98b127727d9bbeb..8aa54779aac1b4e6112d86dc536dd14b1522d6eb 100644 (file)
@@ -294,6 +294,9 @@ int sd_zbc_write_lock_zone(struct scsi_cmnd *cmd)
            test_and_set_bit(zno, sdkp->zones_wlock))
                return BLKPREP_DEFER;
 
+       WARN_ON_ONCE(cmd->flags & SCMD_ZONE_WRITE_LOCK);
+       cmd->flags |= SCMD_ZONE_WRITE_LOCK;
+
        return BLKPREP_OK;
 }
 
@@ -302,9 +305,10 @@ void sd_zbc_write_unlock_zone(struct scsi_cmnd *cmd)
        struct request *rq = cmd->request;
        struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
 
-       if (sdkp->zones_wlock) {
+       if (sdkp->zones_wlock && cmd->flags & SCMD_ZONE_WRITE_LOCK) {
                unsigned int zno = sd_zbc_zone_no(sdkp, blk_rq_pos(rq));
                WARN_ON_ONCE(!test_bit(zno, sdkp->zones_wlock));
+               cmd->flags &= ~SCMD_ZONE_WRITE_LOCK;
                clear_bit_unlock(zno, sdkp->zones_wlock);
                smp_mb__after_atomic();
        }
@@ -335,9 +339,6 @@ void sd_zbc_complete(struct scsi_cmnd *cmd,
        case REQ_OP_WRITE_ZEROES:
        case REQ_OP_WRITE_SAME:
 
-               /* Unlock the zone */
-               sd_zbc_write_unlock_zone(cmd);
-
                if (result &&
                    sshdr->sense_key == ILLEGAL_REQUEST &&
                    sshdr->asc == 0x21)
index f1cdf32d7514120b31515ddf2901960d4f766694..8927f9f54ad926f5b50439e23685a35b24c50edf 100644 (file)
@@ -99,7 +99,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
 
        ret =  scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
                                NULL, SES_TIMEOUT, SES_RETRIES, NULL);
-       if (unlikely(!ret))
+       if (unlikely(ret))
                return ret;
 
        recv_page_code = ((unsigned char *)buf)[0];
index 4fe606b000b4461c05e441cbb787edcfec51e72b..84e782d8e7c3f0cb8dd4c3bdedb46b7060b18f1e 100644 (file)
@@ -751,35 +751,6 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,
        return count;
 }
 
-static bool sg_is_valid_dxfer(sg_io_hdr_t *hp)
-{
-       switch (hp->dxfer_direction) {
-       case SG_DXFER_NONE:
-               if (hp->dxferp || hp->dxfer_len > 0)
-                       return false;
-               return true;
-       case SG_DXFER_FROM_DEV:
-               /*
-                * for SG_DXFER_FROM_DEV we always set dxfer_len to > 0. dxferp
-                * can either be NULL or != NULL so there's no point in checking
-                * it either. So just return true.
-                */
-               return true;
-       case SG_DXFER_TO_DEV:
-       case SG_DXFER_TO_FROM_DEV:
-               if (!hp->dxferp || hp->dxfer_len == 0)
-                       return false;
-               return true;
-       case SG_DXFER_UNKNOWN:
-               if ((!hp->dxferp && hp->dxfer_len) ||
-                   (hp->dxferp && hp->dxfer_len == 0))
-                       return false;
-               return true;
-       default:
-               return false;
-       }
-}
-
 static int
 sg_common_write(Sg_fd * sfp, Sg_request * srp,
                unsigned char *cmnd, int timeout, int blocking)
@@ -800,7 +771,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
                        "sg_common_write:  scsi opcode=0x%02x, cmd_size=%d\n",
                        (int) cmnd[0], (int) hp->cmd_len));
 
-       if (!sg_is_valid_dxfer(hp))
+       if (hp->dxfer_len >= SZ_256M)
                return -EINVAL;
 
        k = sg_start_req(srp, cmnd);
@@ -1050,7 +1021,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
                        read_lock_irqsave(&sfp->rq_list_lock, iflags);
                        val = 0;
                        list_for_each_entry(srp, &sfp->rq_list, entry) {
-                               if (val > SG_MAX_QUEUE)
+                               if (val >= SG_MAX_QUEUE)
                                        break;
                                memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
                                rinfo[val].req_state = srp->done + 1;
index 8e5013d9cad445178a0461edd8eaf9abe4e84c38..94e402ed30f6ae54ecb32160480d554e6e118827 100644 (file)
@@ -4299,11 +4299,11 @@ static int st_probe(struct device *dev)
        kref_init(&tpnt->kref);
        tpnt->disk = disk;
        disk->private_data = &tpnt->driver;
-       disk->queue = SDp->request_queue;
        /* SCSI tape doesn't register this gendisk via add_disk().  Manually
         * take queue reference that release_disk() expects. */
-       if (!blk_get_queue(disk->queue))
+       if (!blk_get_queue(SDp->request_queue))
                goto out_put_disk;
+       disk->queue = SDp->request_queue;
        tpnt->driver = &st_template;
 
        tpnt->device = SDp;
index ca11be21f64b606091d5e8e0e62044ae263dc3ab..34ca7823255d692d05aa753e7c5bc28a385c5583 100644 (file)
@@ -2396,6 +2396,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
                        continue;
                }
 
+               set_current_state(TASK_RUNNING);
                wp = async->buf_write_ptr;
                n1 = min(n, async->prealloc_bufsz - wp);
                n2 = n - n1;
@@ -2528,6 +2529,8 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
                        }
                        continue;
                }
+
+               set_current_state(TASK_RUNNING);
                rp = async->buf_read_ptr;
                n1 = min(n, async->prealloc_bufsz - rp);
                n2 = n - n1;
index b37a6f48225f5209999d54f338635b9b027ab967..8ea3920400a06b6a43e8456375fb6fae2b20577f 100644 (file)
@@ -16,9 +16,9 @@
 
 static bool __must_check fsl_mc_is_allocatable(const char *obj_type)
 {
-       return strcmp(obj_type, "dpbp") ||
-              strcmp(obj_type, "dpmcp") ||
-              strcmp(obj_type, "dpcon");
+       return strcmp(obj_type, "dpbp") == 0 ||
+              strcmp(obj_type, "dpmcp") == 0 ||
+              strcmp(obj_type, "dpcon") == 0;
 }
 
 /**
index a6a8393d66645e75c13ecf8f67ca9c71ef48a6e5..3e00df74b18c883d4e19f0bac7ec087988b58821 100644 (file)
@@ -472,7 +472,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
                             long m)
 {
        struct ad2s1210_state *st = iio_priv(indio_dev);
-       bool negative;
+       u16 negative;
        int ret = 0;
        u16 pos;
        s16 vel;
index d283341cfe4356914e3e9071f8d6851a7a180d46..56cd4e5e51b2f99906b5a7170854ea57629f5f34 100644 (file)
@@ -45,6 +45,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
        {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
        {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
        {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
+       {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
        {}      /* Terminating entry */
 };
 
index e583dd8a418b537eda69a9606fa8a3fc2c6a6207..d4fa41be80f9a1719574af28c8981ef8e8d287ca 100644 (file)
@@ -1510,11 +1510,13 @@ cxgbit_pass_open_rpl(struct cxgbit_device *cdev, struct sk_buff *skb)
 
        if (!cnp) {
                pr_info("%s stid %d lookup failure\n", __func__, stid);
-               return;
+               goto rel_skb;
        }
 
        cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status);
        cxgbit_put_cnp(cnp);
+rel_skb:
+       __kfree_skb(skb);
 }
 
 static void
@@ -1530,11 +1532,13 @@ cxgbit_close_listsrv_rpl(struct cxgbit_device *cdev, struct sk_buff *skb)
 
        if (!cnp) {
                pr_info("%s stid %d lookup failure\n", __func__, stid);
-               return;
+               goto rel_skb;
        }
 
        cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status);
        cxgbit_put_cnp(cnp);
+rel_skb:
+       __kfree_skb(skb);
 }
 
 static void
@@ -1819,12 +1823,16 @@ static void cxgbit_set_tcb_rpl(struct cxgbit_device *cdev, struct sk_buff *skb)
        struct tid_info *t = lldi->tids;
 
        csk = lookup_tid(t, tid);
-       if (unlikely(!csk))
+       if (unlikely(!csk)) {
                pr_err("can't find connection for tid %u.\n", tid);
-       else
+               goto rel_skb;
+       } else {
                cxgbit_wake_up(&csk->com.wr_wait, __func__, rpl->status);
+       }
 
        cxgbit_put_csk(csk);
+rel_skb:
+       __kfree_skb(skb);
 }
 
 static void cxgbit_rx_data(struct cxgbit_device *cdev, struct sk_buff *skb)
index dda13f1af38e581f746e4528590510c07efb916f..514986b57c2d60ce19c1074f4d19d65dd550be2e 100644 (file)
@@ -827,7 +827,7 @@ cxgbit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
 
 static void
 cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg,
-                     unsigned int nents)
+                     unsigned int nents, u32 skip)
 {
        struct skb_seq_state st;
        const u8 *buf;
@@ -846,7 +846,7 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg,
                }
 
                consumed += sg_pcopy_from_buffer(sg, nents, (void *)buf,
-                                                buf_len, consumed);
+                                                buf_len, skip + consumed);
        }
 }
 
@@ -912,7 +912,7 @@ cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,
                struct scatterlist *sg = &cmd->se_cmd.t_data_sg[0];
                u32 sg_nents = max(1UL, DIV_ROUND_UP(pdu_cb->dlen, PAGE_SIZE));
 
-               cxgbit_skb_copy_to_sg(csk->skb, sg, sg_nents);
+               cxgbit_skb_copy_to_sg(csk->skb, sg, sg_nents, 0);
        }
 
        cmd->write_data_done += pdu_cb->dlen;
@@ -1069,11 +1069,13 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)
                  cmd->se_cmd.data_length);
 
        if (!(pdu_cb->flags & PDUCBF_RX_DATA_DDPD)) {
+               u32 skip = data_offset % PAGE_SIZE;
+
                sg_off = data_offset / PAGE_SIZE;
                sg_start = &cmd->se_cmd.t_data_sg[sg_off];
-               sg_nents = max(1UL, DIV_ROUND_UP(data_len, PAGE_SIZE));
+               sg_nents = max(1UL, DIV_ROUND_UP(skip + data_len, PAGE_SIZE));
 
-               cxgbit_skb_copy_to_sg(csk->skb, sg_start, sg_nents);
+               cxgbit_skb_copy_to_sg(csk->skb, sg_start, sg_nents, skip);
        }
 
 check_payload:
index 74e4975dd1b1e74d6c39517be102ccdc92614e80..5001261f5d69d759dd25161401510551d35c3da7 100644 (file)
@@ -418,6 +418,7 @@ int iscsit_reset_np_thread(
                return 0;
        }
        np->np_thread_state = ISCSI_NP_THREAD_RESET;
+       atomic_inc(&np->np_reset_count);
 
        if (np->np_thread) {
                spin_unlock_bh(&np->np_thread_lock);
@@ -2167,6 +2168,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
        cmd->cmd_sn             = be32_to_cpu(hdr->cmdsn);
        cmd->exp_stat_sn        = be32_to_cpu(hdr->exp_statsn);
        cmd->data_direction     = DMA_NONE;
+       kfree(cmd->text_in_ptr);
        cmd->text_in_ptr        = NULL;
 
        return 0;
@@ -3487,9 +3489,9 @@ iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,
                return text_length;
 
        if (completed) {
-               hdr->flags |= ISCSI_FLAG_CMD_FINAL;
+               hdr->flags = ISCSI_FLAG_CMD_FINAL;
        } else {
-               hdr->flags |= ISCSI_FLAG_TEXT_CONTINUE;
+               hdr->flags = ISCSI_FLAG_TEXT_CONTINUE;
                cmd->read_data_done += text_length;
                if (cmd->targ_xfer_tag == 0xFFFFFFFF)
                        cmd->targ_xfer_tag = session_get_next_ttt(conn->sess);
index e9bdc8b86e7d1d71d77cf4388370af6fcf3fded7..dc13afbd4c88dec2390ca8e65b3332d2f78acd73 100644 (file)
@@ -1243,9 +1243,11 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
        flush_signals(current);
 
        spin_lock_bh(&np->np_thread_lock);
-       if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+       if (atomic_dec_if_positive(&np->np_reset_count) >= 0) {
                np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
+               spin_unlock_bh(&np->np_thread_lock);
                complete(&np->np_restart_comp);
+               return 1;
        } else if (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN) {
                spin_unlock_bh(&np->np_thread_lock);
                goto exit;
@@ -1278,7 +1280,8 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
                goto exit;
        } else if (rc < 0) {
                spin_lock_bh(&np->np_thread_lock);
-               if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
+               if (atomic_dec_if_positive(&np->np_reset_count) >= 0) {
+                       np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
                        spin_unlock_bh(&np->np_thread_lock);
                        complete(&np->np_restart_comp);
                        iscsit_put_transport(conn->conn_transport);
index 36913734c6bc58ed326ac793dc19d3d265ec878d..02e8a5d8665837f415ac7b2d78e51067d1ef5b62 100644 (file)
@@ -364,7 +364,7 @@ void core_tpg_del_initiator_node_acl(struct se_node_acl *acl)
        mutex_lock(&tpg->acl_node_mutex);
        if (acl->dynamic_node_acl)
                acl->dynamic_node_acl = 0;
-       list_del(&acl->acl_list);
+       list_del_init(&acl->acl_list);
        mutex_unlock(&tpg->acl_node_mutex);
 
        target_shutdown_sessions(acl);
@@ -548,7 +548,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
         * in transport_deregister_session().
         */
        list_for_each_entry_safe(nacl, nacl_tmp, &node_list, acl_list) {
-               list_del(&nacl->acl_list);
+               list_del_init(&nacl->acl_list);
 
                core_tpg_wait_for_nacl_pr_ref(nacl);
                core_free_device_list_for_node(nacl, se_tpg);
index 97fed9a298bdc29a19d184ba49df458e04e4f9f1..836d552b0385e978bc1a0b98c59a3379c262fd61 100644 (file)
@@ -466,7 +466,7 @@ static void target_complete_nacl(struct kref *kref)
        }
 
        mutex_lock(&se_tpg->acl_node_mutex);
-       list_del(&nacl->acl_list);
+       list_del_init(&nacl->acl_list);
        mutex_unlock(&se_tpg->acl_node_mutex);
 
        core_tpg_wait_for_nacl_pr_ref(nacl);
@@ -538,7 +538,7 @@ void transport_free_session(struct se_session *se_sess)
                        spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags);
 
                        if (se_nacl->dynamic_stop)
-                               list_del(&se_nacl->acl_list);
+                               list_del_init(&se_nacl->acl_list);
                }
                mutex_unlock(&se_tpg->acl_node_mutex);
 
index 80ee130f8253ec44324ac2ba616cfd93beb1ba76..942d094269fba5db66ff7e791dcfaab1c6acec15 100644 (file)
@@ -563,8 +563,6 @@ static int scatter_data_area(struct tcmu_dev *udev,
                                        block_remaining);
                        to_offset = get_block_offset_user(udev, dbi,
                                        block_remaining);
-                       offset = DATA_BLOCK_SIZE - block_remaining;
-                       to += offset;
 
                        if (*iov_cnt != 0 &&
                            to_offset == iov_tail(*iov)) {
@@ -575,8 +573,10 @@ static int scatter_data_area(struct tcmu_dev *udev,
                                (*iov)->iov_len = copy_bytes;
                        }
                        if (copy_data) {
-                               memcpy(to, from + sg->length - sg_remaining,
-                                       copy_bytes);
+                               offset = DATA_BLOCK_SIZE - block_remaining;
+                               memcpy(to + offset,
+                                      from + sg->length - sg_remaining,
+                                      copy_bytes);
                                tcmu_flush_dcache_range(to, copy_bytes);
                        }
                        sg_remaining -= copy_bytes;
@@ -637,9 +637,8 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
                        copy_bytes = min_t(size_t, sg_remaining,
                                        block_remaining);
                        offset = DATA_BLOCK_SIZE - block_remaining;
-                       from += offset;
                        tcmu_flush_dcache_range(from, copy_bytes);
-                       memcpy(to + sg->length - sg_remaining, from,
+                       memcpy(to + sg->length - sg_remaining, from + offset,
                                        copy_bytes);
 
                        sg_remaining -= copy_bytes;
@@ -1433,6 +1432,8 @@ static int tcmu_update_uio_info(struct tcmu_dev *udev)
        if (udev->dev_config[0])
                snprintf(str + used, size - used, "/%s", udev->dev_config);
 
+       /* If the old string exists, free it */
+       kfree(info->name);
        info->name = str;
 
        return 0;
index 308b6e17c88aace0775b4ed0a5460097559d66ca..fe2f00ceafc5d7e1a3bbafea4224c838dc2158a4 100644 (file)
@@ -333,6 +333,15 @@ static int tb_drom_parse_entry_port(struct tb_switch *sw,
        int res;
        enum tb_port_type type;
 
+       /*
+        * Some DROMs list more ports than the controller actually has
+        * so we skip those but allow the parser to continue.
+        */
+       if (header->index > sw->config.max_port_number) {
+               dev_info_once(&sw->dev, "ignoring unnecessary extra entries in DROM\n");
+               return 0;
+       }
+
        port = &sw->ports[header->index];
        port->disabled = header->port_disabled;
        if (port->disabled)
index 284749fb0f6b96d3d6d667332e569ba0d745e048..a6d5164c33a9ca7e3d02bbda7fc94ff783d75929 100644 (file)
@@ -69,13 +69,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
 #ifdef CONFIG_UNIX98_PTYS
                if (tty->driver == ptm_driver) {
                        mutex_lock(&devpts_mutex);
-                       if (tty->link->driver_data) {
-                               struct path *path = tty->link->driver_data;
-
-                               devpts_pty_kill(path->dentry);
-                               path_put(path);
-                               kfree(path);
-                       }
+                       if (tty->link->driver_data)
+                               devpts_pty_kill(tty->link->driver_data);
                        mutex_unlock(&devpts_mutex);
                }
 #endif
@@ -607,25 +602,24 @@ static inline void legacy_pty_init(void) { }
 static struct cdev ptmx_cdev;
 
 /**
- *     pty_open_peer - open the peer of a pty
- *     @tty: the peer of the pty being opened
+ *     ptm_open_peer - open the peer of a pty
+ *     @master: the open struct file of the ptmx device node
+ *     @tty: the master of the pty being opened
+ *     @flags: the flags for open
  *
- *     Open the cached dentry in tty->link, providing a safe way for userspace
- *     to get the slave end of a pty (where they have the master fd and cannot
- *     access or trust the mount namespace /dev/pts was mounted inside).
+ *     Provide a race free way for userspace to open the slave end of a pty
+ *     (where they have the master fd and cannot access or trust the mount
+ *     namespace /dev/pts was mounted inside).
  */
-static struct file *pty_open_peer(struct tty_struct *tty, int flags)
-{
-       if (tty->driver->subtype != PTY_TYPE_MASTER)
-               return ERR_PTR(-EIO);
-       return dentry_open(tty->link->driver_data, flags, current_cred());
-}
-
-static int pty_get_peer(struct tty_struct *tty, int flags)
+int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
 {
        int fd = -1;
-       struct file *filp = NULL;
+       struct file *filp;
        int retval = -EINVAL;
+       struct path path;
+
+       if (tty->driver != ptm_driver)
+               return -EIO;
 
        fd = get_unused_fd_flags(0);
        if (fd < 0) {
@@ -633,7 +627,16 @@ static int pty_get_peer(struct tty_struct *tty, int flags)
                goto err;
        }
 
-       filp = pty_open_peer(tty, flags);
+       /* Compute the slave's path */
+       path.mnt = devpts_mntget(master, tty->driver_data);
+       if (IS_ERR(path.mnt)) {
+               retval = PTR_ERR(path.mnt);
+               goto err_put;
+       }
+       path.dentry = tty->link->driver_data;
+
+       filp = dentry_open(&path, flags, current_cred());
+       mntput(path.mnt);
        if (IS_ERR(filp)) {
                retval = PTR_ERR(filp);
                goto err_put;
@@ -662,8 +665,6 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
                return pty_get_pktmode(tty, (int __user *)arg);
        case TIOCGPTN: /* Get PT Number */
                return put_user(tty->index, (unsigned int __user *)arg);
-       case TIOCGPTPEER: /* Open the other end */
-               return pty_get_peer(tty, (int) arg);
        case TIOCSIG:    /* Send signal to other side of pty */
                return pty_signal(tty, (int) arg);
        }
@@ -791,7 +792,6 @@ static int ptmx_open(struct inode *inode, struct file *filp)
 {
        struct pts_fs_info *fsi;
        struct tty_struct *tty;
-       struct path *pts_path;
        struct dentry *dentry;
        int retval;
        int index;
@@ -845,26 +845,16 @@ static int ptmx_open(struct inode *inode, struct file *filp)
                retval = PTR_ERR(dentry);
                goto err_release;
        }
-       /* We need to cache a fake path for TIOCGPTPEER. */
-       pts_path = kmalloc(sizeof(struct path), GFP_KERNEL);
-       if (!pts_path)
-               goto err_release;
-       pts_path->mnt = filp->f_path.mnt;
-       pts_path->dentry = dentry;
-       path_get(pts_path);
-       tty->link->driver_data = pts_path;
+       tty->link->driver_data = dentry;
 
        retval = ptm_driver->ops->open(tty, filp);
        if (retval)
-               goto err_path_put;
+               goto err_release;
 
        tty_debug_hangup(tty, "opening (count=%d)\n", tty->count);
 
        tty_unlock(tty);
        return 0;
-err_path_put:
-       path_put(pts_path);
-       kfree(pts_path);
 err_release:
        tty_unlock(tty);
        // This will also put-ref the fsi
index b5def356af63b70e3ebc2e23a48da0753e41b47e..1aab3010fbfae76e2c25cb60085f21051a1f24cf 100644 (file)
@@ -1043,13 +1043,24 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
                if (up->dl_write)
                        uart->dl_write = up->dl_write;
 
-               if (serial8250_isa_config != NULL)
-                       serial8250_isa_config(0, &uart->port,
-                                       &uart->capabilities);
+               if (uart->port.type != PORT_8250_CIR) {
+                       if (serial8250_isa_config != NULL)
+                               serial8250_isa_config(0, &uart->port,
+                                               &uart->capabilities);
+
+                       ret = uart_add_one_port(&serial8250_reg,
+                                               &uart->port);
+                       if (ret == 0)
+                               ret = uart->port.line;
+               } else {
+                       dev_info(uart->port.dev,
+                               "skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n",
+                               uart->port.iobase,
+                               (unsigned long long)uart->port.mapbase,
+                               uart->port.irq);
 
-               ret = uart_add_one_port(&serial8250_reg, &uart->port);
-               if (ret == 0)
-                       ret = uart->port.line;
+                       ret = 0;
+               }
        }
        mutex_unlock(&serial_mutex);
 
index 8a857bb34fbb26c6d60784d3fe7576730a9aa5b3..1888d168a41c87c605962da2605df8ab1c02bd20 100644 (file)
@@ -142,15 +142,7 @@ static struct vendor_data vendor_sbsa = {
        .fixed_options          = true,
 };
 
-/*
- * Erratum 44 for QDF2432v1 and QDF2400v1 SoCs describes the BUSY bit as
- * occasionally getting stuck as 1. To avoid the potential for a hang, check
- * TXFE == 0 instead of BUSY == 1. This may not be suitable for all UART
- * implementations, so only do so if an affected platform is detected in
- * parse_spcr().
- */
-static bool qdf2400_e44_present = false;
-
+#ifdef CONFIG_ACPI_SPCR_TABLE
 static struct vendor_data vendor_qdt_qdf2400_e44 = {
        .reg_offset             = pl011_std_offsets,
        .fr_busy                = UART011_FR_TXFE,
@@ -165,6 +157,7 @@ static struct vendor_data vendor_qdt_qdf2400_e44 = {
        .always_enabled         = true,
        .fixed_options          = true,
 };
+#endif
 
 static u16 pl011_st_offsets[REG_ARRAY_SIZE] = {
        [REG_DR] = UART01x_DR,
@@ -2375,12 +2368,14 @@ static int __init pl011_console_match(struct console *co, char *name, int idx,
        resource_size_t addr;
        int i;
 
-       if (strcmp(name, "qdf2400_e44") == 0) {
-               pr_info_once("UART: Working around QDF2400 SoC erratum 44");
-               qdf2400_e44_present = true;
-       } else if (strcmp(name, "pl011") != 0) {
+       /*
+        * Systems affected by the Qualcomm Technologies QDF2400 E44 erratum
+        * have a distinct console name, so make sure we check for that.
+        * The actual implementation of the erratum occurs in the probe
+        * function.
+        */
+       if ((strcmp(name, "qdf2400_e44") != 0) && (strcmp(name, "pl011") != 0))
                return -ENODEV;
-       }
 
        if (uart_parse_earlycon(options, &iotype, &addr, &options))
                return -ENODEV;
@@ -2734,11 +2729,17 @@ static int sbsa_uart_probe(struct platform_device *pdev)
        }
        uap->port.irq   = ret;
 
-       uap->reg_offset = vendor_sbsa.reg_offset;
-       uap->vendor     = qdf2400_e44_present ?
-                                       &vendor_qdt_qdf2400_e44 : &vendor_sbsa;
+#ifdef CONFIG_ACPI_SPCR_TABLE
+       if (qdf2400_e44_present) {
+               dev_info(&pdev->dev, "working around QDF2400 SoC erratum 44\n");
+               uap->vendor = &vendor_qdt_qdf2400_e44;
+       } else
+#endif
+               uap->vendor = &vendor_sbsa;
+
+       uap->reg_offset = uap->vendor->reg_offset;
        uap->fifosize   = 32;
-       uap->port.iotype = vendor_sbsa.access_32b ? UPIO_MEM32 : UPIO_MEM;
+       uap->port.iotype = uap->vendor->access_32b ? UPIO_MEM32 : UPIO_MEM;
        uap->port.ops   = &sbsa_uart_pops;
        uap->fixed_baud = baudrate;
 
index 974b13d244010de234d0350b9c45425251ff99c6..10c4038c0e8dfe9d07b7fd5f02732de03cc4ed3e 100644 (file)
@@ -2518,6 +2518,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case TIOCSSERIAL:
                tty_warn_deprecated_flags(p);
                break;
+       case TIOCGPTPEER:
+               /* Special because the struct file is needed */
+               return ptm_open_peer(file, tty, (int)arg);
        default:
                retval = tty_jobctrl_ioctl(tty, real_tty, file, cmd, arg);
                if (retval != -ENOIOCTLCMD)
index ab1bb3b538ac6175dd1fbe5babb686a6a8f4bc49..7f277b092b5bf070c21d9c321d15b2e0d630792e 100644 (file)
@@ -1888,7 +1888,7 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,
        /* No more submits can occur */
        spin_lock_irq(&hcd_urb_list_lock);
 rescan:
-       list_for_each_entry (urb, &ep->urb_list, urb_list) {
+       list_for_each_entry_reverse(urb, &ep->urb_list, urb_list) {
                int     is_in;
 
                if (urb->unlinked)
@@ -2485,6 +2485,8 @@ void usb_hc_died (struct usb_hcd *hcd)
        }
        if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) {
                hcd = hcd->shared_hcd;
+               clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags);
+               set_bit(HCD_FLAG_DEAD, &hcd->flags);
                if (hcd->rh_registered) {
                        clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
 
index 6e6797d145dd80136c413129641bdbbae2f1e63b..822f8c50e4233c70d159a4e374ad66b49502c0c1 100644 (file)
@@ -4725,7 +4725,8 @@ hub_power_remaining(struct usb_hub *hub)
 static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
                u16 portchange)
 {
-       int status, i;
+       int status = -ENODEV;
+       int i;
        unsigned unit_load;
        struct usb_device *hdev = hub->hdev;
        struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
@@ -4929,9 +4930,10 @@ loop:
 
 done:
        hub_port_disable(hub, port1, 1);
-       if (hcd->driver->relinquish_port && !hub->hdev->parent)
-               hcd->driver->relinquish_port(hcd, port1);
-
+       if (hcd->driver->relinquish_port && !hub->hdev->parent) {
+               if (status != -ENOTCONN && status != -ENODEV)
+                       hcd->driver->relinquish_port(hcd, port1);
+       }
 }
 
 /* Handle physical or logical connection change events.
index 3116edfcdc18558aa768d248f1ff1881448ced09..574da2b4529cc26cc0a97ee7146e42889ca55bbe 100644 (file)
@@ -150,6 +150,9 @@ static const struct usb_device_id usb_quirk_list[] = {
        /* appletouch */
        { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
 
+       /* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
+       { USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },
+
        /* Avision AV600U */
        { USB_DEVICE(0x0638, 0x0a13), .driver_info =
          USB_QUIRK_STRING_FETCH_255 },
@@ -249,6 +252,7 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = {
        { USB_DEVICE(0x093a, 0x2500), .driver_info = USB_QUIRK_RESET_RESUME },
        { USB_DEVICE(0x093a, 0x2510), .driver_info = USB_QUIRK_RESET_RESUME },
        { USB_DEVICE(0x093a, 0x2521), .driver_info = USB_QUIRK_RESET_RESUME },
+       { USB_DEVICE(0x03f0, 0x2b4a), .driver_info = USB_QUIRK_RESET_RESUME },
 
        /* Logitech Optical Mouse M90/M100 */
        { USB_DEVICE(0x046d, 0xc05a), .driver_info = USB_QUIRK_RESET_RESUME },
index 6b299c7b765611e0cb6c0d30e5de50f8ef279cb7..f064f1549333dcd7dab10fd491e43cf31bac887e 100644 (file)
@@ -896,9 +896,40 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
                if (!node) {
                        trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST;
 
+                       /*
+                        * USB Specification 2.0 Section 5.9.2 states that: "If
+                        * there is only a single transaction in the microframe,
+                        * only a DATA0 data packet PID is used.  If there are
+                        * two transactions per microframe, DATA1 is used for
+                        * the first transaction data packet and DATA0 is used
+                        * for the second transaction data packet.  If there are
+                        * three transactions per microframe, DATA2 is used for
+                        * the first transaction data packet, DATA1 is used for
+                        * the second, and DATA0 is used for the third."
+                        *
+                        * IOW, we should satisfy the following cases:
+                        *
+                        * 1) length <= maxpacket
+                        *      - DATA0
+                        *
+                        * 2) maxpacket < length <= (2 * maxpacket)
+                        *      - DATA1, DATA0
+                        *
+                        * 3) (2 * maxpacket) < length <= (3 * maxpacket)
+                        *      - DATA2, DATA1, DATA0
+                        */
                        if (speed == USB_SPEED_HIGH) {
                                struct usb_ep *ep = &dep->endpoint;
-                               trb->size |= DWC3_TRB_SIZE_PCM1(ep->mult - 1);
+                               unsigned int mult = ep->mult - 1;
+                               unsigned int maxp = usb_endpoint_maxp(ep->desc);
+
+                               if (length <= (2 * maxp))
+                                       mult--;
+
+                               if (length <= maxp)
+                                       mult--;
+
+                               trb->size |= DWC3_TRB_SIZE_PCM1(mult);
                        }
                } else {
                        trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS;
index 62dc9c7798e78a034a9e63f8c3163fcebec9e57a..e1de8fe599a35695eceda22d3138492af8995b20 100644 (file)
@@ -838,21 +838,32 @@ static struct renesas_usb3_request *usb3_get_request(struct renesas_usb3_ep
        return usb3_req;
 }
 
-static void usb3_request_done(struct renesas_usb3_ep *usb3_ep,
-                             struct renesas_usb3_request *usb3_req, int status)
+static void __usb3_request_done(struct renesas_usb3_ep *usb3_ep,
+                               struct renesas_usb3_request *usb3_req,
+                               int status)
 {
        struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep);
-       unsigned long flags;
 
        dev_dbg(usb3_to_dev(usb3), "giveback: ep%2d, %u, %u, %d\n",
                usb3_ep->num, usb3_req->req.length, usb3_req->req.actual,
                status);
        usb3_req->req.status = status;
-       spin_lock_irqsave(&usb3->lock, flags);
        usb3_ep->started = false;
        list_del_init(&usb3_req->queue);
-       spin_unlock_irqrestore(&usb3->lock, flags);
+       spin_unlock(&usb3->lock);
        usb_gadget_giveback_request(&usb3_ep->ep, &usb3_req->req);
+       spin_lock(&usb3->lock);
+}
+
+static void usb3_request_done(struct renesas_usb3_ep *usb3_ep,
+                             struct renesas_usb3_request *usb3_req, int status)
+{
+       struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep);
+       unsigned long flags;
+
+       spin_lock_irqsave(&usb3->lock, flags);
+       __usb3_request_done(usb3_ep, usb3_req, status);
+       spin_unlock_irqrestore(&usb3->lock, flags);
 }
 
 static void usb3_irq_epc_pipe0_status_end(struct renesas_usb3 *usb3)
index c8989c62a2621b88cf8b9d0c3001a37a31d5e151..c8f38649f749311a81ff63aa194c1b97cb71718f 100644 (file)
@@ -98,6 +98,7 @@ enum amd_chipset_gen {
        AMD_CHIPSET_HUDSON2,
        AMD_CHIPSET_BOLTON,
        AMD_CHIPSET_YANGTZE,
+       AMD_CHIPSET_TAISHAN,
        AMD_CHIPSET_UNKNOWN,
 };
 
@@ -141,6 +142,11 @@ static int amd_chipset_sb_type_init(struct amd_chipset_info *pinfo)
                        pinfo->sb_type.gen = AMD_CHIPSET_SB700;
                else if (rev >= 0x40 && rev <= 0x4f)
                        pinfo->sb_type.gen = AMD_CHIPSET_SB800;
+       }
+       pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
+                                         0x145c, NULL);
+       if (pinfo->smbus_dev) {
+               pinfo->sb_type.gen = AMD_CHIPSET_TAISHAN;
        } else {
                pinfo->smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
                                PCI_DEVICE_ID_AMD_HUDSON2_SMBUS, NULL);
@@ -260,11 +266,12 @@ int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev)
 {
        /* Make sure amd chipset type has already been initialized */
        usb_amd_find_chipset_info();
-       if (amd_chipset.sb_type.gen != AMD_CHIPSET_YANGTZE)
-               return 0;
-
-       dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
-       return 1;
+       if (amd_chipset.sb_type.gen == AMD_CHIPSET_YANGTZE ||
+           amd_chipset.sb_type.gen == AMD_CHIPSET_TAISHAN) {
+               dev_dbg(&pdev->dev, "QUIRK: Enable AMD remote wakeup fix\n");
+               return 1;
+       }
+       return 0;
 }
 EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk);
 
@@ -1150,3 +1157,23 @@ static void quirk_usb_early_handoff(struct pci_dev *pdev)
 }
 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
                        PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
+
+bool usb_xhci_needs_pci_reset(struct pci_dev *pdev)
+{
+       /*
+        * Our dear uPD72020{1,2} friend only partially resets when
+        * asked to via the XHCI interface, and may end up doing DMA
+        * at the wrong addresses, as it keeps the top 32bit of some
+        * addresses from its previous programming under obscure
+        * circumstances.
+        * Give it a good wack at probe time. Unfortunately, this
+        * needs to happen before we've had a chance to discover any
+        * quirk, or the system will be in a rather bad state.
+        */
+       if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
+           (pdev->device == 0x0014 || pdev->device == 0x0015))
+               return true;
+
+       return false;
+}
+EXPORT_SYMBOL_GPL(usb_xhci_needs_pci_reset);
index 6559944801987728a1db6ba31f09db51b92362e3..5582cbafecd4c1a3ddc5443d6cc9182a9b9bc89f 100644 (file)
@@ -15,6 +15,7 @@ void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev);
 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev);
 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
 void sb800_prefetch(struct device *dev, int on);
+bool usb_xhci_needs_pci_reset(struct pci_dev *pdev);
 #else
 struct pci_dev;
 static inline void usb_amd_quirk_pll_disable(void) {}
index 5b0fa553c8bc940e88a6db731cf6dfeb0c9fb971..8071c8fdd15e741b008af64075cda3c87072bfb4 100644 (file)
@@ -284,6 +284,13 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
        driver = (struct hc_driver *)id->driver_data;
 
+       /* For some HW implementation, a XHCI reset is just not enough... */
+       if (usb_xhci_needs_pci_reset(dev)) {
+               dev_info(&dev->dev, "Resetting\n");
+               if (pci_reset_function_locked(dev))
+                       dev_warn(&dev->dev, "Reset failed");
+       }
+
        /* Prevent runtime suspending between USB-2 and USB-3 initialization */
        pm_runtime_get_noresume(&dev->dev);
 
index 76decb8011ebc2d37d3e7e64a394bd2bb6e5c8ba..3344ffd5bb13743812bab737f52b8e81eb77b9db 100644 (file)
@@ -139,6 +139,7 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep)
                                "Could not flush host TX%d fifo: csr: %04x\n",
                                ep->epnum, csr))
                        return;
+               mdelay(1);
        }
 }
 
index 8fb86a5f458e01275186dc83ff86e38b38fff35b..3d0dd2f9741571423522ee80c972d8db2ffec853 100644 (file)
@@ -197,6 +197,7 @@ struct msm_otg {
        struct regulator *v3p3;
        struct regulator *v1p8;
        struct regulator *vddcx;
+       struct regulator_bulk_data supplies[3];
 
        struct reset_control *phy_rst;
        struct reset_control *link_rst;
@@ -1731,7 +1732,6 @@ static int msm_otg_reboot_notify(struct notifier_block *this,
 
 static int msm_otg_probe(struct platform_device *pdev)
 {
-       struct regulator_bulk_data regs[3];
        int ret = 0;
        struct device_node *np = pdev->dev.of_node;
        struct msm_otg_platform_data *pdata;
@@ -1817,17 +1817,18 @@ static int msm_otg_probe(struct platform_device *pdev)
                return motg->irq;
        }
 
-       regs[0].supply = "vddcx";
-       regs[1].supply = "v3p3";
-       regs[2].supply = "v1p8";
+       motg->supplies[0].supply = "vddcx";
+       motg->supplies[1].supply = "v3p3";
+       motg->supplies[2].supply = "v1p8";
 
-       ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(regs), regs);
+       ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(motg->supplies),
+                                     motg->supplies);
        if (ret)
                return ret;
 
-       motg->vddcx = regs[0].consumer;
-       motg->v3p3  = regs[1].consumer;
-       motg->v1p8  = regs[2].consumer;
+       motg->vddcx = motg->supplies[0].consumer;
+       motg->v3p3  = motg->supplies[1].consumer;
+       motg->v1p8  = motg->supplies[2].consumer;
 
        clk_set_rate(motg->clk, 60000000);
 
index 93fba9033b00a7136b85a9995d7da32a140c61e9..2c8161bcf5b5e22ee8ed2eb413d29fdfde504e95 100644 (file)
@@ -639,14 +639,11 @@ static int usbhsg_ep_disable(struct usb_ep *ep)
        struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
        struct usbhs_pipe *pipe;
        unsigned long flags;
-       int ret = 0;
 
        spin_lock_irqsave(&uep->lock, flags);
        pipe = usbhsg_uep_to_pipe(uep);
-       if (!pipe) {
-               ret = -EINVAL;
+       if (!pipe)
                goto out;
-       }
 
        usbhsg_pipe_disable(uep);
        usbhs_pipe_free(pipe);
index d544b331c9f2ce80d83095f30184e2102eda6ea6..02b67abfc2a16139a3230d1120a17a4a9ab1cc09 100644 (file)
 /* Low Power Status register (LPSTS) */
 #define LPSTS_SUSPM    0x4000
 
-/* USB General control register 2 (UGCTRL2), bit[31:6] should be 0 */
+/*
+ * USB General control register 2 (UGCTRL2)
+ * Remarks: bit[31:11] and bit[9:6] should be 0
+ */
 #define UGCTRL2_RESERVED_3     0x00000001      /* bit[3:0] should be B'0001 */
 #define UGCTRL2_USB0SEL_OTG    0x00000030
+#define UGCTRL2_VBUSSEL                0x00000400
 
 static void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data)
 {
@@ -34,7 +38,8 @@ static int usbhs_rcar3_power_ctrl(struct platform_device *pdev,
 {
        struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
 
-       usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG);
+       usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG |
+                     UGCTRL2_VBUSSEL);
 
        if (enable) {
                usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM);
index f64e914a8985495bf6ef51bb3de4772c40ffbf49..2d945c9f975c04d5cd7909e00a37017a97e8062e 100644 (file)
@@ -142,6 +142,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
        { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
        { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
+       { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
        { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
        { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
        { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
index ebe51f11105d8889d6144a72bbf719f14e4b1103..fe123153b1a5439f016f2637d4f9d19f0fde3f14 100644 (file)
@@ -2025,6 +2025,8 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) },                   /* D-Link DWM-158 */
        { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff),                     /* D-Link DWM-221 B1 */
          .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
+       { USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e35, 0xff),                     /* D-Link DWM-222 */
+         .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
        { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
        { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
        { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
index c9ebefd8f35fdbe5491627f4df89b80c87aeabad..a585b477415dde58b38c9e2defe0d26c24552757 100644 (file)
@@ -52,6 +52,8 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
        { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID),
                .driver_info = PL2303_QUIRK_ENDPOINT_HACK },
+       { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_UC485),
+               .driver_info = PL2303_QUIRK_ENDPOINT_HACK },
        { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID2) },
        { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) },
        { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) },
index 09d9be88209e1ce6b1f53dc052a53c5e4c491336..3b5a15d1dc0dd50a0ebf9d925e33ef4cf8db0090 100644 (file)
@@ -27,6 +27,7 @@
 #define ATEN_VENDOR_ID         0x0557
 #define ATEN_VENDOR_ID2                0x0547
 #define ATEN_PRODUCT_ID                0x2008
+#define ATEN_PRODUCT_UC485     0x2021
 #define ATEN_PRODUCT_ID2       0x2118
 
 #define IODATA_VENDOR_ID       0x04bb
index cbea9f329e715aad97b23928d79579cdcf5e8c92..cde115359793001dcf18b8884c3c9e22eec0fa73 100644 (file)
@@ -124,9 +124,9 @@ UNUSUAL_DEV(0x0bc2, 0xab2a, 0x0000, 0x9999,
 /* Reported-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> */
 UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999,
                "Initio Corporation",
-               "",
+               "INIC-3069",
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-               US_FL_NO_ATA_1X),
+               US_FL_NO_ATA_1X | US_FL_IGNORE_RESIDUE),
 
 /* Reported-by: Tom Arild Naess <tanaess@gmail.com> */
 UNUSUAL_DEV(0x152d, 0x0539, 0x0000, 0x9999,
index 06615934fed1cc537694b03d023b613c95aea9f1..0dceb9fa3a0629af3bd1a1990508d2c32bb42db2 100644 (file)
@@ -315,6 +315,7 @@ static int usb_stor_control_thread(void * __us)
 {
        struct us_data *us = (struct us_data *)__us;
        struct Scsi_Host *host = us_to_host(us);
+       struct scsi_cmnd *srb;
 
        for (;;) {
                usb_stor_dbg(us, "*** thread sleeping\n");
@@ -330,6 +331,7 @@ static int usb_stor_control_thread(void * __us)
                scsi_lock(host);
 
                /* When we are called with no command pending, we're done */
+               srb = us->srb;
                if (us->srb == NULL) {
                        scsi_unlock(host);
                        mutex_unlock(&us->dev_mutex);
@@ -398,14 +400,11 @@ static int usb_stor_control_thread(void * __us)
                /* lock access to the state */
                scsi_lock(host);
 
-               /* indicate that the command is done */
-               if (us->srb->result != DID_ABORT << 16) {
-                       usb_stor_dbg(us, "scsi cmd done, result=0x%x\n",
-                                    us->srb->result);
-                       us->srb->scsi_done(us->srb);
-               } else {
+               /* was the command aborted? */
+               if (us->srb->result == DID_ABORT << 16) {
 SkipForAbort:
                        usb_stor_dbg(us, "scsi command aborted\n");
+                       srb = NULL;     /* Don't call srb->scsi_done() */
                }
 
                /*
@@ -429,6 +428,13 @@ SkipForAbort:
 
                /* unlock the device pointers */
                mutex_unlock(&us->dev_mutex);
+
+               /* now that the locks are released, notify the SCSI core */
+               if (srb) {
+                       usb_stor_dbg(us, "scsi cmd done, result=0x%x\n",
+                                       srb->result);
+                       srb->scsi_done(srb);
+               }
        } /* for (;;) */
 
        /* Wait until we are told to stop */
index ff01bed7112f1566ca13b3e17330851bf02fec05..1e784adb89b17534ce31751b546ef20801b2427f 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/efi.h>
 
 static bool request_mem_succeeded = false;
+static bool nowc = false;
 
 static struct fb_var_screeninfo efifb_defined = {
        .activate               = FB_ACTIVATE_NOW,
@@ -99,6 +100,8 @@ static int efifb_setup(char *options)
                                screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
                        else if (!strncmp(this_opt, "width:", 6))
                                screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
+                       else if (!strcmp(this_opt, "nowc"))
+                               nowc = true;
                }
        }
 
@@ -255,7 +258,10 @@ static int efifb_probe(struct platform_device *dev)
        info->apertures->ranges[0].base = efifb_fix.smem_start;
        info->apertures->ranges[0].size = size_remap;
 
-       info->screen_base = ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len);
+       if (nowc)
+               info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len);
+       else
+               info->screen_base = ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len);
        if (!info->screen_base) {
                pr_err("efifb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
                        efifb_fix.smem_len, efifb_fix.smem_start);
index c166e0725be5dab13e9a685a93ea7ea9c23a3351..ba82f97fb42b2d10fdbebd227fcb7e5eb19dcbdc 100644 (file)
@@ -1073,20 +1073,16 @@ static int imxfb_remove(struct platform_device *pdev)
        imxfb_disable_controller(fbi);
 
        unregister_framebuffer(info);
-
+       fb_dealloc_cmap(&info->cmap);
        pdata = dev_get_platdata(&pdev->dev);
        if (pdata && pdata->exit)
                pdata->exit(fbi->pdev);
-
-       fb_dealloc_cmap(&info->cmap);
-       kfree(info->pseudo_palette);
-       framebuffer_release(info);
-
        dma_free_wc(&pdev->dev, fbi->map_size, info->screen_base,
                    fbi->map_dma);
-
        iounmap(fbi->regs);
        release_mem_region(res->start, resource_size(res));
+       kfree(info->pseudo_palette);
+       framebuffer_release(info);
 
        return 0;
 }
index eecf695c16f41b6996520e47b8fa7e1b71efbabc..09e5bb013d28071c69b63b1968ef6eca44252f1e 100644 (file)
@@ -193,7 +193,6 @@ static struct notifier_block omap_dss_pm_notif_block = {
 
 static int __init omap_dss_probe(struct platform_device *pdev)
 {
-       struct omap_dss_board_info *pdata = pdev->dev.platform_data;
        int r;
 
        core.pdev = pdev;
index 007a4f3660862e1aa6e9a16207ae54bbbab61d58..1c4797e53f686b03323e4316d443c256854268dc 100644 (file)
@@ -107,6 +107,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
 {
        struct virtio_pci_device *vp_dev = to_vp_device(vdev);
        const char *name = dev_name(&vp_dev->vdev.dev);
+       unsigned flags = PCI_IRQ_MSIX;
        unsigned i, v;
        int err = -ENOMEM;
 
@@ -126,10 +127,13 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
                                        GFP_KERNEL))
                        goto error;
 
+       if (desc) {
+               flags |= PCI_IRQ_AFFINITY;
+               desc->pre_vectors++; /* virtio config vector */
+       }
+
        err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors,
-                                            nvectors, PCI_IRQ_MSIX |
-                                            (desc ? PCI_IRQ_AFFINITY : 0),
-                                            desc);
+                                            nvectors, flags, desc);
        if (err < 0)
                goto error;
        vp_dev->msix_enabled = 1;
index 8feab810aed9222b97bd5959b42e6f09ffaaf83d..7f188b8d0c6703dda0ed4ae7647d7b082c429933 100644 (file)
@@ -7,9 +7,6 @@ obj-y   += xenbus/
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_features.o                      := $(nostackp)
 
-CFLAGS_efi.o                           += -fshort-wchar
-LDFLAGS                                        += $(call ld-option, --no-wchar-size-warning)
-
 dom0-$(CONFIG_ARM64) += arm-device.o
 dom0-$(CONFIG_PCI) += pci.o
 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
index 4da69dbf7dcad7f2e2898dd807a118596f86058a..1bdd02a6d6ac757c5a500db192b3d7923c316753 100644 (file)
@@ -10,8 +10,7 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
        unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page));
        unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page));
 
-       return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) &&
-               ((bfn1 == bfn2) || ((bfn1+1) == bfn2));
+       return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2;
 #else
        /*
         * XXX: Add support for merging bio_vec when using different page
index bae1f5d36c26e8eac1a7ce9473a3ca7999b90642..2d43118077e4eecc12f68bee605fb068def11c95 100644 (file)
@@ -574,7 +574,7 @@ static void shutdown_pirq(struct irq_data *data)
 
 static void enable_pirq(struct irq_data *data)
 {
-       startup_pirq(data);
+       enable_dynirq(data);
 }
 
 static void disable_pirq(struct irq_data *data)
index f3bf8f4e2d6cef09101b53aa9f1a69563b206287..82360594fa8e49bcbad179a6bb349564286cf203 100644 (file)
@@ -484,13 +484,6 @@ static void mn_invl_range_start(struct mmu_notifier *mn,
        mutex_unlock(&priv->lock);
 }
 
-static void mn_invl_page(struct mmu_notifier *mn,
-                        struct mm_struct *mm,
-                        unsigned long address)
-{
-       mn_invl_range_start(mn, mm, address, address + PAGE_SIZE);
-}
-
 static void mn_release(struct mmu_notifier *mn,
                       struct mm_struct *mm)
 {
@@ -522,7 +515,6 @@ static void mn_release(struct mmu_notifier *mn,
 
 static const struct mmu_notifier_ops gntdev_mmu_ops = {
        .release                = mn_release,
-       .invalidate_page        = mn_invl_page,
        .invalidate_range_start = mn_invl_range_start,
 };
 
index e460802149555b6f0d5def7659d8e8207828eb53..3e59590c7254ddc8f1a08f4232262a74a29e3711 100644 (file)
@@ -857,6 +857,8 @@ static int xenwatch_thread(void *unused)
        struct list_head *ent;
        struct xs_watch_event *event;
 
+       xenwatch_pid = current->pid;
+
        for (;;) {
                wait_event_interruptible(watch_events_waitq,
                                         !list_empty(&watch_events));
@@ -925,7 +927,6 @@ int xs_init(void)
        task = kthread_run(xenwatch_thread, NULL, "xenwatch");
        if (IS_ERR(task))
                return PTR_ERR(task);
-       xenwatch_pid = task->pid;
 
        /* shutdown watches for kexec boot */
        xs_reset_watches();
index 879ff9c7ffd01a0f1f2d6a7e92c32926af5ef4c2..6466153f2bf099d357166192710167667abefa09 100644 (file)
@@ -664,8 +664,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
 {
        unsigned long random_variable = 0;
 
-       if ((current->flags & PF_RANDOMIZE) &&
-               !(current->personality & ADDR_NO_RANDOMIZE)) {
+       if (current->flags & PF_RANDOMIZE) {
                random_variable = get_random_long();
                random_variable &= STACK_RND_MASK;
                random_variable <<= PAGE_SHIFT;
index 080e2ebb8aa0137baef69edda45aa895bf8b7c7c..f45b61fe9a9ab8d54d87e98ab494e29cedd2e0ab 100644 (file)
@@ -3516,7 +3516,7 @@ static blk_status_t wait_dev_flush(struct btrfs_device *device)
        struct bio *bio = device->flush_bio;
 
        if (!device->flush_bio_sent)
-               return 0;
+               return BLK_STS_OK;
 
        device->flush_bio_sent = 0;
        wait_for_completion_io(&device->flush_wait);
@@ -3563,7 +3563,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
                        continue;
 
                write_dev_flush(dev);
-               dev->last_flush_error = 0;
+               dev->last_flush_error = BLK_STS_OK;
        }
 
        /* wait for all the barriers */
index 95c212037095fea727f4a35ea19d9d7e54ad8cfe..24bcd5cd9cf2fc680cc7ed32fb58cd254bb055b5 100644 (file)
@@ -7924,11 +7924,12 @@ err:
        return ret;
 }
 
-static inline int submit_dio_repair_bio(struct inode *inode, struct bio *bio,
-                                       int mirror_num)
+static inline blk_status_t submit_dio_repair_bio(struct inode *inode,
+                                                struct bio *bio,
+                                                int mirror_num)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-       int ret;
+       blk_status_t ret;
 
        BUG_ON(bio_op(bio) == REQ_OP_WRITE);
 
@@ -7980,10 +7981,10 @@ static int btrfs_check_dio_repairable(struct inode *inode,
        return 1;
 }
 
-static int dio_read_error(struct inode *inode, struct bio *failed_bio,
-                       struct page *page, unsigned int pgoff,
-                       u64 start, u64 end, int failed_mirror,
-                       bio_end_io_t *repair_endio, void *repair_arg)
+static blk_status_t dio_read_error(struct inode *inode, struct bio *failed_bio,
+                                  struct page *page, unsigned int pgoff,
+                                  u64 start, u64 end, int failed_mirror,
+                                  bio_end_io_t *repair_endio, void *repair_arg)
 {
        struct io_failure_record *failrec;
        struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
@@ -7993,18 +7994,19 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio,
        int read_mode = 0;
        int segs;
        int ret;
+       blk_status_t status;
 
        BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE);
 
        ret = btrfs_get_io_failure_record(inode, start, end, &failrec);
        if (ret)
-               return ret;
+               return errno_to_blk_status(ret);
 
        ret = btrfs_check_dio_repairable(inode, failed_bio, failrec,
                                         failed_mirror);
        if (!ret) {
                free_io_failure(failure_tree, io_tree, failrec);
-               return -EIO;
+               return BLK_STS_IOERR;
        }
 
        segs = bio_segments(failed_bio);
@@ -8022,13 +8024,13 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio,
                    "Repair DIO Read Error: submitting new dio read[%#x] to this_mirror=%d, in_validation=%d\n",
                    read_mode, failrec->this_mirror, failrec->in_validation);
 
-       ret = submit_dio_repair_bio(inode, bio, failrec->this_mirror);
-       if (ret) {
+       status = submit_dio_repair_bio(inode, bio, failrec->this_mirror);
+       if (status) {
                free_io_failure(failure_tree, io_tree, failrec);
                bio_put(bio);
        }
 
-       return ret;
+       return status;
 }
 
 struct btrfs_retry_complete {
@@ -8065,8 +8067,8 @@ end:
        bio_put(bio);
 }
 
-static int __btrfs_correct_data_nocsum(struct inode *inode,
-                                      struct btrfs_io_bio *io_bio)
+static blk_status_t __btrfs_correct_data_nocsum(struct inode *inode,
+                                               struct btrfs_io_bio *io_bio)
 {
        struct btrfs_fs_info *fs_info;
        struct bio_vec bvec;
@@ -8076,8 +8078,8 @@ static int __btrfs_correct_data_nocsum(struct inode *inode,
        unsigned int pgoff;
        u32 sectorsize;
        int nr_sectors;
-       int ret;
-       int err = 0;
+       blk_status_t ret;
+       blk_status_t err = BLK_STS_OK;
 
        fs_info = BTRFS_I(inode)->root->fs_info;
        sectorsize = fs_info->sectorsize;
@@ -8183,11 +8185,12 @@ static blk_status_t __btrfs_subio_endio_read(struct inode *inode,
        int csum_pos;
        bool uptodate = (err == 0);
        int ret;
+       blk_status_t status;
 
        fs_info = BTRFS_I(inode)->root->fs_info;
        sectorsize = fs_info->sectorsize;
 
-       err = 0;
+       err = BLK_STS_OK;
        start = io_bio->logical;
        done.inode = inode;
        io_bio->bio.bi_iter = io_bio->iter;
@@ -8209,12 +8212,12 @@ try_again:
                done.start = start;
                init_completion(&done.done);
 
-               ret = dio_read_error(inode, &io_bio->bio, bvec.bv_page,
-                               pgoff, start, start + sectorsize - 1,
-                               io_bio->mirror_num,
-                               btrfs_retry_endio, &done);
-               if (ret) {
-                       err = errno_to_blk_status(ret);
+               status = dio_read_error(inode, &io_bio->bio, bvec.bv_page,
+                                       pgoff, start, start + sectorsize - 1,
+                                       io_bio->mirror_num, btrfs_retry_endio,
+                                       &done);
+               if (status) {
+                       err = status;
                        goto next;
                }
 
@@ -8250,7 +8253,7 @@ static blk_status_t btrfs_subio_endio_read(struct inode *inode,
                if (unlikely(err))
                        return __btrfs_correct_data_nocsum(inode, io_bio);
                else
-                       return 0;
+                       return BLK_STS_OK;
        } else {
                return __btrfs_subio_endio_read(inode, io_bio, err);
        }
@@ -8423,9 +8426,9 @@ static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode,
        return 0;
 }
 
-static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
-                                        u64 file_offset, int skip_sum,
-                                        int async_submit)
+static inline blk_status_t
+__btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset,
+                      int skip_sum, int async_submit)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
        struct btrfs_dio_private *dip = bio->bi_private;
@@ -8488,6 +8491,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
        int clone_offset = 0;
        int clone_len;
        int ret;
+       blk_status_t status;
 
        map_length = orig_bio->bi_iter.bi_size;
        submit_len = map_length;
@@ -8537,9 +8541,9 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
                 */
                atomic_inc(&dip->pending_bios);
 
-               ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
-                                            async_submit);
-               if (ret) {
+               status = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
+                                               async_submit);
+               if (status) {
                        bio_put(bio);
                        atomic_dec(&dip->pending_bios);
                        goto out_err;
@@ -8557,9 +8561,9 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
        } while (submit_len > 0);
 
 submit:
-       ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
-                                    async_submit);
-       if (!ret)
+       status = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
+                                       async_submit);
+       if (!status)
                return 0;
 
        bio_put(bio);
index 208638384cd2abfb1206b2f5927b5763a6330283..2cf6ba40f7c441bb3483f9c543e1e17bbcea1971 100644 (file)
@@ -905,7 +905,7 @@ static void raid_write_end_io(struct bio *bio)
        if (!atomic_dec_and_test(&rbio->stripes_pending))
                return;
 
-       err = 0;
+       err = BLK_STS_OK;
 
        /* OK, we have read all the stripes we need to. */
        max_errors = (rbio->operation == BTRFS_RBIO_PARITY_SCRUB) ?
@@ -1324,7 +1324,7 @@ write_data:
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 /*
@@ -1475,7 +1475,7 @@ static void raid_rmw_end_io(struct bio *bio)
 
 cleanup:
 
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
@@ -1579,7 +1579,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
        return 0;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
        return -EIO;
 
 finish:
@@ -1795,12 +1795,12 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
        void **pointers;
        int faila = -1, failb = -1;
        struct page *page;
-       int err;
+       blk_status_t err;
        int i;
 
        pointers = kcalloc(rbio->real_stripes, sizeof(void *), GFP_NOFS);
        if (!pointers) {
-               err = -ENOMEM;
+               err = BLK_STS_RESOURCE;
                goto cleanup_io;
        }
 
@@ -1856,7 +1856,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
                                         * a bad data or Q stripe.
                                         * TODO, we should redo the xor here.
                                         */
-                                       err = -EIO;
+                                       err = BLK_STS_IOERR;
                                        goto cleanup;
                                }
                                /*
@@ -1882,7 +1882,7 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
                        if (rbio->bbio->raid_map[failb] == RAID6_Q_STRIPE) {
                                if (rbio->bbio->raid_map[faila] ==
                                    RAID5_P_STRIPE) {
-                                       err = -EIO;
+                                       err = BLK_STS_IOERR;
                                        goto cleanup;
                                }
                                /*
@@ -1954,13 +1954,13 @@ pstripe:
                }
        }
 
-       err = 0;
+       err = BLK_STS_OK;
 cleanup:
        kfree(pointers);
 
 cleanup_io:
        if (rbio->operation == BTRFS_RBIO_READ_REBUILD) {
-               if (err == 0)
+               if (err == BLK_STS_OK)
                        cache_rbio_pages(rbio);
                else
                        clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags);
@@ -1968,7 +1968,7 @@ cleanup_io:
                rbio_orig_end_io(rbio, err);
        } else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) {
                rbio_orig_end_io(rbio, err);
-       } else if (err == 0) {
+       } else if (err == BLK_STS_OK) {
                rbio->faila = -1;
                rbio->failb = -1;
 
@@ -2005,7 +2005,7 @@ static void raid_recover_end_io(struct bio *bio)
                return;
 
        if (atomic_read(&rbio->error) > rbio->bbio->max_errors)
-               rbio_orig_end_io(rbio, -EIO);
+               rbio_orig_end_io(rbio, BLK_STS_IOERR);
        else
                __raid_recover_end_io(rbio);
 }
@@ -2104,7 +2104,7 @@ out:
 cleanup:
        if (rbio->operation == BTRFS_RBIO_READ_REBUILD ||
            rbio->operation == BTRFS_RBIO_REBUILD_MISSING)
-               rbio_orig_end_io(rbio, -EIO);
+               rbio_orig_end_io(rbio, BLK_STS_IOERR);
        return -EIO;
 }
 
@@ -2431,7 +2431,7 @@ submit_write:
        nr_data = bio_list_size(&bio_list);
        if (!nr_data) {
                /* Every parity is right */
-               rbio_orig_end_io(rbio, 0);
+               rbio_orig_end_io(rbio, BLK_STS_OK);
                return;
        }
 
@@ -2451,7 +2451,7 @@ submit_write:
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe)
@@ -2519,7 +2519,7 @@ static void validate_rbio_for_parity_scrub(struct btrfs_raid_bio *rbio)
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
 }
 
 /*
@@ -2633,7 +2633,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio)
        return;
 
 cleanup:
-       rbio_orig_end_io(rbio, -EIO);
+       rbio_orig_end_io(rbio, BLK_STS_IOERR);
        return;
 
 finish:
index e8b9a269fddec78fdf42adec32eabaffdf9c3636..bd679bc7a1a956cfc541fcb2a74ed4b49b815642 100644 (file)
@@ -6212,8 +6212,8 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)
        }
 }
 
-int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
-                 int mirror_num, int async_submit)
+blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
+                          int mirror_num, int async_submit)
 {
        struct btrfs_device *dev;
        struct bio *first_bio = bio;
@@ -6233,7 +6233,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                                &map_length, &bbio, mirror_num, 1);
        if (ret) {
                btrfs_bio_counter_dec(fs_info);
-               return ret;
+               return errno_to_blk_status(ret);
        }
 
        total_devs = bbio->num_stripes;
@@ -6256,7 +6256,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                }
 
                btrfs_bio_counter_dec(fs_info);
-               return ret;
+               return errno_to_blk_status(ret);
        }
 
        if (map_length < length) {
@@ -6283,7 +6283,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                                  dev_nr, async_submit);
        }
        btrfs_bio_counter_dec(fs_info);
-       return 0;
+       return BLK_STS_OK;
 }
 
 struct btrfs_device *btrfs_find_device(struct btrfs_fs_info *fs_info, u64 devid,
index 6f45fd60d15a92d7aea7a5711bb365a201cb09f9..93277fc60930561a7ffb8c40d2e4ae61ce5908a0 100644 (file)
@@ -74,7 +74,7 @@ struct btrfs_device {
        int missing;
        int can_discard;
        int is_tgtdev_for_dev_replace;
-       int last_flush_error;
+       blk_status_t last_flush_error;
        int flush_bio_sent;
 
 #ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED
@@ -416,8 +416,8 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                      struct btrfs_fs_info *fs_info, u64 type);
 void btrfs_mapping_init(struct btrfs_mapping_tree *tree);
 void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree);
-int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
-                 int mirror_num, int async_submit);
+blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
+                          int mirror_num, int async_submit);
 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
                       fmode_t flags, void *holder);
 int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
index 50836280a6f8a3a2d1a82d3c00f3f274e5844f7e..1bc709fe330a13bd51963aa39fe827f6ff70ace9 100644 (file)
@@ -189,7 +189,7 @@ static int ceph_releasepage(struct page *page, gfp_t g)
 /*
  * read a single page, without unlocking it.
  */
-static int readpage_nounlock(struct file *filp, struct page *page)
+static int ceph_do_readpage(struct file *filp, struct page *page)
 {
        struct inode *inode = file_inode(filp);
        struct ceph_inode_info *ci = ceph_inode(inode);
@@ -219,7 +219,7 @@ static int readpage_nounlock(struct file *filp, struct page *page)
 
        err = ceph_readpage_from_fscache(inode, page);
        if (err == 0)
-               goto out;
+               return -EINPROGRESS;
 
        dout("readpage inode %p file %p page %p index %lu\n",
             inode, filp, page, page->index);
@@ -249,8 +249,11 @@ out:
 
 static int ceph_readpage(struct file *filp, struct page *page)
 {
-       int r = readpage_nounlock(filp, page);
-       unlock_page(page);
+       int r = ceph_do_readpage(filp, page);
+       if (r != -EINPROGRESS)
+               unlock_page(page);
+       else
+               r = 0;
        return r;
 }
 
@@ -1237,7 +1240,7 @@ retry_locked:
                        goto retry_locked;
                r = writepage_nounlock(page, NULL);
                if (r < 0)
-                       goto fail_nosnap;
+                       goto fail_unlock;
                goto retry_locked;
        }
 
@@ -1265,11 +1268,14 @@ retry_locked:
        }
 
        /* we need to read it. */
-       r = readpage_nounlock(file, page);
-       if (r < 0)
-               goto fail_nosnap;
+       r = ceph_do_readpage(file, page);
+       if (r < 0) {
+               if (r == -EINPROGRESS)
+                       return -EAGAIN;
+               goto fail_unlock;
+       }
        goto retry_locked;
-fail_nosnap:
+fail_unlock:
        unlock_page(page);
        return r;
 }
index fd1172823f8621b6701e91172a0f0f83c2bb3f5c..337f88673ed9f71a83ea39080bdcd726eb116a15 100644 (file)
@@ -297,13 +297,7 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
        }
 }
 
-static void ceph_vfs_readpage_complete(struct page *page, void *data, int error)
-{
-       if (!error)
-               SetPageUptodate(page);
-}
-
-static void ceph_vfs_readpage_complete_unlock(struct page *page, void *data, int error)
+static void ceph_readpage_from_fscache_complete(struct page *page, void *data, int error)
 {
        if (!error)
                SetPageUptodate(page);
@@ -331,7 +325,7 @@ int ceph_readpage_from_fscache(struct inode *inode, struct page *page)
                return -ENOBUFS;
 
        ret = fscache_read_or_alloc_page(ci->fscache, page,
-                                        ceph_vfs_readpage_complete, NULL,
+                                        ceph_readpage_from_fscache_complete, NULL,
                                         GFP_KERNEL);
 
        switch (ret) {
@@ -360,7 +354,7 @@ int ceph_readpages_from_fscache(struct inode *inode,
                return -ENOBUFS;
 
        ret = fscache_read_or_alloc_pages(ci->fscache, mapping, pages, nr_pages,
-                                         ceph_vfs_readpage_complete_unlock,
+                                         ceph_readpage_from_fscache_complete,
                                          NULL, mapping_gfp_mask(mapping));
 
        switch (ret) {
index 56366e9840769dd8a45250ec3a7b65097c979ff9..e702d48bd023411f3bbed69c6cc6a571f2fc059c 100644 (file)
@@ -194,15 +194,20 @@ cifs_bp_rename_retry:
 }
 
 /*
+ * Don't allow path components longer than the server max.
  * Don't allow the separator character in a path component.
  * The VFS will not allow "/", but "\" is allowed by posix.
  */
 static int
-check_name(struct dentry *direntry)
+check_name(struct dentry *direntry, struct cifs_tcon *tcon)
 {
        struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
        int i;
 
+       if (unlikely(direntry->d_name.len >
+                    le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
+               return -ENAMETOOLONG;
+
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) {
                for (i = 0; i < direntry->d_name.len; i++) {
                        if (direntry->d_name.name[i] == '\\') {
@@ -500,10 +505,6 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
                return finish_no_open(file, res);
        }
 
-       rc = check_name(direntry);
-       if (rc)
-               return rc;
-
        xid = get_xid();
 
        cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
@@ -516,6 +517,11 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
        }
 
        tcon = tlink_tcon(tlink);
+
+       rc = check_name(direntry, tcon);
+       if (rc)
+               goto out_free_xid;
+
        server = tcon->ses->server;
 
        if (server->ops->new_lease_key)
@@ -776,7 +782,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
        }
        pTcon = tlink_tcon(tlink);
 
-       rc = check_name(direntry);
+       rc = check_name(direntry, pTcon);
        if (rc)
                goto lookup_out;
 
index 5fb2fc2d0080b6e62fd0ad10e1a9c90c08308f2d..97edb4d376cd40e1e6044ed6b5ff7072e0d1b10c 100644 (file)
@@ -3219,8 +3219,8 @@ copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf,
        kst->f_bsize = le32_to_cpu(pfs_inf->BytesPerSector) *
                          le32_to_cpu(pfs_inf->SectorsPerAllocationUnit);
        kst->f_blocks = le64_to_cpu(pfs_inf->TotalAllocationUnits);
-       kst->f_bfree  = le64_to_cpu(pfs_inf->ActualAvailableAllocationUnits);
-       kst->f_bavail = le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
+       kst->f_bfree  = kst->f_bavail =
+                       le64_to_cpu(pfs_inf->CallerAvailableAllocationUnits);
        return;
 }
 
index 18700fd25a0b3f6ceebce14d59716dc4cf2d3cb0..2826882c81d14f138b393824fac9c9091311cd1f 100644 (file)
@@ -84,8 +84,8 @@
 
 #define NUMBER_OF_SMB2_COMMANDS        0x0013
 
-/* BB FIXME - analyze following length BB */
-#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
+/* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */
+#define MAX_SMB2_HDR_SIZE 0x00b0
 
 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
index 306c2b603fb8aa8845558a2bf8226523e5282cdb..ab925dc6647ac764c5a2620a9ef21c53305f90dc 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -646,11 +646,10 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping,
        pte_t pte, *ptep = NULL;
        pmd_t *pmdp = NULL;
        spinlock_t *ptl;
-       bool changed;
 
        i_mmap_lock_read(mapping);
        vma_interval_tree_foreach(vma, &mapping->i_mmap, index, index) {
-               unsigned long address;
+               unsigned long address, start, end;
 
                cond_resched();
 
@@ -658,8 +657,13 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping,
                        continue;
 
                address = pgoff_address(index, vma);
-               changed = false;
-               if (follow_pte_pmd(vma->vm_mm, address, &ptep, &pmdp, &ptl))
+
+               /*
+                * Note because we provide start/end to follow_pte_pmd it will
+                * call mmu_notifier_invalidate_range_start() on our behalf
+                * before taking any lock.
+                */
+               if (follow_pte_pmd(vma->vm_mm, address, &start, &end, &ptep, &pmdp, &ptl))
                        continue;
 
                if (pmdp) {
@@ -676,7 +680,7 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping,
                        pmd = pmd_wrprotect(pmd);
                        pmd = pmd_mkclean(pmd);
                        set_pmd_at(vma->vm_mm, address, pmdp, pmd);
-                       changed = true;
+                       mmu_notifier_invalidate_range(vma->vm_mm, start, end);
 unlock_pmd:
                        spin_unlock(ptl);
 #endif
@@ -691,13 +695,12 @@ unlock_pmd:
                        pte = pte_wrprotect(pte);
                        pte = pte_mkclean(pte);
                        set_pte_at(vma->vm_mm, address, ptep, pte);
-                       changed = true;
+                       mmu_notifier_invalidate_range(vma->vm_mm, start, end);
 unlock_pte:
                        pte_unmap_unlock(ptep, ptl);
                }
 
-               if (changed)
-                       mmu_notifier_invalidate_page(vma->vm_mm, address);
+               mmu_notifier_invalidate_range_end(vma->vm_mm, start, end);
        }
        i_mmap_unlock_read(mapping);
 }
@@ -1383,6 +1386,16 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
 
        trace_dax_pmd_fault(inode, vmf, max_pgoff, 0);
 
+       /*
+        * Make sure that the faulting address's PMD offset (color) matches
+        * the PMD offset from the start of the file.  This is necessary so
+        * that a PMD range in the page table overlaps exactly with a PMD
+        * range in the radix tree.
+        */
+       if ((vmf->pgoff & PG_PMD_COLOUR) !=
+           ((vmf->address >> PAGE_SHIFT) & PG_PMD_COLOUR))
+               goto fallback;
+
        /* Fall back to PTEs if we're going to COW */
        if (write && !(vma->vm_flags & VM_SHARED))
                goto fallback;
index 108df2e3602c2c63186b61b2fede52794cb46482..7eae33ffa3fcc1d709790b79225521472c6f8281 100644 (file)
@@ -133,6 +133,50 @@ static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb)
        return sb->s_fs_info;
 }
 
+static int devpts_ptmx_path(struct path *path)
+{
+       struct super_block *sb;
+       int err;
+
+       /* Has the devpts filesystem already been found? */
+       if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
+               return 0;
+
+       /* Is a devpts filesystem at "pts" in the same directory? */
+       err = path_pts(path);
+       if (err)
+               return err;
+
+       /* Is the path the root of a devpts filesystem? */
+       sb = path->mnt->mnt_sb;
+       if ((sb->s_magic != DEVPTS_SUPER_MAGIC) ||
+           (path->mnt->mnt_root != sb->s_root))
+               return -ENODEV;
+
+       return 0;
+}
+
+struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi)
+{
+       struct path path;
+       int err;
+
+       path = filp->f_path;
+       path_get(&path);
+
+       err = devpts_ptmx_path(&path);
+       dput(path.dentry);
+       if (err) {
+               mntput(path.mnt);
+               path.mnt = ERR_PTR(err);
+       }
+       if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) {
+               mntput(path.mnt);
+               path.mnt = ERR_PTR(-ENODEV);
+       }
+       return path.mnt;
+}
+
 struct pts_fs_info *devpts_acquire(struct file *filp)
 {
        struct pts_fs_info *result;
@@ -143,27 +187,16 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
        path = filp->f_path;
        path_get(&path);
 
-       /* Has the devpts filesystem already been found? */
-       sb = path.mnt->mnt_sb;
-       if (sb->s_magic != DEVPTS_SUPER_MAGIC) {
-               /* Is a devpts filesystem at "pts" in the same directory? */
-               err = path_pts(&path);
-               if (err) {
-                       result = ERR_PTR(err);
-                       goto out;
-               }
-
-               /* Is the path the root of a devpts filesystem? */
-               result = ERR_PTR(-ENODEV);
-               sb = path.mnt->mnt_sb;
-               if ((sb->s_magic != DEVPTS_SUPER_MAGIC) ||
-                   (path.mnt->mnt_root != sb->s_root))
-                       goto out;
+       err = devpts_ptmx_path(&path);
+       if (err) {
+               result = ERR_PTR(err);
+               goto out;
        }
 
        /*
         * pty code needs to hold extra references in case of last /dev/tty close
         */
+       sb = path.mnt->mnt_sb;
        atomic_inc(&sb->s_active);
        result = DEVPTS_SB(sb);
 
index e767e4389cb13da3525a1e3ec9c2b4e7501f110c..adbe328b957c1e386cc354b8218fec185a992bff 100644 (file)
@@ -600,8 +600,13 @@ static void ep_remove_wait_queue(struct eppoll_entry *pwq)
        wait_queue_head_t *whead;
 
        rcu_read_lock();
-       /* If it is cleared by POLLFREE, it should be rcu-safe */
-       whead = rcu_dereference(pwq->whead);
+       /*
+        * If it is cleared by POLLFREE, it should be rcu-safe.
+        * If we read NULL we need a barrier paired with
+        * smp_store_release() in ep_poll_callback(), otherwise
+        * we rely on whead->lock.
+        */
+       whead = smp_load_acquire(&pwq->whead);
        if (whead)
                remove_wait_queue(whead, &pwq->wait);
        rcu_read_unlock();
@@ -1134,17 +1139,6 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
        struct eventpoll *ep = epi->ep;
        int ewake = 0;
 
-       if ((unsigned long)key & POLLFREE) {
-               ep_pwq_from_wait(wait)->whead = NULL;
-               /*
-                * whead = NULL above can race with ep_remove_wait_queue()
-                * which can do another remove_wait_queue() after us, so we
-                * can't use __remove_wait_queue(). whead->lock is held by
-                * the caller.
-                */
-               list_del_init(&wait->entry);
-       }
-
        spin_lock_irqsave(&ep->lock, flags);
 
        ep_set_busy_poll_napi_id(epi);
@@ -1228,10 +1222,26 @@ out_unlock:
        if (pwake)
                ep_poll_safewake(&ep->poll_wait);
 
-       if (epi->event.events & EPOLLEXCLUSIVE)
-               return ewake;
+       if (!(epi->event.events & EPOLLEXCLUSIVE))
+               ewake = 1;
+
+       if ((unsigned long)key & POLLFREE) {
+               /*
+                * If we race with ep_remove_wait_queue() it can miss
+                * ->whead = NULL and do another remove_wait_queue() after
+                * us, so we can't use __remove_wait_queue().
+                */
+               list_del_init(&wait->entry);
+               /*
+                * ->whead != NULL protects us from the race with ep_free()
+                * or ep_remove(), ep_remove_wait_queue() takes whead->lock
+                * held by the caller. Once we nullify it, nothing protects
+                * ep/epi or even wait.
+                */
+               smp_store_release(&ep_pwq_from_wait(wait)->whead, NULL);
+       }
 
-       return 1;
+       return ewake;
 }
 
 /*
index 5a1052627a81413685241f0c4669bbf755e2c5f9..701085620cd82cee3fda28ff6ca65921a9119fc1 100644 (file)
@@ -2300,7 +2300,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
                                             EXT4_MAX_BLOCK_LOG_SIZE);
        struct sg {
                struct ext4_group_info info;
-               ext4_grpblk_t counters[blocksize_bits + 2];
+               ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2];
        } sg;
 
        group--;
@@ -2309,6 +2309,9 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
                              " 2^0   2^1   2^2   2^3   2^4   2^5   2^6  "
                              " 2^7   2^8   2^9   2^10  2^11  2^12  2^13  ]\n");
 
+       i = (blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) +
+               sizeof(struct ext4_group_info);
+
        grinfo = ext4_get_group_info(sb, group);
        /* Load the group info in memory only if not already loaded. */
        if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) {
@@ -2320,7 +2323,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
                buddy_loaded = 1;
        }
 
-       memcpy(&sg, ext4_get_group_info(sb, group), sizeof(sg));
+       memcpy(&sg, ext4_get_group_info(sb, group), i);
 
        if (buddy_loaded)
                ext4_mb_unload_buddy(&e4b);
index 82a5af9f66685a6165a59a1f0c6ba603dd332e8b..3dd9701684488627d26294dd0489323b72afbba8 100644 (file)
@@ -1543,7 +1543,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
                        /* Clear padding bytes. */
                        memset(val + i->value_len, 0, new_size - i->value_len);
                }
-               return 0;
+               goto update_hash;
        }
 
        /* Compute min_offs and last. */
@@ -1707,6 +1707,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
                here->e_value_size = cpu_to_le32(i->value_len);
        }
 
+update_hash:
        if (i->value) {
                __le32 hash = 0;
 
@@ -1725,7 +1726,8 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
                                                     here->e_name_len,
                                                     &crc32c_hash, 1);
                } else if (is_block) {
-                       __le32 *value = s->base + min_offs - new_size;
+                       __le32 *value = s->base + le16_to_cpu(
+                                                       here->e_value_offs);
 
                        hash = ext4_xattr_hash_entry(here->e_name,
                                                     here->e_name_len, value,
index 3ee4fdc3da9ec359ad847afa36354240329a2da6..ab60051be6e533eb167a72e590494f0a46e3a488 100644 (file)
@@ -46,7 +46,7 @@ struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
 {
        struct fuse_file *ff;
 
-       ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
+       ff = kzalloc(sizeof(struct fuse_file), GFP_KERNEL);
        if (unlikely(!ff))
                return NULL;
 
@@ -609,7 +609,7 @@ static void fuse_aio_complete_req(struct fuse_conn *fc, struct fuse_req *req)
        struct fuse_io_priv *io = req->io;
        ssize_t pos = -1;
 
-       fuse_release_user_pages(req, !io->write);
+       fuse_release_user_pages(req, io->should_dirty);
 
        if (io->write) {
                if (req->misc.write.in.size != req->misc.write.out.size)
@@ -1316,7 +1316,6 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
                       loff_t *ppos, int flags)
 {
        int write = flags & FUSE_DIO_WRITE;
-       bool should_dirty = !write && iter_is_iovec(iter);
        int cuse = flags & FUSE_DIO_CUSE;
        struct file *file = io->file;
        struct inode *inode = file->f_mapping->host;
@@ -1346,6 +1345,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
                        inode_unlock(inode);
        }
 
+       io->should_dirty = !write && iter_is_iovec(iter);
        while (count) {
                size_t nres;
                fl_owner_t owner = current->files;
@@ -1360,7 +1360,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
                        nres = fuse_send_read(req, io, pos, nbytes, owner);
 
                if (!io->async)
-                       fuse_release_user_pages(req, should_dirty);
+                       fuse_release_user_pages(req, io->should_dirty);
                if (req->out.h.error) {
                        err = req->out.h.error;
                        break;
@@ -1669,6 +1669,7 @@ err_nofile:
 err_free:
        fuse_request_free(req);
 err:
+       mapping_set_error(page->mapping, error);
        end_page_writeback(page);
        return error;
 }
index 1bd7ffdad593977013c1ddd233b2a91093471471..bd4d2a3e1ec1b8cc0af29bcb8c26f13d82708804 100644 (file)
@@ -249,6 +249,7 @@ struct fuse_io_priv {
        size_t size;
        __u64 offset;
        bool write;
+       bool should_dirty;
        int err;
        struct kiocb *iocb;
        struct file *file;
index 039266128b7ff0b09ed2a55e621a9a0dc9e38720..59cc98ad7577b438a7928cdace1f2af3a7cabf75 100644 (file)
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
                unsigned long bytes;    /* Bytes to write to page */
 
                offset = (pos & (PAGE_SIZE - 1));
-               bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
+               bytes = min_t(loff_t, PAGE_SIZE - offset, length);
 
                rpage = __iomap_read_page(inode, pos);
                if (IS_ERR(rpage))
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
                unsigned offset, bytes;
 
                offset = pos & (PAGE_SIZE - 1); /* Within page */
-               bytes = min_t(unsigned, PAGE_SIZE - offset, count);
+               bytes = min_t(loff_t, PAGE_SIZE - offset, count);
 
                if (IS_DAX(inode))
                        status = iomap_dax_zero(pos, offset, bytes, iomap);
index 78b41e1d5c67151744fb1c98bf1af54560593457..60726ae7cf26ef9d5b4af4f67f764d3c282a37b8 100644 (file)
@@ -619,16 +619,10 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
        if (!sb->s_root)
                goto out_no_root;
 
-       /* logical blocks are represented by 40 bits in pxd_t, etc. */
-       sb->s_maxbytes = ((u64) sb->s_blocksize) << 40;
-#if BITS_PER_LONG == 32
-       /*
-        * Page cache is indexed by long.
-        * I would use MAX_LFS_FILESIZE, but it's only half as big
+       /* logical blocks are represented by 40 bits in pxd_t, etc.
+        * and page cache is indexed by long
         */
-       sb->s_maxbytes = min(((u64) PAGE_SIZE << 32) - 1,
-                            (u64)sb->s_maxbytes);
-#endif
+       sb->s_maxbytes = min(((loff_t)sb->s_blocksize) << 40, MAX_LFS_FILESIZE);
        sb->s_time_gran = 1;
        return 0;
 
index 69d02cf8cf370678609175d6e5626d0dedf02c3a..5f93cfacb3d14b9befc6ba33a91d79ccde044d89 100644 (file)
@@ -121,6 +121,7 @@ config PNFS_FILE_LAYOUT
 config PNFS_BLOCK
        tristate
        depends on NFS_V4_1 && BLK_DEV_DM
+       depends on 64BIT || LBDAF
        default NFS_V4
 
 config PNFS_FLEXFILE_LAYOUT
index 6df7a0cf566015378aa3f76c480115675454297d..f32c58bbe55671cb75abdcb9934152d110e3537d 100644 (file)
@@ -32,6 +32,7 @@ void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds)
 {
        nfs4_print_deviceid(&mirror_ds->id_node.deviceid);
        nfs4_pnfs_ds_put(mirror_ds->ds);
+       kfree(mirror_ds->ds_versions);
        kfree_rcu(mirror_ds, id_node.rcu);
 }
 
index ffd2e712595d8ac875dc2780b52731543c687ca8..d901326423401c3e7d442f62bfa80d03d281ed02 100644 (file)
@@ -2553,9 +2553,8 @@ static int nfs41_check_open_stateid(struct nfs4_state *state)
                clear_bit(NFS_O_RDWR_STATE, &state->flags);
                clear_bit(NFS_OPEN_STATE, &state->flags);
                stateid->type = NFS4_INVALID_STATEID_TYPE;
-       }
-       if (status != NFS_OK)
                return status;
+       }
        if (nfs_open_stateid_recover_openmode(state))
                return -NFS4ERR_OPENMODE;
        return NFS_OK;
index 20fbcab977531bee75501a9403f4c8f60ee404d4..5f940d2a136b72a8e5ffcbff2f094b9f0ebfdaa3 100644 (file)
@@ -144,7 +144,7 @@ static void next_decode_page(struct nfsd4_compoundargs *argp)
        argp->p = page_address(argp->pagelist[0]);
        argp->pagelist++;
        if (argp->pagelen < PAGE_SIZE) {
-               argp->end = argp->p + (argp->pagelen>>2);
+               argp->end = argp->p + XDR_QUADLEN(argp->pagelen);
                argp->pagelen = 0;
        } else {
                argp->end = argp->p + (PAGE_SIZE>>2);
@@ -1279,9 +1279,7 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
                argp->pagelen -= pages * PAGE_SIZE;
                len -= pages * PAGE_SIZE;
 
-               argp->p = (__be32 *)page_address(argp->pagelist[0]);
-               argp->pagelist++;
-               argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
+               next_decode_page(argp);
        }
        argp->p += XDR_QUADLEN(len);
 
index 8a428498d6b21f08c8c26ef184ff9f4332b5cdd0..509a61668d902b84f6756e2ed1bcb22a6d7020a5 100644 (file)
@@ -106,13 +106,13 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
                    global_node_page_state(NR_FILE_MAPPED));
        show_val_kb(m, "Shmem:          ", i.sharedram);
        show_val_kb(m, "Slab:           ",
-                   global_page_state(NR_SLAB_RECLAIMABLE) +
-                   global_page_state(NR_SLAB_UNRECLAIMABLE));
+                   global_node_page_state(NR_SLAB_RECLAIMABLE) +
+                   global_node_page_state(NR_SLAB_UNRECLAIMABLE));
 
        show_val_kb(m, "SReclaimable:   ",
-                   global_page_state(NR_SLAB_RECLAIMABLE));
+                   global_node_page_state(NR_SLAB_RECLAIMABLE));
        show_val_kb(m, "SUnreclaim:     ",
-                   global_page_state(NR_SLAB_UNRECLAIMABLE));
+                   global_node_page_state(NR_SLAB_UNRECLAIMABLE));
        seq_printf(m, "KernelStack:    %8lu kB\n",
                   global_page_state(NR_KERNEL_STACK_KB));
        show_val_kb(m, "PageTables:     ",
index b836fd61ed878a38d25d5ffe44bb86e30066955c..fe8f3265e8779ac18a5694ef600c024f9e88f281 100644 (file)
 #include <linux/mmu_notifier.h>
 #include <linux/page_idle.h>
 #include <linux/shmem_fs.h>
+#include <linux/uaccess.h>
 
 #include <asm/elf.h>
-#include <linux/uaccess.h>
+#include <asm/tlb.h>
 #include <asm/tlbflush.h>
 #include "internal.h"
 
@@ -1008,6 +1009,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
        struct mm_struct *mm;
        struct vm_area_struct *vma;
        enum clear_refs_types type;
+       struct mmu_gather tlb;
        int itype;
        int rv;
 
@@ -1054,6 +1056,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                }
 
                down_read(&mm->mmap_sem);
+               tlb_gather_mmu(&tlb, mm, 0, -1);
                if (type == CLEAR_REFS_SOFT_DIRTY) {
                        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                                if (!(vma->vm_flags & VM_SOFTDIRTY))
@@ -1075,7 +1078,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
                walk_page_range(0, mm->highest_vm_end, &clear_refs_walk);
                if (type == CLEAR_REFS_SOFT_DIRTY)
                        mmu_notifier_invalidate_range_end(mm, 0, -1);
-               flush_tlb_mm(mm);
+               tlb_finish_mmu(&tlb, 0, -1);
                up_read(&mm->mmap_sem);
 out_mm:
                mmput(mm);
index 53a17496c5c536a9410cba73c16d70c5efdbba88..566e6ef99f077c76680cb005417ae995cb4e2878 100644 (file)
@@ -1124,6 +1124,10 @@ void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
                WARN_ON_ONCE(1);
                dquot->dq_dqb.dqb_rsvspace = 0;
        }
+       if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
+           dquot->dq_dqb.dqb_bsoftlimit)
+               dquot->dq_dqb.dqb_btime = (time64_t) 0;
+       clear_bit(DQ_BLKS_B, &dquot->dq_flags);
 }
 
 static void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
@@ -1145,7 +1149,8 @@ static void dquot_decr_space(struct dquot *dquot, qsize_t number)
                dquot->dq_dqb.dqb_curspace -= number;
        else
                dquot->dq_dqb.dqb_curspace = 0;
-       if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
+       if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
+           dquot->dq_dqb.dqb_bsoftlimit)
                dquot->dq_dqb.dqb_btime = (time64_t) 0;
        clear_bit(DQ_BLKS_B, &dquot->dq_flags);
 }
@@ -1381,14 +1386,18 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes)
 
 static int info_bdq_free(struct dquot *dquot, qsize_t space)
 {
+       qsize_t tspace;
+
+       tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace;
+
        if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
-           dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
+           tspace <= dquot->dq_dqb.dqb_bsoftlimit)
                return QUOTA_NL_NOWARN;
 
-       if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
+       if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
                return QUOTA_NL_BSOFTBELOW;
-       if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit &&
-           dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit)
+       if (tspace >= dquot->dq_dqb.dqb_bhardlimit &&
+           tspace - space < dquot->dq_dqb.dqb_bhardlimit)
                return QUOTA_NL_BHARDBELOW;
        return QUOTA_NL_NOWARN;
 }
@@ -2681,7 +2690,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
 
        if (check_blim) {
                if (!dm->dqb_bsoftlimit ||
-                   dm->dqb_curspace < dm->dqb_bsoftlimit) {
+                   dm->dqb_curspace + dm->dqb_rsvspace < dm->dqb_bsoftlimit) {
                        dm->dqb_btime = 0;
                        clear_bit(DQ_BLKS_B, &dquot->dq_flags);
                } else if (!(di->d_fieldmask & QC_SPC_TIMER))
index 9d5f15ed87fe7999eaaad22497899e696ad34147..c6362e38ae92dcfafd76f2b10541cb9e4464e230 100644 (file)
@@ -1164,11 +1164,7 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
        if (ufdset) {
                return compat_get_bitmap(fdset, ufdset, nr);
        } else {
-               /* Tricky, must clear full unsigned long in the
-                * kernel fdset at the end, ALIGN makes sure that
-                * actually happens.
-                */
-               memset(fdset, 0, ALIGN(nr, BITS_PER_LONG));
+               zero_fd_set(nr, fdset);
                return 0;
        }
 }
index 06ea26b8c996f3cc7a9d6fd177260f89394fb325..b0d5897bc4e6d0e019c79f65b6d41df1d3b0d050 100644 (file)
@@ -1600,7 +1600,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
                                   uffdio_copy.len);
                mmput(ctx->mm);
        } else {
-               return -ENOSPC;
+               return -ESRCH;
        }
        if (unlikely(put_user(ret, &user_uffdio_copy->copy)))
                return -EFAULT;
@@ -1647,7 +1647,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx,
                                     uffdio_zeropage.range.len);
                mmput(ctx->mm);
        } else {
-               return -ENOSPC;
+               return -ESRCH;
        }
        if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
                return -EFAULT;
index ffd5a15d1bb6d0955633d4e1f61f6a84aa79f3f7..abf5beaae907d32b484128f182bee2d1d7a7cd9e 100644 (file)
@@ -1246,13 +1246,13 @@ xfs_dialloc_ag_inobt(
 
                        /* free inodes to the left? */
                        if (useleft && trec.ir_freecount) {
-                               rec = trec;
                                xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
                                cur = tcur;
 
                                pag->pagl_leftrec = trec.ir_startino;
                                pag->pagl_rightrec = rec.ir_startino;
                                pag->pagl_pagino = pagino;
+                               rec = trec;
                                goto alloc_inode;
                        }
 
index ceef77c0416ad5833c2b513006496c8d57a4c62f..ff48f00968100df0de830892f0c9aed7bca6d74d 100644 (file)
@@ -874,7 +874,6 @@ xfs_ialloc(
        case S_IFREG:
        case S_IFDIR:
                if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
-                       uint64_t        di_flags2 = 0;
                        uint            di_flags = 0;
 
                        if (S_ISDIR(mode)) {
@@ -911,20 +910,23 @@ xfs_ialloc(
                                di_flags |= XFS_DIFLAG_NODEFRAG;
                        if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM)
                                di_flags |= XFS_DIFLAG_FILESTREAM;
-                       if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
-                               di_flags2 |= XFS_DIFLAG2_DAX;
 
                        ip->i_d.di_flags |= di_flags;
-                       ip->i_d.di_flags2 |= di_flags2;
                }
                if (pip &&
                    (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY) &&
                    pip->i_d.di_version == 3 &&
                    ip->i_d.di_version == 3) {
+                       uint64_t        di_flags2 = 0;
+
                        if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) {
-                               ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
+                               di_flags2 |= XFS_DIFLAG2_COWEXTSIZE;
                                ip->i_d.di_cowextsize = pip->i_d.di_cowextsize;
                        }
+                       if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
+                               di_flags2 |= XFS_DIFLAG2_DAX;
+
+                       ip->i_d.di_flags2 |= di_flags2;
                }
                /* FALLTHROUGH */
        case S_IFLNK:
index 0053bcf2b10a1de59c459de8c74a8cd1d0269d3b..4ebd0bafc914ce7b7f1e4d35134c9dedb09a23b5 100644 (file)
@@ -749,9 +749,20 @@ xfs_log_mount_finish(
                return 0;
        }
 
+       /*
+        * During the second phase of log recovery, we need iget and
+        * iput to behave like they do for an active filesystem.
+        * xfs_fs_drop_inode needs to be able to prevent the deletion
+        * of inodes before we're done replaying log items on those
+        * inodes.  Turn it off immediately after recovery finishes
+        * so that we don't leak the quota inodes if subsequent mount
+        * activities fail.
+        */
+       mp->m_super->s_flags |= MS_ACTIVE;
        error = xlog_recover_finish(mp->m_log);
        if (!error)
                xfs_log_work_queue(mp);
+       mp->m_super->s_flags &= ~MS_ACTIVE;
 
        return error;
 }
index fbe72b134bef219e80420063bfe2db2abc594e49..43aa42a3a5d319fffff98417bff98055083f1a75 100644 (file)
@@ -539,6 +539,7 @@ xlog_discard_endio(
 
        INIT_WORK(&ctx->discard_endio_work, xlog_discard_endio_work);
        queue_work(xfs_discard_wq, &ctx->discard_endio_work);
+       bio_put(bio);
 }
 
 static void
index 40d4e8b4e193b41a123903735736248568bf26b9..ea7d4b4e50d0ca3eedee85ffd840542e0bb105db 100644 (file)
@@ -944,15 +944,6 @@ xfs_mountfs(
                }
        }
 
-       /*
-        * During the second phase of log recovery, we need iget and
-        * iput to behave like they do for an active filesystem.
-        * xfs_fs_drop_inode needs to be able to prevent the deletion
-        * of inodes before we're done replaying log items on those
-        * inodes.
-        */
-       mp->m_super->s_flags |= MS_ACTIVE;
-
        /*
         * Finish recovering the file system.  This part needed to be delayed
         * until after the root and real-time bitmap inodes were consistently
@@ -1028,12 +1019,13 @@ xfs_mountfs(
  out_quota:
        xfs_qm_unmount_quotas(mp);
  out_rtunmount:
-       mp->m_super->s_flags &= ~MS_ACTIVE;
        xfs_rtunmount_inodes(mp);
  out_rele_rip:
        IRELE(rip);
        cancel_delayed_work_sync(&mp->m_reclaim_work);
        xfs_reclaim_inodes(mp, SYNC_WAIT);
+       /* Clean out dquots that might be in memory after quotacheck. */
+       xfs_qm_unmount(mp);
  out_log_dealloc:
        mp->m_flags |= XFS_MOUNT_UNMOUNTING;
        xfs_log_mount_cancel(mp);
index 8afa4335e5b2bfd0c42c00e1b1506d4e1f7377ac..faddde44de8c902e6884e64eeb8b22bd0d11b75a 100644 (file)
@@ -112,10 +112,11 @@ struct mmu_gather {
 
 #define HAVE_GENERIC_MMU_GATHER
 
-void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end);
+void arch_tlb_gather_mmu(struct mmu_gather *tlb,
+       struct mm_struct *mm, unsigned long start, unsigned long end);
 void tlb_flush_mmu(struct mmu_gather *tlb);
-void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start,
-                                                       unsigned long end);
+void arch_tlb_finish_mmu(struct mmu_gather *tlb,
+                        unsigned long start, unsigned long end, bool force);
 extern bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page,
                                   int page_size);
 
index fc824e2828f3cacad21cd7d3d9d98261cf1d78fb..5d2add1a6c964870b212f848879338f7b9b3ba18 100644 (file)
 #define parent_node(node)      ((void)(node),0)
 #endif
 #ifndef cpumask_of_node
-#define cpumask_of_node(node)  ((void)node, cpu_online_mask)
+  #ifdef CONFIG_NEED_MULTIPLE_NODES
+    #define cpumask_of_node(node)      ((node) == 0 ? cpu_online_mask : cpu_none_mask)
+  #else
+    #define cpumask_of_node(node)      ((void)node, cpu_online_mask)
+  #endif
 #endif
 #ifndef pcibus_to_node
 #define pcibus_to_node(bus)    ((void)(bus), -1)
index da0be9a8d1de4c239e53aec01a5e8b9cd87e3bdd..9623d78f84947e3d2fa51c7e7839932e5572441b 100644 (file)
 /* Align . to a 8 byte boundary equals to maximum function alignment. */
 #define ALIGN_FUNCTION()  . = ALIGN(8)
 
+/*
+ * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections, which
+ * generates .data.identifier sections, which need to be pulled in with
+ * .data. We don't want to pull in .data..other sections, which Linux
+ * has defined. Same for text and bss.
+ */
+#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
+#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]*
+#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#else
+#define TEXT_MAIN .text
+#define DATA_MAIN .data
+#define BSS_MAIN .bss
+#endif
+
 /*
  * Align to a 32 byte boundary equal to the
  * alignment gcc 4.5 uses for a struct
 
 /*
  * .data section
- * LD_DEAD_CODE_DATA_ELIMINATION option enables -fdata-sections generates
- * .data.identifier which needs to be pulled in with .data, but don't want to
- * pull in .data..stuff which has its own requirements. Same for bss.
  */
 #define DATA_DATA                                                      \
-       *(.data .data.[0-9a-zA-Z_]*)                                    \
+       *(DATA_MAIN)                                                    \
        *(.ref.data)                                                    \
        *(.data..shared_aligned) /* percpu related */                   \
        MEM_KEEP(init.data)                                             \
                VMLINUX_SYMBOL(__security_initcall_end) = .;            \
        }
 
-/* .text section. Map to function alignment to avoid address changes
+/*
+ * .text section. Map to function alignment to avoid address changes
  * during second ld run in second ld pass when generating System.map
- * LD_DEAD_CODE_DATA_ELIMINATION option enables -ffunction-sections generates
- * .text.identifier which needs to be pulled in with .text , but some
- * architectures define .text.foo which is not intended to be pulled in here.
- * Those enabling LD_DEAD_CODE_DATA_ELIMINATION must ensure they don't have
- * conflicting section names, and must pull in .text.[0-9a-zA-Z_]* */
+ *
+ * TEXT_MAIN here will match .text.fixup and .text.unlikely if dead
+ * code elimination is enabled, so these sections should be converted
+ * to use ".." first.
+ */
 #define TEXT_TEXT                                                      \
                ALIGN_FUNCTION();                                       \
-               *(.text.hot .text .text.fixup .text.unlikely)           \
+               *(.text.hot TEXT_MAIN .text.fixup .text.unlikely)       \
                *(.ref.text)                                            \
        MEM_KEEP(init.text)                                             \
        MEM_KEEP(exit.text)                                             \
                BSS_FIRST_SECTIONS                                      \
                *(.bss..page_aligned)                                   \
                *(.dynbss)                                              \
-               *(.bss .bss.[0-9a-zA-Z_]*)                              \
+               *(BSS_MAIN)                                             \
                *(COMMON)                                               \
        }
 
index c749eef1daa1557910ec81c5f296dc907f5ccab2..27b4b66152637fe38b82711f0fa66d6ce946f7d7 100644 (file)
@@ -1209,6 +1209,7 @@ static inline bool acpi_has_watchdog(void) { return false; }
 #endif
 
 #ifdef CONFIG_ACPI_SPCR_TABLE
+extern bool qdf2400_e44_present;
 int parse_spcr(bool earlycon);
 #else
 static inline int parse_spcr(bool earlycon) { return 0; }
index e65ae4b2ed485a67a26d7c45d542a76d70ab9d97..c7a353825450a950a2f53f93774ef4c5bce934a0 100644 (file)
@@ -60,7 +60,8 @@ enum {
        ATA_ID_FW_REV           = 23,
        ATA_ID_PROD             = 27,
        ATA_ID_MAX_MULTSECT     = 47,
-       ATA_ID_DWORD_IO         = 48,
+       ATA_ID_DWORD_IO         = 48,   /* before ATA-8 */
+       ATA_ID_TRUSTED          = 48,   /* ATA-8 and later */
        ATA_ID_CAPABILITY       = 49,
        ATA_ID_OLD_PIO_MODES    = 51,
        ATA_ID_OLD_DMA_MODES    = 52,
@@ -889,6 +890,13 @@ static inline bool ata_id_has_dword_io(const u16 *id)
        return id[ATA_ID_DWORD_IO] & (1 << 0);
 }
 
+static inline bool ata_id_has_trusted(const u16 *id)
+{
+       if (ata_id_major_version(id) <= 7)
+               return false;
+       return id[ATA_ID_TRUSTED] & (1 << 0);
+}
+
 static inline bool ata_id_has_unload(const u16 *id)
 {
        if (ata_id_major_version(id) >= 7 &&
index 25f6a0cb27d3e9644c1ef42e7f1ff2b5d817293d..2a5d52fa90f5da353086a0faf5c8a5cdea63128a 100644 (file)
@@ -568,7 +568,6 @@ struct request_queue {
 
 #if defined(CONFIG_BLK_DEV_BSG)
        bsg_job_fn              *bsg_job_fn;
-       int                     bsg_job_size;
        struct bsg_class_device bsg_dev;
 #endif
 
index e34dde2da0ef57c3692ce7001fa66fe37c4dc578..637a20cfb237db4ab76a480172e918e6e48f849b 100644 (file)
@@ -24,6 +24,7 @@
 #define _BLK_BSG_
 
 #include <linux/blkdev.h>
+#include <scsi/scsi_request.h>
 
 struct request;
 struct device;
@@ -37,6 +38,7 @@ struct bsg_buffer {
 };
 
 struct bsg_job {
+       struct scsi_request sreq;
        struct device *dev;
        struct request *req;
 
index eca8ad75e28b054db4657d5e562b3904120b042e..043b60de041e3a03731ef99c4a635ea992d5e6ae 100644 (file)
@@ -517,7 +517,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 # define __compiletime_error_fallback(condition) do { } while (0)
 #endif
 
-#define __compiletime_assert(condition, msg, prefix, suffix)           \
+#ifdef __OPTIMIZE__
+# define __compiletime_assert(condition, msg, prefix, suffix)          \
        do {                                                            \
                bool __cond = !(condition);                             \
                extern void prefix ## suffix(void) __compiletime_error(msg); \
@@ -525,6 +526,9 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
                        prefix ## suffix();                             \
                __compiletime_error_fallback(__cond);                   \
        } while (0)
+#else
+# define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0)
+#endif
 
 #define _compiletime_assert(condition, msg, prefix, suffix) \
        __compiletime_assert(condition, msg, prefix, suffix)
index b56573bf440db4b85f8f11f678edb9e28d4e6cd8..82b30e638430fa6e9b3b410feb84bc79a4bf2b13 100644 (file)
@@ -39,8 +39,6 @@ enum cpuhp_state {
        CPUHP_PCI_XGENE_DEAD,
        CPUHP_IOMMU_INTEL_DEAD,
        CPUHP_LUSTRE_CFS_DEAD,
-       CPUHP_SCSI_BNX2FC_DEAD,
-       CPUHP_SCSI_BNX2I_DEAD,
        CPUHP_WORKQUEUE_PREP,
        CPUHP_POWER_NUMA_PREPARE,
        CPUHP_HRTIMERS_PREPARE,
index 1473455d0341bed5b157cab1cd95d8a08980e711..4f2b3b2076c42556da4d7d244ba786c2d0c045c3 100644 (file)
@@ -549,46 +549,29 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
  *---------------------------------------------------------------*/
 #define DM_NAME "device-mapper"
 
-#ifdef CONFIG_PRINTK
-extern struct ratelimit_state dm_ratelimit_state;
-
-#define dm_ratelimit() __ratelimit(&dm_ratelimit_state)
-#else
-#define dm_ratelimit() 0
-#endif
+#define DM_RATELIMIT(pr_func, fmt, ...)                                        \
+do {                                                                   \
+       static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,   \
+                                     DEFAULT_RATELIMIT_BURST);         \
+                                                                       \
+       if (__ratelimit(&rs))                                           \
+               pr_func(DM_FMT(fmt), ##__VA_ARGS__);                    \
+} while (0)
 
 #define DM_FMT(fmt) DM_NAME ": " DM_MSG_PREFIX ": " fmt "\n"
 
 #define DMCRIT(fmt, ...) pr_crit(DM_FMT(fmt), ##__VA_ARGS__)
 
 #define DMERR(fmt, ...) pr_err(DM_FMT(fmt), ##__VA_ARGS__)
-#define DMERR_LIMIT(fmt, ...)                                          \
-do {                                                                   \
-       if (dm_ratelimit())                                             \
-               DMERR(fmt, ##__VA_ARGS__);                              \
-} while (0)
-
+#define DMERR_LIMIT(fmt, ...) DM_RATELIMIT(pr_err, fmt, ##__VA_ARGS__)
 #define DMWARN(fmt, ...) pr_warn(DM_FMT(fmt), ##__VA_ARGS__)
-#define DMWARN_LIMIT(fmt, ...)                                         \
-do {                                                                   \
-       if (dm_ratelimit())                                             \
-               DMWARN(fmt, ##__VA_ARGS__);                             \
-} while (0)
-
+#define DMWARN_LIMIT(fmt, ...) DM_RATELIMIT(pr_warn, fmt, ##__VA_ARGS__)
 #define DMINFO(fmt, ...) pr_info(DM_FMT(fmt), ##__VA_ARGS__)
-#define DMINFO_LIMIT(fmt, ...)                                         \
-do {                                                                   \
-       if (dm_ratelimit())                                             \
-               DMINFO(fmt, ##__VA_ARGS__);                             \
-} while (0)
+#define DMINFO_LIMIT(fmt, ...) DM_RATELIMIT(pr_info, fmt, ##__VA_ARGS__)
 
 #ifdef CONFIG_DM_DEBUG
 #define DMDEBUG(fmt, ...) printk(KERN_DEBUG DM_FMT(fmt), ##__VA_ARGS__)
-#define DMDEBUG_LIMIT(fmt, ...)                                                \
-do {                                                                   \
-       if (dm_ratelimit())                                             \
-               DMDEBUG(fmt, ##__VA_ARGS__);                            \
-} while (0)
+#define DMDEBUG_LIMIT(fmt, ...) DM_RATELIMIT(pr_debug, fmt, ##__VA_ARGS__)
 #else
 #define DMDEBUG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
 #define DMDEBUG_LIMIT(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
index 723cd54b94da84f95cd18934d14198b6d21040dd..beabdbc0842059b36a2c6b22b882e04ddc968f75 100644 (file)
@@ -843,7 +843,7 @@ struct dev_links_info {
  *             hibernation, system resume and during runtime PM transitions
  *             along with subsystem-level and driver-level callbacks.
  * @pins:      For device pin management.
- *             See Documentation/pinctrl.txt for details.
+ *             See Documentation/driver-api/pinctl.rst for details.
  * @msi_list:  Hosts MSI descriptors
  * @msi_domain: The generic MSI domain this device is using.
  * @numa_node: NUMA node this device is close to.
index 277ab9af9ac29a95773ce2201809f7c7613391a1..100cb43437630114127bfecc3d29ad4454c03446 100644 (file)
@@ -19,6 +19,7 @@
 
 struct pts_fs_info;
 
+struct vfsmount *devpts_mntget(struct file *, struct pts_fs_info *);
 struct pts_fs_info *devpts_acquire(struct file *);
 void devpts_release(struct pts_fs_info *);
 
@@ -32,6 +33,15 @@ void *devpts_get_priv(struct dentry *);
 /* unlink */
 void devpts_pty_kill(struct dentry *);
 
+/* in pty.c */
+int ptm_open_peer(struct file *master, struct tty_struct *tty, int flags);
+
+#else
+static inline int
+ptm_open_peer(struct file *master, struct tty_struct *tty, int flags)
+{
+       return -EIO;
+}
 #endif
 
 
index 6e1fd5d2124877c16bbbfab4487a772c8f7e37ee..cbfe127bccf8b112a2d65289a4ec7fef4809da22 100644 (file)
@@ -907,9 +907,9 @@ static inline struct file *get_file(struct file *f)
 /* Page cache limit. The filesystems should put that into their s_maxbytes 
    limits, otherwise bad things can happen in VM. */ 
 #if BITS_PER_LONG==32
-#define MAX_LFS_FILESIZE       (((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1)
+#define MAX_LFS_FILESIZE       ((loff_t)ULONG_MAX << PAGE_SHIFT)
 #elif BITS_PER_LONG==64
-#define MAX_LFS_FILESIZE       ((loff_t)0x7fffffffffffffffLL)
+#define MAX_LFS_FILESIZE       ((loff_t)LLONG_MAX)
 #endif
 
 #define FL_POSIX       1
index 00ca5b86a753f8023cad87ce02cbe90748255383..d501d3956f13f041864dc25f0d7e8724ea2b5210 100644 (file)
@@ -689,7 +689,8 @@ i2c_unlock_adapter(struct i2c_adapter *adapter)
 #define I2C_CLASS_HWMON                (1<<0)  /* lm_sensors, ... */
 #define I2C_CLASS_DDC          (1<<3)  /* DDC bus on graphics adapters */
 #define I2C_CLASS_SPD          (1<<7)  /* Memory modules */
-#define I2C_CLASS_DEPRECATED   (1<<8)  /* Warn users that adapter will stop using classes */
+/* Warn users that the adapter doesn't support classes anymore */
+#define I2C_CLASS_DEPRECATED   (1<<8)
 
 /* Internal numbers to terminate lists */
 #define I2C_CLIENT_END         0xfffeU
index 497f2b3a5a62c8da6f87107de16519b176cc9f1f..97f1b465d04ff0b1ab33b0c1074a722ca41c1b0a 100644 (file)
@@ -105,6 +105,11 @@ struct st_sensor_fullscale {
        struct st_sensor_fullscale_avl fs_avl[ST_SENSORS_FULLSCALE_AVL_MAX];
 };
 
+struct st_sensor_sim {
+       u8 addr;
+       u8 value;
+};
+
 /**
  * struct st_sensor_bdu - ST sensor device block data update
  * @addr: address of the register.
@@ -197,6 +202,7 @@ struct st_sensor_transfer_function {
  * @bdu: Block data update register.
  * @das: Data Alignment Selection register.
  * @drdy_irq: Data ready register of the sensor.
+ * @sim: SPI serial interface mode register of the sensor.
  * @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read.
  * @bootime: samples to discard when sensor passing from power-down to power-up.
  */
@@ -213,6 +219,7 @@ struct st_sensor_settings {
        struct st_sensor_bdu bdu;
        struct st_sensor_das das;
        struct st_sensor_data_ready_irq drdy_irq;
+       struct st_sensor_sim sim;
        bool multi_read_bit;
        unsigned int bootime;
 };
index d68bec297a45ee5e212ca253d903bf382d0ccfd9..c380daa40c0e3e6594b79a81128fc64326ee8a99 100644 (file)
@@ -535,7 +535,7 @@ struct iio_buffer_setup_ops {
  * @scan_timestamp:    [INTERN] set if any buffers have requested timestamp
  * @scan_index_timestamp:[INTERN] cache of the index to the timestamp
  * @trig:              [INTERN] current device trigger (buffer modes)
- * @trig_readonly      [INTERN] mark the current trigger immutable
+ * @trig_readonly:     [INTERN] mark the current trigger immutable
  * @pollfunc:          [DRIVER] function run on trigger being received
  * @pollfunc_event:    [DRIVER] function run on events trigger being received
  * @channels:          [DRIVER] channel specification structure table
index ea08302f2d7b27967fb1f0947dcede46411f396c..7142d8d6e470e13257ee12035f045bdabe1b4d7e 100644 (file)
@@ -144,8 +144,8 @@ void devm_iio_trigger_unregister(struct device *dev,
 /**
  * iio_trigger_set_immutable() - set an immutable trigger on destination
  *
- * @indio_dev - IIO device structure containing the device
- * @trig - trigger to assign to device
+ * @indio_dev: IIO device structure containing the device
+ * @trig: trigger to assign to device
  *
  **/
 int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig);
index 2cb54adc4a334aa3f3a1732c35eaf9749d64b9e8..176f7569d87408c1e57bf09846809bfef5b0b7c8 100644 (file)
@@ -240,7 +240,7 @@ struct iommu_device {
        struct list_head list;
        const struct iommu_ops *ops;
        struct fwnode_handle *fwnode;
-       struct device dev;
+       struct device *dev;
 };
 
 int  iommu_device_register(struct iommu_device *iommu);
@@ -265,6 +265,11 @@ static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
        iommu->fwnode = fwnode;
 }
 
+static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
+{
+       return (struct iommu_device *)dev_get_drvdata(dev);
+}
+
 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE          1 /* Device added */
 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE          2 /* Pre Device removed */
 #define IOMMU_GROUP_NOTIFY_BIND_DRIVER         3 /* Pre Driver bind */
@@ -589,6 +594,11 @@ static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
 {
 }
 
+static inline struct iommu_device *dev_to_iommu_device(struct device *dev)
+{
+       return NULL;
+}
+
 static inline void iommu_device_unregister(struct iommu_device *iommu)
 {
 }
index 77d427974f575699d181265a9eb4c8d1cdd4dad5..bae11c7e7bf31920fcf0b928b31dc29ad70f6f8b 100644 (file)
@@ -61,6 +61,7 @@ extern int memblock_debug;
 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
 #define __init_memblock __meminit
 #define __initdata_memblock __meminitdata
+void memblock_discard(void);
 #else
 #define __init_memblock
 #define __initdata_memblock
@@ -74,8 +75,6 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
                                        int nid, ulong flags);
 phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
                                   phys_addr_t size, phys_addr_t align);
-phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
-phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
 void memblock_allow_resize(void);
 int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
 int memblock_add(phys_addr_t base, phys_addr_t size);
@@ -110,6 +109,9 @@ void __next_mem_range_rev(u64 *idx, int nid, ulong flags,
 void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start,
                                phys_addr_t *out_end);
 
+void __memblock_free_early(phys_addr_t base, phys_addr_t size);
+void __memblock_free_late(phys_addr_t base, phys_addr_t size);
+
 /**
  * for_each_mem_range - iterate through memblock areas from type_a and not
  * included in type_b. Or just type_a if type_b is NULL.
index 3914e3dd61680a9bc8814d9b9a386c59611eca81..9b15a4bcfa77dca9c51f88a195a753a018425e53 100644 (file)
@@ -484,7 +484,8 @@ bool mem_cgroup_oom_synchronize(bool wait);
 extern int do_swap_account;
 #endif
 
-void lock_page_memcg(struct page *page);
+struct mem_cgroup *lock_page_memcg(struct page *page);
+void __unlock_page_memcg(struct mem_cgroup *memcg);
 void unlock_page_memcg(struct page *page);
 
 static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
@@ -809,7 +810,12 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
 {
 }
 
-static inline void lock_page_memcg(struct page *page)
+static inline struct mem_cgroup *lock_page_memcg(struct page *page)
+{
+       return NULL;
+}
+
+static inline void __unlock_page_memcg(struct mem_cgroup *memcg)
 {
 }
 
index aad5d81dfb444aeb0dcb4b92aef475023aa897c1..b54517c05e9ab20fff33e3526fe0ea8de1e702bb 100644 (file)
@@ -620,6 +620,7 @@ struct mlx4_caps {
        u32                     dmfs_high_rate_qpn_base;
        u32                     dmfs_high_rate_qpn_range;
        u32                     vf_caps;
+       bool                    wol_port[MLX4_MAX_PORTS + 1];
        struct mlx4_rate_limit_caps rl_caps;
 };
 
index df6ce59a1f954257cdef95a7733736e42c8b9491..205d82d4c468717ac26050358acb65a968481097 100644 (file)
@@ -673,9 +673,7 @@ enum mlx5_device_state {
 };
 
 enum mlx5_interface_state {
-       MLX5_INTERFACE_STATE_DOWN = BIT(0),
-       MLX5_INTERFACE_STATE_UP = BIT(1),
-       MLX5_INTERFACE_STATE_SHUTDOWN = BIT(2),
+       MLX5_INTERFACE_STATE_UP = BIT(0),
 };
 
 enum mlx5_pci_status {
index 6f41270d80c03128bdeb60e5c6fc1b6ca2b5fe54..f378dc0e7eaf4db75eab8606f03df4e9269602e4 100644 (file)
@@ -212,7 +212,6 @@ struct mlx5_wqe_ctrl_seg {
 #define MLX5_WQE_CTRL_OPCODE_MASK 0xff
 #define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00
 #define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8
-#define MLX5_WQE_AV_EXT 0x80000000
 
 enum {
        MLX5_ETH_WQE_L3_INNER_CSUM      = 1 << 4,
index 46b9ac5e856923ec77125cf5c468585167bf0ff6..c1f6c95f34963177b13018e8299ddcd88e72e625 100644 (file)
@@ -1260,6 +1260,7 @@ int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
 void unmap_mapping_range(struct address_space *mapping,
                loff_t const holebegin, loff_t const holelen, int even_cows);
 int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
+                            unsigned long *start, unsigned long *end,
                             pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp);
 int follow_pfn(struct vm_area_struct *vma, unsigned long address,
        unsigned long *pfn);
index 7f384bb62d8ec6bc7eafa25828b0716be63c7ccb..3cadee0a350889f748e7b1a999b449ae003e9c3f 100644 (file)
@@ -487,14 +487,12 @@ struct mm_struct {
        /* numa_scan_seq prevents two threads setting pte_numa */
        int numa_scan_seq;
 #endif
-#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
        /*
         * An operation with batched TLB flushing is going on. Anything that
         * can move process memory needs to flush the TLB when moving a
         * PROT_NONE or PROT_NUMA mapped page.
         */
-       bool tlb_flush_pending;
-#endif
+       atomic_t tlb_flush_pending;
 #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
        /* See flush_tlb_batched_pending() */
        bool tlb_flush_batched;
@@ -522,46 +520,60 @@ static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
        return mm->cpu_vm_mask_var;
 }
 
-#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
+struct mmu_gather;
+extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+                               unsigned long start, unsigned long end);
+extern void tlb_finish_mmu(struct mmu_gather *tlb,
+                               unsigned long start, unsigned long end);
+
 /*
  * Memory barriers to keep this state in sync are graciously provided by
  * the page table locks, outside of which no page table modifications happen.
- * The barriers below prevent the compiler from re-ordering the instructions
- * around the memory barriers that are already present in the code.
+ * The barriers are used to ensure the order between tlb_flush_pending updates,
+ * which happen while the lock is not taken, and the PTE updates, which happen
+ * while the lock is taken, are serialized.
  */
 static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
 {
-       barrier();
-       return mm->tlb_flush_pending;
+       return atomic_read(&mm->tlb_flush_pending) > 0;
+}
+
+/*
+ * Returns true if there are two above TLB batching threads in parallel.
+ */
+static inline bool mm_tlb_flush_nested(struct mm_struct *mm)
+{
+       return atomic_read(&mm->tlb_flush_pending) > 1;
+}
+
+static inline void init_tlb_flush_pending(struct mm_struct *mm)
+{
+       atomic_set(&mm->tlb_flush_pending, 0);
 }
-static inline void set_tlb_flush_pending(struct mm_struct *mm)
+
+static inline void inc_tlb_flush_pending(struct mm_struct *mm)
 {
-       mm->tlb_flush_pending = true;
+       atomic_inc(&mm->tlb_flush_pending);
 
        /*
-        * Guarantee that the tlb_flush_pending store does not leak into the
+        * Guarantee that the tlb_flush_pending increase does not leak into the
         * critical section updating the page tables
         */
        smp_mb__before_spinlock();
 }
+
 /* Clearing is done after a TLB flush, which also provides a barrier. */
-static inline void clear_tlb_flush_pending(struct mm_struct *mm)
-{
-       barrier();
-       mm->tlb_flush_pending = false;
-}
-#else
-static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
-{
-       return false;
-}
-static inline void set_tlb_flush_pending(struct mm_struct *mm)
-{
-}
-static inline void clear_tlb_flush_pending(struct mm_struct *mm)
+static inline void dec_tlb_flush_pending(struct mm_struct *mm)
 {
+       /*
+        * Guarantee that the tlb_flush_pending does not not leak into the
+        * critical section, since we must order the PTE change and changes to
+        * the pending TLB flush indication. We could have relied on TLB flush
+        * as a memory barrier, but this behavior is not clearly documented.
+        */
+       smp_mb__before_atomic();
+       atomic_dec(&mm->tlb_flush_pending);
 }
-#endif
 
 struct vm_fault;
 
index c91b3bcd158f8fa8b2dbc3d4738ade5fdcc600cb..7b2e31b1745aaf3a7d3e8af0ca915c6c2dc04516 100644 (file)
@@ -94,17 +94,6 @@ struct mmu_notifier_ops {
                           unsigned long address,
                           pte_t pte);
 
-       /*
-        * Before this is invoked any secondary MMU is still ok to
-        * read/write to the page previously pointed to by the Linux
-        * pte because the page hasn't been freed yet and it won't be
-        * freed until this returns. If required set_page_dirty has to
-        * be called internally to this method.
-        */
-       void (*invalidate_page)(struct mmu_notifier *mn,
-                               struct mm_struct *mm,
-                               unsigned long address);
-
        /*
         * invalidate_range_start() and invalidate_range_end() must be
         * paired and are called only when the mmap_sem and/or the
@@ -220,8 +209,6 @@ extern int __mmu_notifier_test_young(struct mm_struct *mm,
                                     unsigned long address);
 extern void __mmu_notifier_change_pte(struct mm_struct *mm,
                                      unsigned long address, pte_t pte);
-extern void __mmu_notifier_invalidate_page(struct mm_struct *mm,
-                                         unsigned long address);
 extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
                                  unsigned long start, unsigned long end);
 extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm,
@@ -268,13 +255,6 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm,
                __mmu_notifier_change_pte(mm, address, pte);
 }
 
-static inline void mmu_notifier_invalidate_page(struct mm_struct *mm,
-                                         unsigned long address)
-{
-       if (mm_has_notifiers(mm))
-               __mmu_notifier_invalidate_page(mm, address);
-}
-
 static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm,
                                  unsigned long start, unsigned long end)
 {
@@ -442,11 +422,6 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm,
 {
 }
 
-static inline void mmu_notifier_invalidate_page(struct mm_struct *mm,
-                                         unsigned long address)
-{
-}
-
 static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm,
                                  unsigned long start, unsigned long end)
 {
index 892148c448cce2c9c9e9e59b2d44941283635cbd..5216d2eb22891010187b86a5911a10b17aedf273 100644 (file)
@@ -681,10 +681,10 @@ struct nand_buffers {
  * @tWW_min: WP# transition to WE# low
  */
 struct nand_sdr_timings {
-       u32 tBERS_max;
+       u64 tBERS_max;
        u32 tCCS_min;
-       u32 tPROG_max;
-       u32 tR_max;
+       u64 tPROG_max;
+       u64 tR_max;
        u32 tALH_min;
        u32 tADL_min;
        u32 tALS_min;
index dda2cc939a531dab67441c6ddf4b7869c6a06159..ebeb48c920054d705924453f6ed6c6aca0233af4 100644 (file)
@@ -37,7 +37,7 @@ struct net;
 
 /* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located
  * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected.
- * Eventually all flags will be in sk->sk_wq_flags.
+ * Eventually all flags will be in sk->sk_wq->flags.
  */
 #define SOCKWQ_ASYNC_NOSPACE   0
 #define SOCKWQ_ASYNC_WAITDATA  1
index 779b235955968353a926709436483bc3ea63dde9..c99ba7914c0a41d6d829e6018df16f4a229412b5 100644 (file)
@@ -3866,6 +3866,8 @@ int netdev_walk_all_upper_dev_rcu(struct net_device *dev,
 bool netdev_has_upper_dev_all_rcu(struct net_device *dev,
                                  struct net_device *upper_dev);
 
+bool netdev_has_any_upper_dev(struct net_device *dev);
+
 void *netdev_lower_get_next_private(struct net_device *dev,
                                    struct list_head **iter);
 void *netdev_lower_get_next_private_rcu(struct net_device *dev,
index 8aa01fd859fb84e5f64e9d7ffb0c20957afdfd2d..a36abe2da13e1a23edc8aa152205af143f658990 100644 (file)
@@ -168,6 +168,14 @@ extern int sysctl_hardlockup_all_cpu_backtrace;
 #define sysctl_softlockup_all_cpu_backtrace 0
 #define sysctl_hardlockup_all_cpu_backtrace 0
 #endif
+
+#if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \
+    defined(CONFIG_HARDLOCKUP_DETECTOR)
+void watchdog_update_hrtimer_threshold(u64 period);
+#else
+static inline void watchdog_update_hrtimer_threshold(u64 period) { }
+#endif
+
 extern bool is_hardlockup(void);
 struct ctl_table;
 extern int proc_watchdog(struct ctl_table *, int ,
index 6c8c5d8041b72ec01097d1c0563b793ea7449f1f..2591878c1d4804d374d39491c2a3f64d1b43a214 100644 (file)
@@ -346,6 +346,11 @@ struct nvme_fc_remote_port {
  *       indicating an FC transport Aborted status.
  *       Entrypoint is Mandatory.
  *
+ * @defer_rcv:  Called by the transport to signal the LLLD that it has
+ *       begun processing of a previously received NVME CMD IU. The LLDD
+ *       is now free to re-use the rcv buffer associated with the
+ *       nvmefc_tgt_fcp_req.
+ *
  * @max_hw_queues:  indicates the maximum number of hw queues the LLDD
  *       supports for cpu affinitization.
  *       Value is Mandatory. Must be at least 1.
@@ -846,6 +851,8 @@ struct nvmet_fc_target_template {
                                struct nvmefc_tgt_fcp_req *fcpreq);
        void (*fcp_req_release)(struct nvmet_fc_target_port *tgtport,
                                struct nvmefc_tgt_fcp_req *fcpreq);
+       void (*defer_rcv)(struct nvmet_fc_target_port *tgtport,
+                               struct nvmefc_tgt_fcp_req *fcpreq);
 
        u32     max_hw_queues;
        u16     max_sgl_segments;
index 25d8225dbd046d4dcac62e8261d1e49981b72df9..8efff888bd9bccdd4794bfaf4be66a3631e90cf1 100644 (file)
@@ -254,7 +254,7 @@ enum {
        NVME_CTRL_VWC_PRESENT                   = 1 << 0,
        NVME_CTRL_OACS_SEC_SUPP                 = 1 << 0,
        NVME_CTRL_OACS_DIRECTIVES               = 1 << 5,
-       NVME_CTRL_OACS_DBBUF_SUPP               = 1 << 7,
+       NVME_CTRL_OACS_DBBUF_SUPP               = 1 << 8,
 };
 
 struct nvme_lbaf {
index 8a266e2be5a63a29a2de38ff76f0bdc2e4fac08e..76aac4ce39bcf59e2e5eeb38053cf05f0c9d05ae 100644 (file)
@@ -6,6 +6,8 @@
 #include <linux/types.h>
 #include <linux/nodemask.h>
 #include <uapi/linux/oom.h>
+#include <linux/sched/coredump.h> /* MMF_* */
+#include <linux/mm.h> /* VM_FAULT* */
 
 struct zonelist;
 struct notifier_block;
@@ -63,6 +65,26 @@ static inline bool tsk_is_oom_victim(struct task_struct * tsk)
        return tsk->signal->oom_mm;
 }
 
+/*
+ * Checks whether a page fault on the given mm is still reliable.
+ * This is no longer true if the oom reaper started to reap the
+ * address space which is reflected by MMF_UNSTABLE flag set in
+ * the mm. At that moment any !shared mapping would lose the content
+ * and could cause a memory corruption (zero pages instead of the
+ * original content).
+ *
+ * User should call this before establishing a page table entry for
+ * a !shared mapping and under the proper page table lock.
+ *
+ * Return 0 when the PF is safe VM_FAULT_SIGBUS otherwise.
+ */
+static inline int check_stable_address_space(struct mm_struct *mm)
+{
+       if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags)))
+               return VM_FAULT_SIGBUS;
+       return 0;
+}
+
 extern unsigned long oom_badness(struct task_struct *p,
                struct mem_cgroup *memcg, const nodemask_t *nodemask,
                unsigned long totalpages);
index 4869e66dd659a6bc8fe4ad90df2ed9d3ff98ccac..f958d0732af685761c8b996cc6c79ca87f99f43f 100644 (file)
@@ -188,6 +188,8 @@ enum pci_dev_flags {
         * the direct_complete optimization.
         */
        PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11),
+       /* Don't use Relaxed Ordering for TLPs directed at this device */
+       PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 12),
 };
 
 enum pci_irq_reroute_variant {
@@ -1067,6 +1069,7 @@ void pcie_flr(struct pci_dev *dev);
 int __pci_reset_function(struct pci_dev *dev);
 int __pci_reset_function_locked(struct pci_dev *dev);
 int pci_reset_function(struct pci_dev *dev);
+int pci_reset_function_locked(struct pci_dev *dev);
 int pci_try_reset_function(struct pci_dev *dev);
 int pci_probe_reset_slot(struct pci_slot *slot);
 int pci_reset_slot(struct pci_slot *slot);
@@ -1125,6 +1128,7 @@ bool pci_check_pme_status(struct pci_dev *dev);
 void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
+bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
 
 /* PCI Virtual Channel */
 int pci_save_vc_state(struct pci_dev *dev);
index a3b873fc59e41745c78bc31a70f0c71d7e4374c3..b14095bcf4bb40522b66716d4c1e7b59ebf72eb4 100644 (file)
@@ -310,8 +310,8 @@ struct pmu {
         * Notification that the event was mapped or unmapped.  Called
         * in the context of the mapping task.
         */
-       void (*event_mapped)            (struct perf_event *event); /*optional*/
-       void (*event_unmapped)          (struct perf_event *event); /*optional*/
+       void (*event_mapped)            (struct perf_event *event, struct mm_struct *mm); /* optional */
+       void (*event_unmapped)          (struct perf_event *event, struct mm_struct *mm); /* optional */
 
        /*
         * Flags for ->add()/->del()/ ->start()/->stop(). There are
index 4d179316e43108f3a14ef48659a1d3a94ac320fb..719582744a2e873a978dbf9a925e143ec29243da 100644 (file)
@@ -8,7 +8,9 @@ enum pid_type
        PIDTYPE_PID,
        PIDTYPE_PGID,
        PIDTYPE_SID,
-       PIDTYPE_MAX
+       PIDTYPE_MAX,
+       /* only valid to __task_pid_nr_ns() */
+       __PIDTYPE_TGID
 };
 
 /*
index 231d3075815adfa63d462a236e66f214c3216117..e91d1b6a260d5996583a4365d4020524ad57700a 100644 (file)
@@ -81,8 +81,8 @@
  *     it.
  * @PIN_CONFIG_OUTPUT: this will configure the pin as an output and drive a
  *     value on the line. Use argument 1 to indicate high level, argument 0 to
- *     indicate low level. (Please see Documentation/pinctrl.txt, section
- *     "GPIO mode pitfalls" for a discussion around this parameter.)
+ *     indicate low level. (Please see Documentation/driver-api/pinctl.rst,
+ *     section "GPIO mode pitfalls" for a discussion around this parameter.)
  * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power
  *     supplies, the argument to this parameter (on a custom format) tells
  *     the driver which alternative power source to use.
index 79b0e4cdb8141a10e73affb9a837d5bcc5f00a2a..f8274b0c68880ccbd02de1a85ece46a3cab2053f 100644 (file)
  *     Available only for accelerometer and pressure sensors.
  *     Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet).
  * @open_drain: set the interrupt line to be open drain if possible.
+ * @spi_3wire: enable spi-3wire mode.
  */
 struct st_sensors_platform_data {
        u8 drdy_int_pin;
        bool open_drain;
+       bool spi_3wire;
 };
 
 #endif /* ST_SENSORS_PDATA_H */
index a026bfd089db81191b5a322979d4bf58c2777dc5..51349d124ee5d47ded05a433028d765858c61f00 100644 (file)
@@ -99,6 +99,11 @@ struct system_device_crosststamp;
  *            parameter func: the desired function to use.
  *            parameter chan: the function channel index to use.
  *
+ * @do_work:  Request driver to perform auxiliary (periodic) operations
+ *           Driver should return delay of the next auxiliary work scheduling
+ *           time (>=0) or negative value in case further scheduling
+ *           is not required.
+ *
  * Drivers should embed their ptp_clock_info within a private
  * structure, obtaining a reference to it using container_of().
  *
@@ -126,6 +131,7 @@ struct ptp_clock_info {
                      struct ptp_clock_request *request, int on);
        int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,
                      enum ptp_pin_function func, unsigned int chan);
+       long (*do_aux_work)(struct ptp_clock_info *ptp);
 };
 
 struct ptp_clock;
@@ -211,6 +217,16 @@ extern int ptp_clock_index(struct ptp_clock *ptp);
 int ptp_find_pin(struct ptp_clock *ptp,
                 enum ptp_pin_function func, unsigned int chan);
 
+/**
+ * ptp_schedule_worker() - schedule ptp auxiliary work
+ *
+ * @ptp:    The clock obtained from ptp_clock_register().
+ * @delay:  number of jiffies to wait before queuing
+ *          See kthread_queue_delayed_work() for more info.
+ */
+
+int ptp_schedule_worker(struct ptp_clock *ptp, unsigned long delay);
+
 #else
 static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
                                                   struct device *parent)
@@ -225,6 +241,10 @@ static inline int ptp_clock_index(struct ptp_clock *ptp)
 static inline int ptp_find_pin(struct ptp_clock *ptp,
                               enum ptp_pin_function func, unsigned int chan)
 { return -1; }
+static inline int ptp_schedule_worker(struct ptp_clock *ptp,
+                                     unsigned long delay)
+{ return -EOPNOTSUPP; }
+
 #endif
 
 #endif
index d8c97ec8a8e66d865f516f708a5b3f8fe567da29..37b4bb2545b32dc82633df6b76e629b9999f900b 100644 (file)
@@ -436,9 +436,9 @@ static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r,
        __PTR_RING_PEEK_CALL_v; \
 })
 
-static inline void **__ptr_ring_init_queue_alloc(int size, gfp_t gfp)
+static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp)
 {
-       return kzalloc(ALIGN(size * sizeof(void *), SMP_CACHE_BYTES), gfp);
+       return kcalloc(size, sizeof(void *), gfp);
 }
 
 static inline void __ptr_ring_set_size(struct ptr_ring *r, int size)
@@ -582,7 +582,8 @@ static inline int ptr_ring_resize(struct ptr_ring *r, int size, gfp_t gfp,
  * In particular if you consume ring in interrupt or BH context, you must
  * disable interrupts/BH when doing so.
  */
-static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings,
+static inline int ptr_ring_resize_multiple(struct ptr_ring **rings,
+                                          unsigned int nrings,
                                           int size,
                                           gfp_t gfp, void (*destroy)(void *))
 {
@@ -590,7 +591,7 @@ static inline int ptr_ring_resize_multiple(struct ptr_ring **rings, int nrings,
        void ***queues;
        int i;
 
-       queues = kmalloc(nrings * sizeof *queues, gfp);
+       queues = kmalloc_array(nrings, sizeof(*queues), gfp);
        if (!queues)
                goto noqueues;
 
index 8337e2db0bb2e71473f94c283c5e51639ddd8dc8..c05ac5f5aa034db128e9abcdd02e176f21904b8b 100644 (file)
@@ -1163,13 +1163,6 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk)
        return tsk->tgid;
 }
 
-extern pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
-
-static inline pid_t task_tgid_vnr(struct task_struct *tsk)
-{
-       return pid_vnr(task_tgid(tsk));
-}
-
 /**
  * pid_alive - check that a task structure is not stale
  * @p: Task structure to be checked.
@@ -1185,23 +1178,6 @@ static inline int pid_alive(const struct task_struct *p)
        return p->pids[PIDTYPE_PID].pid != NULL;
 }
 
-static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
-{
-       pid_t pid = 0;
-
-       rcu_read_lock();
-       if (pid_alive(tsk))
-               pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
-       rcu_read_unlock();
-
-       return pid;
-}
-
-static inline pid_t task_ppid_nr(const struct task_struct *tsk)
-{
-       return task_ppid_nr_ns(tsk, &init_pid_ns);
-}
-
 static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
 {
        return __task_pid_nr_ns(tsk, PIDTYPE_PGID, ns);
@@ -1223,6 +1199,33 @@ static inline pid_t task_session_vnr(struct task_struct *tsk)
        return __task_pid_nr_ns(tsk, PIDTYPE_SID, NULL);
 }
 
+static inline pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
+{
+       return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, ns);
+}
+
+static inline pid_t task_tgid_vnr(struct task_struct *tsk)
+{
+       return __task_pid_nr_ns(tsk, __PIDTYPE_TGID, NULL);
+}
+
+static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
+{
+       pid_t pid = 0;
+
+       rcu_read_lock();
+       if (pid_alive(tsk))
+               pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
+       rcu_read_unlock();
+
+       return pid;
+}
+
+static inline pid_t task_ppid_nr(const struct task_struct *tsk)
+{
+       return task_ppid_nr_ns(tsk, &init_pid_ns);
+}
+
 /* Obsolete, do not use: */
 static inline pid_t task_pgrp_nr(struct task_struct *tsk)
 {
index 35226cd4efb0f32afcf38cc4a97441e9524424f0..8621ffdeecbf0542e57c2d7fee12f53546af7774 100644 (file)
@@ -193,7 +193,8 @@ static inline int skb_array_resize(struct skb_array *a, int size, gfp_t gfp)
 }
 
 static inline int skb_array_resize_multiple(struct skb_array **rings,
-                                           int nrings, int size, gfp_t gfp)
+                                           int nrings, unsigned int size,
+                                           gfp_t gfp)
 {
        BUILD_BUG_ON(offsetof(struct skb_array, ring));
        return ptr_ring_resize_multiple((struct ptr_ring **)rings,
index dbe29b6c9bd6097b4a7e5763ad39d26921780270..d67a8182e5eb2177d978ca8a5effeaf6bd579394 100644 (file)
@@ -973,7 +973,23 @@ int __must_check skb_to_sgvec_nomark(struct sk_buff *skb, struct scatterlist *sg
 int __must_check skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg,
                              int offset, int len);
 int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
-int skb_pad(struct sk_buff *skb, int pad);
+int __skb_pad(struct sk_buff *skb, int pad, bool free_on_error);
+
+/**
+ *     skb_pad                 -       zero pad the tail of an skb
+ *     @skb: buffer to pad
+ *     @pad: space to pad
+ *
+ *     Ensure that a buffer is followed by a padding area that is zero
+ *     filled. Used by network drivers which may DMA or transfer data
+ *     beyond the buffer end onto the wire.
+ *
+ *     May return error in out of memory cases. The skb is freed on error.
+ */
+static inline int skb_pad(struct sk_buff *skb, int pad)
+{
+       return __skb_pad(skb, pad, true);
+}
 #define dev_kfree_skb(a)       consume_skb(a)
 
 int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
@@ -2825,25 +2841,42 @@ static inline int skb_padto(struct sk_buff *skb, unsigned int len)
  *     skb_put_padto - increase size and pad an skbuff up to a minimal size
  *     @skb: buffer to pad
  *     @len: minimal length
+ *     @free_on_error: free buffer on error
  *
  *     Pads up a buffer to ensure the trailing bytes exist and are
  *     blanked. If the buffer already contains sufficient data it
  *     is untouched. Otherwise it is extended. Returns zero on
- *     success. The skb is freed on error.
+ *     success. The skb is freed on error if @free_on_error is true.
  */
-static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
+static inline int __skb_put_padto(struct sk_buff *skb, unsigned int len,
+                                 bool free_on_error)
 {
        unsigned int size = skb->len;
 
        if (unlikely(size < len)) {
                len -= size;
-               if (skb_pad(skb, len))
+               if (__skb_pad(skb, len, free_on_error))
                        return -ENOMEM;
                __skb_put(skb, len);
        }
        return 0;
 }
 
+/**
+ *     skb_put_padto - increase size and pad an skbuff up to a minimal size
+ *     @skb: buffer to pad
+ *     @len: minimal length
+ *
+ *     Pads up a buffer to ensure the trailing bytes exist and are
+ *     blanked. If the buffer already contains sufficient data it
+ *     is untouched. Otherwise it is extended. Returns zero on
+ *     success. The skb is freed on error.
+ */
+static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
+{
+       return __skb_put_padto(skb, len, true);
+}
+
 static inline int skb_add_data(struct sk_buff *skb,
                               struct iov_iter *from, int copy)
 {
index 5726107963b2d9930d61c3cf5c486abfe244c18a..0ad87c434ae6a344984837e8dd053fe7705d21f1 100644 (file)
@@ -43,12 +43,13 @@ struct sync_file {
 #endif
 
        wait_queue_head_t       wq;
+       unsigned long           flags;
 
        struct dma_fence        *fence;
        struct dma_fence_cb cb;
 };
 
-#define POLL_ENABLED DMA_FENCE_FLAG_USER_BITS
+#define POLL_ENABLED 0
 
 struct sync_file *sync_file_create(struct dma_fence *fence);
 struct dma_fence *sync_file_get_fence(int fd);
index 5b74e36c0ca896481acd04bbea92be002ad4ba64..dc19880c02f5eb9091d185c567b961754cfa46e2 100644 (file)
@@ -757,6 +757,43 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
        __ret;                                                                  \
 })
 
+#define __wait_event_killable_timeout(wq_head, condition, timeout)             \
+       ___wait_event(wq_head, ___wait_cond_timeout(condition),                 \
+                     TASK_KILLABLE, 0, timeout,                                \
+                     __ret = schedule_timeout(__ret))
+
+/**
+ * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses
+ * @wq_head: the waitqueue to wait on
+ * @condition: a C expression for the event to wait for
+ * @timeout: timeout, in jiffies
+ *
+ * The process is put to sleep (TASK_KILLABLE) until the
+ * @condition evaluates to true or a kill signal is received.
+ * The @condition is checked each time the waitqueue @wq_head is woken up.
+ *
+ * wake_up() has to be called after changing any variable that could
+ * change the result of the wait condition.
+ *
+ * Returns:
+ * 0 if the @condition evaluated to %false after the @timeout elapsed,
+ * 1 if the @condition evaluated to %true after the @timeout elapsed,
+ * the remaining jiffies (at least 1) if the @condition evaluated
+ * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
+ * interrupted by a kill signal.
+ *
+ * Only kill signals interrupt this process.
+ */
+#define wait_event_killable_timeout(wq_head, condition, timeout)               \
+({                                                                             \
+       long __ret = timeout;                                                   \
+       might_sleep();                                                          \
+       if (!___wait_cond_timeout(condition))                                   \
+               __ret = __wait_event_killable_timeout(wq_head,                  \
+                                               condition, timeout);            \
+       __ret;                                                                  \
+})
+
 
 #define __wait_event_lock_irq(wq_head, condition, lock, cmd)                   \
        (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0,     \
index 6df79e96a780b3bf0c141fee5b43eded5276775c..f44ff2476758e27ad9f9cc20d96d96f16e5ee98c 100644 (file)
@@ -336,6 +336,16 @@ static inline void in6_dev_put(struct inet6_dev *idev)
                in6_dev_finish_destroy(idev);
 }
 
+static inline void in6_dev_put_clear(struct inet6_dev **pidev)
+{
+       struct inet6_dev *idev = *pidev;
+
+       if (idev) {
+               in6_dev_put(idev);
+               *pidev = NULL;
+       }
+}
+
 static inline void __in6_dev_put(struct inet6_dev *idev)
 {
        refcount_dec(&idev->refcnt);
index b00508d22e0a6adc37ee4e69187377fea3bc102d..b2e68657a2162cd55b957c9230779f5d066fe6f3 100644 (file)
@@ -277,6 +277,11 @@ static inline bool bond_is_lb(const struct bonding *bond)
               BOND_MODE(bond) == BOND_MODE_ALB;
 }
 
+static inline bool bond_needs_speed_duplex(const struct bonding *bond)
+{
+       return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond);
+}
+
 static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
 {
        return (BOND_MODE(bond) == BOND_MODE_TLB)  &&
index 8ffd434676b7a270af73534f3dbcc26f370fe215..71c72a939bf8b21c5102994ea68796dc89c4f097 100644 (file)
 #include <linux/sched/signal.h>
 #include <net/ip.h>
 
-#ifdef CONFIG_NET_RX_BUSY_POLL
-
-struct napi_struct;
-extern unsigned int sysctl_net_busy_read __read_mostly;
-extern unsigned int sysctl_net_busy_poll __read_mostly;
-
 /*             0 - Reserved to indicate value not set
  *     1..NR_CPUS - Reserved for sender_cpu
  *  NR_CPUS+1..~0 - Region available for NAPI IDs
  */
 #define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
 
+#ifdef CONFIG_NET_RX_BUSY_POLL
+
+struct napi_struct;
+extern unsigned int sysctl_net_busy_read __read_mostly;
+extern unsigned int sysctl_net_busy_poll __read_mostly;
+
 static inline bool net_busy_loop_on(void)
 {
        return sysctl_net_busy_poll;
index 821cedcc8e73b68af72d1918242c25d757c63d24..0cf7f5a65fe6be2be30259aa5cd251d02de489d5 100644 (file)
@@ -352,7 +352,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
            !forwarding)
                return dst_mtu(dst);
 
-       return min(dst->dev->mtu, IP_MAX_MTU);
+       return min(READ_ONCE(dst->dev->mtu), IP_MAX_MTU);
 }
 
 static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
@@ -364,7 +364,7 @@ static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
                return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding);
        }
 
-       return min(skb_dst(skb)->dev->mtu, IP_MAX_MTU);
+       return min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU);
 }
 
 u32 ip_idents_reserve(u32 hash, int segs);
index 1a88008cc6f5e14a788491f62ae3c15e47b62c16..af509f801084dcf19a27f9d4c82344c5e54fe792 100644 (file)
@@ -70,6 +70,7 @@ struct fib6_node {
        __u16                   fn_flags;
        int                     fn_sernum;
        struct rt6_info         *rr_ptr;
+       struct rcu_head         rcu;
 };
 
 #ifndef CONFIG_IPV6_SUBTREES
@@ -104,7 +105,7 @@ struct rt6_info {
         * the same cache line.
         */
        struct fib6_table               *rt6i_table;
-       struct fib6_node                *rt6i_node;
+       struct fib6_node __rcu          *rt6i_node;
 
        struct in6_addr                 rt6i_gateway;
 
@@ -167,13 +168,40 @@ static inline void rt6_update_expires(struct rt6_info *rt0, int timeout)
        rt0->rt6i_flags |= RTF_EXPIRES;
 }
 
+/* Function to safely get fn->sernum for passed in rt
+ * and store result in passed in cookie.
+ * Return true if we can get cookie safely
+ * Return false if not
+ */
+static inline bool rt6_get_cookie_safe(const struct rt6_info *rt,
+                                      u32 *cookie)
+{
+       struct fib6_node *fn;
+       bool status = false;
+
+       rcu_read_lock();
+       fn = rcu_dereference(rt->rt6i_node);
+
+       if (fn) {
+               *cookie = fn->fn_sernum;
+               status = true;
+       }
+
+       rcu_read_unlock();
+       return status;
+}
+
 static inline u32 rt6_get_cookie(const struct rt6_info *rt)
 {
+       u32 cookie = 0;
+
        if (rt->rt6i_flags & RTF_PCPU ||
            (unlikely(!list_empty(&rt->rt6i_uncached)) && rt->dst.from))
                rt = (struct rt6_info *)(rt->dst.from);
 
-       return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
+       rt6_get_cookie_safe(rt, &cookie);
+
+       return cookie;
 }
 
 static inline void ip6_rt_put(struct rt6_info *rt)
index b2b5419467cc123b4a2b70c2d926b4576651248d..f8149ca192b430c181406fa9a3e4db8fc0a17252 100644 (file)
@@ -5499,6 +5499,21 @@ static inline void ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif,
        ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS);
 }
 
+/**
+ * ieee80211_rx_ba_timer_expired - stop a Rx BA session due to timeout
+ *
+ * Some device drivers do not offload AddBa/DelBa negotiation, but handle rx
+ * buffer reording internally, and therefore also handle the session timer.
+ *
+ * Trigger the timeout flow, which sends a DelBa.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback
+ * @addr: station mac address
+ * @tid: the rx tid
+ */
+void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
+                                  const u8 *addr, unsigned int tid);
+
 /* Rate control API */
 
 /**
index 1c123e2b2415797e7d32a0248df817cb9fbcb0c9..c1109cdbbfa6afb9aff0d6033aef7b615630ffc1 100644 (file)
@@ -101,6 +101,13 @@ struct Qdisc {
        spinlock_t              busylock ____cacheline_aligned_in_smp;
 };
 
+static inline void qdisc_refcount_inc(struct Qdisc *qdisc)
+{
+       if (qdisc->flags & TCQ_F_BUILTIN)
+               return;
+       refcount_inc(&qdisc->refcnt);
+}
+
 static inline bool qdisc_is_running(const struct Qdisc *qdisc)
 {
        return (raw_read_seqcount(&qdisc->running) & 1) ? true : false;
@@ -806,8 +813,11 @@ static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
        old = *pold;
        *pold = new;
        if (old != NULL) {
-               qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog);
+               unsigned int qlen = old->q.qlen;
+               unsigned int backlog = old->qstats.backlog;
+
                qdisc_reset(old);
+               qdisc_tree_reduce_backlog(old, qlen, backlog);
        }
        sch_tree_unlock(sch);
 
index 7c0632c7e87043ca18fe5d32d7d55792f75ca6e8..aeeec62992ca7dc5ff80f8d7164a1c143f606b03 100644 (file)
@@ -507,9 +507,7 @@ int sk_set_peek_off(struct sock *sk, int val);
 static inline int sk_peek_offset(struct sock *sk, int flags)
 {
        if (unlikely(flags & MSG_PEEK)) {
-               s32 off = READ_ONCE(sk->sk_peek_off);
-               if (off >= 0)
-                       return off;
+               return READ_ONCE(sk->sk_peek_off);
        }
 
        return 0;
index 70483296157f87acdf5acd5e96eaa910119ba220..f642a39f9eeeeb3a1bbff48fd467c3a3acb96160 100644 (file)
@@ -1004,9 +1004,7 @@ void tcp_get_default_congestion_control(char *name);
 void tcp_get_available_congestion_control(char *buf, size_t len);
 void tcp_get_allowed_congestion_control(char *buf, size_t len);
 int tcp_set_allowed_congestion_control(char *allowed);
-int tcp_set_congestion_control(struct sock *sk, const char *name, bool load);
-void tcp_reinit_congestion_control(struct sock *sk,
-                                  const struct tcp_congestion_ops *ca);
+int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, bool reinit);
 u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
 void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked);
 
@@ -1916,6 +1914,16 @@ extern void tcp_rack_advance(struct tcp_sock *tp, u8 sacked, u32 end_seq,
                             u64 xmit_time);
 extern void tcp_rack_reo_timeout(struct sock *sk);
 
+/* At how many usecs into the future should the RTO fire? */
+static inline s64 tcp_rto_delta_us(const struct sock *sk)
+{
+       const struct sk_buff *skb = tcp_write_queue_head(sk);
+       u32 rto = inet_csk(sk)->icsk_rto;
+       u64 rto_time_stamp_us = skb->skb_mstamp + jiffies_to_usecs(rto);
+
+       return rto_time_stamp_us - tcp_sk(sk)->tcp_mstamp;
+}
+
 /*
  * Save and compile IPv4 options, return a pointer to it
  */
index cc8036987dcb885012c6c5eda0fb2bed2e588841..626c2d8a70c59f51fb5b2558433d222b56610246 100644 (file)
@@ -260,7 +260,7 @@ static inline struct sk_buff *skb_recv_udp(struct sock *sk, unsigned int flags,
 }
 
 void udp_v4_early_demux(struct sk_buff *skb);
-void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst);
+bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst);
 int udp_get_port(struct sock *sk, unsigned short snum,
                 int (*saddr_cmp)(const struct sock *,
                                  const struct sock *));
@@ -366,12 +366,13 @@ static inline bool udp_skb_is_linear(struct sk_buff *skb)
 static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
                                  struct iov_iter *to)
 {
-       int n, copy = len - off;
+       int n;
 
-       n = copy_to_iter(skb->data + off, copy, to);
-       if (n == copy)
+       n = copy_to_iter(skb->data + off, len, to);
+       if (n == len)
                return 0;
 
+       iov_iter_revert(to, n);
        return -EFAULT;
 }
 
index b5732432bb297dbf6067ae34b16c00073cb2949d..88c32aba32f71b15370e2d4b5cc724c31feed9d3 100644 (file)
@@ -1683,6 +1683,7 @@ struct ib_qp {
        enum ib_qp_type         qp_type;
        struct ib_rwq_ind_table *rwq_ind_tbl;
        struct ib_qp_security  *qp_sec;
+       u8                      port;
 };
 
 struct ib_mr {
index a1266d318c855dec12dbb41a6bb1ab9e4dc27f08..6af198d8120b098f31d674f15584ec7114832743 100644 (file)
@@ -57,6 +57,7 @@ struct scsi_pointer {
 /* for scmd->flags */
 #define SCMD_TAGGED            (1 << 0)
 #define SCMD_UNCHECKED_ISA_DMA (1 << 1)
+#define SCMD_ZONE_WRITE_LOCK   (1 << 2)
 
 struct scsi_cmnd {
        struct scsi_request req;
index 0ca1fb08805b254fa8ffda73f4decd4c48ac2211..fb87d32f5e513de3c2a1b7c6f402b5f48e401c45 100644 (file)
@@ -786,6 +786,7 @@ struct iscsi_np {
        int                     np_sock_type;
        enum np_thread_state_table np_thread_state;
        bool                    enabled;
+       atomic_t                np_reset_count;
        enum iscsi_timer_flags_table np_login_timer_flags;
        u32                     np_exports;
        enum np_flags_table     np_flags;
index 26c54f6d595d4070c7708ef22daf7533468404a2..ad4eb2863e70ee195f9abc68e6b8c3c3020f27bc 100644 (file)
@@ -171,7 +171,7 @@ struct drm_msm_gem_submit_cmd {
        __u32 size;           /* in, cmdstream size */
        __u32 pad;
        __u32 nr_relocs;      /* in, number of submit_reloc's */
-       __u64 __user relocs;  /* in, ptr to array of submit_reloc's */
+       __u64 relocs;         /* in, ptr to array of submit_reloc's */
 };
 
 /* Each buffer referenced elsewhere in the cmdstream submit (ie. the
@@ -215,8 +215,8 @@ struct drm_msm_gem_submit {
        __u32 fence;          /* out */
        __u32 nr_bos;         /* in, number of submit_bo's */
        __u32 nr_cmds;        /* in, number of submit_cmd's */
-       __u64 __user bos;     /* in, ptr to array of submit_bo's */
-       __u64 __user cmds;    /* in, ptr to array of submit_cmd's */
+       __u64 bos;            /* in, ptr to array of submit_bo's */
+       __u64 cmds;           /* in, ptr to array of submit_cmd's */
        __s32 fence_fd;       /* in/out fence fd (see MSM_SUBMIT_FENCE_FD_IN/OUT) */
 };
 
index a3960f98679c13567c3db4ecb7919cd14a70cfb0..c8125ec1f4f2270a5a01a358832425cd57edb11a 100644 (file)
@@ -22,7 +22,6 @@ enum {
        LO_FLAGS_AUTOCLEAR      = 4,
        LO_FLAGS_PARTSCAN       = 8,
        LO_FLAGS_DIRECT_IO      = 16,
-       LO_FLAGS_BLOCKSIZE      = 32,
 };
 
 #include <asm/posix_types.h>   /* for __kernel_old_dev_t */
@@ -60,8 +59,6 @@ struct loop_info64 {
        __u64              lo_init[2];
 };
 
-#define LO_INFO_BLOCKSIZE(l) (l)->lo_init[0]
-
 /*
  * Loop filter types
  */
index 6d3c54264d8e46f662e3a0caa416538042727fb3..3f03567631cb092dc8f51aae740dd2a3472730e9 100644 (file)
@@ -145,43 +145,6 @@ struct nd_cmd_clear_error {
        __u64 cleared;
 } __packed;
 
-struct nd_cmd_trans_spa {
-       __u64 spa;
-       __u32 status;
-       __u8  flags;
-       __u8  _reserved[3];
-       __u64 trans_length;
-       __u32 num_nvdimms;
-       struct nd_nvdimm_device {
-               __u32 nfit_device_handle;
-               __u32 _reserved;
-               __u64 dpa;
-       } __packed devices[0];
-
-} __packed;
-
-struct nd_cmd_ars_err_inj {
-       __u64 err_inj_spa_range_base;
-       __u64 err_inj_spa_range_length;
-       __u8  err_inj_options;
-       __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_clr {
-       __u64 err_inj_clr_spa_range_base;
-       __u64 err_inj_clr_spa_range_length;
-       __u32 status;
-} __packed;
-
-struct nd_cmd_ars_err_inj_stat {
-       __u32 status;
-       __u32 inj_err_rec_count;
-       struct nd_error_stat_query_record {
-               __u64 err_inj_stat_spa_range_base;
-               __u64 err_inj_stat_spa_range_length;
-       } __packed record[0];
-} __packed;
-
 enum {
        ND_CMD_IMPLEMENTED = 0,
 
index 62d686d965813aeb4b8ef34877e886e08bd71912..9eb8b3511636e96e0607be2484119823b1034fb5 100644 (file)
@@ -66,7 +66,7 @@ static struct fsnotify_group *audit_watch_group;
 
 /* fsnotify events we care about. */
 #define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\
-                       FS_MOVE_SELF | FS_EVENT_ON_CHILD)
+                       FS_MOVE_SELF | FS_EVENT_ON_CHILD | FS_UNMOUNT)
 
 static void audit_free_parent(struct audit_parent *parent)
 {
@@ -457,13 +457,15 @@ void audit_remove_watch_rule(struct audit_krule *krule)
        list_del(&krule->rlist);
 
        if (list_empty(&watch->rules)) {
+               /*
+                * audit_remove_watch() drops our reference to 'parent' which
+                * can get freed. Grab our own reference to be safe.
+                */
+               audit_get_parent(parent);
                audit_remove_watch(watch);
-
-               if (list_empty(&parent->watches)) {
-                       audit_get_parent(parent);
+               if (list_empty(&parent->watches))
                        fsnotify_destroy_mark(&parent->mark, audit_watch_group);
-                       audit_put_parent(parent);
-               }
+               audit_put_parent(parent);
        }
 }
 
index 4fb463172aa88e81d9caaaee271d8d8c8a9db978..d11c8181f4c5f9d612aa0f3bb3960d405dbf16b1 100644 (file)
@@ -652,12 +652,27 @@ static void pcpu_copy_value(struct bpf_htab *htab, void __percpu *pptr,
        }
 }
 
+static bool fd_htab_map_needs_adjust(const struct bpf_htab *htab)
+{
+       return htab->map.map_type == BPF_MAP_TYPE_HASH_OF_MAPS &&
+              BITS_PER_LONG == 64;
+}
+
+static u32 htab_size_value(const struct bpf_htab *htab, bool percpu)
+{
+       u32 size = htab->map.value_size;
+
+       if (percpu || fd_htab_map_needs_adjust(htab))
+               size = round_up(size, 8);
+       return size;
+}
+
 static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
                                         void *value, u32 key_size, u32 hash,
                                         bool percpu, bool onallcpus,
                                         struct htab_elem *old_elem)
 {
-       u32 size = htab->map.value_size;
+       u32 size = htab_size_value(htab, percpu);
        bool prealloc = htab_is_prealloc(htab);
        struct htab_elem *l_new, **pl_new;
        void __percpu *pptr;
@@ -696,9 +711,6 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key,
 
        memcpy(l_new->key, key, key_size);
        if (percpu) {
-               /* round up value_size to 8 bytes */
-               size = round_up(size, 8);
-
                if (prealloc) {
                        pptr = htab_elem_get_ptr(l_new, key_size);
                } else {
@@ -1209,17 +1221,9 @@ const struct bpf_map_ops htab_lru_percpu_map_ops = {
 
 static struct bpf_map *fd_htab_map_alloc(union bpf_attr *attr)
 {
-       struct bpf_map *map;
-
        if (attr->value_size != sizeof(u32))
                return ERR_PTR(-EINVAL);
-
-       /* pointer is stored internally */
-       attr->value_size = sizeof(void *);
-       map = htab_map_alloc(attr);
-       attr->value_size = sizeof(u32);
-
-       return map;
+       return htab_map_alloc(attr);
 }
 
 static void fd_htab_map_free(struct bpf_map *map)
index 8d51516885047c7807cb050979c1ebbdaec6dc07..87a1213dd32678fba0487b7411dc4af5661cf01e 100644 (file)
@@ -1892,6 +1892,7 @@ static struct cftype files[] = {
        {
                .name = "memory_pressure",
                .read_u64 = cpuset_read_u64,
+               .private = FILE_MEMORY_PRESSURE,
        },
 
        {
index 426c2ffba16d4ce1474a798a4c43d78d5abedb1e..3504125871d2f058fa717638e785b9c85220213a 100644 (file)
@@ -2217,6 +2217,33 @@ static int group_can_go_on(struct perf_event *event,
        return can_add_hw;
 }
 
+/*
+ * Complement to update_event_times(). This computes the tstamp_* values to
+ * continue 'enabled' state from @now, and effectively discards the time
+ * between the prior tstamp_stopped and now (as we were in the OFF state, or
+ * just switched (context) time base).
+ *
+ * This further assumes '@event->state == INACTIVE' (we just came from OFF) and
+ * cannot have been scheduled in yet. And going into INACTIVE state means
+ * '@event->tstamp_stopped = @now'.
+ *
+ * Thus given the rules of update_event_times():
+ *
+ *   total_time_enabled = tstamp_stopped - tstamp_enabled
+ *   total_time_running = tstamp_stopped - tstamp_running
+ *
+ * We can insert 'tstamp_stopped == now' and reverse them to compute new
+ * tstamp_* values.
+ */
+static void __perf_event_enable_time(struct perf_event *event, u64 now)
+{
+       WARN_ON_ONCE(event->state != PERF_EVENT_STATE_INACTIVE);
+
+       event->tstamp_stopped = now;
+       event->tstamp_enabled = now - event->total_time_enabled;
+       event->tstamp_running = now - event->total_time_running;
+}
+
 static void add_event_to_ctx(struct perf_event *event,
                               struct perf_event_context *ctx)
 {
@@ -2224,9 +2251,12 @@ static void add_event_to_ctx(struct perf_event *event,
 
        list_add_event(event, ctx);
        perf_group_attach(event);
-       event->tstamp_enabled = tstamp;
-       event->tstamp_running = tstamp;
-       event->tstamp_stopped = tstamp;
+       /*
+        * We can be called with event->state == STATE_OFF when we create with
+        * .disabled = 1. In that case the IOC_ENABLE will call this function.
+        */
+       if (event->state == PERF_EVENT_STATE_INACTIVE)
+               __perf_event_enable_time(event, tstamp);
 }
 
 static void ctx_sched_out(struct perf_event_context *ctx,
@@ -2471,10 +2501,11 @@ static void __perf_event_mark_enabled(struct perf_event *event)
        u64 tstamp = perf_event_time(event);
 
        event->state = PERF_EVENT_STATE_INACTIVE;
-       event->tstamp_enabled = tstamp - event->total_time_enabled;
+       __perf_event_enable_time(event, tstamp);
        list_for_each_entry(sub, &event->sibling_list, group_entry) {
+               /* XXX should not be > INACTIVE if event isn't */
                if (sub->state >= PERF_EVENT_STATE_INACTIVE)
-                       sub->tstamp_enabled = tstamp - sub->total_time_enabled;
+                       __perf_event_enable_time(sub, tstamp);
        }
 }
 
@@ -5090,7 +5121,7 @@ static void perf_mmap_open(struct vm_area_struct *vma)
                atomic_inc(&event->rb->aux_mmap_count);
 
        if (event->pmu->event_mapped)
-               event->pmu->event_mapped(event);
+               event->pmu->event_mapped(event, vma->vm_mm);
 }
 
 static void perf_pmu_output_stop(struct perf_event *event);
@@ -5113,7 +5144,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
        unsigned long size = perf_data_size(rb);
 
        if (event->pmu->event_unmapped)
-               event->pmu->event_unmapped(event);
+               event->pmu->event_unmapped(event, vma->vm_mm);
 
        /*
         * rb->aux_mmap_count will always drop before rb->mmap_count and
@@ -5411,7 +5442,7 @@ aux_unlock:
        vma->vm_ops = &perf_mmap_vmops;
 
        if (event->pmu->event_mapped)
-               event->pmu->event_mapped(event);
+               event->pmu->event_mapped(event, vma->vm_mm);
 
        return ret;
 }
@@ -10001,28 +10032,27 @@ SYSCALL_DEFINE5(perf_event_open,
                        goto err_context;
 
                /*
-                * Do not allow to attach to a group in a different
-                * task or CPU context:
+                * Make sure we're both events for the same CPU;
+                * grouping events for different CPUs is broken; since
+                * you can never concurrently schedule them anyhow.
                 */
-               if (move_group) {
-                       /*
-                        * Make sure we're both on the same task, or both
-                        * per-cpu events.
-                        */
-                       if (group_leader->ctx->task != ctx->task)
-                               goto err_context;
+               if (group_leader->cpu != event->cpu)
+                       goto err_context;
 
-                       /*
-                        * Make sure we're both events for the same CPU;
-                        * grouping events for different CPUs is broken; since
-                        * you can never concurrently schedule them anyhow.
-                        */
-                       if (group_leader->cpu != event->cpu)
-                               goto err_context;
-               } else {
-                       if (group_leader->ctx != ctx)
-                               goto err_context;
-               }
+               /*
+                * Make sure we're both on the same task, or both
+                * per-CPU events.
+                */
+               if (group_leader->ctx->task != ctx->task)
+                       goto err_context;
+
+               /*
+                * Do not allow to attach to a group in a different task
+                * or CPU context. If we're moving SW events, we'll fix
+                * this up later, so allow that.
+                */
+               if (!move_group && group_leader->ctx != ctx)
+                       goto err_context;
 
                /*
                 * Only a group leader can be exclusive or pinned
index 0e137f98a50c30db936a8deecedc1f84455aca23..267f6ef91d9709e2f53c35e053a792d3fcede64d 100644 (file)
@@ -1262,8 +1262,6 @@ void uprobe_end_dup_mmap(void)
 
 void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm)
 {
-       newmm->uprobes_state.xol_area = NULL;
-
        if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) {
                set_bit(MMF_HAS_UPROBES, &newmm->flags);
                /* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */
index 17921b0390b4f91113bcf8c9ccac5c1225751460..b7e9e57b71eaef65bd56b409b32b582e9b16ed4a 100644 (file)
@@ -785,6 +785,13 @@ static void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
 #endif
 }
 
+static void mm_init_uprobes_state(struct mm_struct *mm)
+{
+#ifdef CONFIG_UPROBES
+       mm->uprobes_state.xol_area = NULL;
+#endif
+}
+
 static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
        struct user_namespace *user_ns)
 {
@@ -806,11 +813,13 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
        mm_init_cpumask(mm);
        mm_init_aio(mm);
        mm_init_owner(mm, p);
+       RCU_INIT_POINTER(mm->exe_file, NULL);
        mmu_notifier_mm_init(mm);
-       clear_tlb_flush_pending(mm);
+       init_tlb_flush_pending(mm);
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
        mm->pmd_huge_pte = NULL;
 #endif
+       mm_init_uprobes_state(mm);
 
        if (current->mm) {
                mm->flags = current->mm->flags & MMF_INIT_MASK;
index 16dbe4c938953a70a49faf0a5264af8c19a9491f..f50b434756c18eb0c200ec6e3b4db16231062f24 100644 (file)
@@ -670,13 +670,14 @@ again:
                 * this reference was taken by ihold under the page lock
                 * pinning the inode in place so i_lock was unnecessary. The
                 * only way for this check to fail is if the inode was
-                * truncated in parallel so warn for now if this happens.
+                * truncated in parallel which is almost certainly an
+                * application bug. In such a case, just retry.
                 *
                 * We are not calling into get_futex_key_refs() in file-backed
                 * cases, therefore a successful atomic_inc return below will
                 * guarantee that get_futex_key() will still imply smp_mb(); (B).
                 */
-               if (WARN_ON_ONCE(!atomic_inc_not_zero(&inode->i_count))) {
+               if (!atomic_inc_not_zero(&inode->i_count)) {
                        rcu_read_unlock();
                        put_page(page);
 
index a3cc37c0c85e2267497f650611b656af90aaf5aa..3675c6004f2a68c9d60493c7c46e9c46a0baa73f 100644 (file)
@@ -1000,7 +1000,7 @@ EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name);
 
 void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 {
-       unsigned long flags;
+       unsigned long flags, trigger, tmp;
        struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
 
        if (!desc)
@@ -1014,6 +1014,8 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
 
        irq_settings_clr_and_set(desc, clr, set);
 
+       trigger = irqd_get_trigger_type(&desc->irq_data);
+
        irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
                   IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
        if (irq_settings_has_no_balance_set(desc))
@@ -1025,7 +1027,11 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
        if (irq_settings_is_level(desc))
                irqd_set(&desc->irq_data, IRQD_LEVEL);
 
-       irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc));
+       tmp = irq_settings_get_trigger_mask(desc);
+       if (tmp != IRQ_TYPE_NONE)
+               trigger = tmp;
+
+       irqd_set(&desc->irq_data, trigger);
 
        irq_put_desc_unlock(desc, flags);
 }
index 1a9abc1c8ea0046d6491d1786645f1c1e4e1eee2..259a22aa9934cf9d67eb779e5e3eae22db0a3412 100644 (file)
@@ -165,7 +165,7 @@ irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu)
        struct irq_data *data = irq_get_irq_data(irq);
        struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
 
-       if (!data || !ipimask || cpu > nr_cpu_ids)
+       if (!data || !ipimask || cpu >= nr_cpu_ids)
                return INVALID_HWIRQ;
 
        if (!cpumask_test_cpu(cpu, ipimask))
@@ -195,7 +195,7 @@ static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data,
        if (!chip->ipi_send_single && !chip->ipi_send_mask)
                return -EINVAL;
 
-       if (cpu > nr_cpu_ids)
+       if (cpu >= nr_cpu_ids)
                return -EINVAL;
 
        if (dest) {
index 6d016c5d97c8390f561e6a9456a4e0c1ca59bffe..2f37acde640b6c6e2ce73933a52dbad65f014cf3 100644 (file)
@@ -70,6 +70,18 @@ static DECLARE_RWSEM(umhelper_sem);
 static atomic_t kmod_concurrent_max = ATOMIC_INIT(MAX_KMOD_CONCURRENT);
 static DECLARE_WAIT_QUEUE_HEAD(kmod_wq);
 
+/*
+ * This is a restriction on having *all* MAX_KMOD_CONCURRENT threads
+ * running at the same time without returning. When this happens we
+ * believe you've somehow ended up with a recursive module dependency
+ * creating a loop.
+ *
+ * We have no option but to fail.
+ *
+ * Userspace should proactively try to detect and prevent these.
+ */
+#define MAX_KMOD_ALL_BUSY_TIMEOUT 5
+
 /*
        modprobe_path is set via /proc/sys.
 */
@@ -167,8 +179,17 @@ int __request_module(bool wait, const char *fmt, ...)
                pr_warn_ratelimited("request_module: kmod_concurrent_max (%u) close to 0 (max_modprobes: %u), for module %s, throttling...",
                                    atomic_read(&kmod_concurrent_max),
                                    MAX_KMOD_CONCURRENT, module_name);
-               wait_event_interruptible(kmod_wq,
-                                        atomic_dec_if_positive(&kmod_concurrent_max) >= 0);
+               ret = wait_event_killable_timeout(kmod_wq,
+                                                 atomic_dec_if_positive(&kmod_concurrent_max) >= 0,
+                                                 MAX_KMOD_ALL_BUSY_TIMEOUT * HZ);
+               if (!ret) {
+                       pr_warn_ratelimited("request_module: modprobe %s cannot be processed, kmod busy with %d threads for more than %d seconds now",
+                                           module_name, MAX_KMOD_CONCURRENT, MAX_KMOD_ALL_BUSY_TIMEOUT);
+                       return -ETIME;
+               } else if (ret == -ERESTARTSYS) {
+                       pr_warn_ratelimited("request_module: sigkill sent for modprobe %s, giving up", module_name);
+                       return ret;
+               }
        }
 
        trace_module_request(module_name, wait, _RET_IP_);
index 26db528c1d881bf371ea5b53b7ade0815c990bf1..1c19edf824272db47a48730478af5f3b582bbf67 100644 (file)
@@ -637,6 +637,7 @@ repeat:
                schedule();
 
        try_to_freeze();
+       cond_resched();
        goto repeat;
 }
 EXPORT_SYMBOL_GPL(kthread_worker_fn);
index c69c30d827e5a2fc2605c6449617eb3754d8479b..020dedbdf066bccbc370cba20be8dc7dbc914629 100644 (file)
@@ -527,8 +527,11 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
        if (!ns)
                ns = task_active_pid_ns(current);
        if (likely(pid_alive(task))) {
-               if (type != PIDTYPE_PID)
+               if (type != PIDTYPE_PID) {
+                       if (type == __PIDTYPE_TGID)
+                               type = PIDTYPE_PID;
                        task = task->group_leader;
+               }
                nr = pid_nr_ns(rcu_dereference(task->pids[type].pid), ns);
        }
        rcu_read_unlock();
@@ -537,12 +540,6 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
 }
 EXPORT_SYMBOL(__task_pid_nr_ns);
 
-pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
-{
-       return pid_nr_ns(task_tgid(tsk), ns);
-}
-EXPORT_SYMBOL(task_tgid_nr_ns);
-
 struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
 {
        return ns_of_pid(task_pid(tsk));
index 222317721c5a09291c6b78fc839e722b2196b177..0972a8e09d082d99c7f197cbe6bd4fdb6475ba33 100644 (file)
@@ -1650,7 +1650,7 @@ static unsigned long minimum_image_size(unsigned long saveable)
 {
        unsigned long size;
 
-       size = global_page_state(NR_SLAB_RECLAIMABLE)
+       size = global_node_page_state(NR_SLAB_RECLAIMABLE)
                + global_node_page_state(NR_ACTIVE_ANON)
                + global_node_page_state(NR_INACTIVE_ANON)
                + global_node_page_state(NR_ACTIVE_FILE)
index 17f11c6b0a9f7a87010c17d3b775739d7e0d93a1..d6afed6d0752c6cdd09a094d61d0bcae9184f865 100644 (file)
@@ -70,9 +70,10 @@ static void __wake_up_common(struct wait_queue_head *wq_head, unsigned int mode,
 
        list_for_each_entry_safe(curr, next, &wq_head->head, entry) {
                unsigned flags = curr->flags;
-
-               if (curr->func(curr, mode, wake_flags, key) &&
-                               (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
+               int ret = curr->func(curr, mode, wake_flags, key);
+               if (ret < 0)
+                       break;
+               if (ret && (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
                        break;
        }
 }
index 7e33f8c583e64c91d7cb6ac1fb330b01299b7be2..ed804a470dcd151c18915f956c2f325b6d22bb0f 100644 (file)
@@ -1194,7 +1194,11 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
                        recalc_sigpending_and_wake(t);
                }
        }
-       if (action->sa.sa_handler == SIG_DFL)
+       /*
+        * Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect
+        * debugging to leave init killable.
+        */
+       if (action->sa.sa_handler == SIG_DFL && !t->ptrace)
                t->signal->flags &= ~SIGNAL_UNKILLABLE;
        ret = specific_send_sig_info(sig, info, t);
        spin_unlock_irqrestore(&t->sighand->siglock, flags);
index 8f5d1bf18854593e6fa27730d07a99c6700ab45c..f2674a056c268a58e0525194ea225fcd0bd9e1d5 100644 (file)
@@ -203,6 +203,7 @@ struct timer_base {
        bool                    migration_enabled;
        bool                    nohz_active;
        bool                    is_idle;
+       bool                    must_forward_clk;
        DECLARE_BITMAP(pending_map, WHEEL_SIZE);
        struct hlist_head       vectors[WHEEL_SIZE];
 } ____cacheline_aligned;
@@ -856,13 +857,19 @@ get_target_base(struct timer_base *base, unsigned tflags)
 
 static inline void forward_timer_base(struct timer_base *base)
 {
-       unsigned long jnow = READ_ONCE(jiffies);
+       unsigned long jnow;
 
        /*
-        * We only forward the base when it's idle and we have a delta between
-        * base clock and jiffies.
+        * We only forward the base when we are idle or have just come out of
+        * idle (must_forward_clk logic), and have a delta between base clock
+        * and jiffies. In the common case, run_timers will take care of it.
         */
-       if (!base->is_idle || (long) (jnow - base->clk) < 2)
+       if (likely(!base->must_forward_clk))
+               return;
+
+       jnow = READ_ONCE(jiffies);
+       base->must_forward_clk = base->is_idle;
+       if ((long)(jnow - base->clk) < 2)
                return;
 
        /*
@@ -938,6 +945,11 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
         * same array bucket then just return:
         */
        if (timer_pending(timer)) {
+               /*
+                * The downside of this optimization is that it can result in
+                * larger granularity than you would get from adding a new
+                * timer with this expiry.
+                */
                if (timer->expires == expires)
                        return 1;
 
@@ -948,6 +960,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                 * dequeue/enqueue dance.
                 */
                base = lock_timer_base(timer, &flags);
+               forward_timer_base(base);
 
                clk = base->clk;
                idx = calc_wheel_index(expires, clk);
@@ -964,6 +977,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                }
        } else {
                base = lock_timer_base(timer, &flags);
+               forward_timer_base(base);
        }
 
        ret = detach_if_pending(timer, base, false);
@@ -991,12 +1005,10 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
                        raw_spin_lock(&base->lock);
                        WRITE_ONCE(timer->flags,
                                   (timer->flags & ~TIMER_BASEMASK) | base->cpu);
+                       forward_timer_base(base);
                }
        }
 
-       /* Try to forward a stale timer base clock */
-       forward_timer_base(base);
-
        timer->expires = expires;
        /*
         * If 'idx' was calculated above and the base time did not advance
@@ -1112,6 +1124,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
                WRITE_ONCE(timer->flags,
                           (timer->flags & ~TIMER_BASEMASK) | cpu);
        }
+       forward_timer_base(base);
 
        debug_activate(timer, timer->expires);
        internal_add_timer(base, timer);
@@ -1497,10 +1510,16 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
                if (!is_max_delta)
                        expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
                /*
-                * If we expect to sleep more than a tick, mark the base idle:
+                * If we expect to sleep more than a tick, mark the base idle.
+                * Also the tick is stopped so any added timer must forward
+                * the base clk itself to keep granularity small. This idle
+                * logic is only maintained for the BASE_STD base, deferrable
+                * timers may still see large granularity skew (by design).
                 */
-               if ((expires - basem) > TICK_NSEC)
+               if ((expires - basem) > TICK_NSEC) {
+                       base->must_forward_clk = true;
                        base->is_idle = true;
+               }
        }
        raw_spin_unlock(&base->lock);
 
@@ -1611,6 +1630,19 @@ static __latent_entropy void run_timer_softirq(struct softirq_action *h)
 {
        struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
 
+       /*
+        * must_forward_clk must be cleared before running timers so that any
+        * timer functions that call mod_timer will not try to forward the
+        * base. idle trcking / clock forwarding logic is only used with
+        * BASE_STD timers.
+        *
+        * The deferrable base does not do idle tracking at all, so we do
+        * not forward it. This can result in very large variations in
+        * granularity for deferrable timers, but they can be deferred for
+        * long periods due to idle.
+        */
+       base->must_forward_clk = false;
+
        __run_timers(base);
        if (IS_ENABLED(CONFIG_NO_HZ_COMMON) && base->nohz_active)
                __run_timers(this_cpu_ptr(&timer_bases[BASE_DEF]));
index 37385193a6084ed1b8fdd794eb0938c2021fcfa4..dc498b605d5dd36137eaba7bd0ee93da72a36c33 100644 (file)
@@ -204,10 +204,36 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
                fmt_cnt++;
        }
 
-       return __trace_printk(1/* fake ip will not be printed */, fmt,
-                             mod[0] == 2 ? arg1 : mod[0] == 1 ? (long) arg1 : (u32) arg1,
-                             mod[1] == 2 ? arg2 : mod[1] == 1 ? (long) arg2 : (u32) arg2,
-                             mod[2] == 2 ? arg3 : mod[2] == 1 ? (long) arg3 : (u32) arg3);
+/* Horrid workaround for getting va_list handling working with different
+ * argument type combinations generically for 32 and 64 bit archs.
+ */
+#define __BPF_TP_EMIT()        __BPF_ARG3_TP()
+#define __BPF_TP(...)                                                  \
+       __trace_printk(1 /* Fake ip will not be printed. */,            \
+                      fmt, ##__VA_ARGS__)
+
+#define __BPF_ARG1_TP(...)                                             \
+       ((mod[0] == 2 || (mod[0] == 1 && __BITS_PER_LONG == 64))        \
+         ? __BPF_TP(arg1, ##__VA_ARGS__)                               \
+         : ((mod[0] == 1 || (mod[0] == 0 && __BITS_PER_LONG == 32))    \
+             ? __BPF_TP((long)arg1, ##__VA_ARGS__)                     \
+             : __BPF_TP((u32)arg1, ##__VA_ARGS__)))
+
+#define __BPF_ARG2_TP(...)                                             \
+       ((mod[1] == 2 || (mod[1] == 1 && __BITS_PER_LONG == 64))        \
+         ? __BPF_ARG1_TP(arg2, ##__VA_ARGS__)                          \
+         : ((mod[1] == 1 || (mod[1] == 0 && __BITS_PER_LONG == 32))    \
+             ? __BPF_ARG1_TP((long)arg2, ##__VA_ARGS__)                \
+             : __BPF_ARG1_TP((u32)arg2, ##__VA_ARGS__)))
+
+#define __BPF_ARG3_TP(...)                                             \
+       ((mod[2] == 2 || (mod[2] == 1 && __BITS_PER_LONG == 64))        \
+         ? __BPF_ARG2_TP(arg3, ##__VA_ARGS__)                          \
+         : ((mod[2] == 1 || (mod[2] == 0 && __BITS_PER_LONG == 32))    \
+             ? __BPF_ARG2_TP((long)arg3, ##__VA_ARGS__)                \
+             : __BPF_ARG2_TP((u32)arg3, ##__VA_ARGS__)))
+
+       return __BPF_TP_EMIT();
 }
 
 static const struct bpf_func_proto bpf_trace_printk_proto = {
index 02004ae918608f915b28341b6ed1b3b7f551c5a5..96cea88fa00fcdab41db0a2054ef6cfe50a778aa 100644 (file)
@@ -889,6 +889,10 @@ static int profile_graph_entry(struct ftrace_graph_ent *trace)
 
        function_profile_call(trace->func, 0, NULL, NULL);
 
+       /* If function graph is shutting down, ret_stack can be NULL */
+       if (!current->ret_stack)
+               return 0;
+
        if (index >= 0 && index < FTRACE_RETFUNC_DEPTH)
                current->ret_stack[index].subtime = 0;
 
index 529cc50d7243d6c1007e517bcdc83a5312f7ae6b..81279c6602ff1753d8c38c8def566c3576578962 100644 (file)
@@ -4386,15 +4386,19 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
  * the page that was allocated, with the read page of the buffer.
  *
  * Returns:
- *  The page allocated, or NULL on error.
+ *  The page allocated, or ERR_PTR
  */
 void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu)
 {
-       struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
+       struct ring_buffer_per_cpu *cpu_buffer;
        struct buffer_data_page *bpage = NULL;
        unsigned long flags;
        struct page *page;
 
+       if (!cpumask_test_cpu(cpu, buffer->cpumask))
+               return ERR_PTR(-ENODEV);
+
+       cpu_buffer = buffer->buffers[cpu];
        local_irq_save(flags);
        arch_spin_lock(&cpu_buffer->lock);
 
@@ -4412,7 +4416,7 @@ void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu)
        page = alloc_pages_node(cpu_to_node(cpu),
                                GFP_KERNEL | __GFP_NORETRY, 0);
        if (!page)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        bpage = page_address(page);
 
@@ -4467,8 +4471,8 @@ EXPORT_SYMBOL_GPL(ring_buffer_free_read_page);
  *
  * for example:
  *     rpage = ring_buffer_alloc_read_page(buffer, cpu);
- *     if (!rpage)
- *             return error;
+ *     if (IS_ERR(rpage))
+ *             return PTR_ERR(rpage);
  *     ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0);
  *     if (ret >= 0)
  *             process_page(rpage, ret);
index 9fbcaf56788626335bfd5412dffaf820a9b308bc..68ee79afe31c223218e8fab1ffd829b7be1226d3 100644 (file)
@@ -113,7 +113,7 @@ static enum event_status read_page(int cpu)
        int i;
 
        bpage = ring_buffer_alloc_read_page(buffer, cpu);
-       if (!bpage)
+       if (IS_ERR(bpage))
                return EVENT_DROPPED;
 
        ret = ring_buffer_read_page(buffer, &bpage, PAGE_SIZE, cpu, 1);
index 42b9355033d45d5a7c27bf0606799772e70d7421..44004d8aa3b33f259ed90dd13ce4c102034da23a 100644 (file)
@@ -6598,7 +6598,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
 {
        struct ftrace_buffer_info *info = filp->private_data;
        struct trace_iterator *iter = &info->iter;
-       ssize_t ret;
+       ssize_t ret = 0;
        ssize_t size;
 
        if (!count)
@@ -6612,10 +6612,15 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
        if (!info->spare) {
                info->spare = ring_buffer_alloc_read_page(iter->trace_buffer->buffer,
                                                          iter->cpu_file);
-               info->spare_cpu = iter->cpu_file;
+               if (IS_ERR(info->spare)) {
+                       ret = PTR_ERR(info->spare);
+                       info->spare = NULL;
+               } else {
+                       info->spare_cpu = iter->cpu_file;
+               }
        }
        if (!info->spare)
-               return -ENOMEM;
+               return ret;
 
        /* Do we have previous read data to read? */
        if (info->read < PAGE_SIZE)
@@ -6790,8 +6795,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
                ref->ref = 1;
                ref->buffer = iter->trace_buffer->buffer;
                ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
-               if (!ref->page) {
-                       ret = -ENOMEM;
+               if (IS_ERR(ref->page)) {
+                       ret = PTR_ERR(ref->page);
+                       ref->page = NULL;
                        kfree(ref);
                        break;
                }
@@ -8293,6 +8299,7 @@ __init static int tracer_alloc_buffers(void)
        if (ret < 0)
                goto out_free_cpumask;
        /* Used for event triggers */
+       ret = -ENOMEM;
        temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE);
        if (!temp_buffer)
                goto out_rm_hp_state;
@@ -8407,4 +8414,4 @@ __init static int clear_boot_tracer(void)
 }
 
 fs_initcall(tracer_init_tracefs);
-late_initcall(clear_boot_tracer);
+late_initcall_sync(clear_boot_tracer);
index 59a411ff60c709834121fc70363c74560dfe1ff5..181e139a8057bed695ad6d1d7460036e378f5ca0 100644 (file)
@@ -1959,6 +1959,10 @@ static int create_filter(struct trace_event_call *call,
                if (err && set_str)
                        append_filter_err(ps, filter);
        }
+       if (err && !set_str) {
+               free_event_filter(filter);
+               filter = NULL;
+       }
        create_filter_finish(ps);
 
        *filterp = filter;
index 0a689bbb78ef4fe48d9e55cb867e836aea87a726..305039b122fafba242f73b5982289ce4a12a6e20 100644 (file)
@@ -221,16 +221,19 @@ void tracing_map_array_free(struct tracing_map_array *a)
        if (!a)
                return;
 
-       if (!a->pages) {
-               kfree(a);
-               return;
-       }
+       if (!a->pages)
+               goto free;
 
        for (i = 0; i < a->n_pages; i++) {
                if (!a->pages[i])
                        break;
                free_page((unsigned long)a->pages[i]);
        }
+
+       kfree(a->pages);
+
+ free:
+       kfree(a);
 }
 
 struct tracing_map_array *tracing_map_array_alloc(unsigned int n_elts,
index 06d3389bca0df01c8a730f7b270767f6ed35a8a9..f5d52024f6b72a9d1354b1a44c12c3e3b6af06a9 100644 (file)
@@ -240,6 +240,7 @@ static void set_sample_period(void)
         * hardlockup detector generates a warning
         */
        sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
+       watchdog_update_hrtimer_threshold(sample_period);
 }
 
 /* Commands for resetting the watchdog */
index 295a0d84934cb1d3a9a87abd4a8ac0f1d38656a5..3a09ea1b1d3d5e6e284d058052403ac1396804ca 100644 (file)
@@ -37,6 +37,62 @@ void arch_touch_nmi_watchdog(void)
 }
 EXPORT_SYMBOL(arch_touch_nmi_watchdog);
 
+#ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP
+static DEFINE_PER_CPU(ktime_t, last_timestamp);
+static DEFINE_PER_CPU(unsigned int, nmi_rearmed);
+static ktime_t watchdog_hrtimer_sample_threshold __read_mostly;
+
+void watchdog_update_hrtimer_threshold(u64 period)
+{
+       /*
+        * The hrtimer runs with a period of (watchdog_threshold * 2) / 5
+        *
+        * So it runs effectively with 2.5 times the rate of the NMI
+        * watchdog. That means the hrtimer should fire 2-3 times before
+        * the NMI watchdog expires. The NMI watchdog on x86 is based on
+        * unhalted CPU cycles, so if Turbo-Mode is enabled the CPU cycles
+        * might run way faster than expected and the NMI fires in a
+        * smaller period than the one deduced from the nominal CPU
+        * frequency. Depending on the Turbo-Mode factor this might be fast
+        * enough to get the NMI period smaller than the hrtimer watchdog
+        * period and trigger false positives.
+        *
+        * The sample threshold is used to check in the NMI handler whether
+        * the minimum time between two NMI samples has elapsed. That
+        * prevents false positives.
+        *
+        * Set this to 4/5 of the actual watchdog threshold period so the
+        * hrtimer is guaranteed to fire at least once within the real
+        * watchdog threshold.
+        */
+       watchdog_hrtimer_sample_threshold = period * 2;
+}
+
+static bool watchdog_check_timestamp(void)
+{
+       ktime_t delta, now = ktime_get_mono_fast_ns();
+
+       delta = now - __this_cpu_read(last_timestamp);
+       if (delta < watchdog_hrtimer_sample_threshold) {
+               /*
+                * If ktime is jiffies based, a stalled timer would prevent
+                * jiffies from being incremented and the filter would look
+                * at a stale timestamp and never trigger.
+                */
+               if (__this_cpu_inc_return(nmi_rearmed) < 10)
+                       return false;
+       }
+       __this_cpu_write(nmi_rearmed, 0);
+       __this_cpu_write(last_timestamp, now);
+       return true;
+}
+#else
+static inline bool watchdog_check_timestamp(void)
+{
+       return true;
+}
+#endif
+
 static struct perf_event_attr wd_hw_attr = {
        .type           = PERF_TYPE_HARDWARE,
        .config         = PERF_COUNT_HW_CPU_CYCLES,
@@ -61,6 +117,9 @@ static void watchdog_overflow_callback(struct perf_event *event,
                return;
        }
 
+       if (!watchdog_check_timestamp())
+               return;
+
        /* check for a hardlockup
         * This is done by making sure our timer interrupt
         * is incrementing.  The timer interrupt should have
index 98fe715522e8d1834083e608d32a78ed0600deb9..c617b9d1d6cb687c93fb0c65e8d05424f5dd3c43 100644 (file)
@@ -797,6 +797,13 @@ config HARDLOCKUP_DETECTOR_PERF
        bool
        select SOFTLOCKUP_DETECTOR
 
+#
+# Enables a timestamp based low pass filter to compensate for perf based
+# hard lockup detection which runs too fast due to turbo modes.
+#
+config HARDLOCKUP_CHECK_TIMESTAMP
+       bool
+
 #
 # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard
 # lockup detector rather than the perf based detector.
index 7d315fdb9f13d9b17d8a2aa129c75790c7599bdb..cf7b129b0b2b08adcc1aae98f990c384761532dc 100644 (file)
@@ -110,10 +110,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
        if (in_task()) {
                unsigned int fail_nth = READ_ONCE(current->fail_nth);
 
-               if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1))
-                       goto fail;
+               if (fail_nth) {
+                       if (!WRITE_ONCE(current->fail_nth, fail_nth - 1))
+                               goto fail;
 
-               return false;
+                       return false;
+               }
        }
 
        /* No need to check any other properties if the probability is 0 */
index 5a0f75a3bf01c1b259fb125fbe7266c186d83a71..eead4b339466854f51db30a17f17ee0472ebe6d3 100644 (file)
@@ -364,11 +364,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
        }
 
        miter.consumed = lzeros;
-       sg_miter_stop(&miter);
 
        nbytes -= lzeros;
        nbits = nbytes * 8;
        if (nbits > MAX_EXTERN_MPI_BITS) {
+               sg_miter_stop(&miter);
                pr_info("MPI: mpi too large (%u bits)\n", nbits);
                return NULL;
        }
@@ -376,6 +376,8 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
        if (nbytes > 0)
                nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8);
 
+       sg_miter_stop(&miter);
+
        nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB);
        val = mpi_alloc(nlimbs);
        if (!val)
index 6c1d678bcf8b00ff7b2d2fc70747045e6c14327a..ff9148969b9233ba7502b992b026d31e100be497 100644 (file)
@@ -485,7 +485,7 @@ static ssize_t config_show(struct device *dev,
                                config->test_driver);
        else
                len += snprintf(buf+len, PAGE_SIZE - len,
-                               "driver:\tEMTPY\n");
+                               "driver:\tEMPTY\n");
 
        if (config->test_fs)
                len += snprintf(buf+len, PAGE_SIZE - len,
@@ -493,7 +493,7 @@ static ssize_t config_show(struct device *dev,
                                config->test_fs);
        else
                len += snprintf(buf+len, PAGE_SIZE - len,
-                               "fs:\tEMTPY\n");
+                               "fs:\tEMPTY\n");
 
        mutex_unlock(&test_dev->config_mutex);
 
@@ -746,11 +746,11 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev,
                                                      strlen(test_str));
                break;
        case TEST_KMOD_FS_TYPE:
-               break;
                kfree_const(config->test_fs);
                config->test_driver = NULL;
                copied = config_copy_test_fs(config, test_str,
                                             strlen(test_str));
+               break;
        default:
                mutex_unlock(&test_dev->config_mutex);
                return -EINVAL;
@@ -880,10 +880,10 @@ static int test_dev_config_update_uint_sync(struct kmod_test_device *test_dev,
                                            int (*test_sync)(struct kmod_test_device *test_dev))
 {
        int ret;
-       long new;
+       unsigned long new;
        unsigned int old_val;
 
-       ret = kstrtol(buf, 10, &new);
+       ret = kstrtoul(buf, 10, &new);
        if (ret)
                return ret;
 
@@ -918,9 +918,9 @@ static int test_dev_config_update_uint_range(struct kmod_test_device *test_dev,
                                             unsigned int max)
 {
        int ret;
-       long new;
+       unsigned long new;
 
-       ret = kstrtol(buf, 10, &new);
+       ret = kstrtoul(buf, 10, &new);
        if (ret)
                return ret;
 
@@ -1146,7 +1146,7 @@ static struct kmod_test_device *register_test_dev_kmod(void)
        struct kmod_test_device *test_dev = NULL;
        int ret;
 
-       mutex_unlock(&reg_dev_mutex);
+       mutex_lock(&reg_dev_mutex);
 
        /* int should suffice for number of devices, test for wrap */
        if (unlikely(num_test_devs + 1) < 0) {
index 9075aa54e95517cdbb1094f04e72c36357401e52..b06d9fe23a28c14f71c3263daaa84965dadeee45 100644 (file)
@@ -24,7 +24,7 @@ struct page *balloon_page_enqueue(struct balloon_dev_info *b_dev_info)
 {
        unsigned long flags;
        struct page *page = alloc_page(balloon_mapping_gfp_mask() |
-                               __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_ZERO);
+                                      __GFP_NOMEMALLOC | __GFP_NORETRY);
        if (!page)
                return NULL;
 
index 595b757bef72722fb2715afd9ab0cd1536181c9e..c03ccbc405a066038619361cf995f675dc2efaa1 100644 (file)
@@ -167,7 +167,7 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
        char name[16];
        int u32s;
 
-       sprintf(name, "cma-%s", cma->name);
+       scnprintf(name, sizeof(name), "cma-%s", cma->name);
 
        tmp = debugfs_create_dir(name, cma_debugfs_root);
 
index db1cd26d8752022b7f8b576cdff78f5412209d39..5715448ab0b53db5d8bd4b64d47706f7deaaf7a6 100644 (file)
@@ -124,9 +124,7 @@ void dump_mm(const struct mm_struct *mm)
 #ifdef CONFIG_NUMA_BALANCING
                "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n"
 #endif
-#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
                "tlb_flush_pending %d\n"
-#endif
                "def_flags: %#lx(%pGv)\n",
 
                mm, mm->mmap, mm->vmacache_seqnum, mm->task_size,
@@ -158,9 +156,7 @@ void dump_mm(const struct mm_struct *mm)
 #ifdef CONFIG_NUMA_BALANCING
                mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq,
 #endif
-#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
-               mm->tlb_flush_pending,
-#endif
+               atomic_read(&mm->tlb_flush_pending),
                mm->def_flags, &mm->def_flags
        );
 }
index a49702445ce05beeb8d80b46f0ee57c116986be2..65b4b6e7f7bde69620b73af705ecca33629a8f79 100644 (file)
@@ -885,6 +885,7 @@ void __init pagecache_init(void)
        page_writeback_init();
 }
 
+/* This has the same layout as wait_bit_key - see fs/cachefiles/rdwr.c */
 struct wait_page_key {
        struct page *page;
        int bit_nr;
@@ -909,8 +910,10 @@ static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync,
 
        if (wait_page->bit_nr != key->bit_nr)
                return 0;
+
+       /* Stop walking if it's locked */
        if (test_bit(key->bit_nr, &key->page->flags))
-               return 0;
+               return -1;
 
        return autoremove_wake_function(wait, mode, sync, key);
 }
@@ -964,6 +967,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
        int ret = 0;
 
        init_wait(wait);
+       wait->flags = lock ? WQ_FLAG_EXCLUSIVE : 0;
        wait->func = wake_page_function;
        wait_page.page = page;
        wait_page.bit_nr = bit_nr;
@@ -972,10 +976,7 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
                spin_lock_irq(&q->lock);
 
                if (likely(list_empty(&wait->entry))) {
-                       if (lock)
-                               __add_wait_queue_entry_tail_exclusive(q, wait);
-                       else
-                               __add_wait_queue(q, wait);
+                       __add_wait_queue_entry_tail(q, wait);
                        SetPageWaiters(page);
                }
 
@@ -985,10 +986,6 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
 
                if (likely(test_bit(bit_nr, &page->flags))) {
                        io_schedule();
-                       if (unlikely(signal_pending_state(state, current))) {
-                               ret = -EINTR;
-                               break;
-                       }
                }
 
                if (lock) {
@@ -998,6 +995,11 @@ static inline int wait_on_page_bit_common(wait_queue_head_t *q,
                        if (!test_bit(bit_nr, &page->flags))
                                break;
                }
+
+               if (unlikely(signal_pending_state(state, current))) {
+                       ret = -EINTR;
+                       break;
+               }
        }
 
        finish_wait(q, wait);
@@ -1039,7 +1041,7 @@ void add_page_wait_queue(struct page *page, wait_queue_entry_t *waiter)
        unsigned long flags;
 
        spin_lock_irqsave(&q->lock, flags);
-       __add_wait_queue(q, waiter);
+       __add_wait_queue_entry_tail(q, waiter);
        SetPageWaiters(page);
        spin_unlock_irqrestore(&q->lock, flags);
 }
index 86975dec0ba160feadfb8aa0d13b8f2be943638d..90731e3b7e589ea9f83c21827916917a27f71b82 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/userfaultfd_k.h>
 #include <linux/page_idle.h>
 #include <linux/shmem_fs.h>
+#include <linux/oom.h>
 
 #include <asm/tlb.h>
 #include <asm/pgalloc.h>
@@ -550,6 +551,7 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
        struct mem_cgroup *memcg;
        pgtable_t pgtable;
        unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
+       int ret = 0;
 
        VM_BUG_ON_PAGE(!PageCompound(page), page);
 
@@ -561,9 +563,8 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
 
        pgtable = pte_alloc_one(vma->vm_mm, haddr);
        if (unlikely(!pgtable)) {
-               mem_cgroup_cancel_charge(page, memcg, true);
-               put_page(page);
-               return VM_FAULT_OOM;
+               ret = VM_FAULT_OOM;
+               goto release;
        }
 
        clear_huge_page(page, haddr, HPAGE_PMD_NR);
@@ -576,13 +577,14 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
 
        vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
        if (unlikely(!pmd_none(*vmf->pmd))) {
-               spin_unlock(vmf->ptl);
-               mem_cgroup_cancel_charge(page, memcg, true);
-               put_page(page);
-               pte_free(vma->vm_mm, pgtable);
+               goto unlock_release;
        } else {
                pmd_t entry;
 
+               ret = check_stable_address_space(vma->vm_mm);
+               if (ret)
+                       goto unlock_release;
+
                /* Deliver the page fault to userland */
                if (userfaultfd_missing(vma)) {
                        int ret;
@@ -610,6 +612,15 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
        }
 
        return 0;
+unlock_release:
+       spin_unlock(vmf->ptl);
+release:
+       if (pgtable)
+               pte_free(vma->vm_mm, pgtable);
+       mem_cgroup_cancel_charge(page, memcg, true);
+       put_page(page);
+       return ret;
+
 }
 
 /*
@@ -688,7 +699,10 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf)
                ret = 0;
                set = false;
                if (pmd_none(*vmf->pmd)) {
-                       if (userfaultfd_missing(vma)) {
+                       ret = check_stable_address_space(vma->vm_mm);
+                       if (ret) {
+                               spin_unlock(vmf->ptl);
+                       } else if (userfaultfd_missing(vma)) {
                                spin_unlock(vmf->ptl);
                                ret = handle_userfault(vmf, VM_UFFD_MISSING);
                                VM_BUG_ON(ret & VM_FAULT_FALLBACK);
@@ -1495,6 +1509,13 @@ int do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t pmd)
                goto clear_pmdnuma;
        }
 
+       /*
+        * The page_table_lock above provides a memory barrier
+        * with change_protection_range.
+        */
+       if (mm_tlb_flush_pending(vma->vm_mm))
+               flush_tlb_range(vma, haddr, haddr + HPAGE_PMD_SIZE);
+
        /*
         * Migrate the THP to the requested node, returns with page unlocked
         * and access rights restored.
index a1a0ac0ad6f67ad479916fcbc43036973ddca824..31e207cb399bebd11371e46eb26f625a5b74487c 100644 (file)
@@ -4062,9 +4062,9 @@ out:
        return ret;
 out_release_unlock:
        spin_unlock(ptl);
-out_release_nounlock:
        if (vm_shared)
                unlock_page(page);
+out_release_nounlock:
        put_page(page);
        goto out;
 }
index 4dc92f138786988c4ef0f9d371ff8a48b2e6e905..db20f8436bc3c15bf05f86ccec5e7b1f80d807cc 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1038,7 +1038,8 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page,
                goto out_unlock;
 
        if (pte_write(*pvmw.pte) || pte_dirty(*pvmw.pte) ||
-           (pte_protnone(*pvmw.pte) && pte_savedwrite(*pvmw.pte))) {
+           (pte_protnone(*pvmw.pte) && pte_savedwrite(*pvmw.pte)) ||
+                                               mm_tlb_flush_pending(mm)) {
                pte_t entry;
 
                swapped = PageSwapCache(page);
index 47d8d8a25eae49604f81bcffe40e45ef9b8e4c6c..4d7d1e5ddba9d9b26583b6ca9f05774247d9b1d8 100644 (file)
@@ -368,8 +368,8 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
                                pte_offset_map_lock(mm, pmd, addr, &ptl);
                                goto out;
                        }
-                       put_page(page);
                        unlock_page(page);
+                       put_page(page);
                        pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
                        pte--;
                        addr -= PAGE_SIZE;
@@ -613,6 +613,7 @@ static int madvise_inject_error(int behavior,
                unsigned long start, unsigned long end)
 {
        struct page *page;
+       struct zone *zone;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
@@ -646,6 +647,11 @@ static int madvise_inject_error(int behavior,
                if (ret)
                        return ret;
        }
+
+       /* Ensure that all poisoned pages are removed from per-cpu lists */
+       for_each_populated_zone(zone)
+               drain_all_pages(zone);
+
        return 0;
 }
 #endif
index 2cb25fe4452c279c5ff6ff74cbbfee64128d820e..91205780e6b151f8239574c5f97b8d5ebc89b59f 100644 (file)
@@ -285,31 +285,27 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
 }
 
 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
-
-phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
-                                       phys_addr_t *addr)
-{
-       if (memblock.reserved.regions == memblock_reserved_init_regions)
-               return 0;
-
-       *addr = __pa(memblock.reserved.regions);
-
-       return PAGE_ALIGN(sizeof(struct memblock_region) *
-                         memblock.reserved.max);
-}
-
-phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
-                                       phys_addr_t *addr)
+/**
+ * Discard memory and reserved arrays if they were allocated
+ */
+void __init memblock_discard(void)
 {
-       if (memblock.memory.regions == memblock_memory_init_regions)
-               return 0;
+       phys_addr_t addr, size;
 
-       *addr = __pa(memblock.memory.regions);
+       if (memblock.reserved.regions != memblock_reserved_init_regions) {
+               addr = __pa(memblock.reserved.regions);
+               size = PAGE_ALIGN(sizeof(struct memblock_region) *
+                                 memblock.reserved.max);
+               __memblock_free_late(addr, size);
+       }
 
-       return PAGE_ALIGN(sizeof(struct memblock_region) *
-                         memblock.memory.max);
+       if (memblock.memory.regions != memblock_memory_init_regions) {
+               addr = __pa(memblock.memory.regions);
+               size = PAGE_ALIGN(sizeof(struct memblock_region) *
+                                 memblock.memory.max);
+               __memblock_free_late(addr, size);
+       }
 }
-
 #endif
 
 /**
index 3df3c04d73ab08e3bbb663f25b2e195b396d2149..e09741af816f8a6d5343546ebd23eb7f25f8ab54 100644 (file)
@@ -1611,9 +1611,13 @@ cleanup:
  * @page: the page
  *
  * This function protects unlocked LRU pages from being moved to
- * another cgroup and stabilizes their page->mem_cgroup binding.
+ * another cgroup.
+ *
+ * It ensures lifetime of the returned memcg. Caller is responsible
+ * for the lifetime of the page; __unlock_page_memcg() is available
+ * when @page might get freed inside the locked section.
  */
-void lock_page_memcg(struct page *page)
+struct mem_cgroup *lock_page_memcg(struct page *page)
 {
        struct mem_cgroup *memcg;
        unsigned long flags;
@@ -1622,18 +1626,24 @@ void lock_page_memcg(struct page *page)
         * The RCU lock is held throughout the transaction.  The fast
         * path can get away without acquiring the memcg->move_lock
         * because page moving starts with an RCU grace period.
-        */
+        *
+        * The RCU lock also protects the memcg from being freed when
+        * the page state that is going to change is the only thing
+        * preventing the page itself from being freed. E.g. writeback
+        * doesn't hold a page reference and relies on PG_writeback to
+        * keep off truncation, migration and so forth.
+         */
        rcu_read_lock();
 
        if (mem_cgroup_disabled())
-               return;
+               return NULL;
 again:
        memcg = page->mem_cgroup;
        if (unlikely(!memcg))
-               return;
+               return NULL;
 
        if (atomic_read(&memcg->moving_account) <= 0)
-               return;
+               return memcg;
 
        spin_lock_irqsave(&memcg->move_lock, flags);
        if (memcg != page->mem_cgroup) {
@@ -1649,18 +1659,18 @@ again:
        memcg->move_lock_task = current;
        memcg->move_lock_flags = flags;
 
-       return;
+       return memcg;
 }
 EXPORT_SYMBOL(lock_page_memcg);
 
 /**
- * unlock_page_memcg - unlock a page->mem_cgroup binding
- * @page: the page
+ * __unlock_page_memcg - unlock and unpin a memcg
+ * @memcg: the memcg
+ *
+ * Unlock and unpin a memcg returned by lock_page_memcg().
  */
-void unlock_page_memcg(struct page *page)
+void __unlock_page_memcg(struct mem_cgroup *memcg)
 {
-       struct mem_cgroup *memcg = page->mem_cgroup;
-
        if (memcg && memcg->move_lock_task == current) {
                unsigned long flags = memcg->move_lock_flags;
 
@@ -1672,6 +1682,15 @@ void unlock_page_memcg(struct page *page)
 
        rcu_read_unlock();
 }
+
+/**
+ * unlock_page_memcg - unlock a page->mem_cgroup binding
+ * @page: the page
+ */
+void unlock_page_memcg(struct page *page)
+{
+       __unlock_page_memcg(page->mem_cgroup);
+}
 EXPORT_SYMBOL(unlock_page_memcg);
 
 /*
index f65beaad319be4c597f9a071771e5f376234d753..56e48e4593cb76b1f89be8d2afd72762ebbfff4d 100644 (file)
@@ -68,6 +68,7 @@
 #include <linux/debugfs.h>
 #include <linux/userfaultfd_k.h>
 #include <linux/dax.h>
+#include <linux/oom.h>
 
 #include <asm/io.h>
 #include <asm/mmu_context.h>
@@ -215,12 +216,8 @@ static bool tlb_next_batch(struct mmu_gather *tlb)
        return true;
 }
 
-/* tlb_gather_mmu
- *     Called to initialize an (on-stack) mmu_gather structure for page-table
- *     tear-down from @mm. The @fullmm argument is used when @mm is without
- *     users and we're going to destroy the full address space (exit/execve).
- */
-void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
+void arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+                               unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
 
@@ -275,10 +272,14 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
  *     Called at the end of the shootdown operation to free up any resources
  *     that were required.
  */
-void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
+void arch_tlb_finish_mmu(struct mmu_gather *tlb,
+               unsigned long start, unsigned long end, bool force)
 {
        struct mmu_gather_batch *batch, *next;
 
+       if (force)
+               __tlb_adjust_range(tlb, start, end - start);
+
        tlb_flush_mmu(tlb);
 
        /* keep the page table cache within bounds */
@@ -398,6 +399,34 @@ void tlb_remove_table(struct mmu_gather *tlb, void *table)
 
 #endif /* CONFIG_HAVE_RCU_TABLE_FREE */
 
+/* tlb_gather_mmu
+ *     Called to initialize an (on-stack) mmu_gather structure for page-table
+ *     tear-down from @mm. The @fullmm argument is used when @mm is without
+ *     users and we're going to destroy the full address space (exit/execve).
+ */
+void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm,
+                       unsigned long start, unsigned long end)
+{
+       arch_tlb_gather_mmu(tlb, mm, start, end);
+       inc_tlb_flush_pending(tlb->mm);
+}
+
+void tlb_finish_mmu(struct mmu_gather *tlb,
+               unsigned long start, unsigned long end)
+{
+       /*
+        * If there are parallel threads are doing PTE changes on same range
+        * under non-exclusive lock(e.g., mmap_sem read-side) but defer TLB
+        * flush by batching, a thread has stable TLB entry can fail to flush
+        * the TLB by observing pte_none|!pte_dirty, for example so flush TLB
+        * forcefully if we detect parallel PTE batching threads.
+        */
+       bool force = mm_tlb_flush_nested(tlb->mm);
+
+       arch_tlb_finish_mmu(tlb, start, end, force);
+       dec_tlb_flush_pending(tlb->mm);
+}
+
 /*
  * Note: this doesn't free the actual pages themselves. That
  * has been handled earlier when unmapping all the memory regions.
@@ -2865,6 +2894,7 @@ static int do_anonymous_page(struct vm_fault *vmf)
        struct vm_area_struct *vma = vmf->vma;
        struct mem_cgroup *memcg;
        struct page *page;
+       int ret = 0;
        pte_t entry;
 
        /* File mapping without ->vm_ops ? */
@@ -2897,6 +2927,9 @@ static int do_anonymous_page(struct vm_fault *vmf)
                                vmf->address, &vmf->ptl);
                if (!pte_none(*vmf->pte))
                        goto unlock;
+               ret = check_stable_address_space(vma->vm_mm);
+               if (ret)
+                       goto unlock;
                /* Deliver the page fault to userland, check inside PT lock */
                if (userfaultfd_missing(vma)) {
                        pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -2931,6 +2964,10 @@ static int do_anonymous_page(struct vm_fault *vmf)
        if (!pte_none(*vmf->pte))
                goto release;
 
+       ret = check_stable_address_space(vma->vm_mm);
+       if (ret)
+               goto release;
+
        /* Deliver the page fault to userland, check inside PT lock */
        if (userfaultfd_missing(vma)) {
                pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -2950,7 +2987,7 @@ setpte:
        update_mmu_cache(vma, vmf->address, vmf->pte);
 unlock:
        pte_unmap_unlock(vmf->pte, vmf->ptl);
-       return 0;
+       return ret;
 release:
        mem_cgroup_cancel_charge(page, memcg, false);
        put_page(page);
@@ -3224,7 +3261,7 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
 int finish_fault(struct vm_fault *vmf)
 {
        struct page *page;
-       int ret;
+       int ret = 0;
 
        /* Did we COW the page? */
        if ((vmf->flags & FAULT_FLAG_WRITE) &&
@@ -3232,7 +3269,15 @@ int finish_fault(struct vm_fault *vmf)
                page = vmf->cow_page;
        else
                page = vmf->page;
-       ret = alloc_set_pte(vmf, vmf->memcg, page);
+
+       /*
+        * check even for read faults because we might have lost our CoWed
+        * page
+        */
+       if (!(vmf->vma->vm_flags & VM_SHARED))
+               ret = check_stable_address_space(vmf->vma->vm_mm);
+       if (!ret)
+               ret = alloc_set_pte(vmf, vmf->memcg, page);
        if (vmf->pte)
                pte_unmap_unlock(vmf->pte, vmf->ptl);
        return ret;
@@ -3872,19 +3917,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
                        mem_cgroup_oom_synchronize(false);
        }
 
-       /*
-        * This mm has been already reaped by the oom reaper and so the
-        * refault cannot be trusted in general. Anonymous refaults would
-        * lose data and give a zero page instead e.g. This is especially
-        * problem for use_mm() because regular tasks will just die and
-        * the corrupted data will not be visible anywhere while kthread
-        * will outlive the oom victim and potentially propagate the date
-        * further.
-        */
-       if (unlikely((current->flags & PF_KTHREAD) && !(ret & VM_FAULT_ERROR)
-                               && test_bit(MMF_UNSTABLE, &vma->vm_mm->flags)))
-               ret = VM_FAULT_SIGBUS;
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(handle_mm_fault);
@@ -3976,7 +4008,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
 #endif /* __PAGETABLE_PMD_FOLDED */
 
 static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
-               pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
+                           unsigned long *start, unsigned long *end,
+                           pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
 {
        pgd_t *pgd;
        p4d_t *p4d;
@@ -4003,17 +4036,29 @@ static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
                if (!pmdpp)
                        goto out;
 
+               if (start && end) {
+                       *start = address & PMD_MASK;
+                       *end = *start + PMD_SIZE;
+                       mmu_notifier_invalidate_range_start(mm, *start, *end);
+               }
                *ptlp = pmd_lock(mm, pmd);
                if (pmd_huge(*pmd)) {
                        *pmdpp = pmd;
                        return 0;
                }
                spin_unlock(*ptlp);
+               if (start && end)
+                       mmu_notifier_invalidate_range_end(mm, *start, *end);
        }
 
        if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
                goto out;
 
+       if (start && end) {
+               *start = address & PAGE_MASK;
+               *end = *start + PAGE_SIZE;
+               mmu_notifier_invalidate_range_start(mm, *start, *end);
+       }
        ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
        if (!pte_present(*ptep))
                goto unlock;
@@ -4021,6 +4066,8 @@ static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
        return 0;
 unlock:
        pte_unmap_unlock(ptep, *ptlp);
+       if (start && end)
+               mmu_notifier_invalidate_range_end(mm, *start, *end);
 out:
        return -EINVAL;
 }
@@ -4032,20 +4079,21 @@ static inline int follow_pte(struct mm_struct *mm, unsigned long address,
 
        /* (void) is needed to make gcc happy */
        (void) __cond_lock(*ptlp,
-                          !(res = __follow_pte_pmd(mm, address, ptepp, NULL,
-                                          ptlp)));
+                          !(res = __follow_pte_pmd(mm, address, NULL, NULL,
+                                                   ptepp, NULL, ptlp)));
        return res;
 }
 
 int follow_pte_pmd(struct mm_struct *mm, unsigned long address,
+                            unsigned long *start, unsigned long *end,
                             pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp)
 {
        int res;
 
        /* (void) is needed to make gcc happy */
        (void) __cond_lock(*ptlp,
-                          !(res = __follow_pte_pmd(mm, address, ptepp, pmdpp,
-                                          ptlp)));
+                          !(res = __follow_pte_pmd(mm, address, start, end,
+                                                   ptepp, pmdpp, ptlp)));
        return res;
 }
 EXPORT_SYMBOL(follow_pte_pmd);
index d911fa5cb2a73fe464042a59e1c2676c1129239d..618ab125228baec0810146a0638ce80ce4d50284 100644 (file)
@@ -861,11 +861,6 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
                *policy |= (pol->flags & MPOL_MODE_FLAGS);
        }
 
-       if (vma) {
-               up_read(&current->mm->mmap_sem);
-               vma = NULL;
-       }
-
        err = 0;
        if (nmask) {
                if (mpol_store_user_nodemask(pol)) {
index 62767155187356d54d1fa7333ad402e76183ca0b..e84eeb4e43566c7b1ee85e3759b1b60b72c1c532 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/page_idle.h>
 #include <linux/page_owner.h>
 #include <linux/sched/mm.h>
+#include <linux/ptrace.h>
 
 #include <asm/tlbflush.h>
 
@@ -1652,7 +1653,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
                const int __user *, nodes,
                int __user *, status, int, flags)
 {
-       const struct cred *cred = current_cred(), *tcred;
        struct task_struct *task;
        struct mm_struct *mm;
        int err;
@@ -1676,14 +1676,9 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
 
        /*
         * Check if this process has the right to modify the specified
-        * process. The right exists if the process has administrative
-        * capabilities, superuser privileges or the same
-        * userid as the target process.
+        * process. Use the regular "ptrace_may_access()" checks.
         */
-       tcred = __task_cred(task);
-       if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
-           !uid_eq(cred->uid,  tcred->suid) && !uid_eq(cred->uid,  tcred->uid) &&
-           !capable(CAP_SYS_NICE)) {
+       if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
                rcu_read_unlock();
                err = -EPERM;
                goto out;
@@ -1937,12 +1932,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm,
                put_page(new_page);
                goto out_fail;
        }
-       /*
-        * We are not sure a pending tlb flush here is for a huge page
-        * mapping or not. Hence use the tlb range variant
-        */
-       if (mm_tlb_flush_pending(mm))
-               flush_tlb_range(vma, mmun_start, mmun_end);
 
        /* Prepare a page as a migration target */
        __SetPageLocked(new_page);
index 54ca545629286223a16ef931830a3757b29da77d..314285284e6e6a4c764d0f8126dd0fecf8f7f84e 100644 (file)
@@ -174,20 +174,6 @@ void __mmu_notifier_change_pte(struct mm_struct *mm, unsigned long address,
        srcu_read_unlock(&srcu, id);
 }
 
-void __mmu_notifier_invalidate_page(struct mm_struct *mm,
-                                         unsigned long address)
-{
-       struct mmu_notifier *mn;
-       int id;
-
-       id = srcu_read_lock(&srcu);
-       hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) {
-               if (mn->ops->invalidate_page)
-                       mn->ops->invalidate_page(mn, mm, address);
-       }
-       srcu_read_unlock(&srcu, id);
-}
-
 void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
                                  unsigned long start, unsigned long end)
 {
index 4180ad8cc9c5e70c661efc8f30416af40e9c0066..bd0f409922cb2fc133f9fecba64a839380d4f937 100644 (file)
@@ -244,7 +244,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
        BUG_ON(addr >= end);
        pgd = pgd_offset(mm, addr);
        flush_cache_range(vma, addr, end);
-       set_tlb_flush_pending(mm);
+       inc_tlb_flush_pending(mm);
        do {
                next = pgd_addr_end(addr, end);
                if (pgd_none_or_clear_bad(pgd))
@@ -256,7 +256,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
        /* Only flush the TLB if we actually modified any entries: */
        if (pages)
                flush_tlb_range(vma, start, end);
-       clear_tlb_flush_pending(mm);
+       dec_tlb_flush_pending(mm);
 
        return pages;
 }
index 36454d0f96ee6b91383554c83015a2b47e66f038..3637809a18d04f9c20d1b00d70687ae1eb00b282 100644 (file)
@@ -146,22 +146,6 @@ static unsigned long __init free_low_memory_core_early(void)
                                NULL)
                count += __free_memory_core(start, end);
 
-#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
-       {
-               phys_addr_t size;
-
-               /* Free memblock.reserved array if it was allocated */
-               size = get_allocated_memblock_reserved_regions_info(&start);
-               if (size)
-                       count += __free_memory_core(start, start + size);
-
-               /* Free memblock.memory array if it was allocated */
-               size = get_allocated_memblock_memory_regions_info(&start);
-               if (size)
-                       count += __free_memory_core(start, start + size);
-       }
-#endif
-
        return count;
 }
 
index 96e93b214d317baf4fb4ffbb5fcbe726e110980d..bf050ab025b76a268cd09a37173eac4f86febcb8 100644 (file)
@@ -2724,9 +2724,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io);
 int test_clear_page_writeback(struct page *page)
 {
        struct address_space *mapping = page_mapping(page);
+       struct mem_cgroup *memcg;
+       struct lruvec *lruvec;
        int ret;
 
-       lock_page_memcg(page);
+       memcg = lock_page_memcg(page);
+       lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page));
        if (mapping && mapping_use_writeback_tags(mapping)) {
                struct inode *inode = mapping->host;
                struct backing_dev_info *bdi = inode_to_bdi(inode);
@@ -2754,12 +2757,18 @@ int test_clear_page_writeback(struct page *page)
        } else {
                ret = TestClearPageWriteback(page);
        }
+       /*
+        * NOTE: Page might be free now! Writeback doesn't hold a page
+        * reference on its own, it relies on truncation to wait for
+        * the clearing of PG_writeback. The below can only access
+        * page state that is static across allocation cycles.
+        */
        if (ret) {
-               dec_lruvec_page_state(page, NR_WRITEBACK);
+               dec_lruvec_state(lruvec, NR_WRITEBACK);
                dec_zone_page_state(page, NR_ZONE_WRITE_PENDING);
                inc_node_page_state(page, NR_WRITTEN);
        }
-       unlock_page_memcg(page);
+       __unlock_page_memcg(memcg);
        return ret;
 }
 
index fc32aa81f3593537cc2b11d5f63b5c5f517097a4..1423da8dd16f5bdc83e20ddf6665b2022a9a6492 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/kthread.h>
 #include <linux/memcontrol.h>
 #include <linux/ftrace.h>
+#include <linux/nmi.h>
 
 #include <asm/sections.h>
 #include <asm/tlbflush.h>
@@ -1584,6 +1585,10 @@ void __init page_alloc_init_late(void)
        /* Reinit limits that are based on free pages after the kernel is up */
        files_maxfiles_init();
 #endif
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
+       /* Discard memblock private memory */
+       memblock_discard();
+#endif
 
        for_each_populated_zone(zone)
                set_zone_contiguous(zone);
@@ -2531,9 +2536,14 @@ void drain_all_pages(struct zone *zone)
 
 #ifdef CONFIG_HIBERNATION
 
+/*
+ * Touch the watchdog for every WD_PAGE_COUNT pages.
+ */
+#define WD_PAGE_COUNT  (128*1024)
+
 void mark_free_pages(struct zone *zone)
 {
-       unsigned long pfn, max_zone_pfn;
+       unsigned long pfn, max_zone_pfn, page_count = WD_PAGE_COUNT;
        unsigned long flags;
        unsigned int order, t;
        struct page *page;
@@ -2548,6 +2558,11 @@ void mark_free_pages(struct zone *zone)
                if (pfn_valid(pfn)) {
                        page = pfn_to_page(pfn);
 
+                       if (!--page_count) {
+                               touch_nmi_watchdog();
+                               page_count = WD_PAGE_COUNT;
+                       }
+
                        if (page_zone(page) != zone)
                                continue;
 
@@ -2561,8 +2576,13 @@ void mark_free_pages(struct zone *zone)
                        unsigned long i;
 
                        pfn = page_to_pfn(page);
-                       for (i = 0; i < (1UL << order); i++)
+                       for (i = 0; i < (1UL << order); i++) {
+                               if (!--page_count) {
+                                       touch_nmi_watchdog();
+                                       page_count = WD_PAGE_COUNT;
+                               }
                                swsusp_set_page_free(pfn_to_page(pfn + i));
+                       }
                }
        }
        spin_unlock_irqrestore(&zone->lock, flags);
@@ -3271,10 +3291,13 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
        /*
         * Go through the zonelist yet one more time, keep very high watermark
         * here, this is only to catch a parallel oom killing, we must fail if
-        * we're still under heavy pressure.
+        * we're still under heavy pressure. But make sure that this reclaim
+        * attempt shall not depend on __GFP_DIRECT_RECLAIM && !__GFP_NORETRY
+        * allocation which will never fail due to oom_lock already held.
         */
-       page = get_page_from_freelist(gfp_mask | __GFP_HARDWALL, order,
-                                       ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac);
+       page = get_page_from_freelist((gfp_mask | __GFP_HARDWALL) &
+                                     ~__GFP_DIRECT_RECLAIM, order,
+                                     ALLOC_WMARK_HIGH|ALLOC_CPUSET, ac);
        if (page)
                goto out;
 
@@ -4458,8 +4481,9 @@ long si_mem_available(void)
         * Part of the reclaimable slab consists of items that are in use,
         * and cannot be freed. Cap this estimate at the low watermark.
         */
-       available += global_page_state(NR_SLAB_RECLAIMABLE) -
-                    min(global_page_state(NR_SLAB_RECLAIMABLE) / 2, wmark_low);
+       available += global_node_page_state(NR_SLAB_RECLAIMABLE) -
+                    min(global_node_page_state(NR_SLAB_RECLAIMABLE) / 2,
+                        wmark_low);
 
        if (available < 0)
                available = 0;
@@ -4602,8 +4626,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
                global_node_page_state(NR_FILE_DIRTY),
                global_node_page_state(NR_WRITEBACK),
                global_node_page_state(NR_UNSTABLE_NFS),
-               global_page_state(NR_SLAB_RECLAIMABLE),
-               global_page_state(NR_SLAB_UNRECLAIMABLE),
+               global_node_page_state(NR_SLAB_RECLAIMABLE),
+               global_node_page_state(NR_SLAB_UNRECLAIMABLE),
                global_node_page_state(NR_FILE_MAPPED),
                global_node_page_state(NR_SHMEM),
                global_page_state(NR_PAGETABLE),
@@ -7668,7 +7692,7 @@ int alloc_contig_range(unsigned long start, unsigned long end,
 
        /* Make sure the range is really isolated. */
        if (test_pages_isolated(outer_start, end, false)) {
-               pr_info("%s: [%lx, %lx) PFNs busy\n",
+               pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n",
                        __func__, outer_start, end);
                ret = -EBUSY;
                goto done;
index c8993c63eb259b3a5302a058ce231d1290fc9b66..c570f82e6827153316465b9e18f0fca376a1c1a1 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -887,11 +887,21 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
                .address = address,
                .flags = PVMW_SYNC,
        };
+       unsigned long start = address, end;
        int *cleaned = arg;
 
+       /*
+        * We have to assume the worse case ie pmd for invalidation. Note that
+        * the page can not be free from this function.
+        */
+       end = min(vma->vm_end, start + (PAGE_SIZE << compound_order(page)));
+       mmu_notifier_invalidate_range_start(vma->vm_mm, start, end);
+
        while (page_vma_mapped_walk(&pvmw)) {
+               unsigned long cstart, cend;
                int ret = 0;
-               address = pvmw.address;
+
+               cstart = address = pvmw.address;
                if (pvmw.pte) {
                        pte_t entry;
                        pte_t *pte = pvmw.pte;
@@ -904,6 +914,7 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
                        entry = pte_wrprotect(entry);
                        entry = pte_mkclean(entry);
                        set_pte_at(vma->vm_mm, address, pte, entry);
+                       cend = cstart + PAGE_SIZE;
                        ret = 1;
                } else {
 #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
@@ -918,6 +929,8 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
                        entry = pmd_wrprotect(entry);
                        entry = pmd_mkclean(entry);
                        set_pmd_at(vma->vm_mm, address, pmd, entry);
+                       cstart &= PMD_MASK;
+                       cend = cstart + PMD_SIZE;
                        ret = 1;
 #else
                        /* unexpected pmd-mapped page? */
@@ -926,11 +939,13 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma,
                }
 
                if (ret) {
-                       mmu_notifier_invalidate_page(vma->vm_mm, address);
+                       mmu_notifier_invalidate_range(vma->vm_mm, cstart, cend);
                        (*cleaned)++;
                }
        }
 
+       mmu_notifier_invalidate_range_end(vma->vm_mm, start, end);
+
        return true;
 }
 
@@ -1324,6 +1339,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
        pte_t pteval;
        struct page *subpage;
        bool ret = true;
+       unsigned long start = address, end;
        enum ttu_flags flags = (enum ttu_flags)arg;
 
        /* munlock has nothing to gain from examining un-locked vmas */
@@ -1335,6 +1351,14 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                                flags & TTU_MIGRATION, page);
        }
 
+       /*
+        * We have to assume the worse case ie pmd for invalidation. Note that
+        * the page can not be free in this function as call of try_to_unmap()
+        * must hold a reference on the page.
+        */
+       end = min(vma->vm_end, start + (PAGE_SIZE << compound_order(page)));
+       mmu_notifier_invalidate_range_start(vma->vm_mm, start, end);
+
        while (page_vma_mapped_walk(&pvmw)) {
                /*
                 * If the page is mlock()d, we cannot swap it out.
@@ -1445,6 +1469,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                        if (unlikely(PageSwapBacked(page) != PageSwapCache(page))) {
                                WARN_ON_ONCE(1);
                                ret = false;
+                               /* We have to invalidate as we cleared the pte */
                                page_vma_mapped_walk_done(&pvmw);
                                break;
                        }
@@ -1490,8 +1515,12 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
 discard:
                page_remove_rmap(subpage, PageHuge(page));
                put_page(page);
-               mmu_notifier_invalidate_page(mm, address);
+               mmu_notifier_invalidate_range(mm, address,
+                                             address + PAGE_SIZE);
        }
+
+       mmu_notifier_invalidate_range_end(vma->vm_mm, start, end);
+
        return ret;
 }
 
index b0aa6075d164df9ae4766876cc823394abaebc6d..fbcb3c96a186e8bcf9758189e4d1f17f1bc00cdd 100644 (file)
@@ -1022,7 +1022,11 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
                         */
                        if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) {
                                spin_lock(&sbinfo->shrinklist_lock);
-                               if (list_empty(&info->shrinklist)) {
+                               /*
+                                * _careful to defend against unlocked access to
+                                * ->shrink_list in shmem_unused_huge_shrink()
+                                */
+                               if (list_empty_careful(&info->shrinklist)) {
                                        list_add_tail(&info->shrinklist,
                                                        &sbinfo->shrinklist);
                                        sbinfo->shrinklist_len++;
@@ -1817,7 +1821,11 @@ alloc_nohuge:            page = shmem_alloc_and_acct_page(gfp, info, sbinfo,
                         * to shrink under memory pressure.
                         */
                        spin_lock(&sbinfo->shrinklist_lock);
-                       if (list_empty(&info->shrinklist)) {
+                       /*
+                        * _careful to defend against unlocked access to
+                        * ->shrink_list in shmem_unused_huge_shrink()
+                        */
+                       if (list_empty_careful(&info->shrinklist)) {
                                list_add_tail(&info->shrinklist,
                                                &sbinfo->shrinklist);
                                sbinfo->shrinklist_len++;
@@ -3959,7 +3967,7 @@ int __init shmem_init(void)
        }
 
 #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
-       if (has_transparent_hugepage() && shmem_huge < SHMEM_HUGE_DENY)
+       if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY)
                SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
        else
                shmem_huge = 0; /* just in case it was patched */
@@ -4020,7 +4028,7 @@ static ssize_t shmem_enabled_store(struct kobject *kobj,
                return -EINVAL;
 
        shmem_huge = huge;
-       if (shmem_huge < SHMEM_HUGE_DENY)
+       if (shmem_huge > SHMEM_HUGE_DENY)
                SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
        return count;
 }
index 1d3f9835f4eabe91494f48d8ace08a5e42a895f9..e8b4e31162cae8c4d8e473ae2d78769aaa55089e 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5642,13 +5642,14 @@ static void sysfs_slab_remove_workfn(struct work_struct *work)
                 * A cache is never shut down before deactivation is
                 * complete, so no need to worry about synchronization.
                 */
-               return;
+               goto out;
 
 #ifdef CONFIG_MEMCG
        kset_unregister(s->memcg_kset);
 #endif
        kobject_uevent(&s->kobj, KOBJ_REMOVE);
        kobject_del(&s->kobj);
+out:
        kobject_put(&s->kobj);
 }
 
index 7b07ec852e01fa931b2b302e8df5cff9f17f62d6..9ecddf568fe30e5cf1fba6db8eda3b7abe96d379 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -633,7 +633,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
                 * which are reclaimable, under pressure.  The dentry
                 * cache and most inode caches should fall into this
                 */
-               free += global_page_state(NR_SLAB_RECLAIMABLE);
+               free += global_node_page_state(NR_SLAB_RECLAIMABLE);
 
                /*
                 * Leave reserved pages. The pages are not for anonymous pages.
index 8698c1c86c4dbed685269eae1ecded2f5e714368..a47e3894c775646cd636c3f48bcb75fd4b8771d6 100644 (file)
@@ -1671,7 +1671,10 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
        struct page **pages;
        unsigned int nr_pages, array_size, i;
        const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
-       const gfp_t alloc_mask = gfp_mask | __GFP_HIGHMEM | __GFP_NOWARN;
+       const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
+       const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
+                                       0 :
+                                       __GFP_HIGHMEM;
 
        nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
        array_size = (nr_pages * sizeof(struct page *));
@@ -1679,7 +1682,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
        area->nr_pages = nr_pages;
        /* Please note that the recursion is strictly bounded. */
        if (array_size > PAGE_SIZE) {
-               pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,
+               pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
                                PAGE_KERNEL, node, area->caller);
        } else {
                pages = kmalloc_node(array_size, nested_gfp, node);
@@ -1700,9 +1703,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                }
 
                if (node == NUMA_NO_NODE)
-                       page = alloc_page(alloc_mask);
+                       page = alloc_page(alloc_mask|highmem_mask);
                else
-                       page = alloc_pages_node(node, alloc_mask, 0);
+                       page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
 
                if (unlikely(!page)) {
                        /* Successfully allocated i pages, free them in __vunmap() */
@@ -1710,7 +1713,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
                        goto fail;
                }
                area->pages[i] = page;
-               if (gfpflags_allow_blocking(gfp_mask))
+               if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
                        cond_resched();
        }
 
index e1133bc634b5e8ed9a4639677e577a0d52e7c1d5..8a3ce79b1307b7f260ce2f64e96bdacfb9a322f0 100644 (file)
@@ -1549,9 +1549,41 @@ batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry,
        return found;
 }
 
+/**
+ * batadv_tt_global_sync_flags - update TT sync flags
+ * @tt_global: the TT global entry to update sync flags in
+ *
+ * Updates the sync flag bits in the tt_global flag attribute with a logical
+ * OR of all sync flags from any of its TT orig entries.
+ */
+static void
+batadv_tt_global_sync_flags(struct batadv_tt_global_entry *tt_global)
+{
+       struct batadv_tt_orig_list_entry *orig_entry;
+       const struct hlist_head *head;
+       u16 flags = BATADV_NO_FLAGS;
+
+       rcu_read_lock();
+       head = &tt_global->orig_list;
+       hlist_for_each_entry_rcu(orig_entry, head, list)
+               flags |= orig_entry->flags;
+       rcu_read_unlock();
+
+       flags |= tt_global->common.flags & (~BATADV_TT_SYNC_MASK);
+       tt_global->common.flags = flags;
+}
+
+/**
+ * batadv_tt_global_orig_entry_add - add or update a TT orig entry
+ * @tt_global: the TT global entry to add an orig entry in
+ * @orig_node: the originator to add an orig entry for
+ * @ttvn: translation table version number of this changeset
+ * @flags: TT sync flags
+ */
 static void
 batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
-                               struct batadv_orig_node *orig_node, int ttvn)
+                               struct batadv_orig_node *orig_node, int ttvn,
+                               u8 flags)
 {
        struct batadv_tt_orig_list_entry *orig_entry;
 
@@ -1561,7 +1593,8 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
                 * was added during a "temporary client detection"
                 */
                orig_entry->ttvn = ttvn;
-               goto out;
+               orig_entry->flags = flags;
+               goto sync_flags;
        }
 
        orig_entry = kmem_cache_zalloc(batadv_tt_orig_cache, GFP_ATOMIC);
@@ -1573,6 +1606,7 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
        batadv_tt_global_size_inc(orig_node, tt_global->common.vid);
        orig_entry->orig_node = orig_node;
        orig_entry->ttvn = ttvn;
+       orig_entry->flags = flags;
        kref_init(&orig_entry->refcount);
 
        spin_lock_bh(&tt_global->list_lock);
@@ -1582,6 +1616,8 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
        spin_unlock_bh(&tt_global->list_lock);
        atomic_inc(&tt_global->orig_list_count);
 
+sync_flags:
+       batadv_tt_global_sync_flags(tt_global);
 out:
        if (orig_entry)
                batadv_tt_orig_list_entry_put(orig_entry);
@@ -1703,10 +1739,10 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
                }
 
                /* the change can carry possible "attribute" flags like the
-                * TT_CLIENT_WIFI, therefore they have to be copied in the
+                * TT_CLIENT_TEMP, therefore they have to be copied in the
                 * client entry
                 */
-               common->flags |= flags;
+               common->flags |= flags & (~BATADV_TT_SYNC_MASK);
 
                /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
                 * one originator left in the list and we previously received a
@@ -1723,7 +1759,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
        }
 add_orig_entry:
        /* add the new orig_entry (if needed) or update it */
-       batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn);
+       batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn,
+                                       flags & BATADV_TT_SYNC_MASK);
 
        batadv_dbg(BATADV_DBG_TT, bat_priv,
                   "Creating new global tt entry: %pM (vid: %d, via %pM)\n",
@@ -1946,6 +1983,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
                               struct batadv_tt_orig_list_entry *orig,
                               bool best)
 {
+       u16 flags = (common->flags & (~BATADV_TT_SYNC_MASK)) | orig->flags;
        void *hdr;
        struct batadv_orig_node_vlan *vlan;
        u8 last_ttvn;
@@ -1975,7 +2013,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
            nla_put_u8(msg, BATADV_ATTR_TT_LAST_TTVN, last_ttvn) ||
            nla_put_u32(msg, BATADV_ATTR_TT_CRC32, crc) ||
            nla_put_u16(msg, BATADV_ATTR_TT_VID, common->vid) ||
-           nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, common->flags))
+           nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, flags))
                goto nla_put_failure;
 
        if (best && nla_put_flag(msg, BATADV_ATTR_FLAG_BEST))
@@ -2589,6 +2627,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
                                unsigned short vid)
 {
        struct batadv_hashtable *hash = bat_priv->tt.global_hash;
+       struct batadv_tt_orig_list_entry *tt_orig;
        struct batadv_tt_common_entry *tt_common;
        struct batadv_tt_global_entry *tt_global;
        struct hlist_head *head;
@@ -2627,8 +2666,9 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
                        /* find out if this global entry is announced by this
                         * originator
                         */
-                       if (!batadv_tt_global_entry_has_orig(tt_global,
-                                                            orig_node))
+                       tt_orig = batadv_tt_global_orig_entry_find(tt_global,
+                                                                  orig_node);
+                       if (!tt_orig)
                                continue;
 
                        /* use network order to read the VID: this ensures that
@@ -2640,10 +2680,12 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
                        /* compute the CRC on flags that have to be kept in sync
                         * among nodes
                         */
-                       flags = tt_common->flags & BATADV_TT_SYNC_MASK;
+                       flags = tt_orig->flags;
                        crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
 
                        crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
+
+                       batadv_tt_orig_list_entry_put(tt_orig);
                }
                rcu_read_unlock();
        }
index ea43a64492479809fe6bdf95b436792078f50e9f..a62795868794103d7e712ba91def5997dc3a5779 100644 (file)
@@ -1260,6 +1260,7 @@ struct batadv_tt_global_entry {
  * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
  * @orig_node: pointer to orig node announcing this non-mesh client
  * @ttvn: translation table version number which added the non-mesh client
+ * @flags: per orig entry TT sync flags
  * @list: list node for batadv_tt_global_entry::orig_list
  * @refcount: number of contexts the object is used
  * @rcu: struct used for freeing in an RCU-safe manner
@@ -1267,6 +1268,7 @@ struct batadv_tt_global_entry {
 struct batadv_tt_orig_list_entry {
        struct batadv_orig_node *orig_node;
        u8 ttvn;
+       u8 flags;
        struct hlist_node list;
        struct kref refcount;
        struct rcu_head rcu;
index 861ae2a165f4dc3271b648794486e6a768590733..5a7be3bddfa9f2d02f519df265426b2a29419b0c 100644 (file)
@@ -53,6 +53,9 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
        brstats->tx_bytes += skb->len;
        u64_stats_update_end(&brstats->syncp);
 
+#ifdef CONFIG_NET_SWITCHDEV
+       skb->offload_fwd_mark = 0;
+#endif
        BR_INPUT_SKB_CB(skb)->brdev = dev;
 
        skb_reset_mac_header(skb);
index 181a44d0f1da6364a8965b54cf13aa6a5e44ef22..f6b1c7de059d8053e5820e66ae4bc354f6461b84 100644 (file)
@@ -115,7 +115,7 @@ br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
 void
 br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
 {
-       if (!fdb->added_by_user)
+       if (!fdb->added_by_user || !fdb->dst)
                return;
 
        switch (type) {
index ee5647bd91b3f3a864dccdc46098b30e8561377d..8c2f4489ff8f18680543b6adcad7604036458d5c 100644 (file)
@@ -169,14 +169,20 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
                                          int *peeked, int *off, int *err,
                                          struct sk_buff **last)
 {
+       bool peek_at_off = false;
        struct sk_buff *skb;
-       int _off = *off;
+       int _off = 0;
+
+       if (unlikely(flags & MSG_PEEK && *off >= 0)) {
+               peek_at_off = true;
+               _off = *off;
+       }
 
        *last = queue->prev;
        skb_queue_walk(queue, skb) {
                if (flags & MSG_PEEK) {
-                       if (_off >= skb->len && (skb->len || _off ||
-                                                skb->peeked)) {
+                       if (peek_at_off && _off >= skb->len &&
+                           (_off || skb->peeked)) {
                                _off -= skb->len;
                                continue;
                        }
@@ -356,7 +362,7 @@ int __sk_queue_drop_skb(struct sock *sk, struct sk_buff_head *sk_queue,
        if (flags & MSG_PEEK) {
                err = -ENOENT;
                spin_lock_bh(&sk_queue->lock);
-               if (skb == skb_peek(sk_queue)) {
+               if (skb->next) {
                        __skb_unlink(skb, sk_queue);
                        refcount_dec(&skb->users);
                        if (destructor)
index 8515f8fe0460ae08e08e269a47524e0738714626..86b4b0a79e7abb6554af07ed81a7b91e2f8762bf 100644 (file)
@@ -2739,7 +2739,7 @@ static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
 {
        if (tx_path)
                return skb->ip_summed != CHECKSUM_PARTIAL &&
-                      skb->ip_summed != CHECKSUM_NONE;
+                      skb->ip_summed != CHECKSUM_UNNECESSARY;
 
        return skb->ip_summed == CHECKSUM_NONE;
 }
@@ -5289,6 +5289,7 @@ static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock)
         * Ideally, a new ndo_busy_poll_stop() could avoid another round.
         */
        rc = napi->poll(napi, BUSY_POLL_BUDGET);
+       trace_napi_poll(napi, rc, BUSY_POLL_BUDGET);
        netpoll_poll_unlock(have_poll_lock);
        if (rc == BUSY_POLL_BUDGET)
                __napi_schedule(napi);
@@ -5667,12 +5668,13 @@ EXPORT_SYMBOL(netdev_has_upper_dev_all_rcu);
  * Find out if a device is linked to an upper device and return true in case
  * it is. The caller must hold the RTNL lock.
  */
-static bool netdev_has_any_upper_dev(struct net_device *dev)
+bool netdev_has_any_upper_dev(struct net_device *dev)
 {
        ASSERT_RTNL();
 
        return !list_empty(&dev->adj_list.upper);
 }
+EXPORT_SYMBOL(netdev_has_any_upper_dev);
 
 /**
  * netdev_master_upper_dev_get - Get master upper device
index f44fc22fd45aca4941c618abf97eb48494a67c16..169974998c7692b063947cb925fede167f2fb817 100644 (file)
@@ -2836,15 +2836,12 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
                   sk->sk_prot->setsockopt == tcp_setsockopt) {
                if (optname == TCP_CONGESTION) {
                        char name[TCP_CA_NAME_MAX];
+                       bool reinit = bpf_sock->op > BPF_SOCK_OPS_NEEDS_ECN;
 
                        strncpy(name, optval, min_t(long, optlen,
                                                    TCP_CA_NAME_MAX-1));
                        name[TCP_CA_NAME_MAX-1] = 0;
-                       ret = tcp_set_congestion_control(sk, name, false);
-                       if (!ret && bpf_sock->op > BPF_SOCK_OPS_NEEDS_ECN)
-                               /* replacing an existing ca */
-                               tcp_reinit_congestion_control(sk,
-                                       inet_csk(sk)->icsk_ca_ops);
+                       ret = tcp_set_congestion_control(sk, name, false, reinit);
                } else {
                        struct tcp_sock *tp = tcp_sk(sk);
 
@@ -2872,7 +2869,6 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,
                                ret = -EINVAL;
                        }
                }
-               ret = -EINVAL;
 #endif
        } else {
                ret = -EINVAL;
@@ -3505,6 +3501,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
                                              bpf_target_off(struct sk_buff, tc_index, 2,
                                                             target_size));
 #else
+               *target_size = 2;
                if (type == BPF_WRITE)
                        *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
                else
@@ -3520,6 +3517,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
                *insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
                *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 #else
+               *target_size = 4;
                *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 #endif
                break;
index f990eb8b30a9c4a57ef39d34413dd2f2a75babb6..e0755660628407e5a1cefc9ed2c4a725f68628a0 100644 (file)
@@ -1363,18 +1363,20 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
 EXPORT_SYMBOL(skb_copy_expand);
 
 /**
- *     skb_pad                 -       zero pad the tail of an skb
+ *     __skb_pad               -       zero pad the tail of an skb
  *     @skb: buffer to pad
  *     @pad: space to pad
+ *     @free_on_error: free buffer on error
  *
  *     Ensure that a buffer is followed by a padding area that is zero
  *     filled. Used by network drivers which may DMA or transfer data
  *     beyond the buffer end onto the wire.
  *
- *     May return error in out of memory cases. The skb is freed on error.
+ *     May return error in out of memory cases. The skb is freed on error
+ *     if @free_on_error is true.
  */
 
-int skb_pad(struct sk_buff *skb, int pad)
+int __skb_pad(struct sk_buff *skb, int pad, bool free_on_error)
 {
        int err;
        int ntail;
@@ -1403,10 +1405,11 @@ int skb_pad(struct sk_buff *skb, int pad)
        return 0;
 
 free_skb:
-       kfree_skb(skb);
+       if (free_on_error)
+               kfree_skb(skb);
        return err;
 }
-EXPORT_SYMBOL(skb_pad);
+EXPORT_SYMBOL(__skb_pad);
 
 /**
  *     pskb_put - add data to the tail of a potentially fragmented buffer
index 9fe25bf6329691ecf0acdc35df7278b074d446c1..b68168fcc06aa1981258eca4857511329af62f9a 100644 (file)
@@ -24,6 +24,7 @@
 #include <net/checksum.h>
 
 #include <net/inet_sock.h>
+#include <net/inet_common.h>
 #include <net/sock.h>
 #include <net/xfrm.h>
 
@@ -170,6 +171,15 @@ const char *dccp_packet_name(const int type)
 
 EXPORT_SYMBOL_GPL(dccp_packet_name);
 
+static void dccp_sk_destruct(struct sock *sk)
+{
+       struct dccp_sock *dp = dccp_sk(sk);
+
+       ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
+       dp->dccps_hc_tx_ccid = NULL;
+       inet_sock_destruct(sk);
+}
+
 int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
 {
        struct dccp_sock *dp = dccp_sk(sk);
@@ -179,6 +189,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
        icsk->icsk_syn_retries  = sysctl_dccp_request_retries;
        sk->sk_state            = DCCP_CLOSED;
        sk->sk_write_space      = dccp_write_space;
+       sk->sk_destruct         = dccp_sk_destruct;
        icsk->icsk_sync_mss     = dccp_sync_mss;
        dp->dccps_mss_cache     = 536;
        dp->dccps_rate_last     = jiffies;
@@ -201,10 +212,7 @@ void dccp_destroy_sock(struct sock *sk)
 {
        struct dccp_sock *dp = dccp_sk(sk);
 
-       /*
-        * DCCP doesn't use sk_write_queue, just sk_send_head
-        * for retransmissions
-        */
+       __skb_queue_purge(&sk->sk_write_queue);
        if (sk->sk_send_head != NULL) {
                kfree_skb(sk->sk_send_head);
                sk->sk_send_head = NULL;
@@ -222,8 +230,7 @@ void dccp_destroy_sock(struct sock *sk)
                dp->dccps_hc_rx_ackvec = NULL;
        }
        ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
-       ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
-       dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL;
+       dp->dccps_hc_rx_ccid = NULL;
 
        /* clean up feature negotiation state */
        dccp_feat_list_purge(&dp->dccps_featneg);
index c442051d5a55732d37ddc18187389d66d8d08bd9..20bc9c56fca05c230477b15d6dad15e02b488800 100644 (file)
@@ -577,7 +577,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)
                        return err;
        }
 
-       if (!dst->cpu_dp->netdev) {
+       if (!dst->cpu_dp) {
                pr_warn("Tree has no master device\n");
                return -EINVAL;
        }
index fab41de8e9837b512709b3c853ffb4831fe08317..fcd90f79458e20fefd76661fe7bc7e07d42ed1a3 100644 (file)
@@ -42,6 +42,10 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
        padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
 
        if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
+               /* Let dsa_slave_xmit() free skb */
+               if (__skb_put_padto(skb, skb->len + padlen, false))
+                       return NULL;
+
                nskb = skb;
        } else {
                nskb = alloc_skb(NET_IP_ALIGN + skb->len +
@@ -56,12 +60,15 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
                skb_set_transport_header(nskb,
                                         skb_transport_header(skb) - skb->head);
                skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
-               kfree_skb(skb);
-       }
 
-       /* skb is freed when it fails */
-       if (skb_put_padto(nskb, nskb->len + padlen))
-               return NULL;
+               /* Let skb_put_padto() free nskb, and let dsa_slave_xmit() free
+                * skb
+                */
+               if (skb_put_padto(nskb, nskb->len + padlen))
+                       return NULL;
+
+               consume_skb(skb);
+       }
 
        tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
        tag[0] = 0;
index b09e56214005c7cf9e257eb777882b234a2d6f18..9c7b1d74a5c6cc6a80e51a259ef6645060390d31 100644 (file)
@@ -40,7 +40,7 @@ static struct sk_buff *trailer_xmit(struct sk_buff *skb, struct net_device *dev)
        skb_set_network_header(nskb, skb_network_header(skb) - skb->head);
        skb_set_transport_header(nskb, skb_transport_header(skb) - skb->head);
        skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
-       kfree_skb(skb);
+       consume_skb(skb);
 
        if (padlen) {
                skb_put_zero(nskb, padlen);
index 4e7bdb213cd076e44b5a36b2168413682bb23f68..172d8309f89e52b1c06781571873520a41ef9036 100644 (file)
@@ -314,7 +314,8 @@ static void send_hsr_supervision_frame(struct hsr_port *master,
        hsr_sp = skb_put(skb, sizeof(struct hsr_sup_payload));
        ether_addr_copy(hsr_sp->MacAddressA, master->dev->dev_addr);
 
-       skb_put_padto(skb, ETH_ZLEN + HSR_HLEN);
+       if (skb_put_padto(skb, ETH_ZLEN + HSR_HLEN))
+               return;
 
        hsr_forward_skb(skb, master);
        return;
index 76c2077c3f5b697bf8e0d4b030b70dde8fc70345..2e548eca34898f51316275c918bb1f0f4a63526e 100644 (file)
@@ -1731,6 +1731,13 @@ static __net_init int inet_init_net(struct net *net)
        net->ipv4.sysctl_ip_prot_sock = PROT_SOCK;
 #endif
 
+       /* Some igmp sysctl, whose values are always used */
+       net->ipv4.sysctl_igmp_max_memberships = 20;
+       net->ipv4.sysctl_igmp_max_msf = 10;
+       /* IGMP reports for link-local multicast groups are enabled by default */
+       net->ipv4.sysctl_igmp_llm_reports = 1;
+       net->ipv4.sysctl_igmp_qrv = 2;
+
        return 0;
 }
 
index c4c6e1969ed0606ff9fb4ea46609f75b249e589b..2ae8f54cb32148f2499f78ecbf29259db36bd207 100644 (file)
@@ -1523,9 +1523,17 @@ unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
        int taglen;
 
        for (optlen = iph->ihl*4 - sizeof(struct iphdr); optlen > 0; ) {
-               if (optptr[0] == IPOPT_CIPSO)
+               switch (optptr[0]) {
+               case IPOPT_CIPSO:
                        return optptr;
-               taglen = optptr[1];
+               case IPOPT_END:
+                       return NULL;
+               case IPOPT_NOOP:
+                       taglen = 1;
+                       break;
+               default:
+                       taglen = optptr[1];
+               }
                optlen -= taglen;
                optptr += taglen;
        }
index 0cbee0a666ffd2a1b7451b0b07513b1cf1cebfc0..df68963dc90ada0ec19f8997d920f6faf3186e05 100644 (file)
@@ -258,7 +258,7 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
                esp_output_udp_encap(x, skb, esp);
 
        if (!skb_cloned(skb)) {
-               if (tailen <= skb_availroom(skb)) {
+               if (tailen <= skb_tailroom(skb)) {
                        nfrags = 1;
                        trailer = skb;
                        tail = skb_tail_pointer(trailer);
@@ -292,8 +292,6 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
 
                        kunmap_atomic(vaddr);
 
-                       spin_unlock_bh(&x->lock);
-
                        nfrags = skb_shinfo(skb)->nr_frags;
 
                        __skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
@@ -301,6 +299,9 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
                        skb_shinfo(skb)->nr_frags = ++nfrags;
 
                        pfrag->offset = pfrag->offset + allocsize;
+
+                       spin_unlock_bh(&x->lock);
+
                        nfrags++;
 
                        skb->len += tailen;
@@ -381,7 +382,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
                           (unsigned char *)esph - skb->data,
                           assoclen + ivlen + esp->clen + alen);
        if (unlikely(err < 0))
-               goto error;
+               goto error_free;
 
        if (!esp->inplace) {
                int allocsize;
@@ -392,7 +393,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
                spin_lock_bh(&x->lock);
                if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
                        spin_unlock_bh(&x->lock);
-                       goto error;
+                       goto error_free;
                }
 
                skb_shinfo(skb)->nr_frags = 1;
@@ -409,7 +410,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
                                   (unsigned char *)esph - skb->data,
                                   assoclen + ivlen + esp->clen + alen);
                if (unlikely(err < 0))
-                       goto error;
+                       goto error_free;
        }
 
        if ((x->props.flags & XFRM_STATE_ESN))
@@ -442,8 +443,9 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
 
        if (sg != dsg)
                esp_ssg_unref(x, tmp);
-       kfree(tmp);
 
+error_free:
+       kfree(tmp);
 error:
        return err;
 }
@@ -695,8 +697,10 @@ skip_cow:
 
        sg_init_table(sg, nfrags);
        err = skb_to_sgvec(skb, sg, 0, skb->len);
-       if (unlikely(err < 0))
+       if (unlikely(err < 0)) {
+               kfree(tmp);
                goto out;
+       }
 
        skb->ip_summed = CHECKSUM_NONE;
 
index e0666016a7642c017b4693d32723245adc484982..50112324fa5c3638527b12477c356ce406ba9a36 100644 (file)
@@ -257,7 +257,7 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features_
        esp.seqno = cpu_to_be64(xo->seq.low + ((u64)xo->seq.hi << 32));
 
        err = esp_output_tail(x, skb, &esp);
-       if (err < 0)
+       if (err)
                return err;
 
        secpath_reset(skb);
index b8d18171cca33ab5dab67408c3cd11ad57f25b83..ec3a9ce281a6ffb86b62e21f7284fd7c801668f0 100644 (file)
@@ -1083,15 +1083,17 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
        fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
        if (!fi)
                goto failure;
-       fib_info_cnt++;
        if (cfg->fc_mx) {
                fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL);
-               if (!fi->fib_metrics)
-                       goto failure;
+               if (unlikely(!fi->fib_metrics)) {
+                       kfree(fi);
+                       return ERR_PTR(err);
+               }
                atomic_set(&fi->fib_metrics->refcnt, 1);
-       } else
+       } else {
                fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
-
+       }
+       fib_info_cnt++;
        fi->fib_net = net;
        fi->fib_protocol = cfg->fc_protocol;
        fi->fib_scope = cfg->fc_scope;
index 8e0257d0120097770e37017439684a2345619f5e..1540db65241a6fd4d96b00546f13a3e3d3cd1815 100644 (file)
@@ -450,6 +450,7 @@ out_unlock:
 out:
        NAPI_GRO_CB(skb)->flush |= flush;
        skb_gro_remcsum_cleanup(skb, &grc);
+       skb->remcsum_offload = 0;
 
        return pp;
 }
index 28f14afd0dd3a392da3b84c5e791fffaf46ad254..caf2f1101d027b7b6e8d9683887e16c7bd4a8438 100644 (file)
@@ -1007,10 +1007,18 @@ int igmp_rcv(struct sk_buff *skb)
 {
        /* This basically follows the spec line by line -- see RFC1112 */
        struct igmphdr *ih;
-       struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
+       struct net_device *dev = skb->dev;
+       struct in_device *in_dev;
        int len = skb->len;
        bool dropped = true;
 
+       if (netif_is_l3_master(dev)) {
+               dev = dev_get_by_index_rcu(dev_net(dev), IPCB(skb)->iif);
+               if (!dev)
+                       goto drop;
+       }
+
+       in_dev = __in_dev_get_rcu(dev);
        if (!in_dev)
                goto drop;
 
@@ -2974,12 +2982,6 @@ static int __net_init igmp_net_init(struct net *net)
                goto out_sock;
        }
 
-       /* Sysctl initialization */
-       net->ipv4.sysctl_igmp_max_memberships = 20;
-       net->ipv4.sysctl_igmp_max_msf = 10;
-       /* IGMP reports for link-local multicast groups are enabled by default */
-       net->ipv4.sysctl_igmp_llm_reports = 1;
-       net->ipv4.sysctl_igmp_qrv = 2;
        return 0;
 
 out_sock:
index 50c74cd890bc79ed6c85c958c5397d833e9aa74a..e153c40c2436109d4bca4a9caf34b90cbf000cd9 100644 (file)
@@ -965,11 +965,12 @@ static int __ip_append_data(struct sock *sk,
                csummode = CHECKSUM_PARTIAL;
 
        cork->length += length;
-       if ((((length + (skb ? skb->len : fragheaderlen)) > mtu) ||
-            (skb && skb_is_gso(skb))) &&
+       if ((skb && skb_is_gso(skb)) ||
+           (((length + (skb ? skb->len : fragheaderlen)) > mtu) &&
+           (skb_queue_len(queue) <= 1) &&
            (sk->sk_protocol == IPPROTO_UDP) &&
            (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) &&
-           (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) {
+           (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx)) {
                err = ip_ufo_append_data(sk, queue, getfrag, from, length,
                                         hh_len, fragheaderlen, transhdrlen,
                                         maxfraglen, flags);
@@ -1288,6 +1289,7 @@ ssize_t   ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
                return -EINVAL;
 
        if ((size + skb->len > mtu) &&
+           (skb_queue_len(&sk->sk_write_queue) == 1) &&
            (sk->sk_protocol == IPPROTO_UDP) &&
            (rt->dst.dev->features & NETIF_F_UFO)) {
                if (skb->ip_summed != CHECKSUM_PARTIAL)
index 0bc3c3d73e61e00a04d73f32800256a62c8943a5..9e9d9afd18f745f810dc5d985c5c4532ef8053a3 100644 (file)
@@ -268,14 +268,14 @@ unsigned int arpt_do_table(struct sk_buff *skb,
                acpar.targinfo = t->data;
                verdict = t->u.kernel.target->target(skb, &acpar);
 
-               /* Target might have changed stuff. */
-               arp = arp_hdr(skb);
-
-               if (verdict == XT_CONTINUE)
+               if (verdict == XT_CONTINUE) {
+                       /* Target might have changed stuff. */
+                       arp = arp_hdr(skb);
                        e = arpt_next_entry(e);
-               else
+               } else {
                        /* Verdict */
                        break;
+               }
        } while (!acpar.hotdrop);
        xt_write_recseq_end(addend);
        local_bh_enable();
index 2a55a40211cbfb94a9ade41c33678bba4be2a7e4..622ed2887cd563dc5e708028d2f17726c8ca1c29 100644 (file)
@@ -352,13 +352,14 @@ ipt_do_table(struct sk_buff *skb,
                acpar.targinfo = t->data;
 
                verdict = t->u.kernel.target->target(skb, &acpar);
-               /* Target might have changed stuff. */
-               ip = ip_hdr(skb);
-               if (verdict == XT_CONTINUE)
+               if (verdict == XT_CONTINUE) {
+                       /* Target might have changed stuff. */
+                       ip = ip_hdr(skb);
                        e = ipt_next_entry(e);
-               else
+               } else {
                        /* Verdict */
                        break;
+               }
        } while (!acpar.hotdrop);
 
        xt_write_recseq_end(addend);
index 7d72decb80f9f9c4150bd2a42c4b802ba1fd7f17..efaa04dcc80e3a66ef34fa6bd13be66b601925b0 100644 (file)
@@ -117,7 +117,8 @@ clusterip_config_entry_put(struct net *net, struct clusterip_config *c)
                 * functions are also incrementing the refcount on their own,
                 * so it's safe to remove the entry even if it's in use. */
 #ifdef CONFIG_PROC_FS
-               proc_remove(c->pde);
+               if (cn->procdir)
+                       proc_remove(c->pde);
 #endif
                return;
        }
@@ -815,6 +816,7 @@ static void clusterip_net_exit(struct net *net)
 #ifdef CONFIG_PROC_FS
        struct clusterip_net *cn = net_generic(net, clusterip_net_id);
        proc_remove(cn->procdir);
+       cn->procdir = NULL;
 #endif
        nf_unregister_net_hook(net, &cip_arp_ops);
 }
index 0383e66f59bcef3bd6b8627edae9aa2d34139f5d..2331de20ca505d7f25fe9d93d5320e9e39af6c39 100644 (file)
@@ -1267,7 +1267,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
        if (mtu)
                return mtu;
 
-       mtu = dst->dev->mtu;
+       mtu = READ_ONCE(dst->dev->mtu);
 
        if (unlikely(dst_metric_locked(dst, RTAX_MTU))) {
                if (rt->rt_uses_gateway && mtu > 576)
@@ -2750,26 +2750,34 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
                err = 0;
                if (IS_ERR(rt))
                        err = PTR_ERR(rt);
+               else
+                       skb_dst_set(skb, &rt->dst);
        }
 
        if (err)
                goto errout_free;
 
-       skb_dst_set(skb, &rt->dst);
        if (rtm->rtm_flags & RTM_F_NOTIFY)
                rt->rt_flags |= RTCF_NOTIFY;
 
        if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE)
                table_id = rt->rt_table_id;
 
-       if (rtm->rtm_flags & RTM_F_FIB_MATCH)
+       if (rtm->rtm_flags & RTM_F_FIB_MATCH) {
+               if (!res.fi) {
+                       err = fib_props[res.type].error;
+                       if (!err)
+                               err = -EHOSTUNREACH;
+                       goto errout_free;
+               }
                err = fib_dump_info(skb, NETLINK_CB(in_skb).portid,
                                    nlh->nlmsg_seq, RTM_NEWROUTE, table_id,
                                    rt->rt_type, res.prefix, res.prefixlen,
                                    fl4.flowi4_tos, res.fi, 0);
-       else
+       } else {
                err = rt_fill_info(net, dst, src, table_id, &fl4, skb,
                                   NETLINK_CB(in_skb).portid, nlh->nlmsg_seq);
+       }
        if (err < 0)
                goto errout_free;
 
index 71ce33decd971feee72f225b2bf7ccaf2f5f456f..a3e91b552edce4edee0d3b9ee5e07105946d2dd9 100644 (file)
@@ -2481,7 +2481,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
                name[val] = 0;
 
                lock_sock(sk);
-               err = tcp_set_congestion_control(sk, name, true);
+               err = tcp_set_congestion_control(sk, name, true, true);
                release_sock(sk);
                return err;
        }
index fde983f6376be98247b9f2ff3d0307c2502e6392..421ea1b918da5bc4a3974531539cd67266f70798 100644 (file)
@@ -189,8 +189,8 @@ void tcp_init_congestion_control(struct sock *sk)
                INET_ECN_dontxmit(sk);
 }
 
-void tcp_reinit_congestion_control(struct sock *sk,
-                                  const struct tcp_congestion_ops *ca)
+static void tcp_reinit_congestion_control(struct sock *sk,
+                                         const struct tcp_congestion_ops *ca)
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
 
@@ -338,7 +338,7 @@ out:
  * tcp_reinit_congestion_control (if the current congestion control was
  * already initialized.
  */
-int tcp_set_congestion_control(struct sock *sk, const char *name, bool load)
+int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, bool reinit)
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
        const struct tcp_congestion_ops *ca;
@@ -360,9 +360,18 @@ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load)
        if (!ca) {
                err = -ENOENT;
        } else if (!load) {
-               icsk->icsk_ca_ops = ca;
-               if (!try_module_get(ca->owner))
+               const struct tcp_congestion_ops *old_ca = icsk->icsk_ca_ops;
+
+               if (try_module_get(ca->owner)) {
+                       if (reinit) {
+                               tcp_reinit_congestion_control(sk, ca);
+                       } else {
+                               icsk->icsk_ca_ops = ca;
+                               module_put(old_ca->owner);
+                       }
+               } else {
                        err = -EBUSY;
+               }
        } else if (!((ca->flags & TCP_CONG_NON_RESTRICTED) ||
                     ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))) {
                err = -EPERM;
index 2920e0cb09f8d3e743eb4f49c16060ba1af48ed4..bab7f0493098c6521f445923d721d296f326f7e1 100644 (file)
@@ -107,6 +107,7 @@ int sysctl_tcp_invalid_ratelimit __read_mostly = HZ/2;
 #define FLAG_ORIG_SACK_ACKED   0x200 /* Never retransmitted data are (s)acked  */
 #define FLAG_SND_UNA_ADVANCED  0x400 /* Snd_una was changed (!= FLAG_DATA_ACKED) */
 #define FLAG_DSACKING_ACK      0x800 /* SACK blocks contained D-SACK info */
+#define FLAG_SET_XMIT_TIMER    0x1000 /* Set TLP or RTO timer */
 #define FLAG_SACK_RENEGING     0x2000 /* snd_una advanced to a sacked seq */
 #define FLAG_UPDATE_TS_RECENT  0x4000 /* tcp_replace_ts_recent() */
 #define FLAG_NO_CHALLENGE_ACK  0x8000 /* do not call tcp_send_challenge_ack()  */
@@ -2520,8 +2521,8 @@ static inline void tcp_end_cwnd_reduction(struct sock *sk)
                return;
 
        /* Reset cwnd to ssthresh in CWR or Recovery (unless it's undone) */
-       if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR ||
-           (tp->undo_marker && tp->snd_ssthresh < TCP_INFINITE_SSTHRESH)) {
+       if (tp->snd_ssthresh < TCP_INFINITE_SSTHRESH &&
+           (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR || tp->undo_marker)) {
                tp->snd_cwnd = tp->snd_ssthresh;
                tp->snd_cwnd_stamp = tcp_jiffies32;
        }
@@ -3004,21 +3005,24 @@ void tcp_rearm_rto(struct sock *sk)
                /* Offset the time elapsed after installing regular RTO */
                if (icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT ||
                    icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
-                       struct sk_buff *skb = tcp_write_queue_head(sk);
-                       u64 rto_time_stamp = skb->skb_mstamp +
-                                            jiffies_to_usecs(rto);
-                       s64 delta_us = rto_time_stamp - tp->tcp_mstamp;
+                       s64 delta_us = tcp_rto_delta_us(sk);
                        /* delta_us may not be positive if the socket is locked
                         * when the retrans timer fires and is rescheduled.
                         */
-                       if (delta_us > 0)
-                               rto = usecs_to_jiffies(delta_us);
+                       rto = usecs_to_jiffies(max_t(int, delta_us, 1));
                }
                inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, rto,
                                          TCP_RTO_MAX);
        }
 }
 
+/* Try to schedule a loss probe; if that doesn't work, then schedule an RTO. */
+static void tcp_set_xmit_timer(struct sock *sk)
+{
+       if (!tcp_schedule_loss_probe(sk))
+               tcp_rearm_rto(sk);
+}
+
 /* If we get here, the whole TSO packet has not been acked. */
 static u32 tcp_tso_acked(struct sock *sk, struct sk_buff *skb)
 {
@@ -3180,7 +3184,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
                                        ca_rtt_us, sack->rate);
 
        if (flag & FLAG_ACKED) {
-               tcp_rearm_rto(sk);
+               flag |= FLAG_SET_XMIT_TIMER;  /* set TLP or RTO timer */
                if (unlikely(icsk->icsk_mtup.probe_size &&
                             !after(tp->mtu_probe.probe_seq_end, tp->snd_una))) {
                        tcp_mtup_probe_success(sk);
@@ -3208,7 +3212,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
                 * after when the head was last (re)transmitted. Otherwise the
                 * timeout may continue to extend in loss recovery.
                 */
-               tcp_rearm_rto(sk);
+               flag |= FLAG_SET_XMIT_TIMER;  /* set TLP or RTO timer */
        }
 
        if (icsk->icsk_ca_ops->pkts_acked) {
@@ -3580,9 +3584,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
        if (after(ack, tp->snd_nxt))
                goto invalid_ack;
 
-       if (icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)
-               tcp_rearm_rto(sk);
-
        if (after(ack, prior_snd_una)) {
                flag |= FLAG_SND_UNA_ADVANCED;
                icsk->icsk_retransmits = 0;
@@ -3647,18 +3648,20 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
        flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una, &acked,
                                    &sack_state);
 
+       if (tp->tlp_high_seq)
+               tcp_process_tlp_ack(sk, ack, flag);
+       /* If needed, reset TLP/RTO timer; RACK may later override this. */
+       if (flag & FLAG_SET_XMIT_TIMER)
+               tcp_set_xmit_timer(sk);
+
        if (tcp_ack_is_dubious(sk, flag)) {
                is_dupack = !(flag & (FLAG_SND_UNA_ADVANCED | FLAG_NOT_DUP));
                tcp_fastretrans_alert(sk, acked, is_dupack, &flag, &rexmit);
        }
-       if (tp->tlp_high_seq)
-               tcp_process_tlp_ack(sk, ack, flag);
 
        if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP))
                sk_dst_confirm(sk);
 
-       if (icsk->icsk_pending == ICSK_TIME_RETRANS)
-               tcp_schedule_loss_probe(sk);
        delivered = tp->delivered - delivered;  /* freshly ACKed or SACKed */
        lost = tp->lost - lost;                 /* freshly marked lost */
        tcp_rate_gen(sk, delivered, lost, sack_state.rate);
index a20e7f03d5f7d81ccf7e92de9bfbbcc3e2df6718..e9252c7df8091a8e0d2fc9d7e5722e9fd605a857 100644 (file)
@@ -1722,6 +1722,8 @@ process:
                 */
                sock_hold(sk);
                refcounted = true;
+               if (tcp_filter(sk, skb))
+                       goto discard_and_relse;
                nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
@@ -1729,8 +1731,6 @@ process:
                }
                if (nsk == sk) {
                        reqsk_put(req);
-               } else if (tcp_filter(sk, skb)) {
-                       goto discard_and_relse;
                } else if (tcp_child_process(sk, nsk, skb)) {
                        tcp_v4_send_reset(nsk, skb);
                        goto discard_and_relse;
index 2f1588bf73dad9b34aebee45ce738a7e9a4515ae..b7661a68d4984c485a4853441d21abe8da9e325a 100644 (file)
@@ -2377,24 +2377,15 @@ bool tcp_schedule_loss_probe(struct sock *sk)
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
-       u32 timeout, tlp_time_stamp, rto_time_stamp;
        u32 rtt = usecs_to_jiffies(tp->srtt_us >> 3);
+       u32 timeout, rto_delta_us;
 
-       /* No consecutive loss probes. */
-       if (WARN_ON(icsk->icsk_pending == ICSK_TIME_LOSS_PROBE)) {
-               tcp_rearm_rto(sk);
-               return false;
-       }
        /* Don't do any loss probe on a Fast Open connection before 3WHS
         * finishes.
         */
        if (tp->fastopen_rsk)
                return false;
 
-       /* TLP is only scheduled when next timer event is RTO. */
-       if (icsk->icsk_pending != ICSK_TIME_RETRANS)
-               return false;
-
        /* Schedule a loss probe in 2*RTT for SACK capable connections
         * in Open state, that are either limited by cwnd or application.
         */
@@ -2417,14 +2408,10 @@ bool tcp_schedule_loss_probe(struct sock *sk)
                                (rtt + (rtt >> 1) + TCP_DELACK_MAX));
        timeout = max_t(u32, timeout, msecs_to_jiffies(10));
 
-       /* If RTO is shorter, just schedule TLP in its place. */
-       tlp_time_stamp = tcp_jiffies32 + timeout;
-       rto_time_stamp = (u32)inet_csk(sk)->icsk_timeout;
-       if ((s32)(tlp_time_stamp - rto_time_stamp) > 0) {
-               s32 delta = rto_time_stamp - tcp_jiffies32;
-               if (delta > 0)
-                       timeout = delta;
-       }
+       /* If the RTO formula yields an earlier time, then use that time. */
+       rto_delta_us = tcp_rto_delta_us(sk);  /* How far in future is RTO? */
+       if (rto_delta_us > 0)
+               timeout = min_t(u32, timeout, usecs_to_jiffies(rto_delta_us));
 
        inet_csk_reset_xmit_timer(sk, ICSK_TIME_LOSS_PROBE, timeout,
                                  TCP_RTO_MAX);
@@ -3449,6 +3436,10 @@ int tcp_connect(struct sock *sk)
        int err;
 
        tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_CONNECT_CB);
+
+       if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk))
+               return -EHOSTUNREACH; /* Routing failure or similar. */
+
        tcp_connect_init(sk);
 
        if (unlikely(tp->repair)) {
index c0feeeef962aa31401ee90f8bd015c2aae2ef932..e906014890b64ef6a2bfe022e17358bd9659d204 100644 (file)
@@ -652,7 +652,8 @@ static void tcp_keepalive_timer (unsigned long data)
                goto death;
        }
 
-       if (!sock_flag(sk, SOCK_KEEPOPEN) || sk->sk_state == TCP_CLOSE)
+       if (!sock_flag(sk, SOCK_KEEPOPEN) ||
+           ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)))
                goto out;
 
        elapsed = keepalive_time_when(tp);
index 2417f55374c593c89b2aeb1ec4f6e6e74bb1395f..6bb9e14c710a7e2bfa58ee63ff6e02461a22cbec 100644 (file)
@@ -122,14 +122,14 @@ int tcp_set_ulp(struct sock *sk, const char *name)
 
        ulp_ops = __tcp_ulp_find_autoload(name);
        if (!ulp_ops)
-               err = -ENOENT;
-       else
-               err = ulp_ops->init(sk);
+               return -ENOENT;
 
-       if (err)
-               goto out;
+       err = ulp_ops->init(sk);
+       if (err) {
+               module_put(ulp_ops->owner);
+               return err;
+       }
 
        icsk->icsk_ulp_ops = ulp_ops;
- out:
-       return err;
+       return 0;
 }
index e6276fa3750b909615668fddf84495369bd7d369..62344804baaef96daf405dbdd5418db541b95864 100644 (file)
@@ -802,7 +802,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4)
        if (is_udplite)                                  /*     UDP-Lite      */
                csum = udplite_csum(skb);
 
-       else if (sk->sk_no_check_tx) {   /* UDP csum disabled */
+       else if (sk->sk_no_check_tx && !skb_is_gso(skb)) {   /* UDP csum off */
 
                skb->ip_summed = CHECKSUM_NONE;
                goto send;
@@ -1176,7 +1176,7 @@ static void udp_set_dev_scratch(struct sk_buff *skb)
        scratch->csum_unnecessary = !!skb_csum_unnecessary(skb);
        scratch->is_linear = !skb_is_nonlinear(skb);
 #endif
-       if (likely(!skb->_skb_refdst))
+       if (likely(!skb->_skb_refdst && !skb_sec_path(skb)))
                scratch->_tsize_state |= UDP_SKB_IS_STATELESS;
 }
 
@@ -1574,7 +1574,8 @@ int udp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
                return ip_recv_error(sk, msg, len, addr_len);
 
 try_again:
-       peeking = off = sk_peek_offset(sk, flags);
+       peeking = flags & MSG_PEEK;
+       off = sk_peek_offset(sk, flags);
        skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err);
        if (!skb)
                return err;
@@ -1928,14 +1929,16 @@ drop:
 /* For TCP sockets, sk_rx_dst is protected by socket lock
  * For UDP, we use xchg() to guard against concurrent changes.
  */
-void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
+bool udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
 {
        struct dst_entry *old;
 
        if (dst_hold_safe(dst)) {
                old = xchg(&sk->sk_rx_dst, dst);
                dst_release(old);
+               return old != dst;
        }
+       return false;
 }
 EXPORT_SYMBOL(udp_sk_rx_dst_set);
 
index 781250151d40ee4559f7b90d15dccad8ffaeafd0..0932c85b42af0bc868badd1771b5cb9353c969a9 100644 (file)
@@ -235,7 +235,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
        if (uh->check == 0)
                uh->check = CSUM_MANGLED_0;
 
-       skb->ip_summed = CHECKSUM_NONE;
+       skb->ip_summed = CHECKSUM_UNNECESSARY;
 
        /* If there is no outer header we can fake a checksum offload
         * due to the fact that we have already done the checksum in
index 3c46e9513a31d04eeb1e76384f146b759ae38eed..936e9ab4dda5453ce30b8640b85693b9728502fd 100644 (file)
@@ -5556,7 +5556,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
                 * our DAD process, so we don't need
                 * to do it again
                 */
-               if (!(ifp->rt->rt6i_node))
+               if (!rcu_access_pointer(ifp->rt->rt6i_node))
                        ip6_ins_rt(ifp->rt);
                if (ifp->idev->cnf.forwarding)
                        addrconf_join_anycast(ifp);
index 9ed35473dcb53bd6ae52f8f86e1558410bbcd7b6..ab64f367d11cc256ddc56527d979a06e32170745 100644 (file)
@@ -226,7 +226,7 @@ int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
        int tailen = esp->tailen;
 
        if (!skb_cloned(skb)) {
-               if (tailen <= skb_availroom(skb)) {
+               if (tailen <= skb_tailroom(skb)) {
                        nfrags = 1;
                        trailer = skb;
                        tail = skb_tail_pointer(trailer);
@@ -260,8 +260,6 @@ int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
 
                        kunmap_atomic(vaddr);
 
-                       spin_unlock_bh(&x->lock);
-
                        nfrags = skb_shinfo(skb)->nr_frags;
 
                        __skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
@@ -269,6 +267,9 @@ int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
                        skb_shinfo(skb)->nr_frags = ++nfrags;
 
                        pfrag->offset = pfrag->offset + allocsize;
+
+                       spin_unlock_bh(&x->lock);
+
                        nfrags++;
 
                        skb->len += tailen;
@@ -345,7 +346,7 @@ int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
                           (unsigned char *)esph - skb->data,
                           assoclen + ivlen + esp->clen + alen);
        if (unlikely(err < 0))
-               goto error;
+               goto error_free;
 
        if (!esp->inplace) {
                int allocsize;
@@ -356,7 +357,7 @@ int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
                spin_lock_bh(&x->lock);
                if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
                        spin_unlock_bh(&x->lock);
-                       goto error;
+                       goto error_free;
                }
 
                skb_shinfo(skb)->nr_frags = 1;
@@ -373,7 +374,7 @@ int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
                                   (unsigned char *)esph - skb->data,
                                   assoclen + ivlen + esp->clen + alen);
                if (unlikely(err < 0))
-                       goto error;
+                       goto error_free;
        }
 
        if ((x->props.flags & XFRM_STATE_ESN))
@@ -406,8 +407,9 @@ int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info
 
        if (sg != dsg)
                esp_ssg_unref(x, tmp);
-       kfree(tmp);
 
+error_free:
+       kfree(tmp);
 error:
        return err;
 }
index f02f131f6435a967de395b9a7069051c93a039d7..1cf437f75b0bf2bc446337ededbf58bd22673823 100644 (file)
@@ -286,7 +286,7 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features
        esp.seqno = cpu_to_be64(xo->seq.low + ((u64)xo->seq.hi << 32));
 
        err = esp6_output_tail(x, skb, &esp);
-       if (err < 0)
+       if (err)
                return err;
 
        secpath_reset(skb);
index ebb299cf72b7e81b77999d43d2e7f83212386f73..e1c85bb4eac0fd50905fc441e726eca843fc36a8 100644 (file)
@@ -148,11 +148,23 @@ static struct fib6_node *node_alloc(void)
        return fn;
 }
 
-static void node_free(struct fib6_node *fn)
+static void node_free_immediate(struct fib6_node *fn)
 {
        kmem_cache_free(fib6_node_kmem, fn);
 }
 
+static void node_free_rcu(struct rcu_head *head)
+{
+       struct fib6_node *fn = container_of(head, struct fib6_node, rcu);
+
+       kmem_cache_free(fib6_node_kmem, fn);
+}
+
+static void node_free(struct fib6_node *fn)
+{
+       call_rcu(&fn->rcu, node_free_rcu);
+}
+
 static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
 {
        int cpu;
@@ -601,9 +613,9 @@ insert_above:
 
                if (!in || !ln) {
                        if (in)
-                               node_free(in);
+                               node_free_immediate(in);
                        if (ln)
-                               node_free(ln);
+                               node_free_immediate(ln);
                        return ERR_PTR(-ENOMEM);
                }
 
@@ -877,7 +889,7 @@ add:
 
                rt->dst.rt6_next = iter;
                *ins = rt;
-               rt->rt6i_node = fn;
+               rcu_assign_pointer(rt->rt6i_node, fn);
                atomic_inc(&rt->rt6i_ref);
                if (!info->skip_notify)
                        inet6_rt_notify(RTM_NEWROUTE, rt, info, nlflags);
@@ -903,7 +915,7 @@ add:
                        return err;
 
                *ins = rt;
-               rt->rt6i_node = fn;
+               rcu_assign_pointer(rt->rt6i_node, fn);
                rt->dst.rt6_next = iter->dst.rt6_next;
                atomic_inc(&rt->rt6i_ref);
                if (!info->skip_notify)
@@ -914,6 +926,8 @@ add:
                }
                nsiblings = iter->rt6i_nsiblings;
                fib6_purge_rt(iter, fn, info->nl_net);
+               if (fn->rr_ptr == iter)
+                       fn->rr_ptr = NULL;
                rt6_release(iter);
 
                if (nsiblings) {
@@ -926,6 +940,8 @@ add:
                                if (rt6_qualify_for_ecmp(iter)) {
                                        *ins = iter->dst.rt6_next;
                                        fib6_purge_rt(iter, fn, info->nl_net);
+                                       if (fn->rr_ptr == iter)
+                                               fn->rr_ptr = NULL;
                                        rt6_release(iter);
                                        nsiblings--;
                                } else {
@@ -1014,7 +1030,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
                        /* Create subtree root node */
                        sfn = node_alloc();
                        if (!sfn)
-                               goto st_failure;
+                               goto failure;
 
                        sfn->leaf = info->nl_net->ipv6.ip6_null_entry;
                        atomic_inc(&info->nl_net->ipv6.ip6_null_entry->rt6i_ref);
@@ -1031,12 +1047,12 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
 
                        if (IS_ERR(sn)) {
                                /* If it is failed, discard just allocated
-                                  root, and then (in st_failure) stale node
+                                  root, and then (in failure) stale node
                                   in main tree.
                                 */
-                               node_free(sfn);
+                               node_free_immediate(sfn);
                                err = PTR_ERR(sn);
-                               goto st_failure;
+                               goto failure;
                        }
 
                        /* Now link new subtree to main tree */
@@ -1051,7 +1067,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
 
                        if (IS_ERR(sn)) {
                                err = PTR_ERR(sn);
-                               goto st_failure;
+                               goto failure;
                        }
                }
 
@@ -1092,18 +1108,17 @@ out:
                        atomic_inc(&pn->leaf->rt6i_ref);
                }
 #endif
-               /* Always release dst as dst->__refcnt is guaranteed
-                * to be taken before entering this function
-                */
-               dst_release_immediate(&rt->dst);
+               goto failure;
        }
        return err;
 
-#ifdef CONFIG_IPV6_SUBTREES
-       /* Subtree creation failed, probably main tree node
-          is orphan. If it is, shoot it.
+failure:
+       /* fn->leaf could be NULL if fn is an intermediate node and we
+        * failed to add the new route to it in both subtree creation
+        * failure and fib6_add_rt2node() failure case.
+        * In both cases, fib6_repair_tree() should be called to fix
+        * fn->leaf.
         */
-st_failure:
        if (fn && !(fn->fn_flags & (RTN_RTINFO|RTN_ROOT)))
                fib6_repair_tree(info->nl_net, fn);
        /* Always release dst as dst->__refcnt is guaranteed
@@ -1111,7 +1126,6 @@ st_failure:
         */
        dst_release_immediate(&rt->dst);
        return err;
-#endif
 }
 
 /*
@@ -1466,8 +1480,9 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
 
 int fib6_del(struct rt6_info *rt, struct nl_info *info)
 {
+       struct fib6_node *fn = rcu_dereference_protected(rt->rt6i_node,
+                                   lockdep_is_held(&rt->rt6i_table->tb6_lock));
        struct net *net = info->nl_net;
-       struct fib6_node *fn = rt->rt6i_node;
        struct rt6_info **rtp;
 
 #if RT6_DEBUG >= 2
@@ -1656,7 +1671,9 @@ static int fib6_clean_node(struct fib6_walker *w)
                        if (res) {
 #if RT6_DEBUG >= 2
                                pr_debug("%s: del failed: rt=%p@%p err=%d\n",
-                                        __func__, rt, rt->rt6i_node, res);
+                                        __func__, rt,
+                                        rcu_access_pointer(rt->rt6i_node),
+                                        res);
 #endif
                                continue;
                        }
@@ -1778,8 +1795,10 @@ static int fib6_age(struct rt6_info *rt, void *arg)
                }
                gc_args->more++;
        } else if (rt->rt6i_flags & RTF_CACHE) {
+               if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout))
+                       rt->dst.obsolete = DST_OBSOLETE_KILL;
                if (atomic_read(&rt->dst.__refcnt) == 1 &&
-                   time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
+                   rt->dst.obsolete == DST_OBSOLETE_KILL) {
                        RT6_TRACE("aging clone %p\n", rt);
                        return -1;
                } else if (rt->rt6i_flags & RTF_GATEWAY) {
index 162efba0d0cd851848363588318cf6ade4a5a62c..2dfe50d8d609a7a623edacbe40e93022dfac685e 100644 (file)
@@ -1381,11 +1381,12 @@ emsgsize:
         */
 
        cork->length += length;
-       if ((((length + (skb ? skb->len : headersize)) > mtu) ||
-            (skb && skb_is_gso(skb))) &&
+       if ((skb && skb_is_gso(skb)) ||
+           (((length + (skb ? skb->len : headersize)) > mtu) &&
+           (skb_queue_len(queue) <= 1) &&
            (sk->sk_protocol == IPPROTO_UDP) &&
            (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) &&
-           (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) {
+           (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk))) {
                err = ip6_ufo_append_data(sk, queue, getfrag, from, length,
                                          hh_len, fragheaderlen, exthdrlen,
                                          transhdrlen, mtu, flags, fl6);
index 02d795fe3d7f2c5e6e922a25dbbe69c8139919b6..a5e466d4e09310ed99c391fea4bb6126d83fbb56 100644 (file)
@@ -242,7 +242,6 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
                        pktopt = xchg(&np->pktoptions, NULL);
                        kfree_skb(pktopt);
 
-                       sk->sk_destruct = inet_sock_destruct;
                        /*
                         * ... and add it to the refcnt debug socks count
                         * in the new family. -acme
index abb2c307fbe8337ce1714e7392072c945ed5af51..a338bbc33cf3cd895fa77e137d6f6389e9a6519c 100644 (file)
@@ -86,7 +86,6 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
 
        while (offset <= packet_len) {
                struct ipv6_opt_hdr *exthdr;
-               unsigned int len;
 
                switch (**nexthdr) {
 
@@ -112,10 +111,9 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
 
                exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
                                                 offset);
-               len = ipv6_optlen(exthdr);
-               if (len + offset >= IPV6_MAXPLEN)
+               offset += ipv6_optlen(exthdr);
+               if (offset > IPV6_MAXPLEN)
                        return -EINVAL;
-               offset += len;
                *nexthdr = &exthdr->nexthdr;
        }
 
index 4d30c96a819dee548ec34704a34b22774fac5da1..2d0e7798c793a4058dc0ef3a5b50734e774500a9 100644 (file)
@@ -417,14 +417,11 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
        struct net_device *loopback_dev =
                dev_net(dev)->loopback_dev;
 
-       if (dev != loopback_dev) {
-               if (idev && idev->dev == dev) {
-                       struct inet6_dev *loopback_idev =
-                               in6_dev_get(loopback_dev);
-                       if (loopback_idev) {
-                               rt->rt6i_idev = loopback_idev;
-                               in6_dev_put(idev);
-                       }
+       if (idev && idev->dev != loopback_dev) {
+               struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev);
+               if (loopback_idev) {
+                       rt->rt6i_idev = loopback_idev;
+                       in6_dev_put(idev);
                }
        }
 }
@@ -443,7 +440,8 @@ static bool rt6_check_expired(const struct rt6_info *rt)
                if (time_after(jiffies, rt->dst.expires))
                        return true;
        } else if (rt->dst.from) {
-               return rt6_check_expired((struct rt6_info *) rt->dst.from);
+               return rt->dst.obsolete != DST_OBSOLETE_FORCE_CHK ||
+                      rt6_check_expired((struct rt6_info *)rt->dst.from);
        }
        return false;
 }
@@ -1292,7 +1290,9 @@ static void rt6_dst_from_metrics_check(struct rt6_info *rt)
 
 static struct dst_entry *rt6_check(struct rt6_info *rt, u32 cookie)
 {
-       if (!rt->rt6i_node || (rt->rt6i_node->fn_sernum != cookie))
+       u32 rt_cookie = 0;
+
+       if (!rt6_get_cookie_safe(rt, &rt_cookie) || rt_cookie != cookie)
                return NULL;
 
        if (rt6_check_expired(rt))
@@ -1360,8 +1360,14 @@ static void ip6_link_failure(struct sk_buff *skb)
                if (rt->rt6i_flags & RTF_CACHE) {
                        if (dst_hold_safe(&rt->dst))
                                ip6_del_rt(rt);
-               } else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT)) {
-                       rt->rt6i_node->fn_sernum = -1;
+               } else {
+                       struct fib6_node *fn;
+
+                       rcu_read_lock();
+                       fn = rcu_dereference(rt->rt6i_node);
+                       if (fn && (rt->rt6i_flags & RTF_DEFAULT))
+                               fn->fn_sernum = -1;
+                       rcu_read_unlock();
                }
        }
 }
@@ -1378,7 +1384,8 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
 static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
 {
        return !(rt->rt6i_flags & RTF_CACHE) &&
-               (rt->rt6i_flags & RTF_PCPU || rt->rt6i_node);
+               (rt->rt6i_flags & RTF_PCPU ||
+                rcu_access_pointer(rt->rt6i_node));
 }
 
 static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
@@ -2351,6 +2358,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
        if (on_link)
                nrt->rt6i_flags &= ~RTF_GATEWAY;
 
+       nrt->rt6i_protocol = RTPROT_REDIRECT;
        nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key;
 
        if (ip6_ins_rt(nrt))
@@ -2461,6 +2469,7 @@ static struct rt6_info *rt6_add_route_info(struct net *net,
                .fc_dst_len     = prefixlen,
                .fc_flags       = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO |
                                  RTF_UP | RTF_PREF(pref),
+               .fc_protocol = RTPROT_RA,
                .fc_nlinfo.portid = 0,
                .fc_nlinfo.nlh = NULL,
                .fc_nlinfo.nl_net = net,
@@ -2513,6 +2522,7 @@ struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr,
                .fc_ifindex     = dev->ifindex,
                .fc_flags       = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT |
                                  RTF_UP | RTF_EXPIRES | RTF_PREF(pref),
+               .fc_protocol = RTPROT_RA,
                .fc_nlinfo.portid = 0,
                .fc_nlinfo.nlh = NULL,
                .fc_nlinfo.nl_net = dev_net(dev),
@@ -3424,14 +3434,6 @@ static int rt6_fill_node(struct net *net,
        rtm->rtm_flags = 0;
        rtm->rtm_scope = RT_SCOPE_UNIVERSE;
        rtm->rtm_protocol = rt->rt6i_protocol;
-       if (rt->rt6i_flags & RTF_DYNAMIC)
-               rtm->rtm_protocol = RTPROT_REDIRECT;
-       else if (rt->rt6i_flags & RTF_ADDRCONF) {
-               if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ROUTEINFO))
-                       rtm->rtm_protocol = RTPROT_RA;
-               else
-                       rtm->rtm_protocol = RTPROT_KERNEL;
-       }
 
        if (rt->rt6i_flags & RTF_CACHE)
                rtm->rtm_flags |= RTM_F_CLONED;
@@ -3729,10 +3731,10 @@ static int ip6_route_dev_notify(struct notifier_block *this,
                /* NETDEV_UNREGISTER could be fired for multiple times by
                 * netdev_wait_allrefs(). Make sure we only call this once.
                 */
-               in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev);
+               in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev);
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
-               in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev);
-               in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev);
+               in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev);
+               in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev);
 #endif
        }
 
index 2521690d62d6e591af594c3629f71f004240ed68..206210125fd71d129a9ed2ead51a536749ab62b8 100644 (file)
@@ -1456,6 +1456,8 @@ process:
                }
                sock_hold(sk);
                refcounted = true;
+               if (tcp_filter(sk, skb))
+                       goto discard_and_relse;
                nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
@@ -1464,8 +1466,6 @@ process:
                if (nsk == sk) {
                        reqsk_put(req);
                        tcp_v6_restore_cb(skb);
-               } else if (tcp_filter(sk, skb)) {
-                       goto discard_and_relse;
                } else if (tcp_child_process(sk, nsk, skb)) {
                        tcp_v6_send_reset(nsk, skb);
                        goto discard_and_relse;
index 578142b7ca3e6e91e528b8c81addec812bb6a5ca..d6886228e1d05c4dd192f5fe431fdaca1ffadabd 100644 (file)
@@ -362,7 +362,8 @@ int udpv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
                return ipv6_recv_rxpmtu(sk, msg, len, addr_len);
 
 try_again:
-       peeking = off = sk_peek_offset(sk, flags);
+       peeking = flags & MSG_PEEK;
+       off = sk_peek_offset(sk, flags);
        skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err);
        if (!skb)
                return err;
@@ -767,6 +768,15 @@ start_lookup:
        return 0;
 }
 
+static void udp6_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
+{
+       if (udp_sk_rx_dst_set(sk, dst)) {
+               const struct rt6_info *rt = (const struct rt6_info *)dst;
+
+               inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
+       }
+}
+
 int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
                   int proto)
 {
@@ -816,7 +826,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
                int ret;
 
                if (unlikely(sk->sk_rx_dst != dst))
-                       udp_sk_rx_dst_set(sk, dst);
+                       udp6_sk_rx_dst_set(sk, dst);
 
                ret = udpv6_queue_rcv_skb(sk, skb);
                sock_put(sk);
index a2267f80febbb6f31459097f27bd89d51d0f2b11..e7d378c032cb6ebe80323db987ca201e5ae2d845 100644 (file)
@@ -72,7 +72,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
                if (uh->check == 0)
                        uh->check = CSUM_MANGLED_0;
 
-               skb->ip_summed = CHECKSUM_NONE;
+               skb->ip_summed = CHECKSUM_UNNECESSARY;
 
                /* If there is no outer header we can fake a checksum offload
                 * due to the fact that we have already done the checksum in
index 2e6990f8b80b6b4cc1d59665b0154a81790e1788..23fa7c8b09a5861e2acc042775830cc2dac4e0f4 100644 (file)
@@ -2213,7 +2213,7 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
 {
        struct sock *sk = sock->sk;
        struct irda_sock *self = irda_sk(sk);
-       struct irda_device_list list;
+       struct irda_device_list list = { 0 };
        struct irda_device_info *discoveries;
        struct irda_ias_set *   ias_opt;        /* IAS get/query params */
        struct ias_object *     ias_obj;        /* Object in IAS */
index da49191f7ad0d7edfda0c10762ef5f7471a8f6ac..4abf6287d7e1c29314db5c846acd16c3a2a377db 100644 (file)
@@ -1383,6 +1383,10 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
        if (!csk)
                return -EINVAL;
 
+       /* We must prevent loops or risk deadlock ! */
+       if (csk->sk_family == PF_KCM)
+               return -EOPNOTSUPP;
+
        psock = kmem_cache_zalloc(kcm_psockp, GFP_KERNEL);
        if (!psock)
                return -ENOMEM;
index ca9d3ae665e76ea847a4ce03b4d275f80d7705bc..98f4d8211b9a9d9bc26e7d9979c5c2bf27c1b344 100644 (file)
@@ -228,7 +228,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
 #define BROADCAST_ONE          1
 #define BROADCAST_REGISTERED   2
 #define BROADCAST_PROMISC_ONLY 4
-static int pfkey_broadcast(struct sk_buff *skb,
+static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
                           int broadcast_flags, struct sock *one_sk,
                           struct net *net)
 {
@@ -278,7 +278,7 @@ static int pfkey_broadcast(struct sk_buff *skb,
        rcu_read_unlock();
 
        if (one_sk != NULL)
-               err = pfkey_broadcast_one(skb, &skb2, GFP_KERNEL, one_sk);
+               err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);
 
        kfree_skb(skb2);
        kfree_skb(skb);
@@ -311,7 +311,7 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
                hdr = (struct sadb_msg *) pfk->dump.skb->data;
                hdr->sadb_msg_seq = 0;
                hdr->sadb_msg_errno = rc;
-               pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+               pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
                                &pfk->sk, sock_net(&pfk->sk));
                pfk->dump.skb = NULL;
        }
@@ -355,7 +355,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk)
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) /
                             sizeof(uint64_t));
 
-       pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+       pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk));
 
        return 0;
 }
@@ -1389,7 +1389,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, const struct sadb_
 
        xfrm_state_put(x);
 
-       pfkey_broadcast(resp_skb, BROADCAST_ONE, sk, net);
+       pfkey_broadcast(resp_skb, GFP_KERNEL, BROADCAST_ONE, sk, net);
 
        return 0;
 }
@@ -1476,7 +1476,7 @@ static int key_notify_sa(struct xfrm_state *x, const struct km_event *c)
        hdr->sadb_msg_seq = c->seq;
        hdr->sadb_msg_pid = c->portid;
 
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, xs_net(x));
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x));
 
        return 0;
 }
@@ -1589,7 +1589,7 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, const struct sadb_msg
        out_hdr->sadb_msg_reserved = 0;
        out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
        out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-       pfkey_broadcast(out_skb, BROADCAST_ONE, sk, sock_net(sk));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, sock_net(sk));
 
        return 0;
 }
@@ -1694,8 +1694,8 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad
                return -ENOBUFS;
        }
 
-       pfkey_broadcast(supp_skb, BROADCAST_REGISTERED, sk, sock_net(sk));
-
+       pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk,
+                       sock_net(sk));
        return 0;
 }
 
@@ -1712,7 +1712,8 @@ static int unicast_flush_resp(struct sock *sk, const struct sadb_msg *ihdr)
        hdr->sadb_msg_errno = (uint8_t) 0;
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
 
-       return pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk));
+       return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ONE, sk,
+                              sock_net(sk));
 }
 
 static int key_notify_sa_flush(const struct km_event *c)
@@ -1733,7 +1734,7 @@ static int key_notify_sa_flush(const struct km_event *c)
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
        hdr->sadb_msg_reserved = 0;
 
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, c->net);
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
 
        return 0;
 }
@@ -1790,7 +1791,7 @@ static int dump_sa(struct xfrm_state *x, int count, void *ptr)
        out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
        if (pfk->dump.skb)
-               pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+               pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
                                &pfk->sk, sock_net(&pfk->sk));
        pfk->dump.skb = out_skb;
 
@@ -1878,7 +1879,7 @@ static int pfkey_promisc(struct sock *sk, struct sk_buff *skb, const struct sadb
                new_hdr->sadb_msg_errno = 0;
        }
 
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, sock_net(sk));
+       pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ALL, NULL, sock_net(sk));
        return 0;
 }
 
@@ -2206,7 +2207,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
        out_hdr->sadb_msg_errno = 0;
        out_hdr->sadb_msg_seq = c->seq;
        out_hdr->sadb_msg_pid = c->portid;
-       pfkey_broadcast(out_skb, BROADCAST_ALL, NULL, xp_net(xp));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
        return 0;
 
 }
@@ -2426,7 +2427,7 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struc
        out_hdr->sadb_msg_errno = 0;
        out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
        out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
-       pfkey_broadcast(out_skb, BROADCAST_ONE, sk, xp_net(xp));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp));
        err = 0;
 
 out:
@@ -2682,7 +2683,7 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
        out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
 
        if (pfk->dump.skb)
-               pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE,
+               pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
                                &pfk->sk, sock_net(&pfk->sk));
        pfk->dump.skb = out_skb;
 
@@ -2739,7 +2740,7 @@ static int key_notify_policy_flush(const struct km_event *c)
        hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
        hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
        hdr->sadb_msg_reserved = 0;
-       pfkey_broadcast(skb_out, BROADCAST_ALL, NULL, c->net);
+       pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
        return 0;
 
 }
@@ -2803,7 +2804,7 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb
        void *ext_hdrs[SADB_EXT_MAX];
        int err;
 
-       pfkey_broadcast(skb_clone(skb, GFP_KERNEL),
+       pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
                        BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
 
        memset(ext_hdrs, 0, sizeof(ext_hdrs));
@@ -3024,7 +3025,8 @@ static int key_notify_sa_expire(struct xfrm_state *x, const struct km_event *c)
        out_hdr->sadb_msg_seq = 0;
        out_hdr->sadb_msg_pid = 0;
 
-       pfkey_broadcast(out_skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+       pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+                       xs_net(x));
        return 0;
 }
 
@@ -3212,7 +3214,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
                       xfrm_ctx->ctx_len);
        }
 
-       return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+       return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+                              xs_net(x));
 }
 
 static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
@@ -3408,7 +3411,8 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
        n_port->sadb_x_nat_t_port_port = sport;
        n_port->sadb_x_nat_t_port_reserved = 0;
 
-       return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x));
+       return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
+                              xs_net(x));
 }
 
 #ifdef CONFIG_NET_KEY_MIGRATE
@@ -3599,7 +3603,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
        }
 
        /* broadcast migrate message to sockets */
-       pfkey_broadcast(skb, BROADCAST_ALL, NULL, &init_net);
+       pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net);
 
        return 0;
 
index b0c2d4ae781d2114cdb09269d27768f0632a1776..90165a6874bcee338ce4d10ad5a7970a84954d19 100644 (file)
@@ -113,7 +113,6 @@ struct l2tp_net {
        spinlock_t l2tp_session_hlist_lock;
 };
 
-static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel);
 
 static inline struct l2tp_tunnel *l2tp_tunnel(struct sock *sk)
 {
@@ -127,39 +126,6 @@ static inline struct l2tp_net *l2tp_pernet(const struct net *net)
        return net_generic(net, l2tp_net_id);
 }
 
-/* Tunnel reference counts. Incremented per session that is added to
- * the tunnel.
- */
-static inline void l2tp_tunnel_inc_refcount_1(struct l2tp_tunnel *tunnel)
-{
-       refcount_inc(&tunnel->ref_count);
-}
-
-static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
-{
-       if (refcount_dec_and_test(&tunnel->ref_count))
-               l2tp_tunnel_free(tunnel);
-}
-#ifdef L2TP_REFCNT_DEBUG
-#define l2tp_tunnel_inc_refcount(_t)                                   \
-do {                                                                   \
-       pr_debug("l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n",        \
-                __func__, __LINE__, (_t)->name,                        \
-                refcount_read(&_t->ref_count));                        \
-       l2tp_tunnel_inc_refcount_1(_t);                                 \
-} while (0)
-#define l2tp_tunnel_dec_refcount(_t)                                   \
-do {                                                                   \
-       pr_debug("l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n",        \
-                __func__, __LINE__, (_t)->name,                        \
-                refcount_read(&_t->ref_count));                        \
-       l2tp_tunnel_dec_refcount_1(_t);                                 \
-} while (0)
-#else
-#define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
-#define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
-#endif
-
 /* Session hash global list for L2TPv3.
  * The session_id SHOULD be random according to RFC3931, but several
  * L2TP implementations use incrementing session_ids.  So we do a real
@@ -229,6 +195,27 @@ l2tp_session_id_hash(struct l2tp_tunnel *tunnel, u32 session_id)
        return &tunnel->session_hlist[hash_32(session_id, L2TP_HASH_BITS)];
 }
 
+/* Lookup a tunnel. A new reference is held on the returned tunnel. */
+struct l2tp_tunnel *l2tp_tunnel_get(const struct net *net, u32 tunnel_id)
+{
+       const struct l2tp_net *pn = l2tp_pernet(net);
+       struct l2tp_tunnel *tunnel;
+
+       rcu_read_lock_bh();
+       list_for_each_entry_rcu(tunnel, &pn->l2tp_tunnel_list, list) {
+               if (tunnel->tunnel_id == tunnel_id) {
+                       l2tp_tunnel_inc_refcount(tunnel);
+                       rcu_read_unlock_bh();
+
+                       return tunnel;
+               }
+       }
+       rcu_read_unlock_bh();
+
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(l2tp_tunnel_get);
+
 /* Lookup a session. A new reference is held on the returned session.
  * Optionally calls session->ref() too if do_ref is true.
  */
@@ -1348,17 +1335,6 @@ static void l2tp_udp_encap_destroy(struct sock *sk)
        }
 }
 
-/* Really kill the tunnel.
- * Come here only when all sessions have been cleared from the tunnel.
- */
-static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
-{
-       BUG_ON(refcount_read(&tunnel->ref_count) != 0);
-       BUG_ON(tunnel->sock != NULL);
-       l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: free...\n", tunnel->name);
-       kfree_rcu(tunnel, rcu);
-}
-
 /* Workqueue tunnel deletion function */
 static void l2tp_tunnel_del_work(struct work_struct *work)
 {
@@ -1844,6 +1820,8 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
 
                l2tp_session_set_header_len(session, tunnel->version);
 
+               refcount_set(&session->ref_count, 1);
+
                err = l2tp_session_add_to_tunnel(tunnel, session);
                if (err) {
                        kfree(session);
@@ -1851,10 +1829,6 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
                        return ERR_PTR(err);
                }
 
-               /* Bump the reference count. The session context is deleted
-                * only when this drops to zero.
-                */
-               refcount_set(&session->ref_count, 1);
                l2tp_tunnel_inc_refcount(tunnel);
 
                /* Ensure tunnel socket isn't deleted */
index cdb6e3327f744040f8510ad0882c2f620509dfb9..9101297f27adb218a24bd7edd8ff1842849ab438 100644 (file)
@@ -231,6 +231,8 @@ out:
        return tunnel;
 }
 
+struct l2tp_tunnel *l2tp_tunnel_get(const struct net *net, u32 tunnel_id);
+
 struct l2tp_session *l2tp_session_get(const struct net *net,
                                      struct l2tp_tunnel *tunnel,
                                      u32 session_id, bool do_ref);
@@ -269,6 +271,17 @@ int l2tp_nl_register_ops(enum l2tp_pwtype pw_type,
 void l2tp_nl_unregister_ops(enum l2tp_pwtype pw_type);
 int l2tp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 
+static inline void l2tp_tunnel_inc_refcount(struct l2tp_tunnel *tunnel)
+{
+       refcount_inc(&tunnel->ref_count);
+}
+
+static inline void l2tp_tunnel_dec_refcount(struct l2tp_tunnel *tunnel)
+{
+       if (refcount_dec_and_test(&tunnel->ref_count))
+               kfree_rcu(tunnel, rcu);
+}
+
 /* Session reference counts. Incremented when code obtains a reference
  * to a session.
  */
index 12cfcd0ca807396d18e061e9bcf4c29e760b2563..57427d430f107897322441d7578ce9e97b8017bf 100644 (file)
@@ -65,10 +65,12 @@ static struct l2tp_session *l2tp_nl_session_get(struct genl_info *info,
                   (info->attrs[L2TP_ATTR_CONN_ID])) {
                tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
                session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]);
-               tunnel = l2tp_tunnel_find(net, tunnel_id);
-               if (tunnel)
+               tunnel = l2tp_tunnel_get(net, tunnel_id);
+               if (tunnel) {
                        session = l2tp_session_get(net, tunnel, session_id,
                                                   do_ref);
+                       l2tp_tunnel_dec_refcount(tunnel);
+               }
        }
 
        return session;
@@ -271,8 +273,8 @@ static int l2tp_nl_cmd_tunnel_delete(struct sk_buff *skb, struct genl_info *info
        }
        tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 
-       tunnel = l2tp_tunnel_find(net, tunnel_id);
-       if (tunnel == NULL) {
+       tunnel = l2tp_tunnel_get(net, tunnel_id);
+       if (!tunnel) {
                ret = -ENODEV;
                goto out;
        }
@@ -282,6 +284,8 @@ static int l2tp_nl_cmd_tunnel_delete(struct sk_buff *skb, struct genl_info *info
 
        (void) l2tp_tunnel_delete(tunnel);
 
+       l2tp_tunnel_dec_refcount(tunnel);
+
 out:
        return ret;
 }
@@ -299,8 +303,8 @@ static int l2tp_nl_cmd_tunnel_modify(struct sk_buff *skb, struct genl_info *info
        }
        tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 
-       tunnel = l2tp_tunnel_find(net, tunnel_id);
-       if (tunnel == NULL) {
+       tunnel = l2tp_tunnel_get(net, tunnel_id);
+       if (!tunnel) {
                ret = -ENODEV;
                goto out;
        }
@@ -311,6 +315,8 @@ static int l2tp_nl_cmd_tunnel_modify(struct sk_buff *skb, struct genl_info *info
        ret = l2tp_tunnel_notify(&l2tp_nl_family, info,
                                 tunnel, L2TP_CMD_TUNNEL_MODIFY);
 
+       l2tp_tunnel_dec_refcount(tunnel);
+
 out:
        return ret;
 }
@@ -438,34 +444,37 @@ static int l2tp_nl_cmd_tunnel_get(struct sk_buff *skb, struct genl_info *info)
 
        if (!info->attrs[L2TP_ATTR_CONN_ID]) {
                ret = -EINVAL;
-               goto out;
+               goto err;
        }
 
        tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
 
-       tunnel = l2tp_tunnel_find(net, tunnel_id);
-       if (tunnel == NULL) {
-               ret = -ENODEV;
-               goto out;
-       }
-
        msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
        if (!msg) {
                ret = -ENOMEM;
-               goto out;
+               goto err;
+       }
+
+       tunnel = l2tp_tunnel_get(net, tunnel_id);
+       if (!tunnel) {
+               ret = -ENODEV;
+               goto err_nlmsg;
        }
 
        ret = l2tp_nl_tunnel_send(msg, info->snd_portid, info->snd_seq,
                                  NLM_F_ACK, tunnel, L2TP_CMD_TUNNEL_GET);
        if (ret < 0)
-               goto err_out;
+               goto err_nlmsg_tunnel;
+
+       l2tp_tunnel_dec_refcount(tunnel);
 
        return genlmsg_unicast(net, msg, info->snd_portid);
 
-err_out:
+err_nlmsg_tunnel:
+       l2tp_tunnel_dec_refcount(tunnel);
+err_nlmsg:
        nlmsg_free(msg);
-
-out:
+err:
        return ret;
 }
 
@@ -509,8 +518,9 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
                ret = -EINVAL;
                goto out;
        }
+
        tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]);
-       tunnel = l2tp_tunnel_find(net, tunnel_id);
+       tunnel = l2tp_tunnel_get(net, tunnel_id);
        if (!tunnel) {
                ret = -ENODEV;
                goto out;
@@ -518,24 +528,24 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
 
        if (!info->attrs[L2TP_ATTR_SESSION_ID]) {
                ret = -EINVAL;
-               goto out;
+               goto out_tunnel;
        }
        session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]);
 
        if (!info->attrs[L2TP_ATTR_PEER_SESSION_ID]) {
                ret = -EINVAL;
-               goto out;
+               goto out_tunnel;
        }
        peer_session_id = nla_get_u32(info->attrs[L2TP_ATTR_PEER_SESSION_ID]);
 
        if (!info->attrs[L2TP_ATTR_PW_TYPE]) {
                ret = -EINVAL;
-               goto out;
+               goto out_tunnel;
        }
        cfg.pw_type = nla_get_u16(info->attrs[L2TP_ATTR_PW_TYPE]);
        if (cfg.pw_type >= __L2TP_PWTYPE_MAX) {
                ret = -EINVAL;
-               goto out;
+               goto out_tunnel;
        }
 
        if (tunnel->version > 2) {
@@ -557,7 +567,7 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
                        u16 len = nla_len(info->attrs[L2TP_ATTR_COOKIE]);
                        if (len > 8) {
                                ret = -EINVAL;
-                               goto out;
+                               goto out_tunnel;
                        }
                        cfg.cookie_len = len;
                        memcpy(&cfg.cookie[0], nla_data(info->attrs[L2TP_ATTR_COOKIE]), len);
@@ -566,7 +576,7 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
                        u16 len = nla_len(info->attrs[L2TP_ATTR_PEER_COOKIE]);
                        if (len > 8) {
                                ret = -EINVAL;
-                               goto out;
+                               goto out_tunnel;
                        }
                        cfg.peer_cookie_len = len;
                        memcpy(&cfg.peer_cookie[0], nla_data(info->attrs[L2TP_ATTR_PEER_COOKIE]), len);
@@ -609,7 +619,7 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
        if ((l2tp_nl_cmd_ops[cfg.pw_type] == NULL) ||
            (l2tp_nl_cmd_ops[cfg.pw_type]->session_create == NULL)) {
                ret = -EPROTONOSUPPORT;
-               goto out;
+               goto out_tunnel;
        }
 
        /* Check that pseudowire-specific params are present */
@@ -619,7 +629,7 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
        case L2TP_PWTYPE_ETH_VLAN:
                if (!info->attrs[L2TP_ATTR_VLAN_ID]) {
                        ret = -EINVAL;
-                       goto out;
+                       goto out_tunnel;
                }
                break;
        case L2TP_PWTYPE_ETH:
@@ -647,6 +657,8 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
                }
        }
 
+out_tunnel:
+       l2tp_tunnel_dec_refcount(tunnel);
 out:
        return ret;
 }
index 8708cbe8af5bbcabc5c7ea295c6a0abd15a8eb84..2b36eff5d97ea7c1cef117033c66dd35058ac4e7 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
  * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
  * Copyright 2007-2010, Intel Corporation
- * Copyright(c) 2015 Intel Deutschland GmbH
+ * Copyright(c) 2015-2017 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -466,3 +466,23 @@ void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif,
        rcu_read_unlock();
 }
 EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl);
+
+void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
+                                  const u8 *addr, unsigned int tid)
+{
+       struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+       struct ieee80211_local *local = sdata->local;
+       struct sta_info *sta;
+
+       rcu_read_lock();
+       sta = sta_info_get_bss(sdata, addr);
+       if (!sta)
+               goto unlock;
+
+       set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
+       ieee80211_queue_work(&local->hw, &sta->ampdu_mlme.work);
+
+ unlock:
+       rcu_read_unlock();
+}
+EXPORT_SYMBOL(ieee80211_rx_ba_timer_expired);
index eb541786ccb7c79b3498477dfefc2927368f1a6f..b1d3740ae36ae61c1ad53f35fd818423bf2e4b27 100644 (file)
@@ -441,7 +441,7 @@ nf_nat_setup_info(struct nf_conn *ct,
                else
                        ct->status |= IPS_DST_NAT;
 
-               if (nfct_help(ct))
+               if (nfct_help(ct) && !nfct_seqadj(ct))
                        if (!nfct_seqadj_ext_add(ct))
                                return NF_DROP;
        }
index f5a7cb68694e76db73dec897ad51305f29bb8981..b89f4f65b2a0fbbcd725001e58ae373ab2c3156b 100644 (file)
@@ -305,7 +305,7 @@ static int nft_target_validate(const struct nft_ctx *ctx,
                const struct nf_hook_ops *ops = &basechain->ops[0];
 
                hook_mask = 1 << ops->hooknum;
-               if (!(hook_mask & target->hooks))
+               if (target->hooks && !(hook_mask & target->hooks))
                        return -EINVAL;
 
                ret = nft_compat_chain_validate_dependency(target->table,
@@ -484,7 +484,7 @@ static int nft_match_validate(const struct nft_ctx *ctx,
                const struct nf_hook_ops *ops = &basechain->ops[0];
 
                hook_mask = 1 << ops->hooknum;
-               if (!(hook_mask & match->hooks))
+               if (match->hooks && !(hook_mask & match->hooks))
                        return -EINVAL;
 
                ret = nft_compat_chain_validate_dependency(match->table,
index 18dd57a526513bd726944fa7ad7a9e41fcfb0251..14538b1d4d110e9b00445f477fb55377a5189f94 100644 (file)
@@ -65,19 +65,23 @@ static int nft_limit_init(struct nft_limit *limit,
        limit->nsecs = unit * NSEC_PER_SEC;
        if (limit->rate == 0 || limit->nsecs < unit)
                return -EOVERFLOW;
-       limit->tokens = limit->tokens_max = limit->nsecs;
-
-       if (tb[NFTA_LIMIT_BURST]) {
-               u64 rate;
 
+       if (tb[NFTA_LIMIT_BURST])
                limit->burst = ntohl(nla_get_be32(tb[NFTA_LIMIT_BURST]));
+       else
+               limit->burst = 0;
+
+       if (limit->rate + limit->burst < limit->rate)
+               return -EOVERFLOW;
 
-               rate = limit->rate + limit->burst;
-               if (rate < limit->rate)
-                       return -EOVERFLOW;
+       /* The token bucket size limits the number of tokens can be
+        * accumulated. tokens_max specifies the bucket size.
+        * tokens_max = unit * (rate + burst) / rate.
+        */
+       limit->tokens = div_u64(limit->nsecs * (limit->rate + limit->burst),
+                               limit->rate);
+       limit->tokens_max = limit->tokens;
 
-               limit->rate = rate;
-       }
        if (tb[NFTA_LIMIT_FLAGS]) {
                u32 flags = ntohl(nla_get_be32(tb[NFTA_LIMIT_FLAGS]));
 
@@ -95,9 +99,8 @@ static int nft_limit_dump(struct sk_buff *skb, const struct nft_limit *limit,
 {
        u32 flags = limit->invert ? NFT_LIMIT_F_INV : 0;
        u64 secs = div_u64(limit->nsecs, NSEC_PER_SEC);
-       u64 rate = limit->rate - limit->burst;
 
-       if (nla_put_be64(skb, NFTA_LIMIT_RATE, cpu_to_be64(rate),
+       if (nla_put_be64(skb, NFTA_LIMIT_RATE, cpu_to_be64(limit->rate),
                         NFTA_LIMIT_PAD) ||
            nla_put_be64(skb, NFTA_LIMIT_UNIT, cpu_to_be64(secs),
                         NFTA_LIMIT_PAD) ||
index e4610676299bcdac626db1a30cd4da44ccc62c0b..a54a556fcdb57d95b4a4a6606016ead527b93d64 100644 (file)
@@ -1337,6 +1337,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
                goto out;
        }
 
+       OVS_CB(skb)->acts_origlen = acts->orig_len;
        err = do_execute_actions(dp, skb, key,
                                 acts->actions, acts->actions_len);
 
index 45fe8c8a884df36100bc0cf26d279cb92e51bdf8..6b44fe4052825a87b373bafb58ca014e3ec99015 100644 (file)
@@ -381,7 +381,7 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
 }
 
 static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
-                             unsigned int hdrlen)
+                             unsigned int hdrlen, int actions_attrlen)
 {
        size_t size = NLMSG_ALIGN(sizeof(struct ovs_header))
                + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */
@@ -398,7 +398,7 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
 
        /* OVS_PACKET_ATTR_ACTIONS */
        if (upcall_info->actions_len)
-               size += nla_total_size(upcall_info->actions_len);
+               size += nla_total_size(actions_attrlen);
 
        /* OVS_PACKET_ATTR_MRU */
        if (upcall_info->mru)
@@ -465,7 +465,8 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
        else
                hlen = skb->len;
 
-       len = upcall_msg_size(upcall_info, hlen - cutlen);
+       len = upcall_msg_size(upcall_info, hlen - cutlen,
+                             OVS_CB(skb)->acts_origlen);
        user_skb = genlmsg_new(len, GFP_ATOMIC);
        if (!user_skb) {
                err = -ENOMEM;
index 5d8dcd88815f0622a48a54f14eaf5b5b9c53b18c..480600649d0b03a185f73b587181a3136d75e9b2 100644 (file)
@@ -99,11 +99,13 @@ struct datapath {
  * when a packet is received by OVS.
  * @mru: The maximum received fragement size; 0 if the packet is not
  * fragmented.
+ * @acts_origlen: The netlink size of the flow actions applied to this skb.
  * @cutlen: The number of bytes from the packet end to be removed.
  */
 struct ovs_skb_cb {
        struct vport            *input_vport;
        u16                     mru;
+       u16                     acts_origlen;
        u32                     cutlen;
 };
 #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
index 0615c2a950fab992134d0071707b5b336f6fb231..1c61af9af67dae10ea9675a45b191d7302c69151 100644 (file)
@@ -2191,6 +2191,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
        struct timespec ts;
        __u32 ts_status;
        bool is_drop_n_account = false;
+       bool do_vnet = false;
 
        /* struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
         * We may add members to them until current aligned size without forcing
@@ -2241,8 +2242,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
                netoff = TPACKET_ALIGN(po->tp_hdrlen +
                                       (maclen < 16 ? 16 : maclen)) +
                                       po->tp_reserve;
-               if (po->has_vnet_hdr)
+               if (po->has_vnet_hdr) {
                        netoff += sizeof(struct virtio_net_hdr);
+                       do_vnet = true;
+               }
                macoff = netoff - maclen;
        }
        if (po->tp_version <= TPACKET_V2) {
@@ -2259,8 +2262,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
                                        skb_set_owner_r(copy_skb, sk);
                        }
                        snaplen = po->rx_ring.frame_size - macoff;
-                       if ((int)snaplen < 0)
+                       if ((int)snaplen < 0) {
                                snaplen = 0;
+                               do_vnet = false;
+                       }
                }
        } else if (unlikely(macoff + snaplen >
                            GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len)) {
@@ -2273,6 +2278,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
                if (unlikely((int)snaplen < 0)) {
                        snaplen = 0;
                        macoff = GET_PBDQC_FROM_RB(&po->rx_ring)->max_frame_len;
+                       do_vnet = false;
                }
        }
        spin_lock(&sk->sk_receive_queue.lock);
@@ -2298,7 +2304,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
        }
        spin_unlock(&sk->sk_receive_queue.lock);
 
-       if (po->has_vnet_hdr) {
+       if (do_vnet) {
                if (virtio_net_hdr_from_skb(skb, h.raw + macoff -
                                            sizeof(struct virtio_net_hdr),
                                            vio_le(), true)) {
@@ -3700,14 +3706,19 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
 
                if (optlen != sizeof(val))
                        return -EINVAL;
-               if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
-                       return -EBUSY;
                if (copy_from_user(&val, optval, sizeof(val)))
                        return -EFAULT;
                if (val > INT_MAX)
                        return -EINVAL;
-               po->tp_reserve = val;
-               return 0;
+               lock_sock(sk);
+               if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) {
+                       ret = -EBUSY;
+               } else {
+                       po->tp_reserve = val;
+                       ret = 0;
+               }
+               release_sock(sk);
+               return ret;
        }
        case PACKET_LOSS:
        {
index e10624aa6959b596a2629a9f18bb25504428545f..9722bf839d9dec7fc7c7bed5cca0818389b245ba 100644 (file)
@@ -1015,8 +1015,10 @@ void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,
        if (rds_ib_ring_empty(&ic->i_recv_ring))
                rds_ib_stats_inc(s_ib_rx_ring_empty);
 
-       if (rds_ib_ring_low(&ic->i_recv_ring))
+       if (rds_ib_ring_low(&ic->i_recv_ring)) {
                rds_ib_recv_refill(conn, 0, GFP_NOWAIT);
+               rds_ib_stats_inc(s_ib_rx_refill_from_cq);
+       }
 }
 
 int rds_ib_recv_path(struct rds_conn_path *cp)
@@ -1029,6 +1031,7 @@ int rds_ib_recv_path(struct rds_conn_path *cp)
        if (rds_conn_up(conn)) {
                rds_ib_attempt_ack(ic);
                rds_ib_recv_refill(conn, 0, GFP_KERNEL);
+               rds_ib_stats_inc(s_ib_rx_refill_from_thread);
        }
 
        return ret;
index dd30d74824b0de42d1866f4449300f89c83d6724..ec3383f97d4c3e863c7fe77af8d3ed3ba5ea039f 100644 (file)
@@ -223,6 +223,7 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx)
        tail = b->call_backlog_tail;
        while (CIRC_CNT(head, tail, size) > 0) {
                struct rxrpc_call *call = b->call_backlog[tail];
+               call->socket = rx;
                if (rx->discard_new_call) {
                        _debug("discard %lx", call->user_call_ID);
                        rx->discard_new_call(call, call->user_call_ID);
index 36f0ced9e60c03297e195135ca5a8a53d1a3a27b..541707802a2380e83a96821dd20eb5946824cfe5 100644 (file)
@@ -36,11 +36,12 @@ static struct tc_action_ops act_ipt_ops;
 static unsigned int xt_net_id;
 static struct tc_action_ops act_xt_ops;
 
-static int ipt_init_target(struct xt_entry_target *t, char *table,
-                          unsigned int hook)
+static int ipt_init_target(struct net *net, struct xt_entry_target *t,
+                          char *table, unsigned int hook)
 {
        struct xt_tgchk_param par;
        struct xt_target *target;
+       struct ipt_entry e = {};
        int ret = 0;
 
        target = xt_request_find_target(AF_INET, t->u.user.name,
@@ -49,8 +50,10 @@ static int ipt_init_target(struct xt_entry_target *t, char *table,
                return PTR_ERR(target);
 
        t->u.kernel.target = target;
+       memset(&par, 0, sizeof(par));
+       par.net       = net;
        par.table     = table;
-       par.entryinfo = NULL;
+       par.entryinfo = &e;
        par.target    = target;
        par.targinfo  = t->data;
        par.hook_mask = hook;
@@ -91,10 +94,11 @@ static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = {
        [TCA_IPT_TARG]  = { .len = sizeof(struct xt_entry_target) },
 };
 
-static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
+static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,
                          struct nlattr *est, struct tc_action **a,
                          const struct tc_action_ops *ops, int ovr, int bind)
 {
+       struct tc_action_net *tn = net_generic(net, id);
        struct nlattr *tb[TCA_IPT_MAX + 1];
        struct tcf_ipt *ipt;
        struct xt_entry_target *td, *t;
@@ -159,7 +163,7 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
        if (unlikely(!t))
                goto err2;
 
-       err = ipt_init_target(t, tname, hook);
+       err = ipt_init_target(net, t, tname, hook);
        if (err < 0)
                goto err3;
 
@@ -193,18 +197,16 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla,
                        struct nlattr *est, struct tc_action **a, int ovr,
                        int bind)
 {
-       struct tc_action_net *tn = net_generic(net, ipt_net_id);
-
-       return __tcf_ipt_init(tn, nla, est, a, &act_ipt_ops, ovr, bind);
+       return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr,
+                             bind);
 }
 
 static int tcf_xt_init(struct net *net, struct nlattr *nla,
                       struct nlattr *est, struct tc_action **a, int ovr,
                       int bind)
 {
-       struct tc_action_net *tn = net_generic(net, xt_net_id);
-
-       return __tcf_ipt_init(tn, nla, est, a, &act_xt_ops, ovr, bind);
+       return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, ovr,
+                             bind);
 }
 
 static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a,
index 39da0c5801c908e28c4e258319adefde836c6b0c..6c5ea84d2682ab81fb9755361fa77326fa9d9935 100644 (file)
@@ -205,7 +205,7 @@ static void tcf_chain_flush(struct tcf_chain *chain)
 {
        struct tcf_proto *tp;
 
-       if (*chain->p_filter_chain)
+       if (chain->p_filter_chain)
                RCU_INIT_POINTER(*chain->p_filter_chain, NULL);
        while ((tp = rtnl_dereference(chain->filter_chain)) != NULL) {
                RCU_INIT_POINTER(chain->filter_chain, tp->next);
@@ -215,9 +215,15 @@ static void tcf_chain_flush(struct tcf_chain *chain)
 
 static void tcf_chain_destroy(struct tcf_chain *chain)
 {
-       list_del(&chain->list);
-       tcf_chain_flush(chain);
-       kfree(chain);
+       /* May be already removed from the list by the previous call. */
+       if (!list_empty(&chain->list))
+               list_del_init(&chain->list);
+
+       /* There might still be a reference held when we got here from
+        * tcf_block_put. Wait for the user to drop reference before free.
+        */
+       if (!chain->refcnt)
+               kfree(chain);
 }
 
 struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
@@ -288,8 +294,10 @@ void tcf_block_put(struct tcf_block *block)
        if (!block)
                return;
 
-       list_for_each_entry_safe(chain, tmp, &block->chain_list, list)
+       list_for_each_entry_safe(chain, tmp, &block->chain_list, list) {
+               tcf_chain_flush(chain);
                tcf_chain_destroy(chain);
+       }
        kfree(block);
 }
 EXPORT_SYMBOL(tcf_block_put);
index bd24a550e0f9f114598f4a398d6efd4c72672f50..4fb5a3222d0d324167f079f755be14eb028b4a50 100644 (file)
@@ -286,9 +286,6 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle)
 void qdisc_hash_add(struct Qdisc *q, bool invisible)
 {
        if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) {
-               struct Qdisc *root = qdisc_dev(q)->qdisc;
-
-               WARN_ON_ONCE(root == &noop_qdisc);
                ASSERT_RTNL();
                hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle);
                if (invisible)
@@ -839,7 +836,7 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
 
                        old = dev_graft_qdisc(dev_queue, new);
                        if (new && i > 0)
-                               refcount_inc(&new->refcnt);
+                               qdisc_refcount_inc(new);
 
                        if (!ingress)
                                qdisc_destroy(old);
@@ -850,7 +847,7 @@ skip:
                        notify_and_destroy(net, skb, n, classid,
                                           dev->qdisc, new);
                        if (new && !new->ops->attach)
-                               refcount_inc(&new->refcnt);
+                               qdisc_refcount_inc(new);
                        dev->qdisc = new ? : &noop_qdisc;
 
                        if (new && new->ops->attach)
@@ -1259,7 +1256,7 @@ replay:
                                if (q == p ||
                                    (p && check_loop(q, p, 0)))
                                        return -ELOOP;
-                               refcount_inc(&q->refcnt);
+                               qdisc_refcount_inc(q);
                                goto graft;
                        } else {
                                if (!q)
index 572fe2584e48c81dbf58d90ce9d6a4ae68d2a385..c403c87aff7a44bccfdd5f07e2e00ea0698a5c90 100644 (file)
@@ -572,8 +572,10 @@ static void atm_tc_destroy(struct Qdisc *sch)
        struct atm_flow_data *flow, *tmp;
 
        pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p);
-       list_for_each_entry(flow, &p->flows, list)
+       list_for_each_entry(flow, &p->flows, list) {
                tcf_block_put(flow->block);
+               flow->block = NULL;
+       }
 
        list_for_each_entry_safe(flow, tmp, &p->flows, list) {
                if (flow->ref > 1)
index 481036f6b54e4730ee27fae6236277c64d3eaa1a..156c8a33c6777a644c77b1adec9057b482bac109 100644 (file)
@@ -1139,6 +1139,13 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
        struct tc_ratespec *r;
        int err;
 
+       qdisc_watchdog_init(&q->watchdog, sch);
+       hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
+       q->delay_timer.function = cbq_undelay;
+
+       if (!opt)
+               return -EINVAL;
+
        err = nla_parse_nested(tb, TCA_CBQ_MAX, opt, cbq_policy, NULL);
        if (err < 0)
                return err;
@@ -1177,9 +1184,6 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
        q->link.avpkt = q->link.allot/2;
        q->link.minidle = -0x7FFFFFFF;
 
-       qdisc_watchdog_init(&q->watchdog, sch);
-       hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
-       q->delay_timer.function = cbq_undelay;
        q->toplevel = TC_CBQ_MAXLEVEL;
        q->now = psched_get_time();
 
@@ -1431,8 +1435,10 @@ static void cbq_destroy(struct Qdisc *sch)
         * be bound to classes which have been destroyed already. --TGR '04
         */
        for (h = 0; h < q->clhash.hashsize; h++) {
-               hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode)
+               hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
                        tcf_block_put(cl->block);
+                       cl->block = NULL;
+               }
        }
        for (h = 0; h < q->clhash.hashsize; h++) {
                hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h],
index 337f2d6d81e42e278b63443d904955e2c6692f03..2c0c05f2cc34a9de51390c45f29dd8db810075c7 100644 (file)
@@ -491,10 +491,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)
                if (!q->flows)
                        return -ENOMEM;
                q->backlogs = kvzalloc(q->flows_cnt * sizeof(u32), GFP_KERNEL);
-               if (!q->backlogs) {
-                       kvfree(q->flows);
+               if (!q->backlogs)
                        return -ENOMEM;
-               }
                for (i = 0; i < q->flows_cnt; i++) {
                        struct fq_codel_flow *flow = q->flows + i;
 
index 57ba406f1437323a4ba172d52f14a8b687b86708..4ba6da5fb2546c35ad48fe1f3632df8ca9957b34 100644 (file)
@@ -785,7 +785,7 @@ static void attach_default_qdiscs(struct net_device *dev)
            dev->priv_flags & IFF_NO_QUEUE) {
                netdev_for_each_tx_queue(dev, attach_one_default_qdisc, NULL);
                dev->qdisc = txq->qdisc_sleeping;
-               refcount_inc(&dev->qdisc->refcnt);
+               qdisc_refcount_inc(dev->qdisc);
        } else {
                qdisc = qdisc_create_dflt(txq, &mq_qdisc_ops, TC_H_ROOT);
                if (qdisc) {
index b52f74610dc7539fd7804403a6ff41b690243df7..11ab8dace901534b23b8f376ac704f995dc6b66b 100644 (file)
@@ -1418,6 +1418,8 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
        struct tc_hfsc_qopt *qopt;
        int err;
 
+       qdisc_watchdog_init(&q->watchdog, sch);
+
        if (opt == NULL || nla_len(opt) < sizeof(*qopt))
                return -EINVAL;
        qopt = nla_data(opt);
@@ -1428,6 +1430,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
                return err;
        q->eligible = RB_ROOT;
 
+       err = tcf_block_get(&q->root.block, &q->root.filter_list);
+       if (err)
+               return err;
+
        q->root.cl_common.classid = sch->handle;
        q->root.refcnt  = 1;
        q->root.sched   = q;
@@ -1444,8 +1450,6 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
        qdisc_class_hash_insert(&q->clhash, &q->root.cl_common);
        qdisc_class_hash_grow(sch, &q->clhash);
 
-       qdisc_watchdog_init(&q->watchdog, sch);
-
        return 0;
 }
 
@@ -1522,8 +1526,10 @@ hfsc_destroy_qdisc(struct Qdisc *sch)
        unsigned int i;
 
        for (i = 0; i < q->clhash.hashsize; i++) {
-               hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode)
+               hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode) {
                        tcf_block_put(cl->block);
+                       cl->block = NULL;
+               }
        }
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
index 51d3ba682af9ba0f69a3f3c3036519bf527cdee0..73a53c08091baafde3ef776ce9ea99cac9edfd9d 100644 (file)
@@ -477,6 +477,9 @@ static void hhf_destroy(struct Qdisc *sch)
                kvfree(q->hhf_valid_bits[i]);
        }
 
+       if (!q->hh_flows)
+               return;
+
        for (i = 0; i < HH_FLOWS_CNT; i++) {
                struct hh_flow_state *flow, *next;
                struct list_head *head = &q->hh_flows[i];
index 203286ab442799a07808bd8f73af9f07b0482cbd..5bf5177b2bd3f6aa1b0ba9e4e59a946e1c739e0a 100644 (file)
@@ -1017,6 +1017,9 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
        int err;
        int i;
 
+       qdisc_watchdog_init(&q->watchdog, sch);
+       INIT_WORK(&q->work, htb_work_func);
+
        if (!opt)
                return -EINVAL;
 
@@ -1041,8 +1044,6 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
        for (i = 0; i < TC_HTB_NUMPRIO; i++)
                INIT_LIST_HEAD(q->drops + i);
 
-       qdisc_watchdog_init(&q->watchdog, sch);
-       INIT_WORK(&q->work, htb_work_func);
        qdisc_skb_head_init(&q->direct_queue);
 
        if (tb[TCA_HTB_DIRECT_QLEN])
@@ -1258,8 +1259,10 @@ static void htb_destroy(struct Qdisc *sch)
        tcf_block_put(q->block);
 
        for (i = 0; i < q->clhash.hashsize; i++) {
-               hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode)
+               hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
                        tcf_block_put(cl->block);
+                       cl->block = NULL;
+               }
        }
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
index f143b7bbaa0d5b00d01d36e9f6eefb54bf677e8f..9c454f5d6c38820512485cceecbc06c9fa86f634 100644 (file)
@@ -257,12 +257,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt)
        for (i = 0; i < q->max_bands; i++)
                q->queues[i] = &noop_qdisc;
 
-       err = multiq_tune(sch, opt);
-
-       if (err)
-               kfree(q->queues);
-
-       return err;
+       return multiq_tune(sch, opt);
 }
 
 static int multiq_dump(struct Qdisc *sch, struct sk_buff *skb)
index 1b3dd6190e9386c6f8104153eb9fdc0255e03ac5..14d1724e0dc436f49da643be8606be273ce22ebd 100644 (file)
@@ -933,11 +933,11 @@ static int netem_init(struct Qdisc *sch, struct nlattr *opt)
        struct netem_sched_data *q = qdisc_priv(sch);
        int ret;
 
+       qdisc_watchdog_init(&q->watchdog, sch);
+
        if (!opt)
                return -EINVAL;
 
-       qdisc_watchdog_init(&q->watchdog, sch);
-
        q->loss_model = CLG_RANDOM;
        ret = netem_change(sch, opt);
        if (ret)
index f80ea2cc5f1f4bdee2452c930e3650f79397f3a1..fc69fc5956e9d4d2dbfe645e4c25e83328517371 100644 (file)
@@ -437,6 +437,7 @@ congestion_drop:
                qdisc_drop(head, sch, to_free);
 
                slot_queue_add(slot, skb);
+               qdisc_tree_reduce_backlog(sch, 0, delta);
                return NET_XMIT_CN;
        }
 
@@ -468,8 +469,10 @@ enqueue:
        /* Return Congestion Notification only if we dropped a packet
         * from this flow.
         */
-       if (qlen != slot->qlen)
+       if (qlen != slot->qlen) {
+               qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb));
                return NET_XMIT_CN;
+       }
 
        /* As we dropped a packet, better let upper stack know this */
        qdisc_tree_reduce_backlog(sch, 1, dropped);
@@ -713,13 +716,13 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt)
        int i;
        int err;
 
+       setup_deferrable_timer(&q->perturb_timer, sfq_perturbation,
+                              (unsigned long)sch);
+
        err = tcf_block_get(&q->block, &q->filter_list);
        if (err)
                return err;
 
-       setup_deferrable_timer(&q->perturb_timer, sfq_perturbation,
-                              (unsigned long)sch);
-
        for (i = 0; i < SFQ_MAX_DEPTH + 1; i++) {
                q->dep[i].next = i + SFQ_MAX_FLOWS;
                q->dep[i].prev = i + SFQ_MAX_FLOWS;
index b2e4b6ad241a8e538c654ef4e8417ab756740a45..493270f0d5b055fa07d4dee2b35ec9d40bddc3d0 100644 (file)
@@ -425,12 +425,13 @@ static int tbf_init(struct Qdisc *sch, struct nlattr *opt)
 {
        struct tbf_sched_data *q = qdisc_priv(sch);
 
+       qdisc_watchdog_init(&q->watchdog, sch);
+       q->qdisc = &noop_qdisc;
+
        if (opt == NULL)
                return -EINVAL;
 
        q->t_c = ktime_get_ns();
-       qdisc_watchdog_init(&q->watchdog, sch);
-       q->qdisc = &noop_qdisc;
 
        return tbf_change(sch, opt);
 }
index 2a186b201ad2c20594169633b241dacd0cc971c0..a4b6ffb6149541b78e39aceae859224d13487106 100644 (file)
@@ -512,7 +512,9 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr,
 {
        addr->sa.sa_family = AF_INET6;
        addr->v6.sin6_port = port;
+       addr->v6.sin6_flowinfo = 0;
        addr->v6.sin6_addr = *saddr;
+       addr->v6.sin6_scope_id = 0;
 }
 
 /* Compare addresses exactly.
index 9a647214a91ebc583660db320307e0df1e13e5be..e99518e79b523e973d01e3f6bcfa2c9576c3fdd9 100644 (file)
@@ -70,7 +70,8 @@ static int inet_diag_msg_sctpladdrs_fill(struct sk_buff *skb,
 
        info = nla_data(attr);
        list_for_each_entry_rcu(laddr, address_list, list) {
-               memcpy(info, &laddr->a, addrlen);
+               memcpy(info, &laddr->a, sizeof(laddr->a));
+               memset(info + sizeof(laddr->a), 0, addrlen - sizeof(laddr->a));
                info += addrlen;
        }
 
@@ -93,7 +94,9 @@ static int inet_diag_msg_sctpaddrs_fill(struct sk_buff *skb,
        info = nla_data(attr);
        list_for_each_entry(from, &asoc->peer.transport_addr_list,
                            transports) {
-               memcpy(info, &from->ipaddr, addrlen);
+               memcpy(info, &from->ipaddr, sizeof(from->ipaddr));
+               memset(info + sizeof(from->ipaddr), 0,
+                      addrlen - sizeof(from->ipaddr));
                info += addrlen;
        }
 
index 1db478e345203f75733044d843a763cc3a3966e1..8d760863bc411023835b20383620f38d14ee2df1 100644 (file)
@@ -4538,8 +4538,7 @@ int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc,
        info->sctpi_ictrlchunks = asoc->stats.ictrlchunks;
 
        prim = asoc->peer.primary_path;
-       memcpy(&info->sctpi_p_address, &prim->ipaddr,
-              sizeof(struct sockaddr_storage));
+       memcpy(&info->sctpi_p_address, &prim->ipaddr, sizeof(prim->ipaddr));
        info->sctpi_p_state = prim->state;
        info->sctpi_p_cwnd = prim->cwnd;
        info->sctpi_p_srtt = prim->srtt;
index 2b720fa35c4ff7c2ae906e9e76d13d27a2b2f008..e18500151236ed3b162cebcf24966957e58be484 100644 (file)
@@ -421,6 +421,9 @@ static void svc_data_ready(struct sock *sk)
                dprintk("svc: socket %p(inet %p), busy=%d\n",
                        svsk, sk,
                        test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
+
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_odata(sk);
                if (!test_and_set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags))
                        svc_xprt_enqueue(&svsk->sk_xprt);
@@ -437,6 +440,9 @@ static void svc_write_space(struct sock *sk)
        if (svsk) {
                dprintk("svc: socket %p(inet %p), write_space busy=%d\n",
                        svsk, sk, test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
+
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_owspace(sk);
                svc_xprt_enqueue(&svsk->sk_xprt);
        }
@@ -760,8 +766,12 @@ static void svc_tcp_listen_data_ready(struct sock *sk)
        dprintk("svc: socket %p TCP (listen) state change %d\n",
                sk, sk->sk_state);
 
-       if (svsk)
+       if (svsk) {
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_odata(sk);
+       }
+
        /*
         * This callback may called twice when a new connection
         * is established as a child socket inherits everything
@@ -794,6 +804,8 @@ static void svc_tcp_state_change(struct sock *sk)
        if (!svsk)
                printk("svc: socket %p: no user data\n", sk);
        else {
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
                svsk->sk_ostate(sk);
                if (sk->sk_state != TCP_ESTABLISHED) {
                        set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
@@ -1381,12 +1393,18 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
                return ERR_PTR(err);
        }
 
-       inet->sk_user_data = svsk;
        svsk->sk_sock = sock;
        svsk->sk_sk = inet;
        svsk->sk_ostate = inet->sk_state_change;
        svsk->sk_odata = inet->sk_data_ready;
        svsk->sk_owspace = inet->sk_write_space;
+       /*
+        * This barrier is necessary in order to prevent race condition
+        * with svc_data_ready(), svc_listen_data_ready() and others
+        * when calling callbacks above.
+        */
+       wmb();
+       inet->sk_user_data = svsk;
 
        /* Initialize the socket */
        if (sock->type == SOCK_DGRAM)
index d174ee3254eecb523dbc86061d80a1e812dcc305..89cd061c4468247cf761541ff1a2ca27f0836d6f 100644 (file)
@@ -65,6 +65,8 @@ static struct tipc_bearer *bearer_get(struct net *net, int bearer_id)
 }
 
 static void bearer_disable(struct net *net, struct tipc_bearer *b);
+static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,
+                          struct packet_type *pt, struct net_device *orig_dev);
 
 /**
  * tipc_media_find - locates specified media object by name
@@ -428,6 +430,10 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
 
        /* Associate TIPC bearer with L2 bearer */
        rcu_assign_pointer(b->media_ptr, dev);
+       b->pt.dev = dev;
+       b->pt.type = htons(ETH_P_TIPC);
+       b->pt.func = tipc_l2_rcv_msg;
+       dev_add_pack(&b->pt);
        memset(&b->bcast_addr, 0, sizeof(b->bcast_addr));
        memcpy(b->bcast_addr.value, dev->broadcast, b->media->hwaddr_len);
        b->bcast_addr.media_id = b->media->type_id;
@@ -447,6 +453,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
        struct net_device *dev;
 
        dev = (struct net_device *)rtnl_dereference(b->media_ptr);
+       dev_remove_pack(&b->pt);
        RCU_INIT_POINTER(dev->tipc_ptr, NULL);
        synchronize_net();
        dev_put(dev);
@@ -594,11 +601,12 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,
        struct tipc_bearer *b;
 
        rcu_read_lock();
-       b = rcu_dereference_rtnl(dev->tipc_ptr);
+       b = rcu_dereference_rtnl(dev->tipc_ptr) ?:
+               rcu_dereference_rtnl(orig_dev->tipc_ptr);
        if (likely(b && test_bit(0, &b->up) &&
-                  (skb->pkt_type <= PACKET_BROADCAST))) {
+                  (skb->pkt_type <= PACKET_MULTICAST))) {
                skb->next = NULL;
-               tipc_rcv(dev_net(dev), skb, b);
+               tipc_rcv(dev_net(b->pt.dev), skb, b);
                rcu_read_unlock();
                return NET_RX_SUCCESS;
        }
@@ -659,11 +667,6 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
        return NOTIFY_OK;
 }
 
-static struct packet_type tipc_packet_type __read_mostly = {
-       .type = htons(ETH_P_TIPC),
-       .func = tipc_l2_rcv_msg,
-};
-
 static struct notifier_block notifier = {
        .notifier_call  = tipc_l2_device_event,
        .priority       = 0,
@@ -671,19 +674,12 @@ static struct notifier_block notifier = {
 
 int tipc_bearer_setup(void)
 {
-       int err;
-
-       err = register_netdevice_notifier(&notifier);
-       if (err)
-               return err;
-       dev_add_pack(&tipc_packet_type);
-       return 0;
+       return register_netdevice_notifier(&notifier);
 }
 
 void tipc_bearer_cleanup(void)
 {
        unregister_netdevice_notifier(&notifier);
-       dev_remove_pack(&tipc_packet_type);
 }
 
 void tipc_bearer_stop(struct net *net)
index 635c9086e19af86b81b4dc572a7c2ee0374b02fc..e07a55a80c18ba0f3c4f1187b7544faeca395a4e 100644 (file)
@@ -131,6 +131,7 @@ struct tipc_media {
  * @name: bearer name (format = media:interface)
  * @media: ptr to media structure associated with bearer
  * @bcast_addr: media address used in broadcasting
+ * @pt: packet type for bearer
  * @rcu: rcu struct for tipc_bearer
  * @priority: default link priority for bearer
  * @window: default window size for bearer
@@ -151,6 +152,7 @@ struct tipc_bearer {
        char name[TIPC_MAX_BEARER_NAME];
        struct tipc_media *media;
        struct tipc_media_addr bcast_addr;
+       struct packet_type pt;
        struct rcu_head rcu;
        u32 priority;
        u32 window;
index ab3087687a32446ffa3bbfaccf206028886e6945..6ef379f004ac6da5ef908911368149e10186b5c4 100644 (file)
@@ -479,13 +479,14 @@ bool tipc_msg_make_bundle(struct sk_buff **skb,  struct tipc_msg *msg,
 bool tipc_msg_reverse(u32 own_node,  struct sk_buff **skb, int err)
 {
        struct sk_buff *_skb = *skb;
-       struct tipc_msg *hdr = buf_msg(_skb);
+       struct tipc_msg *hdr;
        struct tipc_msg ohdr;
-       int dlen = min_t(uint, msg_data_sz(hdr), MAX_FORWARD_SIZE);
+       int dlen;
 
        if (skb_linearize(_skb))
                goto exit;
        hdr = buf_msg(_skb);
+       dlen = min_t(uint, msg_data_sz(hdr), MAX_FORWARD_SIZE);
        if (msg_dest_droppable(hdr))
                goto exit;
        if (msg_errcode(hdr))
@@ -511,8 +512,11 @@ bool tipc_msg_reverse(u32 own_node,  struct sk_buff **skb, int err)
            pskb_expand_head(_skb, BUF_HEADROOM, BUF_TAILROOM, GFP_ATOMIC))
                goto exit;
 
+       /* reassign after skb header modifications */
+       hdr = buf_msg(_skb);
        /* Now reverse the concerned fields */
        msg_set_errcode(hdr, err);
+       msg_set_non_seq(hdr, 0);
        msg_set_origport(hdr, msg_destport(&ohdr));
        msg_set_destport(hdr, msg_origport(&ohdr));
        msg_set_destnode(hdr, msg_prevnode(&ohdr));
index 9bfe886ab33080f653ec1c39e0255b15709d0b76..750949dfc1d7d9bc81c55de55f0e7dafb4023a2c 100644 (file)
@@ -258,13 +258,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
        arg = nlmsg_new(0, GFP_KERNEL);
        if (!arg) {
                kfree_skb(msg->rep);
+               msg->rep = NULL;
                return -ENOMEM;
        }
 
        err = __tipc_nl_compat_dumpit(cmd, msg, arg);
-       if (err)
+       if (err) {
                kfree_skb(msg->rep);
-
+               msg->rep = NULL;
+       }
        kfree_skb(arg);
 
        return err;
index aeef8011ac7d82d828289f4085efe3acaa8a3945..7dd22330a6b4bf9113e189c613a863fce13425a2 100644 (file)
@@ -1126,8 +1126,8 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr,
                strncpy(linkname, tipc_link_name(link), len);
                err = 0;
        }
-exit:
        tipc_node_read_unlock(node);
+exit:
        tipc_node_put(node);
        return err;
 }
@@ -1455,10 +1455,8 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb,
        /* Initiate synch mode if applicable */
        if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) {
                syncpt = iseqno + exp_pkts - 1;
-               if (!tipc_link_is_up(l)) {
-                       tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT);
+               if (!tipc_link_is_up(l))
                        __tipc_node_link_up(n, bearer_id, xmitq);
-               }
                if (n->state == SELF_UP_PEER_UP) {
                        n->sync_point = syncpt;
                        tipc_link_fsm_evt(l, LINK_SYNCH_BEGIN_EVT);
@@ -1559,6 +1557,8 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
 
        /* Check/update node state before receiving */
        if (unlikely(skb)) {
+               if (unlikely(skb_linearize(skb)))
+                       goto discard;
                tipc_node_write_lock(n);
                if (tipc_node_check_state(n, skb, bearer_id, &xmitq)) {
                        if (le->link) {
index 101e3597338f7c1e182c9090af0d14caf5be1b8b..d50edd6e00196af04ee7a4011d6339b100cb3537 100644 (file)
@@ -2255,8 +2255,8 @@ void tipc_sk_reinit(struct net *net)
 
        do {
                tsk = ERR_PTR(rhashtable_walk_start(&iter));
-               if (tsk)
-                       continue;
+               if (IS_ERR(tsk))
+                       goto walk_stop;
 
                while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) {
                        spin_lock_bh(&tsk->sk.sk_lock.slock);
@@ -2265,7 +2265,7 @@ void tipc_sk_reinit(struct net *net)
                        msg_set_orignode(msg, tn->own_addr);
                        spin_unlock_bh(&tsk->sk.sk_lock.slock);
                }
-
+walk_stop:
                rhashtable_walk_stop(&iter);
        } while (tsk == ERR_PTR(-EAGAIN));
 }
index 0bf91cd3733cb37ecc8ba4ccf7ae5a26cb6e966d..be3d9e3183dcb1ce929584a074755c1ce0969d0f 100644 (file)
@@ -52,7 +52,6 @@ struct tipc_subscriber {
        struct list_head subscrp_list;
 };
 
-static void tipc_subscrp_delete(struct tipc_subscription *sub);
 static void tipc_subscrb_put(struct tipc_subscriber *subscriber);
 
 /**
@@ -197,15 +196,19 @@ static void tipc_subscrb_subscrp_delete(struct tipc_subscriber *subscriber,
 {
        struct list_head *subscription_list = &subscriber->subscrp_list;
        struct tipc_subscription *sub, *temp;
+       u32 timeout;
 
        spin_lock_bh(&subscriber->lock);
        list_for_each_entry_safe(sub, temp, subscription_list,  subscrp_list) {
                if (s && memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr)))
                        continue;
 
-               tipc_nametbl_unsubscribe(sub);
-               list_del(&sub->subscrp_list);
-               tipc_subscrp_delete(sub);
+               timeout = htohl(sub->evt.s.timeout, sub->swap);
+               if (timeout == TIPC_WAIT_FOREVER || del_timer(&sub->timer)) {
+                       tipc_nametbl_unsubscribe(sub);
+                       list_del(&sub->subscrp_list);
+                       tipc_subscrp_put(sub);
+               }
 
                if (s)
                        break;
@@ -236,18 +239,12 @@ static void tipc_subscrb_delete(struct tipc_subscriber *subscriber)
        tipc_subscrb_put(subscriber);
 }
 
-static void tipc_subscrp_delete(struct tipc_subscription *sub)
-{
-       u32 timeout = htohl(sub->evt.s.timeout, sub->swap);
-
-       if (timeout == TIPC_WAIT_FOREVER || del_timer(&sub->timer))
-               tipc_subscrp_put(sub);
-}
-
 static void tipc_subscrp_cancel(struct tipc_subscr *s,
                                struct tipc_subscriber *subscriber)
 {
+       tipc_subscrb_get(subscriber);
        tipc_subscrb_subscrp_delete(subscriber, s);
+       tipc_subscrb_put(subscriber);
 }
 
 static struct tipc_subscription *tipc_subscrp_create(struct net *net,
index 7b52a380d710d238c440293b6d3b8973fc30c90c..be8982b4f8c00be8bb95748c1c33a76e13079dff 100644 (file)
@@ -2304,10 +2304,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state,
         */
        mutex_lock(&u->iolock);
 
-       if (flags & MSG_PEEK)
-               skip = sk_peek_offset(sk, flags);
-       else
-               skip = 0;
+       skip = max(sk_peek_offset(sk, flags), 0);
 
        do {
                int chunk;
index ff61d85579292dee8a7f1e9926e11734556f4fd9..69b16ee327d9958769f09c66d54ace50889d6665 100644 (file)
@@ -2226,7 +2226,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
                                goto no_transform;
                        }
 
-                       dst_hold(&xdst->u.dst);
                        route = xdst->route;
                }
        }
@@ -3308,9 +3307,15 @@ int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
        struct xfrm_state *x_new[XFRM_MAX_DEPTH];
        struct xfrm_migrate *mp;
 
+       /* Stage 0 - sanity checks */
        if ((err = xfrm_migrate_check(m, num_migrate)) < 0)
                goto out;
 
+       if (dir >= XFRM_POLICY_MAX) {
+               err = -EINVAL;
+               goto out;
+       }
+
        /* Stage 1 - find policy */
        if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) {
                err = -ENOENT;
index 6c0956d10db601add764616df62dbe19999c29b4..a792effdb0b5d51fb88835349a44a756d3a9e5e7 100644 (file)
@@ -1620,6 +1620,7 @@ int
 xfrm_tmpl_sort(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n,
               unsigned short family, struct net *net)
 {
+       int i;
        int err = 0;
        struct xfrm_state_afinfo *afinfo = xfrm_state_get_afinfo(family);
        if (!afinfo)
@@ -1628,6 +1629,9 @@ xfrm_tmpl_sort(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n,
        spin_lock_bh(&net->xfrm.xfrm_state_lock); /*FIXME*/
        if (afinfo->tmpl_sort)
                err = afinfo->tmpl_sort(dst, src, n);
+       else
+               for (i = 0; i < n; i++)
+                       dst[i] = src[i];
        spin_unlock_bh(&net->xfrm.xfrm_state_lock);
        rcu_read_unlock();
        return err;
@@ -1638,6 +1642,7 @@ int
 xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, int n,
                unsigned short family)
 {
+       int i;
        int err = 0;
        struct xfrm_state_afinfo *afinfo = xfrm_state_get_afinfo(family);
        struct net *net = xs_net(*src);
@@ -1648,6 +1653,9 @@ xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, int n,
        spin_lock_bh(&net->xfrm.xfrm_state_lock);
        if (afinfo->state_sort)
                err = afinfo->state_sort(dst, src, n);
+       else
+               for (i = 0; i < n; i++)
+                       dst[i] = src[i];
        spin_unlock_bh(&net->xfrm.xfrm_state_lock);
        rcu_read_unlock();
        return err;
index 2be4c6af008a7917ae5cc1e3306c5466cae387e4..9391ced0525986ce72938a9ed59c27ea124f7ba5 100644 (file)
@@ -796,7 +796,7 @@ static int copy_user_offload(struct xfrm_state_offload *xso, struct sk_buff *skb
                return -EMSGSIZE;
 
        xuo = nla_data(attr);
-
+       memset(xuo, 0, sizeof(*xuo));
        xuo->ifindex = xso->dev->ifindex;
        xuo->flags = xso->flags;
 
@@ -1869,6 +1869,7 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, const struct
                return -EMSGSIZE;
 
        id = nlmsg_data(nlh);
+       memset(&id->sa_id, 0, sizeof(id->sa_id));
        memcpy(&id->sa_id.daddr, &x->id.daddr, sizeof(x->id.daddr));
        id->sa_id.spi = x->id.spi;
        id->sa_id.family = x->props.family;
@@ -2578,6 +2579,8 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, const struct
        ue = nlmsg_data(nlh);
        copy_to_user_state(x, &ue->state);
        ue->hard = (c->data.hard != 0) ? 1 : 0;
+       /* clear the padding bytes */
+       memset(&ue->hard + 1, 0, sizeof(*ue) - offsetofend(typeof(*ue), hard));
 
        err = xfrm_mark_put(skb, &x->mark);
        if (err)
@@ -2715,6 +2718,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, const struct km_event *c)
                struct nlattr *attr;
 
                id = nlmsg_data(nlh);
+               memset(id, 0, sizeof(*id));
                memcpy(&id->daddr, &x->id.daddr, sizeof(id->daddr));
                id->spi = x->id.spi;
                id->family = x->props.family;
index dd8e2dde0b34b3759fe6061eb5c2887f4ecd21fd..9ffd3dda3889c56a7a72229bed21ff5c49d62856 100644 (file)
@@ -85,8 +85,8 @@ TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
 
 # try-run
 # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
-# Exit code chooses option. "$$TMP" is can be used as temporary file and
-# is automatically cleaned up.
+# Exit code chooses option. "$$TMP" serves as a temporary file and is
+# automatically cleaned up.
 try-run = $(shell set -e;              \
        TMP="$(TMPOUT).$$$$.tmp";       \
        TMPO="$(TMPOUT).$$$$.o";        \
@@ -261,7 +261,6 @@ make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
 any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 
 # Execute command if command has changed or prerequisite(s) are updated.
-#
 if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
        @set -e;                                                             \
        $(echo-cmd) $(cmd_$(1));                                             \
@@ -315,7 +314,7 @@ if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
        $(rule_$(1)), @:)
 
 ###
-# why - tell why a a target got build
+# why - tell why a target got built
 #       enabled by make V=2
 #       Output (listed in the order they are checked):
 #          (1) - due to target is PHONY
index 95f7d80901524a4c966505397af6931f3e3316f3..a6c8c17808551aa146102ccb4132f8f5605ea74d 100644 (file)
@@ -1,9 +1,9 @@
 # include/asm-generic contains a lot of files that are used
 # verbatim by several architectures.
 #
-# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
+# This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild
 # and for each file listed in this file with generic-y creates
-# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
+# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src))
 
 kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
 -include $(kbuild-file)
index 4a9a2cec0a1b52d601f9f057eb8fbb515e69de50..f6152c70f7f417ca234da77c8a503a6c974bcec2 100644 (file)
@@ -229,8 +229,8 @@ ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
 endif
 # Due to recursion, we must skip empty.o.
 # The empty.o file is created in the make process in order to determine
-#  the target endianness and word size. It is made before all other C
-#  files, including recordmcount.
+# the target endianness and word size. It is made before all other C
+# files, including recordmcount.
 sub_cmd_record_mcount =                                        \
        if [ $(@) != "scripts/mod/empty.o" ]; then      \
                $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)";   \
@@ -245,13 +245,13 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH
        "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
        "$(if $(part-of-module),1,0)" "$(@)";
 recordmcount_source := $(srctree)/scripts/recordmcount.pl
-endif
+endif # BUILD_C_RECORDMCOUNT
 cmd_record_mcount =                                            \
        if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" =   \
             "$(CC_FLAGS_FTRACE)" ]; then                       \
                $(sub_cmd_record_mcount)                        \
        fi;
-endif
+endif # CONFIG_FTRACE_MCOUNT_RECORD
 
 ifdef CONFIG_STACK_VALIDATION
 ifneq ($(SKIP_STACK_VALIDATION),1)
index 34614a48b717eafa2c15f418e6e6769905e32ec1..993fb85982df2df2a7f8e20780d0cfbe3cb732e8 100644 (file)
@@ -14,7 +14,7 @@ src := $(obj)
 PHONY := __dtbs_install
 __dtbs_install:
 
-export dtbinst-root ?= $(obj)
+export dtbinst_root ?= $(obj)
 
 include include/config/auto.conf
 include scripts/Kbuild.include
@@ -27,7 +27,7 @@ dtbinst-dirs  := $(dts-dirs)
 quiet_cmd_dtb_install =        INSTALL $<
       cmd_dtb_install =        mkdir -p $(2); cp $< $(2)
 
-install-dir = $(patsubst $(dtbinst-root)%,$(INSTALL_DTBS_PATH)%,$(obj))
+install-dir = $(patsubst $(dtbinst_root)%,$(INSTALL_DTBS_PATH)%,$(obj))
 
 $(dtbinst-files): %.dtb: $(obj)/%.dtb
        $(call cmd,dtb_install,$(install-dir))
index ec10d9345bc2d9b978d8cae4d85bf2fd89ab121c..0372b33febe52f74978420c2c559adef5e815374 100644 (file)
@@ -1,5 +1,5 @@
 ###
-# Makefile.basic lists the most basic programs used during the build process.
+# This Makefile lists the most basic programs used during the build process.
 # The programs listed herein are what are needed to do the basic stuff,
 # such as fix file dependencies.
 # This initial step is needed to avoid files to be recompiled
index fff818b92acb7e3e469ce06cc722f3ab0f275171..bbf62cb1f8190917e930d7003eddbf20f0fececc 100644 (file)
@@ -25,7 +25,7 @@
  *
  * So we play the same trick that "mkdep" played before. We replace
  * the dependency on autoconf.h by a dependency on every config
- * option which is mentioned in any of the listed prequisites.
+ * option which is mentioned in any of the listed prerequisites.
  *
  * kconfig populates a tree in include/config/ with an empty file
  * for each config symbol and when the configuration is updated
@@ -34,7 +34,7 @@
  * the config symbols are rebuilt.
  *
  * So if the user changes his CONFIG_HIS_DRIVER option, only the objects
- * which depend on "include/linux/config/his/driver.h" will be rebuilt,
+ * which depend on "include/config/his/driver.h" will be rebuilt,
  * so most likely only his driver ;-)
  *
  * The idea above dates, by the way, back to Michael E Chastain, AFAIK.
@@ -75,7 +75,7 @@
  * and then basically copies the .<target>.d file to stdout, in the
  * process filtering out the dependency on autoconf.h and adding
  * dependencies on include/config/my/option.h for every
- * CONFIG_MY_OPTION encountered in any of the prequisites.
+ * CONFIG_MY_OPTION encountered in any of the prerequisites.
  *
  * It will also filter out all the dependencies on *.ver. We need
  * to make sure that the generated version checksum are globally up
index 4b72b530c84f1f4b4e98d8342d9d62fefe8d34d6..62ea8f83d4a023a9780c6dc219d8f29ba244c506 100644 (file)
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
        while (size--)
                reg = (reg << 32) | fdt32_to_cpu(*(cells++));
 
-       snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
+       snprintf(unit_addr, sizeof(unit_addr), "%llx", (unsigned long long)reg);
        if (!streq(unitname, unit_addr))
                FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
                     node->fullpath, unit_addr);
index 3bd5f4f302354cf8cecd78ae0ab13b9b3bf130ef..bc443201d3ef00ac2b197da0896a186891cff188 100755 (executable)
@@ -18,6 +18,7 @@ my $V = '0.26';
 
 use Getopt::Long qw(:config no_auto_abbrev);
 use Cwd;
+use File::Find;
 
 my $cur_path = fastgetcwd() . '/';
 my $lk_path = "./";
@@ -58,6 +59,7 @@ my $from_filename = 0;
 my $pattern_depth = 0;
 my $version = 0;
 my $help = 0;
+my $find_maintainer_files = 0;
 
 my $vcs_used = 0;
 
@@ -249,6 +251,7 @@ if (!GetOptions(
                'sections!' => \$sections,
                'fe|file-emails!' => \$file_emails,
                'f|file' => \$from_filename,
+               'find-maintainer-files' => \$find_maintainer_files,
                'v|version' => \$version,
                'h|help|usage' => \$help,
                )) {
@@ -307,36 +310,74 @@ if (!top_of_kernel_tree($lk_path)) {
 
 my @typevalue = ();
 my %keyword_hash;
+my @mfiles = ();
 
-open (my $maint, '<', "${lk_path}MAINTAINERS")
-    or die "$P: Can't open MAINTAINERS: $!\n";
-while (<$maint>) {
-    my $line = $_;
-
-    if ($line =~ m/^([A-Z]):\s*(.*)/) {
-       my $type = $1;
-       my $value = $2;
-
-       ##Filename pattern matching
-       if ($type eq "F" || $type eq "X") {
-           $value =~ s@\.@\\\.@g;       ##Convert . to \.
-           $value =~ s/\*/\.\*/g;       ##Convert * to .*
-           $value =~ s/\?/\./g;         ##Convert ? to .
-           ##if pattern is a directory and it lacks a trailing slash, add one
-           if ((-d $value)) {
-               $value =~ s@([^/])$@$1/@;
+sub read_maintainer_file {
+    my ($file) = @_;
+
+    open (my $maint, '<', "$file")
+       or die "$P: Can't open MAINTAINERS file '$file': $!\n";
+    while (<$maint>) {
+       my $line = $_;
+
+       if ($line =~ m/^([A-Z]):\s*(.*)/) {
+           my $type = $1;
+           my $value = $2;
+
+           ##Filename pattern matching
+           if ($type eq "F" || $type eq "X") {
+               $value =~ s@\.@\\\.@g;       ##Convert . to \.
+               $value =~ s/\*/\.\*/g;       ##Convert * to .*
+               $value =~ s/\?/\./g;         ##Convert ? to .
+               ##if pattern is a directory and it lacks a trailing slash, add one
+               if ((-d $value)) {
+                   $value =~ s@([^/])$@$1/@;
+               }
+           } elsif ($type eq "K") {
+               $keyword_hash{@typevalue} = $value;
            }
-       } elsif ($type eq "K") {
-           $keyword_hash{@typevalue} = $value;
+           push(@typevalue, "$type:$value");
+       } elsif (!(/^\s*$/ || /^\s*\#/)) {
+           $line =~ s/\n$//g;
+           push(@typevalue, $line);
        }
-       push(@typevalue, "$type:$value");
-    } elsif (!/^(\s)*$/) {
-       $line =~ s/\n$//g;
-       push(@typevalue, $line);
     }
+    close($maint);
+}
+
+sub find_is_maintainer_file {
+    my ($file) = $_;
+    return if ($file !~ m@/MAINTAINERS$@);
+    $file = $File::Find::name;
+    return if (! -f $file);
+    push(@mfiles, $file);
 }
-close($maint);
 
+sub find_ignore_git {
+    return grep { $_ !~ /^\.git$/; } @_;
+}
+
+if (-d "${lk_path}MAINTAINERS") {
+    opendir(DIR, "${lk_path}MAINTAINERS") or die $!;
+    my @files = readdir(DIR);
+    closedir(DIR);
+    foreach my $file (@files) {
+       push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./);
+    }
+}
+
+if ($find_maintainer_files) {
+    find( { wanted => \&find_is_maintainer_file,
+           preprocess => \&find_ignore_git,
+           no_chdir => 1,
+       }, "${lk_path}");
+} else {
+    push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS";
+}
+
+foreach my $file (@mfiles) {
+    read_maintainer_file("$file");
+}
 
 #
 # Read mail address map
@@ -873,7 +914,7 @@ sub top_of_kernel_tree {
     if (   (-f "${lk_path}COPYING")
        && (-f "${lk_path}CREDITS")
        && (-f "${lk_path}Kbuild")
-       && (-f "${lk_path}MAINTAINERS")
+       && (-e "${lk_path}MAINTAINERS")
        && (-f "${lk_path}Makefile")
        && (-f "${lk_path}README")
        && (-d "${lk_path}Documentation")
index a0fe34349b24fccd9fb9b8834ea51d3e2d9e155a..e40b53db7f9fdc7c8e3f7094f8b862d66ef7651f 100644 (file)
@@ -2,9 +2,9 @@
 
 use strict;
 
-my %map;
+my $P = $0;
 
-# sort comparison function
+# sort comparison functions
 sub by_category($$) {
     my ($a, $b) = @_;
 
@@ -15,20 +15,33 @@ sub by_category($$) {
     $a =~ s/THE REST/ZZZZZZ/g;
     $b =~ s/THE REST/ZZZZZZ/g;
 
-    $a cmp $b;
+    return $a cmp $b;
 }
 
-sub alpha_output {
-    my $key;
-    my $sort_method = \&by_category;
-    my $sep = "";
-
-    foreach $key (sort $sort_method keys %map) {
-        if ($key ne " ") {
-            print $sep . $key . "\n";
-            $sep = "\n";
-        }
-        print $map{$key};
+sub by_pattern($$) {
+    my ($a, $b) = @_;
+    my $preferred_order = 'MRPLSWTQBCFXNK';
+
+    my $a1 = uc(substr($a, 0, 1));
+    my $b1 = uc(substr($b, 0, 1));
+
+    my $a_index = index($preferred_order, $a1);
+    my $b_index = index($preferred_order, $b1);
+
+    $a_index = 1000 if ($a_index == -1);
+    $b_index = 1000 if ($b_index == -1);
+
+    if (($a1 =~ /^F$/ && $b1 =~ /^F$/) ||
+       ($a1 =~ /^X$/ && $b1 =~ /^X$/)) {
+       return $a cmp $b;
+    }
+
+    if ($a_index < $b_index) {
+       return -1;
+    } elsif ($a_index == $b_index) {
+       return 0;
+    } else {
+       return 1;
     }
 }
 
@@ -39,39 +52,77 @@ sub trim {
     return $s;
 }
 
+sub alpha_output {
+    my ($hashref, $filename) = (@_);
+
+    open(my $file, '>', "$filename") or die "$P: $filename: open failed - $!\n";
+    foreach my $key (sort by_category keys %$hashref) {
+       if ($key eq " ") {
+           chomp $$hashref{$key};
+           print $file $$hashref{$key};
+       } else {
+           print $file "\n" . $key . "\n";
+           foreach my $pattern (sort by_pattern split('\n', %$hashref{$key})) {
+               print $file ($pattern . "\n");
+           }
+       }
+    }
+    close($file);
+}
+
 sub file_input {
+    my ($hashref, $filename) = (@_);
+
     my $lastline = "";
     my $case = " ";
-    $map{$case} = "";
+    $$hashref{$case} = "";
+
+    open(my $file, '<', "$filename") or die "$P: $filename: open failed - $!\n";
 
-    while (<>) {
+    while (<$file>) {
         my $line = $_;
 
         # Pattern line?
         if ($line =~ m/^([A-Z]):\s*(.*)/) {
             $line = $1 . ":\t" . trim($2) . "\n";
             if ($lastline eq "") {
-                $map{$case} = $map{$case} . $line;
+                $$hashref{$case} = $$hashref{$case} . $line;
                 next;
             }
             $case = trim($lastline);
-            exists $map{$case} and die "Header '$case' already exists";
-            $map{$case} = $line;
+            exists $$hashref{$case} and die "Header '$case' already exists";
+            $$hashref{$case} = $line;
             $lastline = "";
             next;
         }
 
         if ($case eq " ") {
-            $map{$case} = $map{$case} . $lastline;
+            $$hashref{$case} = $$hashref{$case} . $lastline;
             $lastline = $line;
             next;
         }
         trim($lastline) eq "" or die ("Odd non-pattern line '$lastline' for '$case'");
         $lastline = $line;
     }
-    $map{$case} = $map{$case} . $lastline;
+    $$hashref{$case} = $$hashref{$case} . $lastline;
+    close($file);
 }
 
-&file_input;
-&alpha_output;
+my %hash;
+my %new_hash;
+
+file_input(\%hash, "MAINTAINERS");
+
+foreach my $type (@ARGV) {
+    foreach my $key (keys %hash) {
+       if ($key =~ /$type/ || $hash{$key} =~ /$type/) {
+           $new_hash{$key} = $hash{$key};
+           delete $hash{$key};
+       }
+    }
+}
+
+alpha_output(\%hash, "MAINTAINERS.new");
+alpha_output(\%new_hash, "SECTION.new");
+
 exit(0);
index 3c6be1452e35dfc48e74ad23e1668c633ce57b24..4525e127afd904e62f34af00e26ccee52252b460 100644 (file)
@@ -1137,7 +1137,7 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
                mutex_lock(&ue->card->user_ctl_lock);
                change = ue->tlv_data_size != size;
                if (!change)
-                       change = memcmp(ue->tlv_data, new_data, size);
+                       change = memcmp(ue->tlv_data, new_data, size) != 0;
                kfree(ue->tlv_data);
                ue->tlv_data = new_data;
                ue->tlv_data_size = size;
index 22995cb3bd447ee0744e142b9a6500b706d85853..cf0433f8006772392061b0cf95514a266a44f948 100644 (file)
@@ -3064,6 +3064,7 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
 {
        snd_pcm_uframes_t *frames = arg;
        snd_pcm_sframes_t result;
+       int err;
        
        switch (cmd) {
        case SNDRV_PCM_IOCTL_FORWARD:
@@ -3083,7 +3084,10 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
        case SNDRV_PCM_IOCTL_START:
                return snd_pcm_start_lock_irq(substream);
        case SNDRV_PCM_IOCTL_DRAIN:
-               return snd_pcm_drain(substream, NULL);
+               snd_power_lock(substream->pcm->card);
+               err = snd_pcm_drain(substream, NULL);
+               snd_power_unlock(substream->pcm->card);
+               return err;
        case SNDRV_PCM_IOCTL_DROP:
                return snd_pcm_drop(substream);
        case SNDRV_PCM_IOCTL_DELAY:
index a536760a94c26521a04cbe4233b1d5fa4b69e625..45c1336c6597f1b49a343b8629613fb979b0ef8b 100644 (file)
@@ -47,10 +47,10 @@ config SND_SEQ_HRTIMER_DEFAULT
          timer.
 
 config SND_SEQ_MIDI_EVENT
-       def_tristate SND_RAWMIDI
+       tristate
 
 config SND_SEQ_MIDI
-       tristate
+       def_tristate SND_RAWMIDI
        select SND_SEQ_MIDI_EVENT
 
 config SND_SEQ_MIDI_EMUL
index 272c55fe17c88aec700a7552da4473349c4ce359..ea2d0ae85bd367d5ea70068ee74d925a349789c3 100644 (file)
@@ -1502,16 +1502,11 @@ static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client,
 static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
 {
        struct snd_seq_queue_info *info = arg;
-       int result;
        struct snd_seq_queue *q;
 
-       result = snd_seq_queue_alloc(client->number, info->locked, info->flags);
-       if (result < 0)
-               return result;
-
-       q = queueptr(result);
-       if (q == NULL)
-               return -EINVAL;
+       q = snd_seq_queue_alloc(client->number, info->locked, info->flags);
+       if (IS_ERR(q))
+               return PTR_ERR(q);
 
        info->queue = q->queue;
        info->locked = q->locked;
@@ -1521,7 +1516,7 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
        if (!info->name[0])
                snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue);
        strlcpy(q->name, info->name, sizeof(q->name));
-       queuefree(q);
+       snd_use_lock_free(&q->use_lock);
 
        return 0;
 }
index 450c5187eecb6bb083736d2d2a1aad43b98c7c3f..79e0c5604ef806d62eca084293e66222b8fe6828 100644 (file)
@@ -184,22 +184,26 @@ void __exit snd_seq_queues_delete(void)
 static void queue_use(struct snd_seq_queue *queue, int client, int use);
 
 /* allocate a new queue -
- * return queue index value or negative value for error
+ * return pointer to new queue or ERR_PTR(-errno) for error
+ * The new queue's use_lock is set to 1. It is the caller's responsibility to
+ * call snd_use_lock_free(&q->use_lock).
  */
-int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
+struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
 {
        struct snd_seq_queue *q;
 
        q = queue_new(client, locked);
        if (q == NULL)
-               return -ENOMEM;
+               return ERR_PTR(-ENOMEM);
        q->info_flags = info_flags;
        queue_use(q, client, 1);
+       snd_use_lock_use(&q->use_lock);
        if (queue_list_add(q) < 0) {
+               snd_use_lock_free(&q->use_lock);
                queue_delete(q);
-               return -ENOMEM;
+               return ERR_PTR(-ENOMEM);
        }
-       return q->queue;
+       return q;
 }
 
 /* delete a queue - queue must be owned by the client */
index 30c8111477f61ed26987dc03abbe9670b36db221..719093489a2c4eec57fed70d4ba2b862cb64a9cf 100644 (file)
@@ -71,7 +71,7 @@ void snd_seq_queues_delete(void);
 
 
 /* create new queue (constructor) */
-int snd_seq_queue_alloc(int client, int locked, unsigned int flags);
+struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags);
 
 /* delete queue (destructor) */
 int snd_seq_queue_delete(int client, int queueid);
index f0e4d502d60482ae8374cf9f830b739eb9e38753..066b5df666f42d2259b40ee5d21492f9165e4470 100644 (file)
@@ -210,9 +210,14 @@ EXPORT_SYMBOL(fw_iso_resources_update);
  */
 void fw_iso_resources_free(struct fw_iso_resources *r)
 {
-       struct fw_card *card = fw_parent_device(r->unit)->card;
+       struct fw_card *card;
        int bandwidth, channel;
 
+       /* Not initialized. */
+       if (r->unit == NULL)
+               return;
+       card = fw_parent_device(r->unit)->card;
+
        mutex_lock(&r->mutex);
 
        if (r->allocated) {
index bf779cfeef0dfaea62ea5684997314a9fe02d4c0..59a270406353d71563f2473ff1675116729acda9 100644 (file)
@@ -128,6 +128,7 @@ static void do_registration(struct work_struct *work)
        return;
 error:
        snd_motu_transaction_unregister(motu);
+       snd_motu_stream_destroy_duplex(motu);
        snd_card_free(motu->card);
        dev_info(&motu->unit->device,
                 "Sound card registration failed: %d\n", err);
index dc585959ca32c8cfbfa3aff0557a4e20c7ec1430..a2b56b188be4d90d9c51547e5fd8a7013700b14f 100644 (file)
@@ -698,10 +698,18 @@ static int copy_gctl(struct snd_emu10k1 *emu,
 {
        struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
 
-       if (emu->support_tlv)
-               return copy_from_user(gctl, &_gctl[idx], sizeof(*gctl));
+       if (emu->support_tlv) {
+               if (in_kernel)
+                       memcpy(gctl, (void *)&_gctl[idx], sizeof(*gctl));
+               else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)))
+                       return -EFAULT;
+               return 0;
+       }
+
        octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
-       if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
+       if (in_kernel)
+               memcpy(gctl, (void *)&octl[idx], sizeof(*octl));
+       else if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
                return -EFAULT;
        gctl->tlv = NULL;
        return 0;
index 8c1289963c802b34783a8a8b4af42ed55bbcd71c..a81aacf684b26341ec9257366d7c83a47962a16d 100644 (file)
@@ -947,6 +947,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
        SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
+       SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
        SND_PCI_QUIRK(0x1c06, 0x2011, "Lemote A1004", CXT_PINCFG_LEMOTE_A1004),
index a91a9ef00c40611db8f19ffcd14d414cd7d42d71..217bb582aff16a6ec428311fddc53370e0355288 100644 (file)
@@ -6647,7 +6647,6 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
        SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
                ALC225_STANDARD_PINS,
                {0x12, 0xb7a60130},
-               {0x13, 0xb8a61140},
                {0x17, 0x90170110}),
        {}
 };
index 0ec7985ed306612db13bd6314ccc94733e835cce..054b613cb0d04c9dabe3e67e647448845708b29e 100644 (file)
@@ -567,7 +567,7 @@ int rt5670_set_jack_detect(struct snd_soc_codec *codec,
 
        rt5670->jack = jack;
        rt5670->hp_gpio.gpiod_dev = codec->dev;
-       rt5670->hp_gpio.name = "headphone detect";
+       rt5670->hp_gpio.name = "headset";
        rt5670->hp_gpio.report = SND_JACK_HEADSET |
                SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2;
        rt5670->hp_gpio.debounce_time = 150;
index 36e530a36c8241d5005c8e8f5f933f2a405c3434..6f629278d982d23e53baf1bd7819e2103e7e02b7 100644 (file)
@@ -5021,6 +5021,7 @@ static const struct regmap_config rt5677_regmap = {
 static const struct i2c_device_id rt5677_i2c_id[] = {
        { "rt5677", RT5677 },
        { "rt5676", RT5676 },
+       { "RT5677CE:00", RT5677 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
index 7d7ab4aee42e3ab133926f2dc5b11489b93a28ae..d72f7d58102f7666740866eb3b8b213604df4e54 100644 (file)
@@ -132,7 +132,7 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
 
        /* Parse the card name from DT */
        ret = snd_soc_of_parse_card_name(card, "label");
-       if (ret < 0) {
+       if (ret < 0 || !card->name) {
                char prop[128];
 
                snprintf(prop, sizeof(prop), "%sname", prefix);
index bc2a52de06a39729ac6aae83c38e08e822575445..f597d558222388e0b52302395ecfbf22a5a127d7 100644 (file)
@@ -184,6 +184,13 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
        return 0;
 }
 
+static const struct acpi_gpio_params headset_gpios = { 0, 0, false };
+
+static const struct acpi_gpio_mapping cht_rt5672_gpios[] = {
+       { "headset-gpios", &headset_gpios, 1 },
+       {},
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
        int ret;
@@ -191,6 +198,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
        struct snd_soc_codec *codec = codec_dai->codec;
        struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
 
+       if (devm_acpi_dev_add_driver_gpios(codec->dev, cht_rt5672_gpios))
+               dev_warn(runtime->dev, "Unable to add GPIO mapping table\n");
+
        /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */
        ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0xF, 4, 24);
        if (ret < 0) {
index 082736c539bc14eec73a1afad11e2a3cd5577d89..e630813c5008627d50e41637e03eeaf8ef2bf0c3 100644 (file)
@@ -542,6 +542,8 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
 
        if (size < sizeof(scale))
                return -ENOMEM;
+       if (cval->min_mute)
+               scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE;
        scale[2] = cval->dBmin;
        scale[3] = cval->dBmax;
        if (copy_to_user(_tlv, scale, sizeof(scale)))
index 3417ef347e40432482b84de271a3bb98c8724297..2b4b067646ab099653fe7ea79d9af1570e2971f6 100644 (file)
@@ -64,6 +64,7 @@ struct usb_mixer_elem_info {
        int cached;
        int cache_val[MAX_CHANNELS];
        u8 initialized;
+       u8 min_mute;
        void *private_data;
 };
 
index e3d1dec48ee49f21d4efe4627fc3c264d76fcfe2..e1e7ce9ab217f6f716fc95da5d1544279c0d1b75 100644 (file)
@@ -1878,6 +1878,12 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
                if (unitid == 7 && cval->control == UAC_FU_VOLUME)
                        snd_dragonfly_quirk_db_scale(mixer, cval, kctl);
                break;
+       /* lowest playback value is muted on C-Media devices */
+       case USB_ID(0x0d8c, 0x000c):
+       case USB_ID(0x0d8c, 0x0014):
+               if (strstr(kctl->id.name, "Playback"))
+                       cval->min_mute = 1;
+               break;
        }
 }
 
index d7b0b0a3a2db55617a908e2fe4a8a2af90082e02..5d2a63248b1d4e77b1bf3edde93ba86710d08f38 100644 (file)
@@ -1142,6 +1142,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
        case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
        case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
        case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
+       case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */
        case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
        case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */
        case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
@@ -1308,10 +1309,13 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
            && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(20);
 
-       /* Zoom R16/24 needs a tiny delay here, otherwise requests like
-        * get/set frequency return as failed despite actually succeeding.
+       /* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here,
+        * otherwise requests like get/set frequency return as failed despite
+        * actually succeeding.
         */
-       if (chip->usb_id == USB_ID(0x1686, 0x00dd) &&
+       if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
+            chip->usb_id == USB_ID(0x046d, 0x0a46) ||
+            chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
            (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
                mdelay(1);
 }
@@ -1374,6 +1378,10 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
                        }
                }
                break;
+       case USB_ID(0x16d0, 0x0a23):
+               if (fp->altsetting == 2)
+                       return SNDRV_PCM_FMTBIT_DSD_U32_BE;
+               break;
 
        default:
                break;
index 7598361ef1f10898ea73d944ae0b0c02c4725d99..da2172ff9662d0e86ffd132b6041b30ea232eb87 100644 (file)
@@ -11,6 +11,8 @@
 #  define __NR_bpf 280
 # elif defined(__sparc__)
 #  define __NR_bpf 349
+# elif defined(__s390__)
+#  define __NR_bpf 351
 # else
 #  error __NR_bpf not defined. libbpf does not support your arch.
 # endif
index 256f571f2ab525700c121c94b6a8e866acd79b73..e5bbb090bf88549111f939dcd7c1f500e6f84a4f 100644 (file)
@@ -39,6 +39,8 @@
 #  define __NR_bpf 280
 # elif defined(__sparc__)
 #  define __NR_bpf 349
+# elif defined(__s390__)
+#  define __NR_bpf 351
 # else
 #  error __NR_bpf not defined. libbpf does not support your arch.
 # endif
index 1a2c07eb7795bb4fb43e4a97bdc721d7cbc7f3b8..8c67a90dbd8229062fe1c0a9ae317fd5f3c1689b 100644 (file)
@@ -879,7 +879,8 @@ bpf_object__create_maps(struct bpf_object *obj)
                        size_t j;
                        int err = *pfd;
 
-                       pr_warning("failed to create map: %s\n",
+                       pr_warning("failed to create map (name: '%s'): %s\n",
+                                  obj->maps[i].name,
                                   strerror(errno));
                        for (j = 0; j < i; j++)
                                zclose(obj->maps[j].fd);
index a36c2eba64e7729347e46175a11f89ff5fe8ebbe..4559a21a8de2d788b5242bc4e8df92c484a10764 100644 (file)
@@ -271,7 +271,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
        case 0x8d:
                if (rex == 0x48 && modrm == 0x65) {
 
-                       /* lea -disp(%rbp), %rsp */
+                       /* lea disp(%rbp), %rsp */
                        *type = INSN_STACK;
                        op->src.type = OP_SRC_ADD;
                        op->src.reg = CFI_BP;
@@ -281,6 +281,30 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
                        break;
                }
 
+               if (rex == 0x48 && (modrm == 0xa4 || modrm == 0x64) &&
+                   sib == 0x24) {
+
+                       /* lea disp(%rsp), %rsp */
+                       *type = INSN_STACK;
+                       op->src.type = OP_SRC_ADD;
+                       op->src.reg = CFI_SP;
+                       op->src.offset = insn.displacement.value;
+                       op->dest.type = OP_DEST_REG;
+                       op->dest.reg = CFI_SP;
+                       break;
+               }
+
+               if (rex == 0x48 && modrm == 0x2c && sib == 0x24) {
+
+                       /* lea (%rsp), %rbp */
+                       *type = INSN_STACK;
+                       op->src.type = OP_SRC_REG;
+                       op->src.reg = CFI_SP;
+                       op->dest.type = OP_DEST_REG;
+                       op->dest.reg = CFI_BP;
+                       break;
+               }
+
                if (rex == 0x4c && modrm == 0x54 && sib == 0x24 &&
                    insn.displacement.value == 8) {
 
index 71729d47eb8552bca1350fc923b91ec189e2ef2f..7956302ecdf2ace692ba49927fe72c97ebf0cca3 100644 (file)
 
 int _version SEC("version") = 1;
 
+#if  __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define TEST_FIELD(TYPE, FIELD, MASK)                                  \
        {                                                               \
                TYPE tmp = *(volatile TYPE *)&skb->FIELD;               \
                if (tmp != ((*(volatile __u32 *)&skb->FIELD) & MASK))   \
                        return TC_ACT_SHOT;                             \
        }
+#else
+#define TEST_FIELD_OFFSET(a, b)        ((sizeof(a) - sizeof(b)) / sizeof(b))
+#define TEST_FIELD(TYPE, FIELD, MASK)                                  \
+       {                                                               \
+               TYPE tmp = *((volatile TYPE *)&skb->FIELD +             \
+                             TEST_FIELD_OFFSET(skb->FIELD, TYPE));     \
+               if (tmp != ((*(volatile __u32 *)&skb->FIELD) & MASK))   \
+                       return TC_ACT_SHOT;                             \
+       }
+#endif
 
 SEC("test1")
 int process(struct __sk_buff *skb)
index addea82f76c943edb42ebbb6075abe849b5b7f32..d3ed7324105e4eeeb281c4c90922c27541b2b58f 100644 (file)
@@ -8,6 +8,7 @@
  * License as published by the Free Software Foundation.
  */
 
+#include <endian.h>
 #include <asm/types.h>
 #include <linux/types.h>
 #include <stdint.h>
@@ -1098,7 +1099,7 @@ static struct bpf_test tests[] = {
                "check skb->hash byte load permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct __sk_buff, hash)),
 #else
@@ -1135,7 +1136,7 @@ static struct bpf_test tests[] = {
                "check skb->hash byte load not permitted 3",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct __sk_buff, hash) + 3),
 #else
@@ -1244,7 +1245,7 @@ static struct bpf_test tests[] = {
                "check skb->hash half load permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct __sk_buff, hash)),
 #else
@@ -1259,7 +1260,7 @@ static struct bpf_test tests[] = {
                "check skb->hash half load not permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct __sk_buff, hash) + 2),
 #else
@@ -5422,7 +5423,7 @@ static struct bpf_test tests[] = {
                "check bpf_perf_event_data->sample_period byte load permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct bpf_perf_event_data, sample_period)),
 #else
@@ -5438,7 +5439,7 @@ static struct bpf_test tests[] = {
                "check bpf_perf_event_data->sample_period half load permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct bpf_perf_event_data, sample_period)),
 #else
@@ -5454,7 +5455,7 @@ static struct bpf_test tests[] = {
                "check bpf_perf_event_data->sample_period word load permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct bpf_perf_event_data, sample_period)),
 #else
@@ -5481,7 +5482,7 @@ static struct bpf_test tests[] = {
                "check skb->data half load not permitted",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct __sk_buff, data)),
 #else
@@ -5497,7 +5498,7 @@ static struct bpf_test tests[] = {
                "check skb->tc_classid half load not permitted for lwt prog",
                .insns = {
                        BPF_MOV64_IMM(BPF_REG_0, 0),
-#ifdef __LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                        BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1,
                                    offsetof(struct __sk_buff, tc_classid)),
 #else
index e2fbb890aef9549281318a4241a2e5a8ad68b9d1..7c647f619d63faf3eff4c135c1b302565b7f78d5 100644 (file)
@@ -14,7 +14,7 @@ all:
        done
 
 override define RUN_TESTS
-       @if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi
+       $(OUTPUT)/run.sh
 endef
 
 override define INSTALL_RULE
old mode 100644 (file)
new mode 100755 (executable)
index 8cecae9..7956ea3
@@ -473,8 +473,8 @@ usage()
        echo "    all     Runs all tests (default)"
        echo "    -t      Run test ID the number amount of times is recommended"
        echo "    -w      Watch test ID run until it runs into an error"
-       echo "    -c      Run test ID once"
-       echo "    -s      Run test ID x test-count number of times"
+       echo "    -s      Run test ID once"
+       echo "    -c      Run test ID x test-count number of times"
        echo "    -l      List all test ID list"
        echo " -h|--help  Help"
        echo
index 1c12b5855e4f929c75706a4adf0d117931e29dec..5fc7ad359e2195ed45588091df4b0a439f15551c 100755 (executable)
@@ -333,6 +333,10 @@ function ntb_tool_tests()
        link_test $LOCAL_TOOL $REMOTE_TOOL
        link_test $REMOTE_TOOL $LOCAL_TOOL
 
+       #Ensure the link is up on both sides before continuing
+       write_file Y $LOCAL_TOOL/link_event
+       write_file Y $REMOTE_TOOL/link_event
+
        for PEER_TRANS in $(ls $LOCAL_TOOL/peer_trans*); do
                PT=$(basename $PEER_TRANS)
                write_file $MW_SIZE $LOCAL_TOOL/$PT
old mode 100644 (file)
new mode 100755 (executable)
index e8c61830825a4ba1fedc9b4949561f5c61b185a5..22312eb4c9419a5fc3ee7054b4a0b604f7cdafce 100644 (file)
@@ -229,10 +229,9 @@ static void init_test(void)
        printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t",
               1e9 * precision);
 
-       if (precision > MAX_PRECISION) {
-               printf("[SKIP]\n");
-               ksft_exit_skip();
-       }
+       if (precision > MAX_PRECISION)
+               ksft_exit_skip("precision: %.0f ns > MAX_PRECISION: %.0f ns\n",
+                               1e9 * precision, 1e9 * MAX_PRECISION);
 
        printf("[OK]\n");
        srand(ts.tv_sec ^ ts.tv_nsec);
index 15252d723b54e196d864d29a7aac2040686dc59a..4d81f6ded88e823c064e72eff3a98a37b68125a8 100644 (file)
@@ -322,47 +322,6 @@ static inline struct kvm *mmu_notifier_to_kvm(struct mmu_notifier *mn)
        return container_of(mn, struct kvm, mmu_notifier);
 }
 
-static void kvm_mmu_notifier_invalidate_page(struct mmu_notifier *mn,
-                                            struct mm_struct *mm,
-                                            unsigned long address)
-{
-       struct kvm *kvm = mmu_notifier_to_kvm(mn);
-       int need_tlb_flush, idx;
-
-       /*
-        * When ->invalidate_page runs, the linux pte has been zapped
-        * already but the page is still allocated until
-        * ->invalidate_page returns. So if we increase the sequence
-        * here the kvm page fault will notice if the spte can't be
-        * established because the page is going to be freed. If
-        * instead the kvm page fault establishes the spte before
-        * ->invalidate_page runs, kvm_unmap_hva will release it
-        * before returning.
-        *
-        * The sequence increase only need to be seen at spin_unlock
-        * time, and not at spin_lock time.
-        *
-        * Increasing the sequence after the spin_unlock would be
-        * unsafe because the kvm page fault could then establish the
-        * pte after kvm_unmap_hva returned, without noticing the page
-        * is going to be freed.
-        */
-       idx = srcu_read_lock(&kvm->srcu);
-       spin_lock(&kvm->mmu_lock);
-
-       kvm->mmu_notifier_seq++;
-       need_tlb_flush = kvm_unmap_hva(kvm, address) | kvm->tlbs_dirty;
-       /* we've to flush the tlb before the pages can be freed */
-       if (need_tlb_flush)
-               kvm_flush_remote_tlbs(kvm);
-
-       spin_unlock(&kvm->mmu_lock);
-
-       kvm_arch_mmu_notifier_invalidate_page(kvm, address);
-
-       srcu_read_unlock(&kvm->srcu, idx);
-}
-
 static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
                                        struct mm_struct *mm,
                                        unsigned long address,
@@ -510,7 +469,6 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn,
 }
 
 static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {
-       .invalidate_page        = kvm_mmu_notifier_invalidate_page,
        .invalidate_range_start = kvm_mmu_notifier_invalidate_range_start,
        .invalidate_range_end   = kvm_mmu_notifier_invalidate_range_end,
        .clear_flush_young      = kvm_mmu_notifier_clear_flush_young,