aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/admin-guide/pm/intel_pstate.rst16
-rw-r--r--Documentation/core-api/kernel-api.rst2
-rw-r--r--Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt4
-rw-r--r--Documentation/devicetree/bindings/bus/ti-sysc.txt1
-rw-r--r--Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt23
-rw-r--r--Documentation/driver-api/infrastructure.rst4
-rw-r--r--Documentation/filesystems/Locking7
-rw-r--r--Documentation/filesystems/cifs/AUTHORS7
-rw-r--r--Documentation/filesystems/cifs/CHANGES3
-rw-r--r--Documentation/filesystems/cifs/TODO17
-rw-r--r--Documentation/filesystems/vfs.txt13
-rw-r--r--Documentation/hwmon/raspberrypi-hwmon22
-rw-r--r--Documentation/kbuild/kconfig-language.txt6
-rw-r--r--Documentation/networking/e100.rst112
-rw-r--r--Documentation/networking/e1000.rst76
-rw-r--r--Documentation/networking/strparser.txt2
-rw-r--r--Documentation/trace/histogram.txt23
-rw-r--r--Documentation/usb/gadget_configfs.txt2
-rw-r--r--Documentation/virtual/kvm/api.txt2
-rw-r--r--MAINTAINERS50
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/Kconfig5
-rw-r--r--arch/alpha/lib/Makefile2
-rw-r--r--arch/alpha/lib/dec_and_lock.c44
-rw-r--r--arch/arm/Kconfig8
-rw-r--r--arch/arm/boot/dts/armada-385-synology-ds116.dts2
-rw-r--r--arch/arm/boot/dts/bcm-cygnus.dtsi24
-rw-r--r--arch/arm/boot/dts/bcm-hr2.dtsi24
-rw-r--r--arch/arm/boot/dts/bcm-nsp.dtsi32
-rw-r--r--arch/arm/boot/dts/bcm5301x.dtsi2
-rw-r--r--arch/arm/boot/dts/da850.dtsi6
-rw-r--r--arch/arm/boot/dts/imx6q.dtsi2
-rw-r--r--arch/arm/boot/dts/imx6sx.dtsi2
-rw-r--r--arch/arm/boot/dts/socfpga.dtsi4
-rw-r--r--arch/arm/boot/dts/socfpga_arria10.dtsi5
-rw-r--r--arch/arm/common/Makefile2
-rw-r--r--arch/arm/configs/multi_v7_defconfig378
-rw-r--r--arch/arm/kernel/signal.c4
-rw-r--r--arch/arm/mach-bcm/Kconfig1
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c2
-rw-r--r--arch/arm/mach-socfpga/Kconfig1
-rw-r--r--arch/arm/xen/enlighten.c7
-rw-r--r--arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi6
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-axg-s400.dts15
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-axg.dtsi4
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gx.dtsi12
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi2
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts3
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi7
-rw-r--r--arch/arm64/boot/dts/amlogic/meson-gxl.dtsi8
-rw-r--r--arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi8
-rw-r--r--arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts4
-rw-r--r--arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts4
-rw-r--r--arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi4
-rw-r--r--arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts2
-rw-r--r--arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts2
-rw-r--r--arch/arm64/boot/dts/marvell/armada-cp110.dtsi2
-rw-r--r--arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi2
-rw-r--r--arch/arm64/boot/dts/qcom/msm8916.dtsi4
-rw-r--r--arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts2
-rw-r--r--arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts2
-rw-r--r--arch/arm64/configs/defconfig102
-rw-r--r--arch/arm64/crypto/aes-glue.c2
-rw-r--r--arch/arm64/include/asm/alternative.h7
-rw-r--r--arch/arm64/include/asm/kvm_host.h1
-rw-r--r--arch/arm64/include/asm/pgtable.h6
-rw-r--r--arch/arm64/include/asm/sysreg.h11
-rw-r--r--arch/arm64/kernel/alternative.c51
-rw-r--r--arch/arm64/kernel/cpufeature.c2
-rw-r--r--arch/arm64/kernel/module.c5
-rw-r--r--arch/arm64/kernel/smp.c2
-rw-r--r--arch/arm64/kvm/fpsimd.c36
-rw-r--r--arch/arm64/mm/dma-mapping.c9
-rw-r--r--arch/arm64/mm/proc.S5
-rw-r--r--arch/microblaze/Kconfig.debug7
-rw-r--r--arch/microblaze/include/asm/setup.h5
-rw-r--r--arch/microblaze/include/asm/unistd.h2
-rw-r--r--arch/microblaze/include/uapi/asm/unistd.h2
-rw-r--r--arch/microblaze/kernel/Makefile4
-rw-r--r--arch/microblaze/kernel/heartbeat.c72
-rw-r--r--arch/microblaze/kernel/platform.c29
-rw-r--r--arch/microblaze/kernel/reset.c11
-rw-r--r--arch/microblaze/kernel/syscall_table.S2
-rw-r--r--arch/microblaze/kernel/timer.c7
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/ath79/mach-pb44.c2
-rw-r--r--arch/mips/bcm47xx/setup.c6
-rw-r--r--arch/mips/include/asm/io.h2
-rw-r--r--arch/mips/include/asm/mipsregs.h3
-rw-r--r--arch/mips/include/uapi/asm/unistd.h18
-rw-r--r--arch/mips/kernel/entry.S8
-rw-r--r--arch/mips/kernel/mcount.S27
-rw-r--r--arch/mips/kernel/scall32-o32.S2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/signal.c3
-rw-r--r--arch/parisc/Kconfig6
-rw-r--r--arch/parisc/Makefile4
-rw-r--r--arch/parisc/include/asm/signal.h8
-rw-r--r--arch/parisc/include/uapi/asm/unistd.h3
-rw-r--r--arch/parisc/kernel/drivers.c25
-rw-r--r--arch/parisc/kernel/syscall_table.S1
-rw-r--r--arch/parisc/kernel/unwind.c4
-rw-r--r--arch/powerpc/Makefile1
-rw-r--r--arch/powerpc/include/asm/book3s/32/pgalloc.h2
-rw-r--r--arch/powerpc/include/asm/book3s/64/pgtable-4k.h21
-rw-r--r--arch/powerpc/include/asm/book3s/64/pgtable-64k.h9
-rw-r--r--arch/powerpc/include/asm/book3s/64/pgtable.h5
-rw-r--r--arch/powerpc/include/asm/nmi.h2
-rw-r--r--arch/powerpc/include/asm/nohash/32/pgalloc.h2
-rw-r--r--arch/powerpc/include/asm/nohash/64/pgalloc.h1
-rw-r--r--arch/powerpc/include/asm/systbl.h1
-rw-r--r--arch/powerpc/include/asm/unistd.h2
-rw-r--r--arch/powerpc/include/uapi/asm/unistd.h1
-rw-r--r--arch/powerpc/kernel/dt_cpu_ftrs.c3
-rw-r--r--arch/powerpc/kernel/pci_32.c4
-rw-r--r--arch/powerpc/kernel/pci_64.c4
-rw-r--r--arch/powerpc/kernel/rtas.c4
-rw-r--r--arch/powerpc/kernel/setup-common.c12
-rw-r--r--arch/powerpc/kernel/setup_64.c8
-rw-r--r--arch/powerpc/kernel/signal.c4
-rw-r--r--arch/powerpc/kernel/signal_32.c8
-rw-r--r--arch/powerpc/kernel/signal_64.c4
-rw-r--r--arch/powerpc/kernel/smp.c6
-rw-r--r--arch/powerpc/kernel/stacktrace.c4
-rw-r--r--arch/powerpc/kernel/syscalls.c4
-rw-r--r--arch/powerpc/mm/hugetlbpage.c3
-rw-r--r--arch/powerpc/mm/pgtable-book3s64.c12
-rw-r--r--arch/powerpc/mm/subpage-prot.c4
-rw-r--r--arch/powerpc/mm/tlb-radix.c98
-rw-r--r--arch/powerpc/platforms/powermac/time.c29
-rw-r--r--arch/s390/include/asm/css_chars.h62
-rw-r--r--arch/x86/Makefile6
-rw-r--r--arch/x86/boot/compressed/eboot.c2
-rw-r--r--arch/x86/entry/common.c2
-rw-r--r--arch/x86/entry/entry_32.S2
-rw-r--r--arch/x86/entry/entry_64_compat.S16
-rw-r--r--arch/x86/include/asm/barrier.h2
-rw-r--r--arch/x86/include/asm/pgalloc.h3
-rw-r--r--arch/x86/include/asm/pgtable.h2
-rw-r--r--arch/x86/include/asm/pgtable_64.h4
-rw-r--r--arch/x86/include/asm/vmx.h3
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c60
-rw-r--r--arch/x86/kernel/cpu/bugs.c4
-rw-r--r--arch/x86/kernel/cpu/cacheinfo.c2
-rw-r--r--arch/x86/kernel/cpu/common.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-severity.c5
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c44
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c5
-rw-r--r--arch/x86/kernel/e820.c15
-rw-r--r--arch/x86/kernel/head64.c2
-rw-r--r--arch/x86/kernel/quirks.c11
-rw-r--r--arch/x86/kernel/signal.c2
-rw-r--r--arch/x86/kernel/traps.c14
-rw-r--r--arch/x86/kernel/uprobes.c2
-rw-r--r--arch/x86/kvm/vmx.c67
-rw-r--r--arch/x86/kvm/x86.h9
-rw-r--r--arch/x86/mm/fault.c21
-rw-r--r--arch/x86/mm/init_64.c20
-rw-r--r--arch/x86/platform/efi/efi_64.c4
-rw-r--r--arch/x86/xen/enlighten.c7
-rw-r--r--arch/x86/xen/enlighten_pv.c1
-rw-r--r--arch/x86/xen/enlighten_pvh.c1
-rw-r--r--arch/x86/xen/smp_pv.c5
-rw-r--r--block/bio.c3
-rw-r--r--block/blk-core.c12
-rw-r--r--block/blk-mq-debugfs.c2
-rw-r--r--block/blk-mq.c13
-rw-r--r--block/blk-softirq.c1
-rw-r--r--block/blk-timeout.c1
-rw-r--r--block/sed-opal.c4
-rw-r--r--certs/blacklist.h2
-rw-r--r--crypto/af_alg.c13
-rw-r--r--crypto/algif_aead.c4
-rw-r--r--crypto/algif_skcipher.c4
-rw-r--r--crypto/asymmetric_keys/x509_cert_parser.c9
-rw-r--r--crypto/morus640.c3
-rw-r--r--crypto/sha3_generic.c2
-rw-r--r--drivers/acpi/acpi_lpss.c18
-rw-r--r--drivers/acpi/ec.c20
-rw-r--r--drivers/acpi/osl.c72
-rw-r--r--drivers/base/Makefile3
-rw-r--r--drivers/base/core.c15
-rw-r--r--drivers/base/power/domain.c7
-rw-r--r--drivers/block/drbd/drbd_req.c4
-rw-r--r--drivers/block/nbd.c42
-rw-r--r--drivers/block/null_blk.c2
-rw-r--r--drivers/bluetooth/hci_nokia.c2
-rw-r--r--drivers/bus/ti-sysc.c72
-rw-r--r--drivers/char/hw_random/core.c11
-rw-r--r--drivers/char/random.c29
-rw-r--r--drivers/clk/ti/clk-7xx.c1
-rw-r--r--drivers/clocksource/timer-stm32.c4
-rw-r--r--drivers/cpufreq/intel_pstate.c27
-rw-r--r--drivers/cpufreq/qcom-cpufreq-kryo.c33
-rw-r--r--drivers/crypto/chelsio/chtls/chtls_io.c5
-rw-r--r--drivers/dax/super.c8
-rw-r--r--drivers/firmware/dmi-id.c2
-rw-r--r--drivers/firmware/dmi_scan.c1
-rw-r--r--drivers/firmware/efi/libstub/tpm.c2
-rw-r--r--drivers/firmware/raspberrypi.c29
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c24
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c14
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c33
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c39
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c16
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c2
-rw-r--r--drivers/gpu/drm/arm/malidp_drv.c3
-rw-r--r--drivers/gpu/drm/arm/malidp_hw.c3
-rw-r--r--drivers/gpu/drm/arm/malidp_planes.c9
-rw-r--r--drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c2
-rw-r--r--drivers/gpu/drm/bridge/sil-sii8620.c309
-rw-r--r--drivers/gpu/drm/drm_drv.c14
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h24
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c57
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c49
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c12
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h5
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c20
-rw-r--r--drivers/gpu/drm/i915/intel_display.c16
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c34
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c6
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.c6
-rw-r--r--drivers/gpu/drm/i915/intel_dvo.c6
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c6
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c18
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c5
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c6
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c12
-rw-r--r--drivers/gpu/drm/meson/meson_drv.c12
-rw-r--r--drivers/gpu/drm/nouveau/dispnv50/curs507a.c2
-rw-r--r--drivers/gpu/drm/nouveau/dispnv50/wndw.c13
-rw-r--r--drivers/gpu/drm/qxl/qxl_display.c7
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_tcon.c25
-rw-r--r--drivers/hid/hid-google-hammer.c2
-rw-r--r--drivers/hid/hid-ids.h1
-rw-r--r--drivers/hid/hid-steam.c10
-rw-r--r--drivers/hid/intel-ish-hid/ipc/pci-ish.c22
-rw-r--r--drivers/hid/wacom_sys.c8
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/dell-smm-hwmon.c7
-rw-r--r--drivers/hwmon/nct6775.c2
-rw-r--r--drivers/hwmon/raspberrypi-hwmon.c166
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c8
-rw-r--r--drivers/i2c/busses/i2c-gpio.c4
-rw-r--r--drivers/i2c/i2c-core-smbus.c14
-rw-r--r--drivers/iio/accel/mma8452.c2
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c2
-rw-r--r--drivers/iio/light/tsl2772.c2
-rw-r--r--drivers/iio/pressure/bmp280-core.c5
-rw-r--r--drivers/infiniband/core/uverbs_main.c14
-rw-r--r--drivers/infiniband/core/verbs.c14
-rw-r--r--drivers/infiniband/hw/mlx4/mr.c7
-rw-r--r--drivers/infiniband/hw/mlx5/main.c36
-rw-r--r--drivers/infiniband/hw/qedr/verbs.c3
-rw-r--r--drivers/infiniband/sw/rxe/rxe_req.c5
-rw-r--r--drivers/input/input-mt.c12
-rw-r--r--drivers/input/joystick/xpad.c2
-rw-r--r--drivers/input/keyboard/goldfish_events.c9
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/sc27xx-vibra.c154
-rw-r--r--drivers/input/mouse/elan_i2c.h2
-rw-r--r--drivers/input/mouse/elan_i2c_core.c3
-rw-r--r--drivers/input/mouse/elan_i2c_smbus.c10
-rw-r--r--drivers/input/mouse/elantech.c11
-rw-r--r--drivers/input/mouse/psmouse-base.c12
-rw-r--r--drivers/input/rmi4/Kconfig1
-rw-r--r--drivers/input/rmi4/rmi_2d_sensor.c34
-rw-r--r--drivers/input/rmi4/rmi_bus.c50
-rw-r--r--drivers/input/rmi4/rmi_bus.h10
-rw-r--r--drivers/input/rmi4/rmi_driver.c52
-rw-r--r--drivers/input/rmi4/rmi_f01.c10
-rw-r--r--drivers/input/rmi4/rmi_f03.c9
-rw-r--r--drivers/input/rmi4/rmi_f11.c42
-rw-r--r--drivers/input/rmi4/rmi_f12.c8
-rw-r--r--drivers/input/rmi4/rmi_f30.c9
-rw-r--r--drivers/input/rmi4/rmi_f34.c5
-rw-r--r--drivers/input/rmi4/rmi_f54.c6
-rw-r--r--drivers/input/touchscreen/silead.c1
-rw-r--r--drivers/irqchip/irq-gic-v2m.c2
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c62
-rw-r--r--drivers/irqchip/irq-ls-scfg-msi.c10
-rw-r--r--drivers/isdn/mISDN/socket.c2
-rw-r--r--drivers/lightnvm/Kconfig2
-rw-r--r--drivers/md/dm-raid.c2
-rw-r--r--drivers/md/dm-table.c7
-rw-r--r--drivers/md/dm-thin-metadata.c9
-rw-r--r--drivers/md/dm-thin.c11
-rw-r--r--drivers/md/dm-writecache.c10
-rw-r--r--drivers/md/dm-zoned-target.c2
-rw-r--r--drivers/md/dm.c8
-rw-r--r--drivers/memory/ti-emif-pm.c33
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c19
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c4
-rw-r--r--drivers/mtd/nand/raw/denali_dt.c6
-rw-r--r--drivers/mtd/nand/raw/mxc_nand.c5
-rw-r--r--drivers/mtd/nand/raw/nand_base.c2
-rw-r--r--drivers/mtd/nand/raw/nand_macronix.c48
-rw-r--r--drivers/mtd/nand/raw/nand_micron.c2
-rw-r--r--drivers/net/ethernet/amd/Kconfig2
-rw-r--r--drivers/net/ethernet/apm/xgene-v2/Kconfig1
-rw-r--r--drivers/net/ethernet/apm/xgene/Kconfig1
-rw-r--r--drivers/net/ethernet/arc/Kconfig6
-rw-r--r--drivers/net/ethernet/broadcom/Kconfig2
-rw-r--r--drivers/net/ethernet/cadence/macb_ptp.c5
-rw-r--r--drivers/net/ethernet/calxeda/Kconfig2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c2
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_clsf.c3
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c12
-rw-r--r--drivers/net/ethernet/faraday/ftgmac100.c4
-rw-r--r--drivers/net/ethernet/hisilicon/Kconfig2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c7
-rw-r--r--drivers/net/ethernet/marvell/Kconfig8
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/Kconfig2
-rw-r--r--drivers/net/ethernet/mscc/ocelot.c11
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_dcbx.c11
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_ll2.c11
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_main.c12
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/renesas/Kconfig2
-rw-r--r--drivers/net/ethernet/sfc/efx.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/Kconfig2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c18
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c10
-rw-r--r--drivers/net/ethernet/sun/sungem.c22
-rw-r--r--drivers/net/ethernet/ti/davinci_cpdma.c2
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c19
-rw-r--r--drivers/net/hamradio/bpqether.c8
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c4
-rw-r--r--drivers/net/net_failover.c2
-rw-r--r--drivers/net/ppp/pppoe.c2
-rw-r--r--drivers/net/usb/cdc_ncm.c3
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/Kconfig1
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/Kconfig2
-rw-r--r--drivers/net/xen-netfront.c11
-rw-r--r--drivers/nfc/pn533/usb.c4
-rw-r--r--drivers/nvdimm/pmem.c3
-rw-r--r--drivers/nvme/host/core.c1
-rw-r--r--drivers/nvme/host/fc.c6
-rw-r--r--drivers/nvme/host/nvme.h1
-rw-r--r--drivers/nvme/host/pci.c44
-rw-r--r--drivers/nvme/host/rdma.c76
-rw-r--r--drivers/nvme/target/core.c8
-rw-r--r--drivers/opp/core.c2
-rw-r--r--drivers/pci/Makefile6
-rw-r--r--drivers/pci/controller/Kconfig3
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c10
-rw-r--r--drivers/perf/xgene_pmu.c2
-rw-r--r--drivers/pinctrl/actions/pinctrl-owl.c2
-rw-r--r--drivers/pinctrl/devicetree.c7
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mt7622.c6
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-common.c5
-rw-r--r--drivers/pinctrl/pinctrl-single.c14
-rw-r--r--drivers/ptp/ptp_chardev.c4
-rw-r--r--drivers/ptp/ptp_qoriq.c2
-rw-r--r--drivers/s390/block/dasd.c171
-rw-r--r--drivers/s390/block/dasd_alias.c6
-rw-r--r--drivers/s390/block/dasd_diag.c3
-rw-r--r--drivers/s390/block/dasd_eckd.c46
-rw-r--r--drivers/s390/block/dasd_eer.c10
-rw-r--r--drivers/s390/block/dasd_fba.c6
-rw-r--r--drivers/s390/block/dasd_int.h26
-rw-r--r--drivers/s390/cio/Makefile1
-rw-r--r--drivers/s390/cio/vfio_ccw_cp.c140
-rw-r--r--drivers/s390/cio/vfio_ccw_drv.c5
-rw-r--r--drivers/s390/cio/vfio_ccw_fsm.c17
-rw-r--r--drivers/s390/cio/vfio_ccw_trace.h54
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c7
-rw-r--r--drivers/scsi/scsi_debug.c2
-rw-r--r--drivers/scsi/scsi_transport_fc.c2
-rw-r--r--drivers/scsi/xen-scsifront.c33
-rw-r--r--drivers/soc/bcm/brcmstb/pm/pm-arm.c16
-rw-r--r--drivers/soc/imx/gpcv2.c13
-rw-r--r--drivers/soc/qcom/Kconfig3
-rw-r--r--drivers/soc/renesas/rcar-sysc.c35
-rw-r--r--drivers/soc/ti/wkup_m3_ipc.c76
-rw-r--r--drivers/staging/android/ion/ion_heap.c2
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c2
-rw-r--r--drivers/staging/typec/Kconfig1
-rw-r--r--drivers/target/target_core_user.c44
-rw-r--r--drivers/tee/optee/Kconfig8
-rw-r--r--drivers/tee/optee/core.c2
-rw-r--r--drivers/tee/optee/rpc.c2
-rw-r--r--drivers/tty/n_tty.c55
-rw-r--r--drivers/tty/serdev/core.c1
-rw-r--r--drivers/tty/serial/8250/8250_pci.c2
-rw-r--r--drivers/tty/vt/vt.c4
-rw-r--r--drivers/usb/chipidea/host.c5
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/dwc2/core.h3
-rw-r--r--drivers/usb/dwc2/gadget.c20
-rw-r--r--drivers/usb/dwc2/hcd.c93
-rw-r--r--drivers/usb/dwc2/hcd.h8
-rw-r--r--drivers/usb/dwc2/hcd_intr.c11
-rw-r--r--drivers/usb/dwc2/hcd_queue.c5
-rw-r--r--drivers/usb/dwc3/core.c23
-rw-r--r--drivers/usb/dwc3/dwc3-of-simple.c3
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/dwc3/dwc3-qcom.c13
-rw-r--r--drivers/usb/gadget/composite.c3
-rw-r--r--drivers/usb/gadget/function/f_fs.c26
-rw-r--r--drivers/usb/host/xhci-mem.c4
-rw-r--r--drivers/usb/host/xhci-tegra.c6
-rw-r--r--drivers/usb/host/xhci-trace.h36
-rw-r--r--drivers/usb/host/xhci.c47
-rw-r--r--drivers/usb/host/xhci.h4
-rw-r--r--drivers/usb/serial/cp210x.c14
-rw-r--r--drivers/usb/typec/tcpm.c10
-rw-r--r--drivers/usb/typec/ucsi/ucsi.c13
-rw-r--r--drivers/usb/typec/ucsi/ucsi_acpi.c5
-rw-r--r--drivers/vhost/net.c3
-rw-r--r--drivers/xen/Makefile2
-rw-r--r--drivers/xen/events/events_base.c2
-rw-r--r--drivers/xen/grant-table.c4
-rw-r--r--drivers/xen/manage.c18
-rw-r--r--drivers/xen/privcmd-buf.c210
-rw-r--r--drivers/xen/privcmd.c9
-rw-r--r--drivers/xen/privcmd.h3
-rw-r--r--drivers/xen/xen-scsiback.c16
-rw-r--r--fs/aio.c148
-rw-r--r--fs/btrfs/extent_io.c5
-rw-r--r--fs/btrfs/inode.c7
-rw-r--r--fs/btrfs/ioctl.c10
-rw-r--r--fs/btrfs/qgroup.c17
-rw-r--r--fs/ceph/inode.c1
-rw-r--r--fs/cifs/cifs_debug.c29
-rw-r--r--fs/cifs/cifsencrypt.c20
-rw-r--r--fs/cifs/cifsglob.h40
-rw-r--r--fs/cifs/cifsproto.h7
-rw-r--r--fs/cifs/cifssmb.c8
-rw-r--r--fs/cifs/connect.c8
-rw-r--r--fs/cifs/inode.c13
-rw-r--r--fs/cifs/misc.c9
-rw-r--r--fs/cifs/smb2misc.c19
-rw-r--r--fs/cifs/smb2ops.c277
-rw-r--r--fs/cifs/smb2pdu.c333
-rw-r--r--fs/cifs/smb2pdu.h23
-rw-r--r--fs/cifs/smb2proto.h6
-rw-r--r--fs/cifs/smb2transport.c18
-rw-r--r--fs/cifs/smbdirect.c19
-rw-r--r--fs/cifs/trace.h3
-rw-r--r--fs/cifs/transport.c173
-rw-r--r--fs/eventfd.c19
-rw-r--r--fs/eventpoll.c15
-rw-r--r--fs/ext2/ext2.h2
-rw-r--r--fs/ext2/super.c6
-rw-r--r--fs/jfs/xattr.c10
-rw-r--r--fs/nfs/delegation.c4
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c21
-rw-r--r--fs/nfs/nfs4proc.c33
-rw-r--r--fs/nfs/pnfs.h5
-rw-r--r--fs/pipe.c22
-rw-r--r--fs/proc/base.c28
-rw-r--r--fs/proc/generic.c11
-rw-r--r--fs/quota/dquot.c7
-rw-r--r--fs/select.c23
-rw-r--r--fs/timerfd.c22
-rw-r--r--fs/udf/balloc.c5
-rw-r--r--fs/udf/directory.c8
-rw-r--r--fs/udf/inode.c8
-rw-r--r--fs/udf/namei.c14
-rw-r--r--fs/udf/udfdecl.h9
-rw-r--r--fs/xfs/libxfs/xfs_ag_resv.c31
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c26
-rw-r--r--fs/xfs/libxfs/xfs_bmap.h2
-rw-r--r--fs/xfs/libxfs/xfs_format.h5
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c76
-rw-r--r--fs/xfs/libxfs/xfs_rtbitmap.c4
-rw-r--r--fs/xfs/xfs_bmap_util.c106
-rw-r--r--fs/xfs/xfs_fsmap.c4
-rw-r--r--fs/xfs/xfs_fsops.c2
-rw-r--r--fs/xfs/xfs_inode.c57
-rw-r--r--fs/xfs/xfs_iomap.c15
-rw-r--r--fs/xfs/xfs_trans.c7
-rw-r--r--include/acpi/processor.h3
-rw-r--r--include/asm-generic/qspinlock_types.h2
-rw-r--r--include/crypto/if_alg.h3
-rw-r--r--include/dt-bindings/bus/ti-sysc.h2
-rw-r--r--include/dt-bindings/clock/dra7.h1
-rw-r--r--include/linux/acpi.h3
-rw-r--r--include/linux/atmdev.h15
-rw-r--r--include/linux/backing-dev-defs.h2
-rw-r--r--include/linux/blkdev.h4
-rw-r--r--include/linux/bpf.h12
-rw-r--r--include/linux/compat.h8
-rw-r--r--include/linux/compiler-gcc.h25
-rw-r--r--include/linux/compiler_types.h18
-rw-r--r--include/linux/dax.h2
-rw-r--r--include/linux/dma-contiguous.h2
-rw-r--r--include/linux/filter.h83
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/iio/buffer-dma.h2
-rw-r--r--include/linux/input/mt.h2
-rw-r--r--include/linux/irq.h1
-rw-r--r--include/linux/irqdesc.h5
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/memory.h1
-rw-r--r--include/linux/mod_devicetable.h1
-rw-r--r--include/linux/net.h1
-rw-r--r--include/linux/nfs_xdr.h2
-rw-r--r--include/linux/platform_data/ti-sysc.h1
-rw-r--r--include/linux/pm_domain.h6
-rw-r--r--include/linux/poll.h12
-rw-r--r--include/linux/refcount.h4
-rw-r--r--include/linux/rmi.h2
-rw-r--r--include/linux/scatterlist.h18
-rw-r--r--include/linux/sched.h23
-rw-r--r--include/linux/skbuff.h3
-rw-r--r--include/linux/slub_def.h4
-rw-r--r--include/linux/spinlock.h5
-rw-r--r--include/linux/syscalls.h4
-rw-r--r--include/linux/wkup_m3_ipc.h9
-rw-r--r--include/net/bluetooth/bluetooth.h2
-rw-r--r--include/net/ip6_fib.h5
-rw-r--r--include/net/iucv/af_iucv.h2
-rw-r--r--include/net/sctp/sctp.h3
-rw-r--r--include/net/tcp.h3
-rw-r--r--include/net/tls.h6
-rw-r--r--include/net/udp.h2
-rw-r--r--include/rdma/ib_verbs.h13
-rw-r--r--include/soc/bcm2835/raspberrypi-firmware.h1
-rw-r--r--include/uapi/linux/aio_abi.h6
-rw-r--r--include/uapi/linux/nbd.h3
-rw-r--r--include/uapi/linux/target_core_user.h4
-rw-r--r--include/xen/xen.h6
-rw-r--r--init/Kconfig11
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/bpf/core.c69
-rw-r--r--kernel/bpf/devmap.c14
-rw-r--r--kernel/bpf/syscall.c12
-rw-r--r--kernel/dma/Kconfig50
-rw-r--r--kernel/dma/Makefile11
-rw-r--r--kernel/dma/coherent.c (renamed from drivers/base/dma-coherent.c)0
-rw-r--r--kernel/dma/contiguous.c (renamed from drivers/base/dma-contiguous.c)0
-rw-r--r--kernel/dma/debug.c (renamed from lib/dma-debug.c)0
-rw-r--r--kernel/dma/direct.c (renamed from lib/dma-direct.c)0
-rw-r--r--kernel/dma/mapping.c (renamed from drivers/base/dma-mapping.c)2
-rw-r--r--kernel/dma/noncoherent.c (renamed from lib/dma-noncoherent.c)0
-rw-r--r--kernel/dma/swiotlb.c (renamed from lib/swiotlb.c)1
-rw-r--r--kernel/dma/virt.c (renamed from lib/dma-virt.c)2
-rw-r--r--kernel/events/core.c2
-rw-r--r--kernel/events/ring_buffer.c6
-rw-r--r--kernel/irq/debugfs.c1
-rw-r--r--kernel/locking/lockdep.c12
-rw-r--r--kernel/locking/rwsem.c1
-rw-r--r--kernel/rseq.c7
-rw-r--r--kernel/softirq.c6
-rw-r--r--kernel/time/hrtimer.c2
-rw-r--r--kernel/time/posix-cpu-timers.c2
-rw-r--r--kernel/time/time.c6
-rw-r--r--kernel/trace/trace.c6
-rw-r--r--kernel/trace/trace_events_filter.c10
-rw-r--r--lib/Kconfig47
-rw-r--r--lib/Kconfig.kasan1
-rw-r--r--lib/Makefile12
-rw-r--r--lib/dec_and_lock.c16
-rw-r--r--lib/percpu_ida.c2
-rw-r--r--lib/refcount.c28
-rw-r--r--lib/scatterlist.c6
-rw-r--r--lib/test_printf.c7
-rw-r--r--mm/backing-dev.c20
-rw-r--r--mm/memblock.c1
-rw-r--r--mm/slab_common.c4
-rw-r--r--mm/slub.c7
-rw-r--r--mm/vmstat.c2
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/atm/br2684.c3
-rw-r--r--net/atm/clip.c3
-rw-r--r--net/atm/common.c14
-rw-r--r--net/atm/common.h2
-rw-r--r--net/atm/lec.c3
-rw-r--r--net/atm/mpc.c3
-rw-r--r--net/atm/pppoatm.c3
-rw-r--r--net/atm/pvc.c2
-rw-r--r--net/atm/raw.c4
-rw-r--r--net/atm/svc.c2
-rw-r--r--net/ax25/af_ax25.c2
-rw-r--r--net/bluetooth/af_bluetooth.c7
-rw-r--r--net/bluetooth/hci_sock.c2
-rw-r--r--net/bluetooth/l2cap_sock.c2
-rw-r--r--net/bluetooth/rfcomm/sock.c2
-rw-r--r--net/bluetooth/sco.c2
-rw-r--r--net/bpfilter/.gitignore1
-rw-r--r--net/bpfilter/Makefile6
-rw-r--r--net/caif/caif_socket.c12
-rw-r--r--net/can/bcm.c2
-rw-r--r--net/can/raw.c2
-rw-r--r--net/core/datagram.c13
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/filter.c21
-rw-r--r--net/dccp/ccids/ccid3.c16
-rw-r--r--net/dccp/dccp.h3
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/dccp/ipv6.c2
-rw-r--r--net/dccp/proto.c13
-rw-r--r--net/decnet/af_decnet.c6
-rw-r--r--net/ieee802154/socket.c4
-rw-r--r--net/ipv4/af_inet.c8
-rw-r--r--net/ipv4/inet_hashtables.c4
-rw-r--r--net/ipv4/ip_output.c3
-rw-r--r--net/ipv4/tcp.c23
-rw-r--r--net/ipv4/udp.c10
-rw-r--r--net/ipv6/af_inet6.c4
-rw-r--r--net/ipv6/inet6_hashtables.c4
-rw-r--r--net/ipv6/ip6_fib.c5
-rw-r--r--net/ipv6/ip6_output.c3
-rw-r--r--net/ipv6/mcast.c9
-rw-r--r--net/ipv6/raw.c4
-rw-r--r--net/iucv/af_iucv.c7
-rw-r--r--net/kcm/kcmsock.c10
-rw-r--r--net/key/af_key.c2
-rw-r--r--net/l2tp/l2tp_ip.c2
-rw-r--r--net/l2tp/l2tp_ip6.c2
-rw-r--r--net/l2tp/l2tp_ppp.c2
-rw-r--r--net/llc/af_llc.c2
-rw-r--r--net/ncsi/ncsi-aen.c10
-rw-r--r--net/ncsi/ncsi-manage.c49
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/netrom/af_netrom.c2
-rw-r--r--net/nfc/llcp_sock.c9
-rw-r--r--net/nfc/rawsock.c4
-rw-r--r--net/packet/af_packet.c25
-rw-r--r--net/phonet/socket.c9
-rw-r--r--net/qrtr/qrtr.c2
-rw-r--r--net/rose/af_rose.c2
-rw-r--r--net/rxrpc/af_rxrpc.c10
-rw-r--r--net/sched/act_ife.c12
-rw-r--r--net/sched/cls_flower.c21
-rw-r--r--net/sched/sch_blackhole.c2
-rw-r--r--net/sched/sch_hfsc.c4
-rw-r--r--net/sctp/chunk.c4
-rw-r--r--net/sctp/ipv6.c2
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/sctp/socket.c4
-rw-r--r--net/smc/af_smc.c12
-rw-r--r--net/socket.c50
-rw-r--r--net/strparser/strparser.c5
-rw-r--r--net/sunrpc/xprt.c10
-rw-r--r--net/tipc/socket.c14
-rw-r--r--net/tls/tls_main.c2
-rw-r--r--net/tls/tls_sw.c19
-rw-r--r--net/unix/af_unix.c30
-rw-r--r--net/vmw_vsock/af_vsock.c19
-rw-r--r--net/vmw_vsock/virtio_transport.c2
-rw-r--r--net/x25/af_x25.c2
-rw-r--r--net/xdp/xsk.c10
-rw-r--r--scripts/Makefile.build2
-rwxr-xr-xscripts/checkpatch.pl6
-rwxr-xr-xscripts/gcc-x86_64-has-stack-protector.sh2
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/preprocess.c2
-rw-r--r--scripts/kconfig/zconf.y8
-rw-r--r--security/keys/dh.c6
-rw-r--r--security/selinux/selinuxfs.c78
-rw-r--r--security/smack/smack_lsm.c1
-rw-r--r--sound/core/seq/seq_clientmgr.c3
-rw-r--r--sound/core/timer.c2
-rw-r--r--sound/pci/hda/hda_codec.c5
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/patch_ca0132.c64
-rw-r--r--sound/pci/hda/patch_hdmi.c5
-rw-r--r--sound/pci/hda/patch_realtek.c20
-rw-r--r--sound/pci/lx6464es/lx6464es.c1
-rw-r--r--tools/arch/arm/include/uapi/asm/kvm.h1
-rw-r--r--tools/arch/arm64/include/uapi/asm/kvm.h1
-rw-r--r--tools/arch/powerpc/include/uapi/asm/kvm.h1
-rw-r--r--tools/arch/powerpc/include/uapi/asm/unistd.h1
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h2
-rw-r--r--tools/bpf/bpftool/perf.c5
-rw-r--r--tools/bpf/bpftool/prog.c4
-rw-r--r--tools/include/uapi/drm/drm.h7
-rw-r--r--tools/include/uapi/linux/bpf.h2
-rw-r--r--tools/include/uapi/linux/if_link.h2
-rw-r--r--tools/include/uapi/linux/kvm.h1
-rw-r--r--tools/objtool/check.c1
-rw-r--r--tools/perf/Documentation/perf-stat.txt3
-rw-r--r--tools/perf/arch/powerpc/util/skip-callchain-idx.c2
-rw-r--r--tools/perf/arch/x86/entry/syscalls/syscall_64.tbl2
-rw-r--r--tools/perf/bench/numa.c5
-rw-r--r--tools/perf/builtin-annotate.c11
-rw-r--r--tools/perf/builtin-c2c.c10
-rw-r--r--tools/perf/builtin-report.c3
-rw-r--r--tools/perf/builtin-script.c42
-rw-r--r--tools/perf/builtin-stat.c48
-rw-r--r--tools/perf/tests/parse-events.c25
-rw-r--r--tools/perf/tests/topology.c1
-rw-r--r--tools/perf/ui/gtk/hists.c2
-rw-r--r--tools/perf/util/c++/clang.cpp11
-rw-r--r--tools/perf/util/header.c12
-rw-r--r--tools/perf/util/hist.c12
-rw-r--r--tools/perf/util/hist.h4
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c2
-rw-r--r--tools/perf/util/parse-events.y5
-rw-r--r--tools/perf/util/pmu.c99
-rw-r--r--tools/perf/util/sort.h4
-rw-r--r--tools/power/x86/turbostat/turbostat.82
-rw-r--r--tools/power/x86/turbostat/turbostat.c240
-rw-r--r--tools/testing/selftests/bpf/config10
-rwxr-xr-xtools/testing/selftests/bpf/test_offload.py12
-rwxr-xr-xtools/testing/selftests/bpf/test_tunnel.sh26
-rw-r--r--tools/testing/selftests/net/.gitignore1
-rw-r--r--tools/testing/selftests/net/config2
-rwxr-xr-xtools/testing/selftests/pstore/pstore_post_reboot_tests5
-rw-r--r--tools/testing/selftests/rseq/param_test.c24
-rw-r--r--tools/testing/selftests/rseq/rseq-arm.h1
-rw-r--r--tools/testing/selftests/rseq/rseq-mips.h725
-rw-r--r--tools/testing/selftests/rseq/rseq.h2
-rwxr-xr-x[-rw-r--r--]tools/testing/selftests/rseq/run_param_test.sh0
-rw-r--r--tools/testing/selftests/sparc64/Makefile20
-rw-r--r--tools/testing/selftests/sparc64/drivers/Makefile2
-rwxr-xr-xtools/testing/selftests/static_keys/test_static_keys.sh13
-rw-r--r--tools/testing/selftests/sync/config4
-rwxr-xr-xtools/testing/selftests/sysctl/sysctl.sh20
-rwxr-xr-xtools/testing/selftests/user/test_user_copy.sh7
-rw-r--r--tools/testing/selftests/vm/compaction_test.c4
-rw-r--r--tools/testing/selftests/vm/mlock2-tests.c12
-rwxr-xr-xtools/testing/selftests/vm/run_vmtests5
-rw-r--r--tools/testing/selftests/vm/userfaultfd.c4
-rw-r--r--tools/testing/selftests/x86/sigreturn.c59
-rwxr-xr-xtools/testing/selftests/zram/zram.sh5
-rwxr-xr-xtools/testing/selftests/zram/zram_lib.sh5
-rw-r--r--tools/virtio/linux/scatterlist.h18
-rw-r--r--virt/kvm/Kconfig2
-rw-r--r--virt/kvm/arm/mmu.c2
-rw-r--r--virt/kvm/arm/vgic/vgic-v3.c5
-rw-r--r--virt/kvm/kvm_main.c19
738 files changed, 7590 insertions, 3797 deletions
diff --git a/Documentation/admin-guide/pm/intel_pstate.rst b/Documentation/admin-guide/pm/intel_pstate.rst
index ab2fe0eda1d7..8f1d3de449b5 100644
--- a/Documentation/admin-guide/pm/intel_pstate.rst
+++ b/Documentation/admin-guide/pm/intel_pstate.rst
@@ -324,8 +324,7 @@ Global Attributes
324 324
325``intel_pstate`` exposes several global attributes (files) in ``sysfs`` to 325``intel_pstate`` exposes several global attributes (files) in ``sysfs`` to
326control its functionality at the system level. They are located in the 326control its functionality at the system level. They are located in the
327``/sys/devices/system/cpu/cpufreq/intel_pstate/`` directory and affect all 327``/sys/devices/system/cpu/intel_pstate/`` directory and affect all CPUs.
328CPUs.
329 328
330Some of them are not present if the ``intel_pstate=per_cpu_perf_limits`` 329Some of them are not present if the ``intel_pstate=per_cpu_perf_limits``
331argument is passed to the kernel in the command line. 330argument is passed to the kernel in the command line.
@@ -379,6 +378,17 @@ argument is passed to the kernel in the command line.
379 but it affects the maximum possible value of per-policy P-state limits 378 but it affects the maximum possible value of per-policy P-state limits
380 (see `Interpretation of Policy Attributes`_ below for details). 379 (see `Interpretation of Policy Attributes`_ below for details).
381 380
381``hwp_dynamic_boost``
382 This attribute is only present if ``intel_pstate`` works in the
383 `active mode with the HWP feature enabled <Active Mode With HWP_>`_ in
384 the processor. If set (equal to 1), it causes the minimum P-state limit
385 to be increased dynamically for a short time whenever a task previously
386 waiting on I/O is selected to run on a given logical CPU (the purpose
387 of this mechanism is to improve performance).
388
389 This setting has no effect on logical CPUs whose minimum P-state limit
390 is directly set to the highest non-turbo P-state or above it.
391
382.. _status_attr: 392.. _status_attr:
383 393
384``status`` 394``status``
@@ -410,7 +420,7 @@ argument is passed to the kernel in the command line.
410 That only is supported in some configurations, though (for example, if 420 That only is supported in some configurations, though (for example, if
411 the `HWP feature is enabled in the processor <Active Mode With HWP_>`_, 421 the `HWP feature is enabled in the processor <Active Mode With HWP_>`_,
412 the operation mode of the driver cannot be changed), and if it is not 422 the operation mode of the driver cannot be changed), and if it is not
413 supported in the current configuration, writes to this attribute with 423 supported in the current configuration, writes to this attribute will
414 fail with an appropriate error. 424 fail with an appropriate error.
415 425
416Interpretation of Policy Attributes 426Interpretation of Policy Attributes
diff --git a/Documentation/core-api/kernel-api.rst b/Documentation/core-api/kernel-api.rst
index 8e44aea366c2..76fe2d0f5e7d 100644
--- a/Documentation/core-api/kernel-api.rst
+++ b/Documentation/core-api/kernel-api.rst
@@ -284,7 +284,7 @@ Resources Management
284MTRR Handling 284MTRR Handling
285------------- 285-------------
286 286
287.. kernel-doc:: arch/x86/kernel/cpu/mtrr/main.c 287.. kernel-doc:: arch/x86/kernel/cpu/mtrr/mtrr.c
288 :export: 288 :export:
289 289
290Security Framework 290Security Framework
diff --git a/Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt b/Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt
index c052caad36e8..104cc9b41df4 100644
--- a/Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt
+++ b/Documentation/devicetree/bindings/arm/bcm/brcm,brcmstb.txt
@@ -189,7 +189,11 @@ Power-Down (SRPD), among other things.
189 189
190Required properties: 190Required properties:
191- compatible : should contain one of these 191- compatible : should contain one of these
192 "brcm,brcmstb-memc-ddr-rev-b.2.1"
192 "brcm,brcmstb-memc-ddr-rev-b.2.2" 193 "brcm,brcmstb-memc-ddr-rev-b.2.2"
194 "brcm,brcmstb-memc-ddr-rev-b.2.3"
195 "brcm,brcmstb-memc-ddr-rev-b.3.0"
196 "brcm,brcmstb-memc-ddr-rev-b.3.1"
193 "brcm,brcmstb-memc-ddr" 197 "brcm,brcmstb-memc-ddr"
194- reg : the MEMC DDR register range 198- reg : the MEMC DDR register range
195 199
diff --git a/Documentation/devicetree/bindings/bus/ti-sysc.txt b/Documentation/devicetree/bindings/bus/ti-sysc.txt
index d8ed5b780ed9..91dc2333af01 100644
--- a/Documentation/devicetree/bindings/bus/ti-sysc.txt
+++ b/Documentation/devicetree/bindings/bus/ti-sysc.txt
@@ -36,6 +36,7 @@ Required standard properties:
36 "ti,sysc-omap-aes" 36 "ti,sysc-omap-aes"
37 "ti,sysc-mcasp" 37 "ti,sysc-mcasp"
38 "ti,sysc-usb-host-fs" 38 "ti,sysc-usb-host-fs"
39 "ti,sysc-dra7-mcan"
39 40
40- reg shall have register areas implemented for the interconnect 41- reg shall have register areas implemented for the interconnect
41 target module in question such as revision, sysc and syss 42 target module in question such as revision, sysc and syss
diff --git a/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
new file mode 100644
index 000000000000..f2ec0d4f2dff
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/sprd,sc27xx-vibra.txt
@@ -0,0 +1,23 @@
1Spreadtrum SC27xx PMIC Vibrator
2
3Required properties:
4- compatible: should be "sprd,sc2731-vibrator".
5- reg: address of vibrator control register.
6
7Example :
8
9 sc2731_pmic: pmic@0 {
10 compatible = "sprd,sc2731";
11 reg = <0>;
12 spi-max-frequency = <26000000>;
13 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
14 interrupt-controller;
15 #interrupt-cells = <2>;
16 #address-cells = <1>;
17 #size-cells = <0>;
18
19 vibrator@eb4 {
20 compatible = "sprd,sc2731-vibrator";
21 reg = <0xeb4>;
22 };
23 };
diff --git a/Documentation/driver-api/infrastructure.rst b/Documentation/driver-api/infrastructure.rst
index bee1b9a1702f..6172f3cc3d0b 100644
--- a/Documentation/driver-api/infrastructure.rst
+++ b/Documentation/driver-api/infrastructure.rst
@@ -49,10 +49,10 @@ Device Drivers Base
49Device Drivers DMA Management 49Device Drivers DMA Management
50----------------------------- 50-----------------------------
51 51
52.. kernel-doc:: drivers/base/dma-coherent.c 52.. kernel-doc:: kernel/dma/coherent.c
53 :export: 53 :export:
54 54
55.. kernel-doc:: drivers/base/dma-mapping.c 55.. kernel-doc:: kernel/dma/mapping.c
56 :export: 56 :export:
57 57
58Device drivers PnP support 58Device drivers PnP support
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index 2c391338c675..37bf0a9de75c 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -441,8 +441,6 @@ prototypes:
441 int (*iterate) (struct file *, struct dir_context *); 441 int (*iterate) (struct file *, struct dir_context *);
442 int (*iterate_shared) (struct file *, struct dir_context *); 442 int (*iterate_shared) (struct file *, struct dir_context *);
443 __poll_t (*poll) (struct file *, struct poll_table_struct *); 443 __poll_t (*poll) (struct file *, struct poll_table_struct *);
444 struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
445 __poll_t (*poll_mask) (struct file *, __poll_t);
446 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 444 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
447 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 445 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
448 int (*mmap) (struct file *, struct vm_area_struct *); 446 int (*mmap) (struct file *, struct vm_area_struct *);
@@ -473,7 +471,7 @@ prototypes:
473}; 471};
474 472
475locking rules: 473locking rules:
476 All except for ->poll_mask may block. 474 All may block.
477 475
478->llseek() locking has moved from llseek to the individual llseek 476->llseek() locking has moved from llseek to the individual llseek
479implementations. If your fs is not using generic_file_llseek, you 477implementations. If your fs is not using generic_file_llseek, you
@@ -505,9 +503,6 @@ in sys_read() and friends.
505the lease within the individual filesystem to record the result of the 503the lease within the individual filesystem to record the result of the
506operation 504operation
507 505
508->poll_mask can be called with or without the waitqueue lock for the waitqueue
509returned from ->get_poll_head.
510
511--------------------------- dquot_operations ------------------------------- 506--------------------------- dquot_operations -------------------------------
512prototypes: 507prototypes:
513 int (*write_dquot) (struct dquot *); 508 int (*write_dquot) (struct dquot *);
diff --git a/Documentation/filesystems/cifs/AUTHORS b/Documentation/filesystems/cifs/AUTHORS
index 9f4f87e16240..75865da2ce14 100644
--- a/Documentation/filesystems/cifs/AUTHORS
+++ b/Documentation/filesystems/cifs/AUTHORS
@@ -42,9 +42,11 @@ Jeff Layton (many, many fixes, as well as great work on the cifs Kerberos code)
42Scott Lovenberg 42Scott Lovenberg
43Pavel Shilovsky (for great work adding SMB2 support, and various SMB3 features) 43Pavel Shilovsky (for great work adding SMB2 support, and various SMB3 features)
44Aurelien Aptel (for DFS SMB3 work and some key bug fixes) 44Aurelien Aptel (for DFS SMB3 work and some key bug fixes)
45Ronnie Sahlberg (for SMB3 xattr work and bug fixes) 45Ronnie Sahlberg (for SMB3 xattr work, bug fixes, and lots of great work on compounding)
46Shirish Pargaonkar (for many ACL patches over the years) 46Shirish Pargaonkar (for many ACL patches over the years)
47Sachin Prabhu (many bug fixes, including for reconnect, copy offload and security) 47Sachin Prabhu (many bug fixes, including for reconnect, copy offload and security)
48Paulo Alcantara
49Long Li (some great work on RDMA, SMB Direct)
48 50
49 51
50Test case and Bug Report contributors 52Test case and Bug Report contributors
@@ -58,5 +60,4 @@ mention to the Stanford Checker (SWAT) which pointed out many minor
58bugs in error paths. Valuable suggestions also have come from Al Viro 60bugs in error paths. Valuable suggestions also have come from Al Viro
59and Dave Miller. 61and Dave Miller.
60 62
61And thanks to the IBM LTC and Power test teams and SuSE testers for 63And thanks to the IBM LTC and Power test teams and SuSE and Citrix and RedHat testers for finding multiple bugs during excellent stress test runs.
62finding multiple bugs during excellent stress test runs.
diff --git a/Documentation/filesystems/cifs/CHANGES b/Documentation/filesystems/cifs/CHANGES
index bc0025cdd1c9..455e1cc494a9 100644
--- a/Documentation/filesystems/cifs/CHANGES
+++ b/Documentation/filesystems/cifs/CHANGES
@@ -1,3 +1,6 @@
1See https://wiki.samba.org/index.php/LinuxCIFSKernel for
2more current information.
3
1Version 1.62 4Version 1.62
2------------ 5------------
3Add sockopt=TCP_NODELAY mount option. EA (xattr) routines hardened 6Add sockopt=TCP_NODELAY mount option. EA (xattr) routines hardened
diff --git a/Documentation/filesystems/cifs/TODO b/Documentation/filesystems/cifs/TODO
index c5adf149b57f..852499aed64b 100644
--- a/Documentation/filesystems/cifs/TODO
+++ b/Documentation/filesystems/cifs/TODO
@@ -9,14 +9,14 @@ is a partial list of the known problems and missing features:
9 9
10a) SMB3 (and SMB3.02) missing optional features: 10a) SMB3 (and SMB3.02) missing optional features:
11 - multichannel (started), integration with RDMA 11 - multichannel (started), integration with RDMA
12 - directory leases (improved metadata caching) 12 - directory leases (improved metadata caching), started (root dir only)
13 - T10 copy offload (copy chunk, and "Duplicate Extents" ioctl 13 - T10 copy offload ie "ODX" (copy chunk, and "Duplicate Extents" ioctl
14 currently the only two server side copy mechanisms supported) 14 currently the only two server side copy mechanisms supported)
15 15
16b) improved sparse file support 16b) improved sparse file support
17 17
18c) Directory entry caching relies on a 1 second timer, rather than 18c) Directory entry caching relies on a 1 second timer, rather than
19using Directory Leases 19using Directory Leases, currently only the root file handle is cached longer
20 20
21d) quota support (needs minor kernel change since quota calls 21d) quota support (needs minor kernel change since quota calls
22to make it to network filesystems or deviceless filesystems) 22to make it to network filesystems or deviceless filesystems)
@@ -42,6 +42,8 @@ mount or a per server basis to client UIDs or nobody if no mapping
42exists. Also better integration with winbind for resolving SID owners 42exists. Also better integration with winbind for resolving SID owners
43 43
44k) Add tools to take advantage of more smb3 specific ioctls and features 44k) Add tools to take advantage of more smb3 specific ioctls and features
45(passthrough ioctl/fsctl for sending various SMB3 fsctls to the server
46is in progress)
45 47
46l) encrypted file support 48l) encrypted file support
47 49
@@ -71,9 +73,8 @@ t) split cifs and smb3 support into separate modules so legacy (and less
71secure) CIFS dialect can be disabled in environments that don't need it 73secure) CIFS dialect can be disabled in environments that don't need it
72and simplify the code. 74and simplify the code.
73 75
74u) Finish up SMB3.1.1 dialect support 76v) POSIX Extensions for SMB3.1.1 (started, create and mkdir support added
75 77so far).
76v) POSIX Extensions for SMB3.1.1
77 78
78KNOWN BUGS 79KNOWN BUGS
79==================================== 80====================================
@@ -92,8 +93,8 @@ Misc testing to do
921) check out max path names and max path name components against various server 931) check out max path names and max path name components against various server
93types. Try nested symlinks (8 deep). Return max path name in stat -f information 94types. Try nested symlinks (8 deep). Return max path name in stat -f information
94 95
952) Improve xfstest's cifs enablement and adapt xfstests where needed to test 962) Improve xfstest's cifs/smb3 enablement and adapt xfstests where needed to test
96cifs better 97cifs/smb3 better
97 98
983) Additional performance testing and optimization using iozone and similar - 993) Additional performance testing and optimization using iozone and similar -
99there are some easy changes that can be done to parallelize sequential writes, 100there are some easy changes that can be done to parallelize sequential writes,
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 829a7b7857a4..f608180ad59d 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -857,8 +857,6 @@ struct file_operations {
857 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); 857 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
858 int (*iterate) (struct file *, struct dir_context *); 858 int (*iterate) (struct file *, struct dir_context *);
859 __poll_t (*poll) (struct file *, struct poll_table_struct *); 859 __poll_t (*poll) (struct file *, struct poll_table_struct *);
860 struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
861 __poll_t (*poll_mask) (struct file *, __poll_t);
862 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 860 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
863 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 861 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
864 int (*mmap) (struct file *, struct vm_area_struct *); 862 int (*mmap) (struct file *, struct vm_area_struct *);
@@ -903,17 +901,6 @@ otherwise noted.
903 activity on this file and (optionally) go to sleep until there 901 activity on this file and (optionally) go to sleep until there
904 is activity. Called by the select(2) and poll(2) system calls 902 is activity. Called by the select(2) and poll(2) system calls
905 903
906 get_poll_head: Returns the struct wait_queue_head that callers can
907 wait on. Callers need to check the returned events using ->poll_mask
908 once woken. Can return NULL to indicate polling is not supported,
909 or any error code using the ERR_PTR convention to indicate that a
910 grave error occured and ->poll_mask shall not be called.
911
912 poll_mask: return the mask of EPOLL* values describing the file descriptor
913 state. Called either before going to sleep on the waitqueue returned by
914 get_poll_head, or after it has been woken. If ->get_poll_head and
915 ->poll_mask are implemented ->poll does not need to be implement.
916
917 unlocked_ioctl: called by the ioctl(2) system call. 904 unlocked_ioctl: called by the ioctl(2) system call.
918 905
919 compat_ioctl: called by the ioctl(2) system call when 32 bit system calls 906 compat_ioctl: called by the ioctl(2) system call when 32 bit system calls
diff --git a/Documentation/hwmon/raspberrypi-hwmon b/Documentation/hwmon/raspberrypi-hwmon
new file mode 100644
index 000000000000..3c92e2cb52d6
--- /dev/null
+++ b/Documentation/hwmon/raspberrypi-hwmon
@@ -0,0 +1,22 @@
1Kernel driver raspberrypi-hwmon
2===============================
3
4Supported boards:
5 * Raspberry Pi A+ (via GPIO on SoC)
6 * Raspberry Pi B+ (via GPIO on SoC)
7 * Raspberry Pi 2 B (via GPIO on SoC)
8 * Raspberry Pi 3 B (via GPIO on port expander)
9 * Raspberry Pi 3 B+ (via PMIC)
10
11Author: Stefan Wahren <stefan.wahren@i2se.com>
12
13Description
14-----------
15
16This driver periodically polls a mailbox property of the VC4 firmware to detect
17undervoltage conditions.
18
19Sysfs entries
20-------------
21
22in0_lcrit_alarm Undervoltage alarm
diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt
index 3534a84d206c..64e0775a62d4 100644
--- a/Documentation/kbuild/kconfig-language.txt
+++ b/Documentation/kbuild/kconfig-language.txt
@@ -430,6 +430,12 @@ This sets the config program's title bar if the config program chooses
430to use it. It should be placed at the top of the configuration, before any 430to use it. It should be placed at the top of the configuration, before any
431other statement. 431other statement.
432 432
433'#' Kconfig source file comment:
434
435An unquoted '#' character anywhere in a source file line indicates
436the beginning of a source file comment. The remainder of that line
437is a comment.
438
433 439
434Kconfig hints 440Kconfig hints
435------------- 441-------------
diff --git a/Documentation/networking/e100.rst b/Documentation/networking/e100.rst
index d4d837027925..9708f5fa76de 100644
--- a/Documentation/networking/e100.rst
+++ b/Documentation/networking/e100.rst
@@ -1,3 +1,4 @@
1==============================================================
1Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters 2Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
2============================================================== 3==============================================================
3 4
@@ -86,83 +87,84 @@ Event Log Message Level: The driver uses the message level flag to log events
86Additional Configurations 87Additional Configurations
87========================= 88=========================
88 89
89 Configuring the Driver on Different Distributions 90Configuring the Driver on Different Distributions
90 ------------------------------------------------- 91-------------------------------------------------
91 92
92 Configuring a network driver to load properly when the system is started is 93Configuring a network driver to load properly when the system is started
93 distribution dependent. Typically, the configuration process involves adding 94is distribution dependent. Typically, the configuration process involves
94 an alias line to /etc/modprobe.d/*.conf as well as editing other system 95adding an alias line to /etc/modprobe.d/*.conf as well as editing other
95 startup scripts and/or configuration files. Many popular Linux 96system startup scripts and/or configuration files. Many popular Linux
96 distributions ship with tools to make these changes for you. To learn the 97distributions ship with tools to make these changes for you. To learn
97 proper way to configure a network device for your system, refer to your 98the proper way to configure a network device for your system, refer to
98 distribution documentation. If during this process you are asked for the 99your distribution documentation. If during this process you are asked
99 driver or module name, the name for the Linux Base Driver for the Intel 100for the driver or module name, the name for the Linux Base Driver for
100 PRO/100 Family of Adapters is e100. 101the Intel PRO/100 Family of Adapters is e100.
101 102
102 As an example, if you install the e100 driver for two PRO/100 adapters 103As an example, if you install the e100 driver for two PRO/100 adapters
103 (eth0 and eth1), add the following to a configuration file in /etc/modprobe.d/ 104(eth0 and eth1), add the following to a configuration file in
105/etc/modprobe.d/::
104 106
105 alias eth0 e100 107 alias eth0 e100
106 alias eth1 e100 108 alias eth1 e100
107 109
108 Viewing Link Messages 110Viewing Link Messages
109 --------------------- 111---------------------
110 In order to see link messages and other Intel driver information on your
111 console, you must set the dmesg level up to six. This can be done by
112 entering the following on the command line before loading the e100 driver::
113
114 dmesg -n 6
115 112
116 If you wish to see all messages issued by the driver, including debug 113In order to see link messages and other Intel driver information on your
117 messages, set the dmesg level to eight. 114console, you must set the dmesg level up to six. This can be done by
115entering the following on the command line before loading the e100
116driver::
118 117
119 NOTE: This setting is not saved across reboots. 118 dmesg -n 6
120 119
120If you wish to see all messages issued by the driver, including debug
121messages, set the dmesg level to eight.
121 122
122 ethtool 123NOTE: This setting is not saved across reboots.
123 -------
124 124
125 The driver utilizes the ethtool interface for driver configuration and 125ethtool
126 diagnostics, as well as displaying statistical information. The ethtool 126-------
127 version 1.6 or later is required for this functionality.
128 127
129 The latest release of ethtool can be found from 128The driver utilizes the ethtool interface for driver configuration and
130 https://www.kernel.org/pub/software/network/ethtool/ 129diagnostics, as well as displaying statistical information. The ethtool
130version 1.6 or later is required for this functionality.
131 131
132 Enabling Wake on LAN* (WoL) 132The latest release of ethtool can be found from
133 --------------------------- 133https://www.kernel.org/pub/software/network/ethtool/
134 WoL is provided through the ethtool* utility. For instructions on enabling
135 WoL with ethtool, refer to the ethtool man page.
136 134
137 WoL will be enabled on the system during the next shut down or reboot. For 135Enabling Wake on LAN* (WoL)
138 this driver version, in order to enable WoL, the e100 driver must be 136---------------------------
139 loaded when shutting down or rebooting the system. 137WoL is provided through the ethtool* utility. For instructions on
138enabling WoL with ethtool, refer to the ethtool man page. WoL will be
139enabled on the system during the next shut down or reboot. For this
140driver version, in order to enable WoL, the e100 driver must be loaded
141when shutting down or rebooting the system.
140 142
141 NAPI 143NAPI
142 ---- 144----
143 145
144 NAPI (Rx polling mode) is supported in the e100 driver. 146NAPI (Rx polling mode) is supported in the e100 driver.
145 147
146 See https://wiki.linuxfoundation.org/networking/napi for more information 148See https://wiki.linuxfoundation.org/networking/napi for more
147 on NAPI. 149information on NAPI.
148 150
149 Multiple Interfaces on Same Ethernet Broadcast Network 151Multiple Interfaces on Same Ethernet Broadcast Network
150 ------------------------------------------------------ 152------------------------------------------------------
151 153
152 Due to the default ARP behavior on Linux, it is not possible to have 154Due to the default ARP behavior on Linux, it is not possible to have one
153 one system on two IP networks in the same Ethernet broadcast domain 155system on two IP networks in the same Ethernet broadcast domain
154 (non-partitioned switch) behave as expected. All Ethernet interfaces 156(non-partitioned switch) behave as expected. All Ethernet interfaces
155 will respond to IP traffic for any IP address assigned to the system. 157will respond to IP traffic for any IP address assigned to the system.
156 This results in unbalanced receive traffic. 158This results in unbalanced receive traffic.
157 159
158 If you have multiple interfaces in a server, either turn on ARP 160If you have multiple interfaces in a server, either turn on ARP
159 filtering by 161filtering by
160 162
161 (1) entering:: echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter 163(1) entering:: echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
162 (this only works if your kernel's version is higher than 2.4.5), or 164 (this only works if your kernel's version is higher than 2.4.5), or
163 165
164 (2) installing the interfaces in separate broadcast domains (either 166(2) installing the interfaces in separate broadcast domains (either
165 in different switches or in a switch partitioned to VLANs). 167 in different switches or in a switch partitioned to VLANs).
166 168
167 169
168Support 170Support
diff --git a/Documentation/networking/e1000.rst b/Documentation/networking/e1000.rst
index 616848940e63..144b87eef153 100644
--- a/Documentation/networking/e1000.rst
+++ b/Documentation/networking/e1000.rst
@@ -1,3 +1,4 @@
1===========================================================
1Linux* Base Driver for Intel(R) Ethernet Network Connection 2Linux* Base Driver for Intel(R) Ethernet Network Connection
2=========================================================== 3===========================================================
3 4
@@ -354,57 +355,58 @@ previously mentioned to force the adapter to the same speed and duplex.
354Additional Configurations 355Additional Configurations
355========================= 356=========================
356 357
357 Jumbo Frames 358Jumbo Frames
358 ------------ 359------------
359 Jumbo Frames support is enabled by changing the MTU to a value larger than 360Jumbo Frames support is enabled by changing the MTU to a value larger
360 the default of 1500. Use the ifconfig command to increase the MTU size. 361than the default of 1500. Use the ifconfig command to increase the MTU
361 For example:: 362size. For example::
362 363
363 ifconfig eth<x> mtu 9000 up 364 ifconfig eth<x> mtu 9000 up
364 365
365 This setting is not saved across reboots. It can be made permanent if 366This setting is not saved across reboots. It can be made permanent if
366 you add:: 367you add::
367 368
368 MTU=9000 369 MTU=9000
369 370
370 to the file /etc/sysconfig/network-scripts/ifcfg-eth<x>. This example 371to the file /etc/sysconfig/network-scripts/ifcfg-eth<x>. This example
371 applies to the Red Hat distributions; other distributions may store this 372applies to the Red Hat distributions; other distributions may store this
372 setting in a different location. 373setting in a different location.
374
375Notes: Degradation in throughput performance may be observed in some
376Jumbo frames environments. If this is observed, increasing the
377application's socket buffer size and/or increasing the
378/proc/sys/net/ipv4/tcp_*mem entry values may help. See the specific
379application manual and /usr/src/linux*/Documentation/
380networking/ip-sysctl.txt for more details.
373 381
374 Notes: 382- The maximum MTU setting for Jumbo Frames is 16110. This value
375 Degradation in throughput performance may be observed in some Jumbo frames 383 coincides with the maximum Jumbo Frames size of 16128.
376 environments. If this is observed, increasing the application's socket buffer
377 size and/or increasing the /proc/sys/net/ipv4/tcp_*mem entry values may help.
378 See the specific application manual and /usr/src/linux*/Documentation/
379 networking/ip-sysctl.txt for more details.
380 384
381 - The maximum MTU setting for Jumbo Frames is 16110. This value coincides 385- Using Jumbo frames at 10 or 100 Mbps is not supported and may result
382 with the maximum Jumbo Frames size of 16128. 386 in poor performance or loss of link.
383 387
384 - Using Jumbo frames at 10 or 100 Mbps is not supported and may result in 388- Adapters based on the Intel(R) 82542 and 82573V/E controller do not
385 poor performance or loss of link. 389 support Jumbo Frames. These correspond to the following product names:
390 Intel(R) PRO/1000 Gigabit Server Adapter Intel(R) PRO/1000 PM Network
391 Connection
386 392
387 - Adapters based on the Intel(R) 82542 and 82573V/E controller do not 393ethtool
388 support Jumbo Frames. These correspond to the following product names: 394-------
389 Intel(R) PRO/1000 Gigabit Server Adapter 395The driver utilizes the ethtool interface for driver configuration and
390 Intel(R) PRO/1000 PM Network Connection 396diagnostics, as well as displaying statistical information. The ethtool
397version 1.6 or later is required for this functionality.
391 398
392 ethtool 399The latest release of ethtool can be found from
393 ------- 400https://www.kernel.org/pub/software/network/ethtool/
394 The driver utilizes the ethtool interface for driver configuration and
395 diagnostics, as well as displaying statistical information. The ethtool
396 version 1.6 or later is required for this functionality.
397 401
398 The latest release of ethtool can be found from 402Enabling Wake on LAN* (WoL)
399 https://www.kernel.org/pub/software/network/ethtool/ 403---------------------------
404WoL is configured through the ethtool* utility.
400 405
401 Enabling Wake on LAN* (WoL) 406WoL will be enabled on the system during the next shut down or reboot.
402 --------------------------- 407For this driver version, in order to enable WoL, the e1000 driver must be
403 WoL is configured through the ethtool* utility. 408loaded when shutting down or rebooting the system.
404 409
405 WoL will be enabled on the system during the next shut down or reboot.
406 For this driver version, in order to enable WoL, the e1000 driver must be
407 loaded when shutting down or rebooting the system.
408 410
409Support 411Support
410======= 412=======
diff --git a/Documentation/networking/strparser.txt b/Documentation/networking/strparser.txt
index 13081b3decef..a7d354ddda7b 100644
--- a/Documentation/networking/strparser.txt
+++ b/Documentation/networking/strparser.txt
@@ -48,7 +48,7 @@ void strp_pause(struct strparser *strp)
48 Temporarily pause a stream parser. Message parsing is suspended 48 Temporarily pause a stream parser. Message parsing is suspended
49 and no new messages are delivered to the upper layer. 49 and no new messages are delivered to the upper layer.
50 50
51void strp_pause(struct strparser *strp) 51void strp_unpause(struct strparser *strp)
52 52
53 Unpause a paused stream parser. 53 Unpause a paused stream parser.
54 54
diff --git a/Documentation/trace/histogram.txt b/Documentation/trace/histogram.txt
index e73bcf9cb5f3..7ffea6aa22e3 100644
--- a/Documentation/trace/histogram.txt
+++ b/Documentation/trace/histogram.txt
@@ -1729,35 +1729,35 @@ If a variable isn't a key variable or prefixed with 'vals=', the
1729associated event field will be saved in a variable but won't be summed 1729associated event field will be saved in a variable but won't be summed
1730as a value: 1730as a value:
1731 1731
1732 # echo 'hist:keys=next_pid:ts1=common_timestamp ... >> event/trigger 1732 # echo 'hist:keys=next_pid:ts1=common_timestamp ...' >> event/trigger
1733 1733
1734Multiple variables can be assigned at the same time. The below would 1734Multiple variables can be assigned at the same time. The below would
1735result in both ts0 and b being created as variables, with both 1735result in both ts0 and b being created as variables, with both
1736common_timestamp and field1 additionally being summed as values: 1736common_timestamp and field1 additionally being summed as values:
1737 1737
1738 # echo 'hist:keys=pid:vals=$ts0,$b:ts0=common_timestamp,b=field1 ... >> \ 1738 # echo 'hist:keys=pid:vals=$ts0,$b:ts0=common_timestamp,b=field1 ...' >> \
1739 event/trigger 1739 event/trigger
1740 1740
1741Note that variable assignments can appear either preceding or 1741Note that variable assignments can appear either preceding or
1742following their use. The command below behaves identically to the 1742following their use. The command below behaves identically to the
1743command above: 1743command above:
1744 1744
1745 # echo 'hist:keys=pid:ts0=common_timestamp,b=field1:vals=$ts0,$b ... >> \ 1745 # echo 'hist:keys=pid:ts0=common_timestamp,b=field1:vals=$ts0,$b ...' >> \
1746 event/trigger 1746 event/trigger
1747 1747
1748Any number of variables not bound to a 'vals=' prefix can also be 1748Any number of variables not bound to a 'vals=' prefix can also be
1749assigned by simply separating them with colons. Below is the same 1749assigned by simply separating them with colons. Below is the same
1750thing but without the values being summed in the histogram: 1750thing but without the values being summed in the histogram:
1751 1751
1752 # echo 'hist:keys=pid:ts0=common_timestamp:b=field1 ... >> event/trigger 1752 # echo 'hist:keys=pid:ts0=common_timestamp:b=field1 ...' >> event/trigger
1753 1753
1754Variables set as above can be referenced and used in expressions on 1754Variables set as above can be referenced and used in expressions on
1755another event. 1755another event.
1756 1756
1757For example, here's how a latency can be calculated: 1757For example, here's how a latency can be calculated:
1758 1758
1759 # echo 'hist:keys=pid,prio:ts0=common_timestamp ... >> event1/trigger 1759 # echo 'hist:keys=pid,prio:ts0=common_timestamp ...' >> event1/trigger
1760 # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ... >> event2/trigger 1760 # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ...' >> event2/trigger
1761 1761
1762In the first line above, the event's timetamp is saved into the 1762In the first line above, the event's timetamp is saved into the
1763variable ts0. In the next line, ts0 is subtracted from the second 1763variable ts0. In the next line, ts0 is subtracted from the second
@@ -1766,7 +1766,7 @@ yet another variable, 'wakeup_lat'. The hist trigger below in turn
1766makes use of the wakeup_lat variable to compute a combined latency 1766makes use of the wakeup_lat variable to compute a combined latency
1767using the same key and variable from yet another event: 1767using the same key and variable from yet another event:
1768 1768
1769 # echo 'hist:key=pid:wakeupswitch_lat=$wakeup_lat+$switchtime_lat ... >> event3/trigger 1769 # echo 'hist:key=pid:wakeupswitch_lat=$wakeup_lat+$switchtime_lat ...' >> event3/trigger
1770 1770
17712.2.2 Synthetic Events 17712.2.2 Synthetic Events
1772---------------------- 1772----------------------
@@ -1807,10 +1807,11 @@ the command that defined it with a '!':
1807At this point, there isn't yet an actual 'wakeup_latency' event 1807At this point, there isn't yet an actual 'wakeup_latency' event
1808instantiated in the event subsytem - for this to happen, a 'hist 1808instantiated in the event subsytem - for this to happen, a 'hist
1809trigger action' needs to be instantiated and bound to actual fields 1809trigger action' needs to be instantiated and bound to actual fields
1810and variables defined on other events (see Section 6.3.3 below). 1810and variables defined on other events (see Section 2.2.3 below on
1811how that is done using hist trigger 'onmatch' action). Once that is
1812done, the 'wakeup_latency' synthetic event instance is created.
1811 1813
1812Once that is done, an event instance is created, and a histogram can 1814A histogram can now be defined for the new synthetic event:
1813be defined using it:
1814 1815
1815 # echo 'hist:keys=pid,prio,lat.log2:sort=pid,lat' >> \ 1816 # echo 'hist:keys=pid,prio,lat.log2:sort=pid,lat' >> \
1816 /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger 1817 /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger
@@ -1960,7 +1961,7 @@ hist trigger specification.
1960 back to that pid, the timestamp difference is calculated. If the 1961 back to that pid, the timestamp difference is calculated. If the
1961 resulting latency, stored in wakeup_lat, exceeds the current 1962 resulting latency, stored in wakeup_lat, exceeds the current
1962 maximum latency, the values specified in the save() fields are 1963 maximum latency, the values specified in the save() fields are
1963 recoreded: 1964 recorded:
1964 1965
1965 # echo 'hist:keys=pid:ts0=common_timestamp.usecs \ 1966 # echo 'hist:keys=pid:ts0=common_timestamp.usecs \
1966 if comm=="cyclictest"' >> \ 1967 if comm=="cyclictest"' >> \
diff --git a/Documentation/usb/gadget_configfs.txt b/Documentation/usb/gadget_configfs.txt
index 635e57493709..b8cb38a98c19 100644
--- a/Documentation/usb/gadget_configfs.txt
+++ b/Documentation/usb/gadget_configfs.txt
@@ -226,7 +226,7 @@ $ rm configs/<config name>.<number>/<function>
226where <config name>.<number> specify the configuration and <function> is 226where <config name>.<number> specify the configuration and <function> is
227a symlink to a function being removed from the configuration, e.g.: 227a symlink to a function being removed from the configuration, e.g.:
228 228
229$ rm configfs/c.1/ncm.usb0 229$ rm configs/c.1/ncm.usb0
230 230
231... 231...
232... 232...
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 495b7742ab58..d10944e619d3 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -4610,7 +4610,7 @@ This capability indicates that kvm will implement the interfaces to handle
4610reset, migration and nested KVM for branch prediction blocking. The stfle 4610reset, migration and nested KVM for branch prediction blocking. The stfle
4611facility 82 should not be provided to the guest without this capability. 4611facility 82 should not be provided to the guest without this capability.
4612 4612
46138.14 KVM_CAP_HYPERV_TLBFLUSH 46138.18 KVM_CAP_HYPERV_TLBFLUSH
4614 4614
4615Architectures: x86 4615Architectures: x86
4616 4616
diff --git a/MAINTAINERS b/MAINTAINERS
index 9d5eeff51b5f..07d1576fc766 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2971,9 +2971,13 @@ N: bcm585*
2971N: bcm586* 2971N: bcm586*
2972N: bcm88312 2972N: bcm88312
2973N: hr2 2973N: hr2
2974F: arch/arm64/boot/dts/broadcom/ns2* 2974N: stingray
2975F: arch/arm64/boot/dts/broadcom/northstar2/*
2976F: arch/arm64/boot/dts/broadcom/stingray/*
2975F: drivers/clk/bcm/clk-ns* 2977F: drivers/clk/bcm/clk-ns*
2978F: drivers/clk/bcm/clk-sr*
2976F: drivers/pinctrl/bcm/pinctrl-ns* 2979F: drivers/pinctrl/bcm/pinctrl-ns*
2980F: include/dt-bindings/clock/bcm-sr*
2977 2981
2978BROADCOM KONA GPIO DRIVER 2982BROADCOM KONA GPIO DRIVER
2979M: Ray Jui <rjui@broadcom.com> 2983M: Ray Jui <rjui@broadcom.com>
@@ -4360,12 +4364,7 @@ L: iommu@lists.linux-foundation.org
4360T: git git://git.infradead.org/users/hch/dma-mapping.git 4364T: git git://git.infradead.org/users/hch/dma-mapping.git
4361W: http://git.infradead.org/users/hch/dma-mapping.git 4365W: http://git.infradead.org/users/hch/dma-mapping.git
4362S: Supported 4366S: Supported
4363F: lib/dma-debug.c 4367F: kernel/dma/
4364F: lib/dma-direct.c
4365F: lib/dma-noncoherent.c
4366F: lib/dma-virt.c
4367F: drivers/base/dma-mapping.c
4368F: drivers/base/dma-coherent.c
4369F: include/asm-generic/dma-mapping.h 4368F: include/asm-generic/dma-mapping.h
4370F: include/linux/dma-direct.h 4369F: include/linux/dma-direct.h
4371F: include/linux/dma-mapping.h 4370F: include/linux/dma-mapping.h
@@ -5674,7 +5673,7 @@ F: drivers/crypto/caam/
5674F: Documentation/devicetree/bindings/crypto/fsl-sec4.txt 5673F: Documentation/devicetree/bindings/crypto/fsl-sec4.txt
5675 5674
5676FREESCALE DIU FRAMEBUFFER DRIVER 5675FREESCALE DIU FRAMEBUFFER DRIVER
5677M: Timur Tabi <timur@tabi.org> 5676M: Timur Tabi <timur@kernel.org>
5678L: linux-fbdev@vger.kernel.org 5677L: linux-fbdev@vger.kernel.org
5679S: Maintained 5678S: Maintained
5680F: drivers/video/fbdev/fsl-diu-fb.* 5679F: drivers/video/fbdev/fsl-diu-fb.*
@@ -5774,7 +5773,7 @@ S: Maintained
5774F: drivers/net/wan/fsl_ucc_hdlc* 5773F: drivers/net/wan/fsl_ucc_hdlc*
5775 5774
5776FREESCALE QUICC ENGINE UCC UART DRIVER 5775FREESCALE QUICC ENGINE UCC UART DRIVER
5777M: Timur Tabi <timur@tabi.org> 5776M: Timur Tabi <timur@kernel.org>
5778L: linuxppc-dev@lists.ozlabs.org 5777L: linuxppc-dev@lists.ozlabs.org
5779S: Maintained 5778S: Maintained
5780F: drivers/tty/serial/ucc_uart.c 5779F: drivers/tty/serial/ucc_uart.c
@@ -5798,7 +5797,7 @@ F: drivers/net/ethernet/freescale/fs_enet/
5798F: include/linux/fs_enet_pd.h 5797F: include/linux/fs_enet_pd.h
5799 5798
5800FREESCALE SOC SOUND DRIVERS 5799FREESCALE SOC SOUND DRIVERS
5801M: Timur Tabi <timur@tabi.org> 5800M: Timur Tabi <timur@kernel.org>
5802M: Nicolin Chen <nicoleotsuka@gmail.com> 5801M: Nicolin Chen <nicoleotsuka@gmail.com>
5803M: Xiubo Li <Xiubo.Lee@gmail.com> 5802M: Xiubo Li <Xiubo.Lee@gmail.com>
5804R: Fabio Estevam <fabio.estevam@nxp.com> 5803R: Fabio Estevam <fabio.estevam@nxp.com>
@@ -9756,6 +9755,11 @@ L: linux-scsi@vger.kernel.org
9756S: Maintained 9755S: Maintained
9757F: drivers/scsi/NCR_D700.* 9756F: drivers/scsi/NCR_D700.*
9758 9757
9758NCSI LIBRARY:
9759M: Samuel Mendoza-Jonas <sam@mendozajonas.com>
9760S: Maintained
9761F: net/ncsi/
9762
9759NCT6775 HARDWARE MONITOR DRIVER 9763NCT6775 HARDWARE MONITOR DRIVER
9760M: Guenter Roeck <linux@roeck-us.net> 9764M: Guenter Roeck <linux@roeck-us.net>
9761L: linux-hwmon@vger.kernel.org 9765L: linux-hwmon@vger.kernel.org
@@ -9882,6 +9886,7 @@ M: Andrew Lunn <andrew@lunn.ch>
9882M: Vivien Didelot <vivien.didelot@savoirfairelinux.com> 9886M: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
9883M: Florian Fainelli <f.fainelli@gmail.com> 9887M: Florian Fainelli <f.fainelli@gmail.com>
9884S: Maintained 9888S: Maintained
9889F: Documentation/devicetree/bindings/net/dsa/
9885F: net/dsa/ 9890F: net/dsa/
9886F: include/net/dsa.h 9891F: include/net/dsa.h
9887F: include/linux/dsa/ 9892F: include/linux/dsa/
@@ -11476,6 +11481,15 @@ W: http://wireless.kernel.org/en/users/Drivers/p54
11476S: Obsolete 11481S: Obsolete
11477F: drivers/net/wireless/intersil/prism54/ 11482F: drivers/net/wireless/intersil/prism54/
11478 11483
11484PROC FILESYSTEM
11485R: Alexey Dobriyan <adobriyan@gmail.com>
11486L: linux-kernel@vger.kernel.org
11487L: linux-fsdevel@vger.kernel.org
11488S: Maintained
11489F: fs/proc/
11490F: include/linux/proc_fs.h
11491F: tools/testing/selftests/proc/
11492
11479PROC SYSCTL 11493PROC SYSCTL
11480M: "Luis R. Rodriguez" <mcgrof@kernel.org> 11494M: "Luis R. Rodriguez" <mcgrof@kernel.org>
11481M: Kees Cook <keescook@chromium.org> 11495M: Kees Cook <keescook@chromium.org>
@@ -11808,9 +11822,9 @@ F: Documentation/devicetree/bindings/opp/kryo-cpufreq.txt
11808F: drivers/cpufreq/qcom-cpufreq-kryo.c 11822F: drivers/cpufreq/qcom-cpufreq-kryo.c
11809 11823
11810QUALCOMM EMAC GIGABIT ETHERNET DRIVER 11824QUALCOMM EMAC GIGABIT ETHERNET DRIVER
11811M: Timur Tabi <timur@codeaurora.org> 11825M: Timur Tabi <timur@kernel.org>
11812L: netdev@vger.kernel.org 11826L: netdev@vger.kernel.org
11813S: Supported 11827S: Maintained
11814F: drivers/net/ethernet/qualcomm/emac/ 11828F: drivers/net/ethernet/qualcomm/emac/
11815 11829
11816QUALCOMM HEXAGON ARCHITECTURE 11830QUALCOMM HEXAGON ARCHITECTURE
@@ -13648,7 +13662,7 @@ M: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
13648L: iommu@lists.linux-foundation.org 13662L: iommu@lists.linux-foundation.org
13649T: git git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git 13663T: git git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git
13650S: Supported 13664S: Supported
13651F: lib/swiotlb.c 13665F: kernel/dma/swiotlb.c
13652F: arch/*/kernel/pci-swiotlb.c 13666F: arch/*/kernel/pci-swiotlb.c
13653F: include/linux/swiotlb.h 13667F: include/linux/swiotlb.h
13654 13668
@@ -15572,9 +15586,17 @@ M: x86@kernel.org
15572L: linux-kernel@vger.kernel.org 15586L: linux-kernel@vger.kernel.org
15573T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core 15587T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core
15574S: Maintained 15588S: Maintained
15589F: Documentation/devicetree/bindings/x86/
15575F: Documentation/x86/ 15590F: Documentation/x86/
15576F: arch/x86/ 15591F: arch/x86/
15577 15592
15593X86 ENTRY CODE
15594M: Andy Lutomirski <luto@kernel.org>
15595L: linux-kernel@vger.kernel.org
15596T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/asm
15597S: Maintained
15598F: arch/x86/entry/
15599
15578X86 MCE INFRASTRUCTURE 15600X86 MCE INFRASTRUCTURE
15579M: Tony Luck <tony.luck@intel.com> 15601M: Tony Luck <tony.luck@intel.com>
15580M: Borislav Petkov <bp@alien8.de> 15602M: Borislav Petkov <bp@alien8.de>
@@ -15597,7 +15619,7 @@ F: drivers/platform/x86/
15597F: drivers/platform/olpc/ 15619F: drivers/platform/olpc/
15598 15620
15599X86 VDSO 15621X86 VDSO
15600M: Andy Lutomirski <luto@amacapital.net> 15622M: Andy Lutomirski <luto@kernel.org>
15601L: linux-kernel@vger.kernel.org 15623L: linux-kernel@vger.kernel.org
15602T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/vdso 15624T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/vdso
15603S: Maintained 15625S: Maintained
diff --git a/Makefile b/Makefile
index ca2af1ab91eb..c5ce55cbc543 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
2VERSION = 4 2VERSION = 4
3PATCHLEVEL = 18 3PATCHLEVEL = 18
4SUBLEVEL = 0 4SUBLEVEL = 0
5EXTRAVERSION = -rc1 5EXTRAVERSION = -rc3
6NAME = Merciless Moray 6NAME = Merciless Moray
7 7
8# *DOCUMENTATION* 8# *DOCUMENTATION*
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 0c4805a572c8..04a4a138ed13 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -555,11 +555,6 @@ config SMP
555 555
556 If you don't know what to do here, say N. 556 If you don't know what to do here, say N.
557 557
558config HAVE_DEC_LOCK
559 bool
560 depends on SMP
561 default y
562
563config NR_CPUS 558config NR_CPUS
564 int "Maximum number of CPUs (2-32)" 559 int "Maximum number of CPUs (2-32)"
565 range 2 32 560 range 2 32
diff --git a/arch/alpha/lib/Makefile b/arch/alpha/lib/Makefile
index 04f9729de57c..854d5e79979e 100644
--- a/arch/alpha/lib/Makefile
+++ b/arch/alpha/lib/Makefile
@@ -35,8 +35,6 @@ lib-y = __divqu.o __remqu.o __divlu.o __remlu.o \
35 callback_srm.o srm_puts.o srm_printk.o \ 35 callback_srm.o srm_puts.o srm_printk.o \
36 fls.o 36 fls.o
37 37
38lib-$(CONFIG_SMP) += dec_and_lock.o
39
40# The division routines are built from single source, with different defines. 38# The division routines are built from single source, with different defines.
41AFLAGS___divqu.o = -DDIV 39AFLAGS___divqu.o = -DDIV
42AFLAGS___remqu.o = -DREM 40AFLAGS___remqu.o = -DREM
diff --git a/arch/alpha/lib/dec_and_lock.c b/arch/alpha/lib/dec_and_lock.c
deleted file mode 100644
index a117707f57fe..000000000000
--- a/arch/alpha/lib/dec_and_lock.c
+++ /dev/null
@@ -1,44 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * arch/alpha/lib/dec_and_lock.c
4 *
5 * ll/sc version of atomic_dec_and_lock()
6 *
7 */
8
9#include <linux/spinlock.h>
10#include <linux/atomic.h>
11#include <linux/export.h>
12
13 asm (".text \n\
14 .global _atomic_dec_and_lock \n\
15 .ent _atomic_dec_and_lock \n\
16 .align 4 \n\
17_atomic_dec_and_lock: \n\
18 .prologue 0 \n\
191: ldl_l $1, 0($16) \n\
20 subl $1, 1, $1 \n\
21 beq $1, 2f \n\
22 stl_c $1, 0($16) \n\
23 beq $1, 4f \n\
24 mb \n\
25 clr $0 \n\
26 ret \n\
272: br $29, 3f \n\
283: ldgp $29, 0($29) \n\
29 br $atomic_dec_and_lock_1..ng \n\
30 .subsection 2 \n\
314: br 1b \n\
32 .previous \n\
33 .end _atomic_dec_and_lock");
34
35static int __used atomic_dec_and_lock_1(atomic_t *atomic, spinlock_t *lock)
36{
37 /* Slow path */
38 spin_lock(lock);
39 if (atomic_dec_and_test(atomic))
40 return 1;
41 spin_unlock(lock);
42 return 0;
43}
44EXPORT_SYMBOL(_atomic_dec_and_lock);
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 54eeb8d00bc6..843edfd000be 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1245,8 +1245,14 @@ config PCI
1245 VESA. If you have PCI, say Y, otherwise N. 1245 VESA. If you have PCI, say Y, otherwise N.
1246 1246
1247config PCI_DOMAINS 1247config PCI_DOMAINS
1248 bool 1248 bool "Support for multiple PCI domains"
1249 depends on PCI 1249 depends on PCI
1250 help
1251 Enable PCI domains kernel management. Say Y if your machine
1252 has a PCI bus hierarchy that requires more than one PCI
1253 domain (aka segment) to be correctly managed. Say N otherwise.
1254
1255 If you don't know what to do here, say N.
1250 1256
1251config PCI_DOMAINS_GENERIC 1257config PCI_DOMAINS_GENERIC
1252 def_bool PCI_DOMAINS 1258 def_bool PCI_DOMAINS
diff --git a/arch/arm/boot/dts/armada-385-synology-ds116.dts b/arch/arm/boot/dts/armada-385-synology-ds116.dts
index 6782ce481ac9..d8769956cbfc 100644
--- a/arch/arm/boot/dts/armada-385-synology-ds116.dts
+++ b/arch/arm/boot/dts/armada-385-synology-ds116.dts
@@ -139,7 +139,7 @@
139 3700 5 139 3700 5
140 3900 6 140 3900 6
141 4000 7>; 141 4000 7>;
142 cooling-cells = <2>; 142 #cooling-cells = <2>;
143 }; 143 };
144 144
145 gpio-leds { 145 gpio-leds {
diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 9fe4f5a6379e..2c4df2d2d4a6 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -216,7 +216,7 @@
216 reg = <0x18008000 0x100>; 216 reg = <0x18008000 0x100>;
217 #address-cells = <1>; 217 #address-cells = <1>;
218 #size-cells = <0>; 218 #size-cells = <0>;
219 interrupts = <GIC_SPI 85 IRQ_TYPE_NONE>; 219 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
220 clock-frequency = <100000>; 220 clock-frequency = <100000>;
221 status = "disabled"; 221 status = "disabled";
222 }; 222 };
@@ -245,7 +245,7 @@
245 reg = <0x1800b000 0x100>; 245 reg = <0x1800b000 0x100>;
246 #address-cells = <1>; 246 #address-cells = <1>;
247 #size-cells = <0>; 247 #size-cells = <0>;
248 interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>; 248 interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
249 clock-frequency = <100000>; 249 clock-frequency = <100000>;
250 status = "disabled"; 250 status = "disabled";
251 }; 251 };
@@ -256,7 +256,7 @@
256 256
257 #interrupt-cells = <1>; 257 #interrupt-cells = <1>;
258 interrupt-map-mask = <0 0 0 0>; 258 interrupt-map-mask = <0 0 0 0>;
259 interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>; 259 interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
260 260
261 linux,pci-domain = <0>; 261 linux,pci-domain = <0>;
262 262
@@ -278,10 +278,10 @@
278 compatible = "brcm,iproc-msi"; 278 compatible = "brcm,iproc-msi";
279 msi-controller; 279 msi-controller;
280 interrupt-parent = <&gic>; 280 interrupt-parent = <&gic>;
281 interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>, 281 interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>,
282 <GIC_SPI 97 IRQ_TYPE_NONE>, 282 <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>,
283 <GIC_SPI 98 IRQ_TYPE_NONE>, 283 <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
284 <GIC_SPI 99 IRQ_TYPE_NONE>; 284 <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
285 }; 285 };
286 }; 286 };
287 287
@@ -291,7 +291,7 @@
291 291
292 #interrupt-cells = <1>; 292 #interrupt-cells = <1>;
293 interrupt-map-mask = <0 0 0 0>; 293 interrupt-map-mask = <0 0 0 0>;
294 interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>; 294 interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
295 295
296 linux,pci-domain = <1>; 296 linux,pci-domain = <1>;
297 297
@@ -313,10 +313,10 @@
313 compatible = "brcm,iproc-msi"; 313 compatible = "brcm,iproc-msi";
314 msi-controller; 314 msi-controller;
315 interrupt-parent = <&gic>; 315 interrupt-parent = <&gic>;
316 interrupts = <GIC_SPI 102 IRQ_TYPE_NONE>, 316 interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>,
317 <GIC_SPI 103 IRQ_TYPE_NONE>, 317 <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
318 <GIC_SPI 104 IRQ_TYPE_NONE>, 318 <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>,
319 <GIC_SPI 105 IRQ_TYPE_NONE>; 319 <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
320 }; 320 };
321 }; 321 };
322 322
diff --git a/arch/arm/boot/dts/bcm-hr2.dtsi b/arch/arm/boot/dts/bcm-hr2.dtsi
index 3f9cedd8011f..3084a7c95733 100644
--- a/arch/arm/boot/dts/bcm-hr2.dtsi
+++ b/arch/arm/boot/dts/bcm-hr2.dtsi
@@ -264,7 +264,7 @@
264 reg = <0x38000 0x50>; 264 reg = <0x38000 0x50>;
265 #address-cells = <1>; 265 #address-cells = <1>;
266 #size-cells = <0>; 266 #size-cells = <0>;
267 interrupts = <GIC_SPI 95 IRQ_TYPE_NONE>; 267 interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
268 clock-frequency = <100000>; 268 clock-frequency = <100000>;
269 }; 269 };
270 270
@@ -279,7 +279,7 @@
279 reg = <0x3b000 0x50>; 279 reg = <0x3b000 0x50>;
280 #address-cells = <1>; 280 #address-cells = <1>;
281 #size-cells = <0>; 281 #size-cells = <0>;
282 interrupts = <GIC_SPI 96 IRQ_TYPE_NONE>; 282 interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
283 clock-frequency = <100000>; 283 clock-frequency = <100000>;
284 }; 284 };
285 }; 285 };
@@ -300,7 +300,7 @@
300 300
301 #interrupt-cells = <1>; 301 #interrupt-cells = <1>;
302 interrupt-map-mask = <0 0 0 0>; 302 interrupt-map-mask = <0 0 0 0>;
303 interrupt-map = <0 0 0 0 &gic GIC_SPI 186 IRQ_TYPE_NONE>; 303 interrupt-map = <0 0 0 0 &gic GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
304 304
305 linux,pci-domain = <0>; 305 linux,pci-domain = <0>;
306 306
@@ -322,10 +322,10 @@
322 compatible = "brcm,iproc-msi"; 322 compatible = "brcm,iproc-msi";
323 msi-controller; 323 msi-controller;
324 interrupt-parent = <&gic>; 324 interrupt-parent = <&gic>;
325 interrupts = <GIC_SPI 182 IRQ_TYPE_NONE>, 325 interrupts = <GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>,
326 <GIC_SPI 183 IRQ_TYPE_NONE>, 326 <GIC_SPI 183 IRQ_TYPE_LEVEL_HIGH>,
327 <GIC_SPI 184 IRQ_TYPE_NONE>, 327 <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>,
328 <GIC_SPI 185 IRQ_TYPE_NONE>; 328 <GIC_SPI 185 IRQ_TYPE_LEVEL_HIGH>;
329 brcm,pcie-msi-inten; 329 brcm,pcie-msi-inten;
330 }; 330 };
331 }; 331 };
@@ -336,7 +336,7 @@
336 336
337 #interrupt-cells = <1>; 337 #interrupt-cells = <1>;
338 interrupt-map-mask = <0 0 0 0>; 338 interrupt-map-mask = <0 0 0 0>;
339 interrupt-map = <0 0 0 0 &gic GIC_SPI 192 IRQ_TYPE_NONE>; 339 interrupt-map = <0 0 0 0 &gic GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
340 340
341 linux,pci-domain = <1>; 341 linux,pci-domain = <1>;
342 342
@@ -358,10 +358,10 @@
358 compatible = "brcm,iproc-msi"; 358 compatible = "brcm,iproc-msi";
359 msi-controller; 359 msi-controller;
360 interrupt-parent = <&gic>; 360 interrupt-parent = <&gic>;
361 interrupts = <GIC_SPI 188 IRQ_TYPE_NONE>, 361 interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>,
362 <GIC_SPI 189 IRQ_TYPE_NONE>, 362 <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>,
363 <GIC_SPI 190 IRQ_TYPE_NONE>, 363 <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>,
364 <GIC_SPI 191 IRQ_TYPE_NONE>; 364 <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
365 brcm,pcie-msi-inten; 365 brcm,pcie-msi-inten;
366 }; 366 };
367 }; 367 };
diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
index dcc55aa84583..09ba85046322 100644
--- a/arch/arm/boot/dts/bcm-nsp.dtsi
+++ b/arch/arm/boot/dts/bcm-nsp.dtsi
@@ -391,7 +391,7 @@
391 reg = <0x38000 0x50>; 391 reg = <0x38000 0x50>;
392 #address-cells = <1>; 392 #address-cells = <1>;
393 #size-cells = <0>; 393 #size-cells = <0>;
394 interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>; 394 interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
395 clock-frequency = <100000>; 395 clock-frequency = <100000>;
396 dma-coherent; 396 dma-coherent;
397 status = "disabled"; 397 status = "disabled";
@@ -496,7 +496,7 @@
496 496
497 #interrupt-cells = <1>; 497 #interrupt-cells = <1>;
498 interrupt-map-mask = <0 0 0 0>; 498 interrupt-map-mask = <0 0 0 0>;
499 interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_NONE>; 499 interrupt-map = <0 0 0 0 &gic GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
500 500
501 linux,pci-domain = <0>; 501 linux,pci-domain = <0>;
502 502
@@ -519,10 +519,10 @@
519 compatible = "brcm,iproc-msi"; 519 compatible = "brcm,iproc-msi";
520 msi-controller; 520 msi-controller;
521 interrupt-parent = <&gic>; 521 interrupt-parent = <&gic>;
522 interrupts = <GIC_SPI 127 IRQ_TYPE_NONE>, 522 interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>,
523 <GIC_SPI 128 IRQ_TYPE_NONE>, 523 <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>,
524 <GIC_SPI 129 IRQ_TYPE_NONE>, 524 <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>,
525 <GIC_SPI 130 IRQ_TYPE_NONE>; 525 <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>;
526 brcm,pcie-msi-inten; 526 brcm,pcie-msi-inten;
527 }; 527 };
528 }; 528 };
@@ -533,7 +533,7 @@
533 533
534 #interrupt-cells = <1>; 534 #interrupt-cells = <1>;
535 interrupt-map-mask = <0 0 0 0>; 535 interrupt-map-mask = <0 0 0 0>;
536 interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_NONE>; 536 interrupt-map = <0 0 0 0 &gic GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
537 537
538 linux,pci-domain = <1>; 538 linux,pci-domain = <1>;
539 539
@@ -556,10 +556,10 @@
556 compatible = "brcm,iproc-msi"; 556 compatible = "brcm,iproc-msi";
557 msi-controller; 557 msi-controller;
558 interrupt-parent = <&gic>; 558 interrupt-parent = <&gic>;
559 interrupts = <GIC_SPI 133 IRQ_TYPE_NONE>, 559 interrupts = <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>,
560 <GIC_SPI 134 IRQ_TYPE_NONE>, 560 <GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>,
561 <GIC_SPI 135 IRQ_TYPE_NONE>, 561 <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
562 <GIC_SPI 136 IRQ_TYPE_NONE>; 562 <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
563 brcm,pcie-msi-inten; 563 brcm,pcie-msi-inten;
564 }; 564 };
565 }; 565 };
@@ -570,7 +570,7 @@
570 570
571 #interrupt-cells = <1>; 571 #interrupt-cells = <1>;
572 interrupt-map-mask = <0 0 0 0>; 572 interrupt-map-mask = <0 0 0 0>;
573 interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_NONE>; 573 interrupt-map = <0 0 0 0 &gic GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
574 574
575 linux,pci-domain = <2>; 575 linux,pci-domain = <2>;
576 576
@@ -593,10 +593,10 @@
593 compatible = "brcm,iproc-msi"; 593 compatible = "brcm,iproc-msi";
594 msi-controller; 594 msi-controller;
595 interrupt-parent = <&gic>; 595 interrupt-parent = <&gic>;
596 interrupts = <GIC_SPI 139 IRQ_TYPE_NONE>, 596 interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>,
597 <GIC_SPI 140 IRQ_TYPE_NONE>, 597 <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>,
598 <GIC_SPI 141 IRQ_TYPE_NONE>, 598 <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>,
599 <GIC_SPI 142 IRQ_TYPE_NONE>; 599 <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>;
600 brcm,pcie-msi-inten; 600 brcm,pcie-msi-inten;
601 }; 601 };
602 }; 602 };
diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
index 9a076c409f4e..ef995e50ee12 100644
--- a/arch/arm/boot/dts/bcm5301x.dtsi
+++ b/arch/arm/boot/dts/bcm5301x.dtsi
@@ -365,7 +365,7 @@
365 i2c0: i2c@18009000 { 365 i2c0: i2c@18009000 {
366 compatible = "brcm,iproc-i2c"; 366 compatible = "brcm,iproc-i2c";
367 reg = <0x18009000 0x50>; 367 reg = <0x18009000 0x50>;
368 interrupts = <GIC_SPI 121 IRQ_TYPE_NONE>; 368 interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
369 #address-cells = <1>; 369 #address-cells = <1>;
370 #size-cells = <0>; 370 #size-cells = <0>;
371 clock-frequency = <100000>; 371 clock-frequency = <100000>;
diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index f6f1597b03df..0f4f817a9e22 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -549,11 +549,7 @@
549 gpio-controller; 549 gpio-controller;
550 #gpio-cells = <2>; 550 #gpio-cells = <2>;
551 reg = <0x226000 0x1000>; 551 reg = <0x226000 0x1000>;
552 interrupts = <42 IRQ_TYPE_EDGE_BOTH 552 interrupts = <42 43 44 45 46 47 48 49 50>;
553 43 IRQ_TYPE_EDGE_BOTH 44 IRQ_TYPE_EDGE_BOTH
554 45 IRQ_TYPE_EDGE_BOTH 46 IRQ_TYPE_EDGE_BOTH
555 47 IRQ_TYPE_EDGE_BOTH 48 IRQ_TYPE_EDGE_BOTH
556 49 IRQ_TYPE_EDGE_BOTH 50 IRQ_TYPE_EDGE_BOTH>;
557 ti,ngpio = <144>; 553 ti,ngpio = <144>;
558 ti,davinci-gpio-unbanked = <0>; 554 ti,davinci-gpio-unbanked = <0>;
559 status = "disabled"; 555 status = "disabled";
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 70483ce72ba6..77f8f030dd07 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -90,7 +90,7 @@
90 clocks = <&clks IMX6Q_CLK_ECSPI5>, 90 clocks = <&clks IMX6Q_CLK_ECSPI5>,
91 <&clks IMX6Q_CLK_ECSPI5>; 91 <&clks IMX6Q_CLK_ECSPI5>;
92 clock-names = "ipg", "per"; 92 clock-names = "ipg", "per";
93 dmas = <&sdma 11 7 1>, <&sdma 12 7 2>; 93 dmas = <&sdma 11 8 1>, <&sdma 12 8 2>;
94 dma-names = "rx", "tx"; 94 dma-names = "rx", "tx";
95 status = "disabled"; 95 status = "disabled";
96 }; 96 };
diff --git a/arch/arm/boot/dts/imx6sx.dtsi b/arch/arm/boot/dts/imx6sx.dtsi
index d8b94f47498b..4e4a55aad5c9 100644
--- a/arch/arm/boot/dts/imx6sx.dtsi
+++ b/arch/arm/boot/dts/imx6sx.dtsi
@@ -1344,7 +1344,7 @@
1344 ranges = <0x81000000 0 0 0x08f80000 0 0x00010000 /* downstream I/O */ 1344 ranges = <0x81000000 0 0 0x08f80000 0 0x00010000 /* downstream I/O */
1345 0x82000000 0 0x08000000 0x08000000 0 0x00f00000>; /* non-prefetchable memory */ 1345 0x82000000 0 0x08000000 0x08000000 0 0x00f00000>; /* non-prefetchable memory */
1346 num-lanes = <1>; 1346 num-lanes = <1>;
1347 interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>; 1347 interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
1348 interrupt-names = "msi"; 1348 interrupt-names = "msi";
1349 #interrupt-cells = <1>; 1349 #interrupt-cells = <1>;
1350 interrupt-map-mask = <0 0 0 0x7>; 1350 interrupt-map-mask = <0 0 0 0x7>;
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 486d4e7433ed..b38f8c240558 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -748,13 +748,13 @@
748 nand0: nand@ff900000 { 748 nand0: nand@ff900000 {
749 #address-cells = <0x1>; 749 #address-cells = <0x1>;
750 #size-cells = <0x1>; 750 #size-cells = <0x1>;
751 compatible = "denali,denali-nand-dt"; 751 compatible = "altr,socfpga-denali-nand";
752 reg = <0xff900000 0x100000>, 752 reg = <0xff900000 0x100000>,
753 <0xffb80000 0x10000>; 753 <0xffb80000 0x10000>;
754 reg-names = "nand_data", "denali_reg"; 754 reg-names = "nand_data", "denali_reg";
755 interrupts = <0x0 0x90 0x4>; 755 interrupts = <0x0 0x90 0x4>;
756 dma-mask = <0xffffffff>; 756 dma-mask = <0xffffffff>;
757 clocks = <&nand_clk>; 757 clocks = <&nand_x_clk>;
758 status = "disabled"; 758 status = "disabled";
759 }; 759 };
760 760
diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi b/arch/arm/boot/dts/socfpga_arria10.dtsi
index bead79e4b2aa..791ca15c799e 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -593,8 +593,7 @@
593 #size-cells = <0>; 593 #size-cells = <0>;
594 reg = <0xffda5000 0x100>; 594 reg = <0xffda5000 0x100>;
595 interrupts = <0 102 4>; 595 interrupts = <0 102 4>;
596 num-chipselect = <4>; 596 num-cs = <4>;
597 bus-num = <0>;
598 /*32bit_access;*/ 597 /*32bit_access;*/
599 tx-dma-channel = <&pdma 16>; 598 tx-dma-channel = <&pdma 16>;
600 rx-dma-channel = <&pdma 17>; 599 rx-dma-channel = <&pdma 17>;
@@ -633,7 +632,7 @@
633 nand: nand@ffb90000 { 632 nand: nand@ffb90000 {
634 #address-cells = <1>; 633 #address-cells = <1>;
635 #size-cells = <1>; 634 #size-cells = <1>;
636 compatible = "denali,denali-nand-dt", "altr,socfpga-denali-nand"; 635 compatible = "altr,socfpga-denali-nand";
637 reg = <0xffb90000 0x72000>, 636 reg = <0xffb90000 0x72000>,
638 <0xffb80000 0x10000>; 637 <0xffb80000 0x10000>;
639 reg-names = "nand_data", "denali_reg"; 638 reg-names = "nand_data", "denali_reg";
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index 1e9f7af8f70f..3157be413297 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -10,7 +10,7 @@ obj-$(CONFIG_DMABOUNCE) += dmabounce.o
10obj-$(CONFIG_SHARP_LOCOMO) += locomo.o 10obj-$(CONFIG_SHARP_LOCOMO) += locomo.o
11obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o 11obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o
12obj-$(CONFIG_SHARP_SCOOP) += scoop.o 12obj-$(CONFIG_SHARP_SCOOP) += scoop.o
13obj-$(CONFIG_SMP) += secure_cntvoff.o 13obj-$(CONFIG_CPU_V7) += secure_cntvoff.o
14obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o 14obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o
15obj-$(CONFIG_MCPM) += mcpm_head.o mcpm_entry.o mcpm_platsmp.o vlock.o 15obj-$(CONFIG_MCPM) += mcpm_head.o mcpm_entry.o mcpm_platsmp.o vlock.o
16CFLAGS_REMOVE_mcpm_entry.o = -pg 16CFLAGS_REMOVE_mcpm_entry.o = -pg
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 7e1c543162c3..8f6be1982545 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -1,5 +1,4 @@
1CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
2CONFIG_FHANDLE=y
3CONFIG_NO_HZ=y 2CONFIG_NO_HZ=y
4CONFIG_HIGH_RES_TIMERS=y 3CONFIG_HIGH_RES_TIMERS=y
5CONFIG_CGROUPS=y 4CONFIG_CGROUPS=y
@@ -10,20 +9,10 @@ CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y 9CONFIG_MODULE_UNLOAD=y
11CONFIG_PARTITION_ADVANCED=y 10CONFIG_PARTITION_ADVANCED=y
12CONFIG_CMDLINE_PARTITION=y 11CONFIG_CMDLINE_PARTITION=y
13CONFIG_ARCH_MULTI_V7=y
14# CONFIG_ARCH_MULTI_V5 is not set
15# CONFIG_ARCH_MULTI_V4 is not set
16CONFIG_ARCH_VIRT=y 12CONFIG_ARCH_VIRT=y
17CONFIG_ARCH_ALPINE=y 13CONFIG_ARCH_ALPINE=y
18CONFIG_ARCH_ARTPEC=y 14CONFIG_ARCH_ARTPEC=y
19CONFIG_MACH_ARTPEC6=y 15CONFIG_MACH_ARTPEC6=y
20CONFIG_ARCH_MVEBU=y
21CONFIG_MACH_ARMADA_370=y
22CONFIG_MACH_ARMADA_375=y
23CONFIG_MACH_ARMADA_38X=y
24CONFIG_MACH_ARMADA_39X=y
25CONFIG_MACH_ARMADA_XP=y
26CONFIG_MACH_DOVE=y
27CONFIG_ARCH_AT91=y 16CONFIG_ARCH_AT91=y
28CONFIG_SOC_SAMA5D2=y 17CONFIG_SOC_SAMA5D2=y
29CONFIG_SOC_SAMA5D3=y 18CONFIG_SOC_SAMA5D3=y
@@ -32,9 +21,9 @@ CONFIG_ARCH_BCM=y
32CONFIG_ARCH_BCM_CYGNUS=y 21CONFIG_ARCH_BCM_CYGNUS=y
33CONFIG_ARCH_BCM_HR2=y 22CONFIG_ARCH_BCM_HR2=y
34CONFIG_ARCH_BCM_NSP=y 23CONFIG_ARCH_BCM_NSP=y
35CONFIG_ARCH_BCM_21664=y
36CONFIG_ARCH_BCM_281XX=y
37CONFIG_ARCH_BCM_5301X=y 24CONFIG_ARCH_BCM_5301X=y
25CONFIG_ARCH_BCM_281XX=y
26CONFIG_ARCH_BCM_21664=y
38CONFIG_ARCH_BCM2835=y 27CONFIG_ARCH_BCM2835=y
39CONFIG_ARCH_BCM_63XX=y 28CONFIG_ARCH_BCM_63XX=y
40CONFIG_ARCH_BRCMSTB=y 29CONFIG_ARCH_BRCMSTB=y
@@ -43,14 +32,14 @@ CONFIG_MACH_BERLIN_BG2=y
43CONFIG_MACH_BERLIN_BG2CD=y 32CONFIG_MACH_BERLIN_BG2CD=y
44CONFIG_MACH_BERLIN_BG2Q=y 33CONFIG_MACH_BERLIN_BG2Q=y
45CONFIG_ARCH_DIGICOLOR=y 34CONFIG_ARCH_DIGICOLOR=y
35CONFIG_ARCH_EXYNOS=y
36CONFIG_EXYNOS5420_MCPM=y
46CONFIG_ARCH_HIGHBANK=y 37CONFIG_ARCH_HIGHBANK=y
47CONFIG_ARCH_HISI=y 38CONFIG_ARCH_HISI=y
48CONFIG_ARCH_HI3xxx=y 39CONFIG_ARCH_HI3xxx=y
49CONFIG_ARCH_HIX5HD2=y
50CONFIG_ARCH_HIP01=y 40CONFIG_ARCH_HIP01=y
51CONFIG_ARCH_HIP04=y 41CONFIG_ARCH_HIP04=y
52CONFIG_ARCH_KEYSTONE=y 42CONFIG_ARCH_HIX5HD2=y
53CONFIG_ARCH_MESON=y
54CONFIG_ARCH_MXC=y 43CONFIG_ARCH_MXC=y
55CONFIG_SOC_IMX50=y 44CONFIG_SOC_IMX50=y
56CONFIG_SOC_IMX51=y 45CONFIG_SOC_IMX51=y
@@ -60,29 +49,30 @@ CONFIG_SOC_IMX6SL=y
60CONFIG_SOC_IMX6SX=y 49CONFIG_SOC_IMX6SX=y
61CONFIG_SOC_IMX6UL=y 50CONFIG_SOC_IMX6UL=y
62CONFIG_SOC_IMX7D=y 51CONFIG_SOC_IMX7D=y
63CONFIG_SOC_VF610=y
64CONFIG_SOC_LS1021A=y 52CONFIG_SOC_LS1021A=y
53CONFIG_SOC_VF610=y
54CONFIG_ARCH_KEYSTONE=y
55CONFIG_ARCH_MEDIATEK=y
56CONFIG_ARCH_MESON=y
57CONFIG_ARCH_MVEBU=y
58CONFIG_MACH_ARMADA_370=y
59CONFIG_MACH_ARMADA_375=y
60CONFIG_MACH_ARMADA_38X=y
61CONFIG_MACH_ARMADA_39X=y
62CONFIG_MACH_ARMADA_XP=y
63CONFIG_MACH_DOVE=y
65CONFIG_ARCH_OMAP3=y 64CONFIG_ARCH_OMAP3=y
66CONFIG_ARCH_OMAP4=y 65CONFIG_ARCH_OMAP4=y
67CONFIG_SOC_OMAP5=y 66CONFIG_SOC_OMAP5=y
68CONFIG_SOC_AM33XX=y 67CONFIG_SOC_AM33XX=y
69CONFIG_SOC_AM43XX=y 68CONFIG_SOC_AM43XX=y
70CONFIG_SOC_DRA7XX=y 69CONFIG_SOC_DRA7XX=y
70CONFIG_ARCH_SIRF=y
71CONFIG_ARCH_QCOM=y 71CONFIG_ARCH_QCOM=y
72CONFIG_ARCH_MEDIATEK=y
73CONFIG_ARCH_MSM8X60=y 72CONFIG_ARCH_MSM8X60=y
74CONFIG_ARCH_MSM8960=y 73CONFIG_ARCH_MSM8960=y
75CONFIG_ARCH_MSM8974=y 74CONFIG_ARCH_MSM8974=y
76CONFIG_ARCH_ROCKCHIP=y 75CONFIG_ARCH_ROCKCHIP=y
77CONFIG_ARCH_SOCFPGA=y
78CONFIG_PLAT_SPEAR=y
79CONFIG_ARCH_SPEAR13XX=y
80CONFIG_MACH_SPEAR1310=y
81CONFIG_MACH_SPEAR1340=y
82CONFIG_ARCH_STI=y
83CONFIG_ARCH_STM32=y
84CONFIG_ARCH_EXYNOS=y
85CONFIG_EXYNOS5420_MCPM=y
86CONFIG_ARCH_RENESAS=y 76CONFIG_ARCH_RENESAS=y
87CONFIG_ARCH_EMEV2=y 77CONFIG_ARCH_EMEV2=y
88CONFIG_ARCH_R7S72100=y 78CONFIG_ARCH_R7S72100=y
@@ -99,40 +89,33 @@ CONFIG_ARCH_R8A7792=y
99CONFIG_ARCH_R8A7793=y 89CONFIG_ARCH_R8A7793=y
100CONFIG_ARCH_R8A7794=y 90CONFIG_ARCH_R8A7794=y
101CONFIG_ARCH_SH73A0=y 91CONFIG_ARCH_SH73A0=y
92CONFIG_ARCH_SOCFPGA=y
93CONFIG_PLAT_SPEAR=y
94CONFIG_ARCH_SPEAR13XX=y
95CONFIG_MACH_SPEAR1310=y
96CONFIG_MACH_SPEAR1340=y
97CONFIG_ARCH_STI=y
98CONFIG_ARCH_STM32=y
102CONFIG_ARCH_SUNXI=y 99CONFIG_ARCH_SUNXI=y
103CONFIG_ARCH_SIRF=y
104CONFIG_ARCH_TEGRA=y 100CONFIG_ARCH_TEGRA=y
105CONFIG_ARCH_TEGRA_2x_SOC=y
106CONFIG_ARCH_TEGRA_3x_SOC=y
107CONFIG_ARCH_TEGRA_114_SOC=y
108CONFIG_ARCH_TEGRA_124_SOC=y
109CONFIG_ARCH_UNIPHIER=y 101CONFIG_ARCH_UNIPHIER=y
110CONFIG_ARCH_U8500=y 102CONFIG_ARCH_U8500=y
111CONFIG_MACH_HREFV60=y
112CONFIG_MACH_SNOWBALL=y
113CONFIG_ARCH_VEXPRESS=y 103CONFIG_ARCH_VEXPRESS=y
114CONFIG_ARCH_VEXPRESS_TC2_PM=y 104CONFIG_ARCH_VEXPRESS_TC2_PM=y
115CONFIG_ARCH_WM8850=y 105CONFIG_ARCH_WM8850=y
116CONFIG_ARCH_ZYNQ=y 106CONFIG_ARCH_ZYNQ=y
117CONFIG_TRUSTED_FOUNDATIONS=y 107CONFIG_PCIEPORTBUS=y
118CONFIG_PCI=y
119CONFIG_PCI_HOST_GENERIC=y
120CONFIG_PCI_DRA7XX=y
121CONFIG_PCI_DRA7XX_EP=y
122CONFIG_PCI_KEYSTONE=y
123CONFIG_PCI_MSI=y
124CONFIG_PCI_MVEBU=y 108CONFIG_PCI_MVEBU=y
125CONFIG_PCI_TEGRA=y 109CONFIG_PCI_TEGRA=y
126CONFIG_PCI_RCAR_GEN2=y 110CONFIG_PCI_RCAR_GEN2=y
127CONFIG_PCIE_RCAR=y 111CONFIG_PCIE_RCAR=y
128CONFIG_PCIEPORTBUS=y 112CONFIG_PCI_DRA7XX_EP=y
113CONFIG_PCI_KEYSTONE=y
129CONFIG_PCI_ENDPOINT=y 114CONFIG_PCI_ENDPOINT=y
130CONFIG_PCI_ENDPOINT_CONFIGFS=y 115CONFIG_PCI_ENDPOINT_CONFIGFS=y
131CONFIG_PCI_EPF_TEST=m 116CONFIG_PCI_EPF_TEST=m
132CONFIG_SMP=y 117CONFIG_SMP=y
133CONFIG_NR_CPUS=16 118CONFIG_NR_CPUS=16
134CONFIG_HIGHPTE=y
135CONFIG_CMA=y
136CONFIG_SECCOMP=y 119CONFIG_SECCOMP=y
137CONFIG_ARM_APPENDED_DTB=y 120CONFIG_ARM_APPENDED_DTB=y
138CONFIG_ARM_ATAG_DTB_COMPAT=y 121CONFIG_ARM_ATAG_DTB_COMPAT=y
@@ -145,14 +128,14 @@ CONFIG_CPU_FREQ_GOV_POWERSAVE=m
145CONFIG_CPU_FREQ_GOV_USERSPACE=m 128CONFIG_CPU_FREQ_GOV_USERSPACE=m
146CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m 129CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
147CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y 130CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
131CONFIG_CPUFREQ_DT=y
148CONFIG_ARM_IMX6Q_CPUFREQ=y 132CONFIG_ARM_IMX6Q_CPUFREQ=y
149CONFIG_QORIQ_CPUFREQ=y 133CONFIG_QORIQ_CPUFREQ=y
150CONFIG_CPU_IDLE=y 134CONFIG_CPU_IDLE=y
151CONFIG_ARM_CPUIDLE=y 135CONFIG_ARM_CPUIDLE=y
152CONFIG_NEON=y
153CONFIG_KERNEL_MODE_NEON=y
154CONFIG_ARM_ZYNQ_CPUIDLE=y 136CONFIG_ARM_ZYNQ_CPUIDLE=y
155CONFIG_ARM_EXYNOS_CPUIDLE=y 137CONFIG_ARM_EXYNOS_CPUIDLE=y
138CONFIG_KERNEL_MODE_NEON=y
156CONFIG_NET=y 139CONFIG_NET=y
157CONFIG_PACKET=y 140CONFIG_PACKET=y
158CONFIG_UNIX=y 141CONFIG_UNIX=y
@@ -170,23 +153,13 @@ CONFIG_IPV6_MIP6=m
170CONFIG_IPV6_TUNNEL=m 153CONFIG_IPV6_TUNNEL=m
171CONFIG_IPV6_MULTIPLE_TABLES=y 154CONFIG_IPV6_MULTIPLE_TABLES=y
172CONFIG_NET_DSA=m 155CONFIG_NET_DSA=m
173CONFIG_NET_SWITCHDEV=y
174CONFIG_CAN=y 156CONFIG_CAN=y
175CONFIG_CAN_RAW=y
176CONFIG_CAN_BCM=y
177CONFIG_CAN_DEV=y
178CONFIG_CAN_AT91=m 157CONFIG_CAN_AT91=m
179CONFIG_CAN_FLEXCAN=m 158CONFIG_CAN_FLEXCAN=m
180CONFIG_CAN_RCAR=m 159CONFIG_CAN_SUN4I=y
181CONFIG_CAN_XILINXCAN=y 160CONFIG_CAN_XILINXCAN=y
161CONFIG_CAN_RCAR=m
182CONFIG_CAN_MCP251X=y 162CONFIG_CAN_MCP251X=y
183CONFIG_NET_DSA_BCM_SF2=m
184CONFIG_B53=m
185CONFIG_B53_SPI_DRIVER=m
186CONFIG_B53_MDIO_DRIVER=m
187CONFIG_B53_MMAP_DRIVER=m
188CONFIG_B53_SRAB_DRIVER=m
189CONFIG_CAN_SUN4I=y
190CONFIG_BT=m 163CONFIG_BT=m
191CONFIG_BT_HCIUART=m 164CONFIG_BT_HCIUART=m
192CONFIG_BT_HCIUART_BCM=y 165CONFIG_BT_HCIUART_BCM=y
@@ -199,11 +172,9 @@ CONFIG_RFKILL_INPUT=y
199CONFIG_RFKILL_GPIO=y 172CONFIG_RFKILL_GPIO=y
200CONFIG_DEVTMPFS=y 173CONFIG_DEVTMPFS=y
201CONFIG_DEVTMPFS_MOUNT=y 174CONFIG_DEVTMPFS_MOUNT=y
202CONFIG_DMA_CMA=y
203CONFIG_CMA_SIZE_MBYTES=64 175CONFIG_CMA_SIZE_MBYTES=64
204CONFIG_OMAP_OCP2SCP=y 176CONFIG_OMAP_OCP2SCP=y
205CONFIG_SIMPLE_PM_BUS=y 177CONFIG_SIMPLE_PM_BUS=y
206CONFIG_SUNXI_RSB=y
207CONFIG_MTD=y 178CONFIG_MTD=y
208CONFIG_MTD_CMDLINE_PARTS=y 179CONFIG_MTD_CMDLINE_PARTS=y
209CONFIG_MTD_BLOCK=y 180CONFIG_MTD_BLOCK=y
@@ -236,7 +207,6 @@ CONFIG_PCI_ENDPOINT_TEST=m
236CONFIG_EEPROM_AT24=y 207CONFIG_EEPROM_AT24=y
237CONFIG_BLK_DEV_SD=y 208CONFIG_BLK_DEV_SD=y
238CONFIG_BLK_DEV_SR=y 209CONFIG_BLK_DEV_SR=y
239CONFIG_SCSI_MULTI_LUN=y
240CONFIG_ATA=y 210CONFIG_ATA=y
241CONFIG_SATA_AHCI=y 211CONFIG_SATA_AHCI=y
242CONFIG_SATA_AHCI_PLATFORM=y 212CONFIG_SATA_AHCI_PLATFORM=y
@@ -251,14 +221,20 @@ CONFIG_SATA_MV=y
251CONFIG_SATA_RCAR=y 221CONFIG_SATA_RCAR=y
252CONFIG_NETDEVICES=y 222CONFIG_NETDEVICES=y
253CONFIG_VIRTIO_NET=y 223CONFIG_VIRTIO_NET=y
254CONFIG_HIX5HD2_GMAC=y 224CONFIG_B53_SPI_DRIVER=m
225CONFIG_B53_MDIO_DRIVER=m
226CONFIG_B53_MMAP_DRIVER=m
227CONFIG_B53_SRAB_DRIVER=m
228CONFIG_NET_DSA_BCM_SF2=m
255CONFIG_SUN4I_EMAC=y 229CONFIG_SUN4I_EMAC=y
256CONFIG_MACB=y
257CONFIG_BCMGENET=m 230CONFIG_BCMGENET=m
258CONFIG_BGMAC_BCMA=y 231CONFIG_BGMAC_BCMA=y
259CONFIG_SYSTEMPORT=m 232CONFIG_SYSTEMPORT=m
233CONFIG_MACB=y
260CONFIG_NET_CALXEDA_XGMAC=y 234CONFIG_NET_CALXEDA_XGMAC=y
261CONFIG_GIANFAR=y 235CONFIG_GIANFAR=y
236CONFIG_HIX5HD2_GMAC=y
237CONFIG_E1000E=y
262CONFIG_IGB=y 238CONFIG_IGB=y
263CONFIG_MV643XX_ETH=y 239CONFIG_MV643XX_ETH=y
264CONFIG_MVNETA=y 240CONFIG_MVNETA=y
@@ -268,19 +244,17 @@ CONFIG_R8169=y
268CONFIG_SH_ETH=y 244CONFIG_SH_ETH=y
269CONFIG_SMSC911X=y 245CONFIG_SMSC911X=y
270CONFIG_STMMAC_ETH=y 246CONFIG_STMMAC_ETH=y
271CONFIG_STMMAC_PLATFORM=y
272CONFIG_DWMAC_DWC_QOS_ETH=y 247CONFIG_DWMAC_DWC_QOS_ETH=y
273CONFIG_TI_CPSW=y 248CONFIG_TI_CPSW=y
274CONFIG_XILINX_EMACLITE=y 249CONFIG_XILINX_EMACLITE=y
275CONFIG_AT803X_PHY=y 250CONFIG_AT803X_PHY=y
276CONFIG_MARVELL_PHY=y
277CONFIG_SMSC_PHY=y
278CONFIG_BROADCOM_PHY=y 251CONFIG_BROADCOM_PHY=y
279CONFIG_ICPLUS_PHY=y 252CONFIG_ICPLUS_PHY=y
280CONFIG_REALTEK_PHY=y 253CONFIG_MARVELL_PHY=y
281CONFIG_MICREL_PHY=y 254CONFIG_MICREL_PHY=y
282CONFIG_FIXED_PHY=y 255CONFIG_REALTEK_PHY=y
283CONFIG_ROCKCHIP_PHY=y 256CONFIG_ROCKCHIP_PHY=y
257CONFIG_SMSC_PHY=y
284CONFIG_USB_PEGASUS=y 258CONFIG_USB_PEGASUS=y
285CONFIG_USB_RTL8152=m 259CONFIG_USB_RTL8152=m
286CONFIG_USB_LAN78XX=m 260CONFIG_USB_LAN78XX=m
@@ -288,29 +262,29 @@ CONFIG_USB_USBNET=y
288CONFIG_USB_NET_SMSC75XX=y 262CONFIG_USB_NET_SMSC75XX=y
289CONFIG_USB_NET_SMSC95XX=y 263CONFIG_USB_NET_SMSC95XX=y
290CONFIG_BRCMFMAC=m 264CONFIG_BRCMFMAC=m
291CONFIG_RT2X00=m
292CONFIG_RT2800USB=m
293CONFIG_MWIFIEX=m 265CONFIG_MWIFIEX=m
294CONFIG_MWIFIEX_SDIO=m 266CONFIG_MWIFIEX_SDIO=m
267CONFIG_RT2X00=m
268CONFIG_RT2800USB=m
295CONFIG_INPUT_JOYDEV=y 269CONFIG_INPUT_JOYDEV=y
296CONFIG_INPUT_EVDEV=y 270CONFIG_INPUT_EVDEV=y
297CONFIG_KEYBOARD_QT1070=m 271CONFIG_KEYBOARD_QT1070=m
298CONFIG_KEYBOARD_GPIO=y 272CONFIG_KEYBOARD_GPIO=y
299CONFIG_KEYBOARD_TEGRA=y 273CONFIG_KEYBOARD_TEGRA=y
300CONFIG_KEYBOARD_SPEAR=y 274CONFIG_KEYBOARD_SAMSUNG=m
301CONFIG_KEYBOARD_ST_KEYSCAN=y 275CONFIG_KEYBOARD_ST_KEYSCAN=y
276CONFIG_KEYBOARD_SPEAR=y
302CONFIG_KEYBOARD_CROS_EC=m 277CONFIG_KEYBOARD_CROS_EC=m
303CONFIG_KEYBOARD_SAMSUNG=m
304CONFIG_MOUSE_PS2_ELANTECH=y 278CONFIG_MOUSE_PS2_ELANTECH=y
305CONFIG_MOUSE_CYAPA=m 279CONFIG_MOUSE_CYAPA=m
306CONFIG_MOUSE_ELAN_I2C=y 280CONFIG_MOUSE_ELAN_I2C=y
307CONFIG_INPUT_TOUCHSCREEN=y 281CONFIG_INPUT_TOUCHSCREEN=y
308CONFIG_TOUCHSCREEN_ATMEL_MXT=m 282CONFIG_TOUCHSCREEN_ATMEL_MXT=m
309CONFIG_TOUCHSCREEN_MMS114=m 283CONFIG_TOUCHSCREEN_MMS114=m
284CONFIG_TOUCHSCREEN_WM97XX=m
310CONFIG_TOUCHSCREEN_ST1232=m 285CONFIG_TOUCHSCREEN_ST1232=m
311CONFIG_TOUCHSCREEN_STMPE=y 286CONFIG_TOUCHSCREEN_STMPE=y
312CONFIG_TOUCHSCREEN_SUN4I=y 287CONFIG_TOUCHSCREEN_SUN4I=y
313CONFIG_TOUCHSCREEN_WM97XX=m
314CONFIG_INPUT_MISC=y 288CONFIG_INPUT_MISC=y
315CONFIG_INPUT_MAX77693_HAPTIC=m 289CONFIG_INPUT_MAX77693_HAPTIC=m
316CONFIG_INPUT_MAX8997_HAPTIC=m 290CONFIG_INPUT_MAX8997_HAPTIC=m
@@ -327,13 +301,12 @@ CONFIG_SERIAL_8250_DW=y
327CONFIG_SERIAL_8250_EM=y 301CONFIG_SERIAL_8250_EM=y
328CONFIG_SERIAL_8250_MT6577=y 302CONFIG_SERIAL_8250_MT6577=y
329CONFIG_SERIAL_8250_UNIPHIER=y 303CONFIG_SERIAL_8250_UNIPHIER=y
304CONFIG_SERIAL_OF_PLATFORM=y
330CONFIG_SERIAL_AMBA_PL011=y 305CONFIG_SERIAL_AMBA_PL011=y
331CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 306CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
332CONFIG_SERIAL_ATMEL=y 307CONFIG_SERIAL_ATMEL=y
333CONFIG_SERIAL_ATMEL_CONSOLE=y 308CONFIG_SERIAL_ATMEL_CONSOLE=y
334CONFIG_SERIAL_ATMEL_TTYAT=y 309CONFIG_SERIAL_ATMEL_TTYAT=y
335CONFIG_SERIAL_BCM63XX=y
336CONFIG_SERIAL_BCM63XX_CONSOLE=y
337CONFIG_SERIAL_MESON=y 310CONFIG_SERIAL_MESON=y
338CONFIG_SERIAL_MESON_CONSOLE=y 311CONFIG_SERIAL_MESON_CONSOLE=y
339CONFIG_SERIAL_SAMSUNG=y 312CONFIG_SERIAL_SAMSUNG=y
@@ -345,15 +318,14 @@ CONFIG_SERIAL_IMX=y
345CONFIG_SERIAL_IMX_CONSOLE=y 318CONFIG_SERIAL_IMX_CONSOLE=y
346CONFIG_SERIAL_SH_SCI=y 319CONFIG_SERIAL_SH_SCI=y
347CONFIG_SERIAL_SH_SCI_NR_UARTS=20 320CONFIG_SERIAL_SH_SCI_NR_UARTS=20
348CONFIG_SERIAL_SH_SCI_CONSOLE=y
349CONFIG_SERIAL_SH_SCI_DMA=y
350CONFIG_SERIAL_MSM=y 321CONFIG_SERIAL_MSM=y
351CONFIG_SERIAL_MSM_CONSOLE=y 322CONFIG_SERIAL_MSM_CONSOLE=y
352CONFIG_SERIAL_VT8500=y 323CONFIG_SERIAL_VT8500=y
353CONFIG_SERIAL_VT8500_CONSOLE=y 324CONFIG_SERIAL_VT8500_CONSOLE=y
354CONFIG_SERIAL_OF_PLATFORM=y
355CONFIG_SERIAL_OMAP=y 325CONFIG_SERIAL_OMAP=y
356CONFIG_SERIAL_OMAP_CONSOLE=y 326CONFIG_SERIAL_OMAP_CONSOLE=y
327CONFIG_SERIAL_BCM63XX=y
328CONFIG_SERIAL_BCM63XX_CONSOLE=y
357CONFIG_SERIAL_XILINX_PS_UART=y 329CONFIG_SERIAL_XILINX_PS_UART=y
358CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y 330CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y
359CONFIG_SERIAL_FSL_LPUART=y 331CONFIG_SERIAL_FSL_LPUART=y
@@ -365,12 +337,10 @@ CONFIG_SERIAL_ST_ASC_CONSOLE=y
365CONFIG_SERIAL_STM32=y 337CONFIG_SERIAL_STM32=y
366CONFIG_SERIAL_STM32_CONSOLE=y 338CONFIG_SERIAL_STM32_CONSOLE=y
367CONFIG_SERIAL_DEV_BUS=y 339CONFIG_SERIAL_DEV_BUS=y
368CONFIG_HVC_DRIVER=y
369CONFIG_VIRTIO_CONSOLE=y 340CONFIG_VIRTIO_CONSOLE=y
341CONFIG_HW_RANDOM=y
342CONFIG_HW_RANDOM_ST=y
370CONFIG_I2C_CHARDEV=y 343CONFIG_I2C_CHARDEV=y
371CONFIG_I2C_DAVINCI=y
372CONFIG_I2C_MESON=y
373CONFIG_I2C_MUX=y
374CONFIG_I2C_ARB_GPIO_CHALLENGE=m 344CONFIG_I2C_ARB_GPIO_CHALLENGE=m
375CONFIG_I2C_MUX_PCA954x=y 345CONFIG_I2C_MUX_PCA954x=y
376CONFIG_I2C_MUX_PINCTRL=y 346CONFIG_I2C_MUX_PINCTRL=y
@@ -378,12 +348,13 @@ CONFIG_I2C_DEMUX_PINCTRL=y
378CONFIG_I2C_AT91=m 348CONFIG_I2C_AT91=m
379CONFIG_I2C_BCM2835=y 349CONFIG_I2C_BCM2835=y
380CONFIG_I2C_CADENCE=y 350CONFIG_I2C_CADENCE=y
351CONFIG_I2C_DAVINCI=y
381CONFIG_I2C_DESIGNWARE_PLATFORM=y 352CONFIG_I2C_DESIGNWARE_PLATFORM=y
382CONFIG_I2C_DIGICOLOR=m 353CONFIG_I2C_DIGICOLOR=m
383CONFIG_I2C_EMEV2=m 354CONFIG_I2C_EMEV2=m
384CONFIG_I2C_GPIO=m 355CONFIG_I2C_GPIO=m
385CONFIG_I2C_EXYNOS5=y
386CONFIG_I2C_IMX=y 356CONFIG_I2C_IMX=y
357CONFIG_I2C_MESON=y
387CONFIG_I2C_MV64XXX=y 358CONFIG_I2C_MV64XXX=y
388CONFIG_I2C_RIIC=y 359CONFIG_I2C_RIIC=y
389CONFIG_I2C_RK3X=y 360CONFIG_I2C_RK3X=y
@@ -427,7 +398,6 @@ CONFIG_SPI_SPIDEV=y
427CONFIG_SPMI=y 398CONFIG_SPMI=y
428CONFIG_PINCTRL_AS3722=y 399CONFIG_PINCTRL_AS3722=y
429CONFIG_PINCTRL_PALMAS=y 400CONFIG_PINCTRL_PALMAS=y
430CONFIG_PINCTRL_BCM2835=y
431CONFIG_PINCTRL_APQ8064=y 401CONFIG_PINCTRL_APQ8064=y
432CONFIG_PINCTRL_APQ8084=y 402CONFIG_PINCTRL_APQ8084=y
433CONFIG_PINCTRL_IPQ8064=y 403CONFIG_PINCTRL_IPQ8064=y
@@ -437,25 +407,33 @@ CONFIG_PINCTRL_MSM8X74=y
437CONFIG_PINCTRL_MSM8916=y 407CONFIG_PINCTRL_MSM8916=y
438CONFIG_PINCTRL_QCOM_SPMI_PMIC=y 408CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
439CONFIG_PINCTRL_QCOM_SSBI_PMIC=y 409CONFIG_PINCTRL_QCOM_SSBI_PMIC=y
440CONFIG_GPIO_GENERIC_PLATFORM=y
441CONFIG_GPIO_DAVINCI=y 410CONFIG_GPIO_DAVINCI=y
442CONFIG_GPIO_DWAPB=y 411CONFIG_GPIO_DWAPB=y
443CONFIG_GPIO_EM=y 412CONFIG_GPIO_EM=y
444CONFIG_GPIO_RCAR=y 413CONFIG_GPIO_RCAR=y
414CONFIG_GPIO_SYSCON=y
445CONFIG_GPIO_UNIPHIER=y 415CONFIG_GPIO_UNIPHIER=y
446CONFIG_GPIO_XILINX=y 416CONFIG_GPIO_XILINX=y
447CONFIG_GPIO_ZYNQ=y 417CONFIG_GPIO_ZYNQ=y
448CONFIG_GPIO_PCA953X=y 418CONFIG_GPIO_PCA953X=y
449CONFIG_GPIO_PCA953X_IRQ=y 419CONFIG_GPIO_PCA953X_IRQ=y
450CONFIG_GPIO_PCF857X=y 420CONFIG_GPIO_PCF857X=y
451CONFIG_GPIO_TWL4030=y
452CONFIG_GPIO_PALMAS=y 421CONFIG_GPIO_PALMAS=y
453CONFIG_GPIO_SYSCON=y
454CONFIG_GPIO_TPS6586X=y 422CONFIG_GPIO_TPS6586X=y
455CONFIG_GPIO_TPS65910=y 423CONFIG_GPIO_TPS65910=y
424CONFIG_GPIO_TWL4030=y
425CONFIG_POWER_AVS=y
426CONFIG_ROCKCHIP_IODOMAIN=y
427CONFIG_POWER_RESET_AS3722=y
428CONFIG_POWER_RESET_GPIO=y
429CONFIG_POWER_RESET_GPIO_RESTART=y
430CONFIG_POWER_RESET_ST=y
431CONFIG_POWER_RESET_KEYSTONE=y
432CONFIG_POWER_RESET_RMOBILE=y
456CONFIG_BATTERY_ACT8945A=y 433CONFIG_BATTERY_ACT8945A=y
457CONFIG_BATTERY_CPCAP=m 434CONFIG_BATTERY_CPCAP=m
458CONFIG_BATTERY_SBS=y 435CONFIG_BATTERY_SBS=y
436CONFIG_AXP20X_POWER=m
459CONFIG_BATTERY_MAX17040=m 437CONFIG_BATTERY_MAX17040=m
460CONFIG_BATTERY_MAX17042=m 438CONFIG_BATTERY_MAX17042=m
461CONFIG_CHARGER_CPCAP=m 439CONFIG_CHARGER_CPCAP=m
@@ -464,15 +442,6 @@ CONFIG_CHARGER_MAX77693=m
464CONFIG_CHARGER_MAX8997=m 442CONFIG_CHARGER_MAX8997=m
465CONFIG_CHARGER_MAX8998=m 443CONFIG_CHARGER_MAX8998=m
466CONFIG_CHARGER_TPS65090=y 444CONFIG_CHARGER_TPS65090=y
467CONFIG_AXP20X_POWER=m
468CONFIG_POWER_RESET_AS3722=y
469CONFIG_POWER_RESET_GPIO=y
470CONFIG_POWER_RESET_GPIO_RESTART=y
471CONFIG_POWER_RESET_KEYSTONE=y
472CONFIG_POWER_RESET_RMOBILE=y
473CONFIG_POWER_RESET_ST=y
474CONFIG_POWER_AVS=y
475CONFIG_ROCKCHIP_IODOMAIN=y
476CONFIG_SENSORS_IIO_HWMON=y 445CONFIG_SENSORS_IIO_HWMON=y
477CONFIG_SENSORS_LM90=y 446CONFIG_SENSORS_LM90=y
478CONFIG_SENSORS_LM95245=y 447CONFIG_SENSORS_LM95245=y
@@ -480,14 +449,12 @@ CONFIG_SENSORS_NTC_THERMISTOR=m
480CONFIG_SENSORS_PWM_FAN=m 449CONFIG_SENSORS_PWM_FAN=m
481CONFIG_SENSORS_INA2XX=m 450CONFIG_SENSORS_INA2XX=m
482CONFIG_CPU_THERMAL=y 451CONFIG_CPU_THERMAL=y
483CONFIG_BCM2835_THERMAL=m
484CONFIG_BRCMSTB_THERMAL=m
485CONFIG_IMX_THERMAL=y 452CONFIG_IMX_THERMAL=y
486CONFIG_ROCKCHIP_THERMAL=y 453CONFIG_ROCKCHIP_THERMAL=y
487CONFIG_RCAR_THERMAL=y 454CONFIG_RCAR_THERMAL=y
488CONFIG_ARMADA_THERMAL=y 455CONFIG_ARMADA_THERMAL=y
489CONFIG_DAVINCI_WATCHDOG=m 456CONFIG_BCM2835_THERMAL=m
490CONFIG_EXYNOS_THERMAL=m 457CONFIG_BRCMSTB_THERMAL=m
491CONFIG_ST_THERMAL_MEMMAP=y 458CONFIG_ST_THERMAL_MEMMAP=y
492CONFIG_WATCHDOG=y 459CONFIG_WATCHDOG=y
493CONFIG_DA9063_WATCHDOG=m 460CONFIG_DA9063_WATCHDOG=m
@@ -495,20 +462,24 @@ CONFIG_XILINX_WATCHDOG=y
495CONFIG_ARM_SP805_WATCHDOG=y 462CONFIG_ARM_SP805_WATCHDOG=y
496CONFIG_AT91SAM9X_WATCHDOG=y 463CONFIG_AT91SAM9X_WATCHDOG=y
497CONFIG_SAMA5D4_WATCHDOG=y 464CONFIG_SAMA5D4_WATCHDOG=y
465CONFIG_DW_WATCHDOG=y
466CONFIG_DAVINCI_WATCHDOG=m
498CONFIG_ORION_WATCHDOG=y 467CONFIG_ORION_WATCHDOG=y
499CONFIG_RN5T618_WATCHDOG=y 468CONFIG_RN5T618_WATCHDOG=y
500CONFIG_ST_LPC_WATCHDOG=y
501CONFIG_SUNXI_WATCHDOG=y 469CONFIG_SUNXI_WATCHDOG=y
502CONFIG_IMX2_WDT=y 470CONFIG_IMX2_WDT=y
471CONFIG_ST_LPC_WATCHDOG=y
503CONFIG_TEGRA_WATCHDOG=m 472CONFIG_TEGRA_WATCHDOG=m
504CONFIG_MESON_WATCHDOG=y 473CONFIG_MESON_WATCHDOG=y
505CONFIG_DW_WATCHDOG=y
506CONFIG_DIGICOLOR_WATCHDOG=y 474CONFIG_DIGICOLOR_WATCHDOG=y
507CONFIG_RENESAS_WDT=m 475CONFIG_RENESAS_WDT=m
508CONFIG_BCM2835_WDT=y
509CONFIG_BCM47XX_WDT=y 476CONFIG_BCM47XX_WDT=y
510CONFIG_BCM7038_WDT=m 477CONFIG_BCM2835_WDT=y
511CONFIG_BCM_KONA_WDT=y 478CONFIG_BCM_KONA_WDT=y
479CONFIG_BCM7038_WDT=m
480CONFIG_BCMA_HOST_SOC=y
481CONFIG_BCMA_DRIVER_GMAC_CMN=y
482CONFIG_BCMA_DRIVER_GPIO=y
512CONFIG_MFD_ACT8945A=y 483CONFIG_MFD_ACT8945A=y
513CONFIG_MFD_AS3711=y 484CONFIG_MFD_AS3711=y
514CONFIG_MFD_AS3722=y 485CONFIG_MFD_AS3722=y
@@ -516,7 +487,6 @@ CONFIG_MFD_ATMEL_FLEXCOM=y
516CONFIG_MFD_ATMEL_HLCDC=m 487CONFIG_MFD_ATMEL_HLCDC=m
517CONFIG_MFD_BCM590XX=y 488CONFIG_MFD_BCM590XX=y
518CONFIG_MFD_AC100=y 489CONFIG_MFD_AC100=y
519CONFIG_MFD_AXP20X=y
520CONFIG_MFD_AXP20X_I2C=y 490CONFIG_MFD_AXP20X_I2C=y
521CONFIG_MFD_AXP20X_RSB=y 491CONFIG_MFD_AXP20X_RSB=y
522CONFIG_MFD_CROS_EC=m 492CONFIG_MFD_CROS_EC=m
@@ -529,11 +499,11 @@ CONFIG_MFD_MAX77693=m
529CONFIG_MFD_MAX8907=y 499CONFIG_MFD_MAX8907=y
530CONFIG_MFD_MAX8997=y 500CONFIG_MFD_MAX8997=y
531CONFIG_MFD_MAX8998=y 501CONFIG_MFD_MAX8998=y
532CONFIG_MFD_RK808=y
533CONFIG_MFD_CPCAP=y 502CONFIG_MFD_CPCAP=y
534CONFIG_MFD_PM8XXX=y 503CONFIG_MFD_PM8XXX=y
535CONFIG_MFD_QCOM_RPM=y 504CONFIG_MFD_QCOM_RPM=y
536CONFIG_MFD_SPMI_PMIC=y 505CONFIG_MFD_SPMI_PMIC=y
506CONFIG_MFD_RK808=y
537CONFIG_MFD_RN5T618=y 507CONFIG_MFD_RN5T618=y
538CONFIG_MFD_SEC_CORE=y 508CONFIG_MFD_SEC_CORE=y
539CONFIG_MFD_STMPE=y 509CONFIG_MFD_STMPE=y
@@ -543,10 +513,10 @@ CONFIG_MFD_TPS65217=y
543CONFIG_MFD_TPS65218=y 513CONFIG_MFD_TPS65218=y
544CONFIG_MFD_TPS6586X=y 514CONFIG_MFD_TPS6586X=y
545CONFIG_MFD_TPS65910=y 515CONFIG_MFD_TPS65910=y
546CONFIG_REGULATOR_ACT8945A=y
547CONFIG_REGULATOR_AB8500=y
548CONFIG_REGULATOR_ACT8865=y 516CONFIG_REGULATOR_ACT8865=y
517CONFIG_REGULATOR_ACT8945A=y
549CONFIG_REGULATOR_ANATOP=y 518CONFIG_REGULATOR_ANATOP=y
519CONFIG_REGULATOR_AB8500=y
550CONFIG_REGULATOR_AS3711=y 520CONFIG_REGULATOR_AS3711=y
551CONFIG_REGULATOR_AS3722=y 521CONFIG_REGULATOR_AS3722=y
552CONFIG_REGULATOR_AXP20X=y 522CONFIG_REGULATOR_AXP20X=y
@@ -554,10 +524,7 @@ CONFIG_REGULATOR_BCM590XX=y
554CONFIG_REGULATOR_CPCAP=y 524CONFIG_REGULATOR_CPCAP=y
555CONFIG_REGULATOR_DA9210=y 525CONFIG_REGULATOR_DA9210=y
556CONFIG_REGULATOR_FAN53555=y 526CONFIG_REGULATOR_FAN53555=y
557CONFIG_REGULATOR_RK808=y
558CONFIG_REGULATOR_GPIO=y 527CONFIG_REGULATOR_GPIO=y
559CONFIG_MFD_SYSCON=y
560CONFIG_POWER_RESET_SYSCON=y
561CONFIG_REGULATOR_LP872X=y 528CONFIG_REGULATOR_LP872X=y
562CONFIG_REGULATOR_MAX14577=m 529CONFIG_REGULATOR_MAX14577=m
563CONFIG_REGULATOR_MAX8907=y 530CONFIG_REGULATOR_MAX8907=y
@@ -571,7 +538,8 @@ CONFIG_REGULATOR_PALMAS=y
571CONFIG_REGULATOR_PBIAS=y 538CONFIG_REGULATOR_PBIAS=y
572CONFIG_REGULATOR_PWM=y 539CONFIG_REGULATOR_PWM=y
573CONFIG_REGULATOR_QCOM_RPM=y 540CONFIG_REGULATOR_QCOM_RPM=y
574CONFIG_REGULATOR_QCOM_SMD_RPM=y 541CONFIG_REGULATOR_QCOM_SMD_RPM=m
542CONFIG_REGULATOR_RK808=y
575CONFIG_REGULATOR_RN5T618=y 543CONFIG_REGULATOR_RN5T618=y
576CONFIG_REGULATOR_S2MPS11=y 544CONFIG_REGULATOR_S2MPS11=y
577CONFIG_REGULATOR_S5M8767=y 545CONFIG_REGULATOR_S5M8767=y
@@ -592,18 +560,17 @@ CONFIG_MEDIA_CEC_SUPPORT=y
592CONFIG_MEDIA_CONTROLLER=y 560CONFIG_MEDIA_CONTROLLER=y
593CONFIG_VIDEO_V4L2_SUBDEV_API=y 561CONFIG_VIDEO_V4L2_SUBDEV_API=y
594CONFIG_MEDIA_USB_SUPPORT=y 562CONFIG_MEDIA_USB_SUPPORT=y
595CONFIG_USB_VIDEO_CLASS=y 563CONFIG_USB_VIDEO_CLASS=m
596CONFIG_USB_GSPCA=y
597CONFIG_V4L_PLATFORM_DRIVERS=y 564CONFIG_V4L_PLATFORM_DRIVERS=y
598CONFIG_SOC_CAMERA=m 565CONFIG_SOC_CAMERA=m
599CONFIG_SOC_CAMERA_PLATFORM=m 566CONFIG_SOC_CAMERA_PLATFORM=m
600CONFIG_VIDEO_RCAR_VIN=m
601CONFIG_VIDEO_ATMEL_ISI=m
602CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS=m 567CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS=m
603CONFIG_VIDEO_S5P_FIMC=m 568CONFIG_VIDEO_S5P_FIMC=m
604CONFIG_VIDEO_S5P_MIPI_CSIS=m 569CONFIG_VIDEO_S5P_MIPI_CSIS=m
605CONFIG_VIDEO_EXYNOS_FIMC_LITE=m 570CONFIG_VIDEO_EXYNOS_FIMC_LITE=m
606CONFIG_VIDEO_EXYNOS4_FIMC_IS=m 571CONFIG_VIDEO_EXYNOS4_FIMC_IS=m
572CONFIG_VIDEO_RCAR_VIN=m
573CONFIG_VIDEO_ATMEL_ISI=m
607CONFIG_V4L_MEM2MEM_DRIVERS=y 574CONFIG_V4L_MEM2MEM_DRIVERS=y
608CONFIG_VIDEO_SAMSUNG_S5P_JPEG=m 575CONFIG_VIDEO_SAMSUNG_S5P_JPEG=m
609CONFIG_VIDEO_SAMSUNG_S5P_MFC=m 576CONFIG_VIDEO_SAMSUNG_S5P_MFC=m
@@ -614,19 +581,15 @@ CONFIG_VIDEO_STI_DELTA=m
614CONFIG_VIDEO_RENESAS_JPU=m 581CONFIG_VIDEO_RENESAS_JPU=m
615CONFIG_VIDEO_RENESAS_VSP1=m 582CONFIG_VIDEO_RENESAS_VSP1=m
616CONFIG_V4L_TEST_DRIVERS=y 583CONFIG_V4L_TEST_DRIVERS=y
584CONFIG_VIDEO_VIVID=m
617CONFIG_CEC_PLATFORM_DRIVERS=y 585CONFIG_CEC_PLATFORM_DRIVERS=y
618CONFIG_VIDEO_SAMSUNG_S5P_CEC=m 586CONFIG_VIDEO_SAMSUNG_S5P_CEC=m
619# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set 587# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
620CONFIG_VIDEO_ADV7180=m 588CONFIG_VIDEO_ADV7180=m
621CONFIG_VIDEO_ML86V7667=m 589CONFIG_VIDEO_ML86V7667=m
622CONFIG_DRM=y 590CONFIG_DRM=y
623CONFIG_DRM_I2C_ADV7511=m
624CONFIG_DRM_I2C_ADV7511_AUDIO=y
625# CONFIG_DRM_I2C_CH7006 is not set 591# CONFIG_DRM_I2C_CH7006 is not set
626# CONFIG_DRM_I2C_SIL164 is not set 592# CONFIG_DRM_I2C_SIL164 is not set
627CONFIG_DRM_DUMB_VGA_DAC=m
628CONFIG_DRM_NXP_PTN3460=m
629CONFIG_DRM_PARADE_PS8622=m
630CONFIG_DRM_NOUVEAU=m 593CONFIG_DRM_NOUVEAU=m
631CONFIG_DRM_EXYNOS=m 594CONFIG_DRM_EXYNOS=m
632CONFIG_DRM_EXYNOS_FIMD=y 595CONFIG_DRM_EXYNOS_FIMD=y
@@ -645,13 +608,18 @@ CONFIG_DRM_RCAR_LVDS=y
645CONFIG_DRM_SUN4I=m 608CONFIG_DRM_SUN4I=m
646CONFIG_DRM_FSL_DCU=m 609CONFIG_DRM_FSL_DCU=m
647CONFIG_DRM_TEGRA=y 610CONFIG_DRM_TEGRA=y
611CONFIG_DRM_PANEL_SIMPLE=y
648CONFIG_DRM_PANEL_SAMSUNG_LD9040=m 612CONFIG_DRM_PANEL_SAMSUNG_LD9040=m
649CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03=m 613CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03=m
650CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0=m 614CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0=m
651CONFIG_DRM_PANEL_SIMPLE=y 615CONFIG_DRM_DUMB_VGA_DAC=m
616CONFIG_DRM_NXP_PTN3460=m
617CONFIG_DRM_PARADE_PS8622=m
652CONFIG_DRM_SII9234=m 618CONFIG_DRM_SII9234=m
619CONFIG_DRM_I2C_ADV7511=m
620CONFIG_DRM_I2C_ADV7511_AUDIO=y
653CONFIG_DRM_STI=m 621CONFIG_DRM_STI=m
654CONFIG_DRM_VC4=y 622CONFIG_DRM_VC4=m
655CONFIG_DRM_ETNAVIV=m 623CONFIG_DRM_ETNAVIV=m
656CONFIG_DRM_MXSFB=m 624CONFIG_DRM_MXSFB=m
657CONFIG_FB_ARMCLCD=y 625CONFIG_FB_ARMCLCD=y
@@ -659,8 +627,6 @@ CONFIG_FB_EFI=y
659CONFIG_FB_WM8505=y 627CONFIG_FB_WM8505=y
660CONFIG_FB_SH_MOBILE_LCDC=y 628CONFIG_FB_SH_MOBILE_LCDC=y
661CONFIG_FB_SIMPLE=y 629CONFIG_FB_SIMPLE=y
662CONFIG_BACKLIGHT_LCD_SUPPORT=y
663CONFIG_BACKLIGHT_CLASS_DEVICE=y
664CONFIG_LCD_PLATFORM=m 630CONFIG_LCD_PLATFORM=m
665CONFIG_BACKLIGHT_PWM=y 631CONFIG_BACKLIGHT_PWM=y
666CONFIG_BACKLIGHT_AS3711=y 632CONFIG_BACKLIGHT_AS3711=y
@@ -668,7 +634,6 @@ CONFIG_FRAMEBUFFER_CONSOLE=y
668CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y 634CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
669CONFIG_SOUND=m 635CONFIG_SOUND=m
670CONFIG_SND=m 636CONFIG_SND=m
671CONFIG_SND_DYNAMIC_MINORS=y
672CONFIG_SND_HDA_TEGRA=m 637CONFIG_SND_HDA_TEGRA=m
673CONFIG_SND_HDA_INPUT_BEEP=y 638CONFIG_SND_HDA_INPUT_BEEP=y
674CONFIG_SND_HDA_PATCH_LOADER=y 639CONFIG_SND_HDA_PATCH_LOADER=y
@@ -692,7 +657,7 @@ CONFIG_SND_SOC_SNOW=m
692CONFIG_SND_SOC_ODROID=m 657CONFIG_SND_SOC_ODROID=m
693CONFIG_SND_SOC_SH4_FSI=m 658CONFIG_SND_SOC_SH4_FSI=m
694CONFIG_SND_SOC_RCAR=m 659CONFIG_SND_SOC_RCAR=m
695CONFIG_SND_SIMPLE_SCU_CARD=m 660CONFIG_SND_SOC_STI=m
696CONFIG_SND_SUN4I_CODEC=m 661CONFIG_SND_SUN4I_CODEC=m
697CONFIG_SND_SOC_TEGRA=m 662CONFIG_SND_SOC_TEGRA=m
698CONFIG_SND_SOC_TEGRA20_I2S=m 663CONFIG_SND_SOC_TEGRA20_I2S=m
@@ -703,31 +668,25 @@ CONFIG_SND_SOC_TEGRA_WM8903=m
703CONFIG_SND_SOC_TEGRA_WM9712=m 668CONFIG_SND_SOC_TEGRA_WM9712=m
704CONFIG_SND_SOC_TEGRA_TRIMSLICE=m 669CONFIG_SND_SOC_TEGRA_TRIMSLICE=m
705CONFIG_SND_SOC_TEGRA_ALC5632=m 670CONFIG_SND_SOC_TEGRA_ALC5632=m
706CONFIG_SND_SOC_CPCAP=m
707CONFIG_SND_SOC_TEGRA_MAX98090=m 671CONFIG_SND_SOC_TEGRA_MAX98090=m
708CONFIG_SND_SOC_AK4642=m 672CONFIG_SND_SOC_AK4642=m
673CONFIG_SND_SOC_CPCAP=m
709CONFIG_SND_SOC_SGTL5000=m 674CONFIG_SND_SOC_SGTL5000=m
710CONFIG_SND_SOC_SPDIF=m 675CONFIG_SND_SOC_SPDIF=m
711CONFIG_SND_SOC_WM8978=m
712CONFIG_SND_SOC_STI=m
713CONFIG_SND_SOC_STI_SAS=m 676CONFIG_SND_SOC_STI_SAS=m
714CONFIG_SND_SIMPLE_CARD=m 677CONFIG_SND_SOC_WM8978=m
678CONFIG_SND_SIMPLE_SCU_CARD=m
715CONFIG_USB=y 679CONFIG_USB=y
716CONFIG_USB_OTG=y 680CONFIG_USB_OTG=y
717CONFIG_USB_XHCI_HCD=y 681CONFIG_USB_XHCI_HCD=y
718CONFIG_USB_XHCI_MVEBU=y 682CONFIG_USB_XHCI_MVEBU=y
719CONFIG_USB_XHCI_RCAR=m
720CONFIG_USB_XHCI_TEGRA=m 683CONFIG_USB_XHCI_TEGRA=m
721CONFIG_USB_EHCI_HCD=y 684CONFIG_USB_EHCI_HCD=y
722CONFIG_USB_EHCI_MSM=m
723CONFIG_USB_EHCI_EXYNOS=y
724CONFIG_USB_EHCI_TEGRA=y
725CONFIG_USB_EHCI_HCD_STI=y 685CONFIG_USB_EHCI_HCD_STI=y
726CONFIG_USB_EHCI_HCD_PLATFORM=y 686CONFIG_USB_EHCI_TEGRA=y
727CONFIG_USB_ISP1760=y 687CONFIG_USB_EHCI_EXYNOS=y
728CONFIG_USB_OHCI_HCD=y 688CONFIG_USB_OHCI_HCD=y
729CONFIG_USB_OHCI_HCD_STI=y 689CONFIG_USB_OHCI_HCD_STI=y
730CONFIG_USB_OHCI_HCD_PLATFORM=y
731CONFIG_USB_OHCI_EXYNOS=m 690CONFIG_USB_OHCI_EXYNOS=m
732CONFIG_USB_R8A66597_HCD=m 691CONFIG_USB_R8A66597_HCD=m
733CONFIG_USB_RENESAS_USBHS=m 692CONFIG_USB_RENESAS_USBHS=m
@@ -746,18 +705,18 @@ CONFIG_USB_TI_CPPI41_DMA=y
746CONFIG_USB_TUSB_OMAP_DMA=y 705CONFIG_USB_TUSB_OMAP_DMA=y
747CONFIG_USB_DWC3=y 706CONFIG_USB_DWC3=y
748CONFIG_USB_DWC2=y 707CONFIG_USB_DWC2=y
749CONFIG_USB_HSIC_USB3503=y
750CONFIG_USB_CHIPIDEA=y 708CONFIG_USB_CHIPIDEA=y
751CONFIG_USB_CHIPIDEA_UDC=y 709CONFIG_USB_CHIPIDEA_UDC=y
752CONFIG_USB_CHIPIDEA_HOST=y 710CONFIG_USB_CHIPIDEA_HOST=y
711CONFIG_USB_ISP1760=y
712CONFIG_USB_HSIC_USB3503=y
753CONFIG_AB8500_USB=y 713CONFIG_AB8500_USB=y
754CONFIG_KEYSTONE_USB_PHY=y 714CONFIG_KEYSTONE_USB_PHY=m
755CONFIG_NOP_USB_XCEIV=m 715CONFIG_NOP_USB_XCEIV=m
756CONFIG_AM335X_PHY_USB=m 716CONFIG_AM335X_PHY_USB=m
757CONFIG_TWL6030_USB=m 717CONFIG_TWL6030_USB=m
758CONFIG_USB_GPIO_VBUS=y 718CONFIG_USB_GPIO_VBUS=y
759CONFIG_USB_ISP1301=y 719CONFIG_USB_ISP1301=y
760CONFIG_USB_MSM_OTG=m
761CONFIG_USB_MXS_PHY=y 720CONFIG_USB_MXS_PHY=y
762CONFIG_USB_GADGET=y 721CONFIG_USB_GADGET=y
763CONFIG_USB_FSL_USB2=y 722CONFIG_USB_FSL_USB2=y
@@ -793,21 +752,20 @@ CONFIG_MMC_SDHCI_OF_ESDHC=y
793CONFIG_MMC_SDHCI_ESDHC_IMX=y 752CONFIG_MMC_SDHCI_ESDHC_IMX=y
794CONFIG_MMC_SDHCI_DOVE=y 753CONFIG_MMC_SDHCI_DOVE=y
795CONFIG_MMC_SDHCI_TEGRA=y 754CONFIG_MMC_SDHCI_TEGRA=y
755CONFIG_MMC_SDHCI_S3C=y
796CONFIG_MMC_SDHCI_PXAV3=y 756CONFIG_MMC_SDHCI_PXAV3=y
797CONFIG_MMC_SDHCI_SPEAR=y 757CONFIG_MMC_SDHCI_SPEAR=y
798CONFIG_MMC_SDHCI_S3C=y
799CONFIG_MMC_SDHCI_S3C_DMA=y 758CONFIG_MMC_SDHCI_S3C_DMA=y
800CONFIG_MMC_SDHCI_BCM_KONA=y 759CONFIG_MMC_SDHCI_BCM_KONA=y
760CONFIG_MMC_MESON_MX_SDIO=y
801CONFIG_MMC_SDHCI_ST=y 761CONFIG_MMC_SDHCI_ST=y
802CONFIG_MMC_OMAP=y 762CONFIG_MMC_OMAP=y
803CONFIG_MMC_OMAP_HS=y 763CONFIG_MMC_OMAP_HS=y
804CONFIG_MMC_ATMELMCI=y 764CONFIG_MMC_ATMELMCI=y
805CONFIG_MMC_SDHCI_MSM=y 765CONFIG_MMC_SDHCI_MSM=y
806CONFIG_MMC_MESON_MX_SDIO=y
807CONFIG_MMC_MVSDIO=y 766CONFIG_MMC_MVSDIO=y
808CONFIG_MMC_SDHI=y 767CONFIG_MMC_SDHI=y
809CONFIG_MMC_DW=y 768CONFIG_MMC_DW=y
810CONFIG_MMC_DW_PLTFM=y
811CONFIG_MMC_DW_EXYNOS=y 769CONFIG_MMC_DW_EXYNOS=y
812CONFIG_MMC_DW_ROCKCHIP=y 770CONFIG_MMC_DW_ROCKCHIP=y
813CONFIG_MMC_SH_MMCIF=y 771CONFIG_MMC_SH_MMCIF=y
@@ -847,94 +805,85 @@ CONFIG_RTC_DRV_MAX77686=y
847CONFIG_RTC_DRV_RK808=m 805CONFIG_RTC_DRV_RK808=m
848CONFIG_RTC_DRV_RS5C372=m 806CONFIG_RTC_DRV_RS5C372=m
849CONFIG_RTC_DRV_BQ32K=m 807CONFIG_RTC_DRV_BQ32K=m
850CONFIG_RTC_DRV_PALMAS=y
851CONFIG_RTC_DRV_ST_LPC=y
852CONFIG_RTC_DRV_TWL4030=y 808CONFIG_RTC_DRV_TWL4030=y
809CONFIG_RTC_DRV_PALMAS=y
853CONFIG_RTC_DRV_TPS6586X=y 810CONFIG_RTC_DRV_TPS6586X=y
854CONFIG_RTC_DRV_TPS65910=y 811CONFIG_RTC_DRV_TPS65910=y
855CONFIG_RTC_DRV_S35390A=m 812CONFIG_RTC_DRV_S35390A=m
856CONFIG_RTC_DRV_RX8581=m 813CONFIG_RTC_DRV_RX8581=m
857CONFIG_RTC_DRV_EM3027=y 814CONFIG_RTC_DRV_EM3027=y
815CONFIG_RTC_DRV_S5M=m
858CONFIG_RTC_DRV_DA9063=m 816CONFIG_RTC_DRV_DA9063=m
859CONFIG_RTC_DRV_EFI=m 817CONFIG_RTC_DRV_EFI=m
860CONFIG_RTC_DRV_DIGICOLOR=m 818CONFIG_RTC_DRV_DIGICOLOR=m
861CONFIG_RTC_DRV_S5M=m
862CONFIG_RTC_DRV_S3C=m 819CONFIG_RTC_DRV_S3C=m
863CONFIG_RTC_DRV_PL031=y 820CONFIG_RTC_DRV_PL031=y
864CONFIG_RTC_DRV_AT91RM9200=m 821CONFIG_RTC_DRV_AT91RM9200=m
865CONFIG_RTC_DRV_AT91SAM9=m 822CONFIG_RTC_DRV_AT91SAM9=m
866CONFIG_RTC_DRV_VT8500=y 823CONFIG_RTC_DRV_VT8500=y
867CONFIG_RTC_DRV_SUN6I=y
868CONFIG_RTC_DRV_SUNXI=y 824CONFIG_RTC_DRV_SUNXI=y
869CONFIG_RTC_DRV_MV=y 825CONFIG_RTC_DRV_MV=y
870CONFIG_RTC_DRV_TEGRA=y 826CONFIG_RTC_DRV_TEGRA=y
827CONFIG_RTC_DRV_ST_LPC=y
871CONFIG_RTC_DRV_CPCAP=m 828CONFIG_RTC_DRV_CPCAP=m
872CONFIG_DMADEVICES=y 829CONFIG_DMADEVICES=y
873CONFIG_DW_DMAC=y
874CONFIG_AT_HDMAC=y 830CONFIG_AT_HDMAC=y
875CONFIG_AT_XDMAC=y 831CONFIG_AT_XDMAC=y
832CONFIG_DMA_BCM2835=y
833CONFIG_DMA_SUN6I=y
876CONFIG_FSL_EDMA=y 834CONFIG_FSL_EDMA=y
835CONFIG_IMX_DMA=y
836CONFIG_IMX_SDMA=y
877CONFIG_MV_XOR=y 837CONFIG_MV_XOR=y
838CONFIG_MXS_DMA=y
839CONFIG_PL330_DMA=y
840CONFIG_SIRF_DMA=y
841CONFIG_STE_DMA40=y
842CONFIG_ST_FDMA=m
878CONFIG_TEGRA20_APB_DMA=y 843CONFIG_TEGRA20_APB_DMA=y
844CONFIG_XILINX_DMA=y
845CONFIG_QCOM_BAM_DMA=y
846CONFIG_DW_DMAC=y
879CONFIG_SH_DMAE=y 847CONFIG_SH_DMAE=y
880CONFIG_RCAR_DMAC=y 848CONFIG_RCAR_DMAC=y
881CONFIG_RENESAS_USB_DMAC=m 849CONFIG_RENESAS_USB_DMAC=m
882CONFIG_STE_DMA40=y 850CONFIG_VIRTIO_PCI=y
883CONFIG_SIRF_DMA=y 851CONFIG_VIRTIO_MMIO=y
884CONFIG_TI_EDMA=y
885CONFIG_PL330_DMA=y
886CONFIG_IMX_SDMA=y
887CONFIG_IMX_DMA=y
888CONFIG_MXS_DMA=y
889CONFIG_DMA_BCM2835=y
890CONFIG_DMA_OMAP=y
891CONFIG_QCOM_BAM_DMA=y
892CONFIG_XILINX_DMA=y
893CONFIG_DMA_SUN6I=y
894CONFIG_ST_FDMA=m
895CONFIG_STAGING=y 852CONFIG_STAGING=y
896CONFIG_SENSORS_ISL29018=y
897CONFIG_SENSORS_ISL29028=y
898CONFIG_MFD_NVEC=y 853CONFIG_MFD_NVEC=y
899CONFIG_KEYBOARD_NVEC=y 854CONFIG_KEYBOARD_NVEC=y
900CONFIG_SERIO_NVEC_PS2=y 855CONFIG_SERIO_NVEC_PS2=y
901CONFIG_NVEC_POWER=y 856CONFIG_NVEC_POWER=y
902CONFIG_NVEC_PAZ00=y 857CONFIG_NVEC_PAZ00=y
903CONFIG_BCMA=y
904CONFIG_BCMA_HOST_SOC=y
905CONFIG_BCMA_DRIVER_GMAC_CMN=y
906CONFIG_BCMA_DRIVER_GPIO=y
907CONFIG_QCOM_GSBI=y
908CONFIG_QCOM_PM=y
909CONFIG_QCOM_SMEM=y
910CONFIG_QCOM_SMD_RPM=y
911CONFIG_QCOM_SMP2P=y
912CONFIG_QCOM_SMSM=y
913CONFIG_QCOM_WCNSS_CTRL=m
914CONFIG_ROCKCHIP_PM_DOMAINS=y
915CONFIG_COMMON_CLK_QCOM=y
916CONFIG_QCOM_CLK_RPM=y
917CONFIG_CHROME_PLATFORMS=y
918CONFIG_STAGING_BOARD=y 858CONFIG_STAGING_BOARD=y
919CONFIG_CROS_EC_CHARDEV=m
920CONFIG_COMMON_CLK_MAX77686=y 859CONFIG_COMMON_CLK_MAX77686=y
921CONFIG_COMMON_CLK_RK808=m 860CONFIG_COMMON_CLK_RK808=m
922CONFIG_COMMON_CLK_S2MPS11=m 861CONFIG_COMMON_CLK_S2MPS11=m
862CONFIG_COMMON_CLK_QCOM=y
863CONFIG_QCOM_CLK_RPM=y
923CONFIG_APQ_MMCC_8084=y 864CONFIG_APQ_MMCC_8084=y
924CONFIG_MSM_GCC_8660=y 865CONFIG_MSM_GCC_8660=y
925CONFIG_MSM_MMCC_8960=y 866CONFIG_MSM_MMCC_8960=y
926CONFIG_MSM_MMCC_8974=y 867CONFIG_MSM_MMCC_8974=y
927CONFIG_HWSPINLOCK_QCOM=y 868CONFIG_BCM2835_MBOX=y
928CONFIG_ROCKCHIP_IOMMU=y 869CONFIG_ROCKCHIP_IOMMU=y
929CONFIG_TEGRA_IOMMU_GART=y 870CONFIG_TEGRA_IOMMU_GART=y
930CONFIG_TEGRA_IOMMU_SMMU=y 871CONFIG_TEGRA_IOMMU_SMMU=y
931CONFIG_REMOTEPROC=m 872CONFIG_REMOTEPROC=m
932CONFIG_ST_REMOTEPROC=m 873CONFIG_ST_REMOTEPROC=m
933CONFIG_RPMSG_VIRTIO=m 874CONFIG_RPMSG_VIRTIO=m
875CONFIG_RASPBERRYPI_POWER=y
876CONFIG_QCOM_GSBI=y
877CONFIG_QCOM_PM=y
878CONFIG_QCOM_SMD_RPM=m
879CONFIG_QCOM_WCNSS_CTRL=m
880CONFIG_ROCKCHIP_PM_DOMAINS=y
881CONFIG_ARCH_TEGRA_2x_SOC=y
882CONFIG_ARCH_TEGRA_3x_SOC=y
883CONFIG_ARCH_TEGRA_114_SOC=y
884CONFIG_ARCH_TEGRA_124_SOC=y
934CONFIG_PM_DEVFREQ=y 885CONFIG_PM_DEVFREQ=y
935CONFIG_ARM_TEGRA_DEVFREQ=m 886CONFIG_ARM_TEGRA_DEVFREQ=m
936CONFIG_MEMORY=y
937CONFIG_EXTCON=y
938CONFIG_TI_AEMIF=y 887CONFIG_TI_AEMIF=y
939CONFIG_IIO=y 888CONFIG_IIO=y
940CONFIG_IIO_SW_TRIGGER=y 889CONFIG_IIO_SW_TRIGGER=y
@@ -947,56 +896,54 @@ CONFIG_VF610_ADC=m
947CONFIG_XILINX_XADC=y 896CONFIG_XILINX_XADC=y
948CONFIG_MPU3050_I2C=y 897CONFIG_MPU3050_I2C=y
949CONFIG_CM36651=m 898CONFIG_CM36651=m
899CONFIG_SENSORS_ISL29018=y
900CONFIG_SENSORS_ISL29028=y
950CONFIG_AK8975=y 901CONFIG_AK8975=y
951CONFIG_RASPBERRYPI_POWER=y
952CONFIG_IIO_HRTIMER_TRIGGER=y 902CONFIG_IIO_HRTIMER_TRIGGER=y
953CONFIG_PWM=y 903CONFIG_PWM=y
954CONFIG_PWM_ATMEL=m 904CONFIG_PWM_ATMEL=m
955CONFIG_PWM_ATMEL_HLCDC_PWM=m 905CONFIG_PWM_ATMEL_HLCDC_PWM=m
956CONFIG_PWM_ATMEL_TCB=m 906CONFIG_PWM_ATMEL_TCB=m
907CONFIG_PWM_BCM2835=y
908CONFIG_PWM_BRCMSTB=m
957CONFIG_PWM_FSL_FTM=m 909CONFIG_PWM_FSL_FTM=m
958CONFIG_PWM_MESON=m 910CONFIG_PWM_MESON=m
959CONFIG_PWM_RCAR=m 911CONFIG_PWM_RCAR=m
960CONFIG_PWM_RENESAS_TPU=y 912CONFIG_PWM_RENESAS_TPU=y
961CONFIG_PWM_ROCKCHIP=m 913CONFIG_PWM_ROCKCHIP=m
962CONFIG_PWM_SAMSUNG=m 914CONFIG_PWM_SAMSUNG=m
915CONFIG_PWM_STI=y
963CONFIG_PWM_SUN4I=y 916CONFIG_PWM_SUN4I=y
964CONFIG_PWM_TEGRA=y 917CONFIG_PWM_TEGRA=y
965CONFIG_PWM_VT8500=y 918CONFIG_PWM_VT8500=y
919CONFIG_KEYSTONE_IRQ=y
920CONFIG_PHY_SUN4I_USB=y
921CONFIG_PHY_SUN9I_USB=y
966CONFIG_PHY_HIX5HD2_SATA=y 922CONFIG_PHY_HIX5HD2_SATA=y
967CONFIG_E1000E=y 923CONFIG_PHY_BERLIN_SATA=y
968CONFIG_PWM_STI=y
969CONFIG_PWM_BCM2835=y
970CONFIG_PWM_BRCMSTB=m
971CONFIG_PHY_DM816X_USB=m
972CONFIG_OMAP_USB2=y
973CONFIG_TI_PIPE3=y
974CONFIG_TWL4030_USB=m
975CONFIG_PHY_BERLIN_USB=y 924CONFIG_PHY_BERLIN_USB=y
976CONFIG_PHY_CPCAP_USB=m 925CONFIG_PHY_CPCAP_USB=m
977CONFIG_PHY_BERLIN_SATA=y 926CONFIG_PHY_QCOM_APQ8064_SATA=m
927CONFIG_PHY_RCAR_GEN2=m
978CONFIG_PHY_ROCKCHIP_DP=m 928CONFIG_PHY_ROCKCHIP_DP=m
979CONFIG_PHY_ROCKCHIP_USB=y 929CONFIG_PHY_ROCKCHIP_USB=y
980CONFIG_PHY_QCOM_APQ8064_SATA=m 930CONFIG_PHY_SAMSUNG_USB2=m
981CONFIG_PHY_MIPHY28LP=y 931CONFIG_PHY_MIPHY28LP=y
982CONFIG_PHY_RCAR_GEN2=m
983CONFIG_PHY_STIH407_USB=y 932CONFIG_PHY_STIH407_USB=y
984CONFIG_PHY_STM32_USBPHYC=y 933CONFIG_PHY_STM32_USBPHYC=y
985CONFIG_PHY_SUN4I_USB=y
986CONFIG_PHY_SUN9I_USB=y
987CONFIG_PHY_SAMSUNG_USB2=m
988CONFIG_PHY_TEGRA_XUSB=y 934CONFIG_PHY_TEGRA_XUSB=y
989CONFIG_PHY_BRCM_SATA=y 935CONFIG_PHY_DM816X_USB=m
990CONFIG_NVMEM=y 936CONFIG_OMAP_USB2=y
937CONFIG_TI_PIPE3=y
938CONFIG_TWL4030_USB=m
991CONFIG_NVMEM_IMX_OCOTP=y 939CONFIG_NVMEM_IMX_OCOTP=y
992CONFIG_NVMEM_SUNXI_SID=y 940CONFIG_NVMEM_SUNXI_SID=y
993CONFIG_NVMEM_VF610_OCOTP=y 941CONFIG_NVMEM_VF610_OCOTP=y
994CONFIG_BCM2835_MBOX=y
995CONFIG_RASPBERRYPI_FIRMWARE=y 942CONFIG_RASPBERRYPI_FIRMWARE=y
996CONFIG_EFI_VARS=m
997CONFIG_EFI_CAPSULE_LOADER=m
998CONFIG_BCM47XX_NVRAM=y 943CONFIG_BCM47XX_NVRAM=y
999CONFIG_BCM47XX_SPROM=y 944CONFIG_BCM47XX_SPROM=y
945CONFIG_EFI_VARS=m
946CONFIG_EFI_CAPSULE_LOADER=m
1000CONFIG_EXT4_FS=y 947CONFIG_EXT4_FS=y
1001CONFIG_AUTOFS4_FS=y 948CONFIG_AUTOFS4_FS=y
1002CONFIG_MSDOS_FS=y 949CONFIG_MSDOS_FS=y
@@ -1004,7 +951,6 @@ CONFIG_VFAT_FS=y
1004CONFIG_NTFS_FS=y 951CONFIG_NTFS_FS=y
1005CONFIG_TMPFS_POSIX_ACL=y 952CONFIG_TMPFS_POSIX_ACL=y
1006CONFIG_UBIFS_FS=y 953CONFIG_UBIFS_FS=y
1007CONFIG_TMPFS=y
1008CONFIG_SQUASHFS=y 954CONFIG_SQUASHFS=y
1009CONFIG_SQUASHFS_LZO=y 955CONFIG_SQUASHFS_LZO=y
1010CONFIG_SQUASHFS_XZ=y 956CONFIG_SQUASHFS_XZ=y
@@ -1020,13 +966,7 @@ CONFIG_NLS_CODEPAGE_437=y
1020CONFIG_NLS_ISO8859_1=y 966CONFIG_NLS_ISO8859_1=y
1021CONFIG_NLS_UTF8=y 967CONFIG_NLS_UTF8=y
1022CONFIG_PRINTK_TIME=y 968CONFIG_PRINTK_TIME=y
1023CONFIG_DEBUG_FS=y
1024CONFIG_MAGIC_SYSRQ=y 969CONFIG_MAGIC_SYSRQ=y
1025CONFIG_LOCKUP_DETECTOR=y
1026CONFIG_CPUFREQ_DT=y
1027CONFIG_KEYSTONE_IRQ=y
1028CONFIG_HW_RANDOM=y
1029CONFIG_HW_RANDOM_ST=y
1030CONFIG_CRYPTO_USER=m 970CONFIG_CRYPTO_USER=m
1031CONFIG_CRYPTO_USER_API_HASH=m 971CONFIG_CRYPTO_USER_API_HASH=m
1032CONFIG_CRYPTO_USER_API_SKCIPHER=m 972CONFIG_CRYPTO_USER_API_SKCIPHER=m
@@ -1035,27 +975,19 @@ CONFIG_CRYPTO_USER_API_AEAD=m
1035CONFIG_CRYPTO_DEV_MARVELL_CESA=m 975CONFIG_CRYPTO_DEV_MARVELL_CESA=m
1036CONFIG_CRYPTO_DEV_EXYNOS_RNG=m 976CONFIG_CRYPTO_DEV_EXYNOS_RNG=m
1037CONFIG_CRYPTO_DEV_S5P=m 977CONFIG_CRYPTO_DEV_S5P=m
978CONFIG_CRYPTO_DEV_ATMEL_AES=m
979CONFIG_CRYPTO_DEV_ATMEL_TDES=m
980CONFIG_CRYPTO_DEV_ATMEL_SHA=m
1038CONFIG_CRYPTO_DEV_SUN4I_SS=m 981CONFIG_CRYPTO_DEV_SUN4I_SS=m
1039CONFIG_CRYPTO_DEV_ROCKCHIP=m 982CONFIG_CRYPTO_DEV_ROCKCHIP=m
1040CONFIG_ARM_CRYPTO=y 983CONFIG_ARM_CRYPTO=y
1041CONFIG_CRYPTO_SHA1_ARM=m
1042CONFIG_CRYPTO_SHA1_ARM_NEON=m 984CONFIG_CRYPTO_SHA1_ARM_NEON=m
1043CONFIG_CRYPTO_SHA1_ARM_CE=m 985CONFIG_CRYPTO_SHA1_ARM_CE=m
1044CONFIG_CRYPTO_SHA2_ARM_CE=m 986CONFIG_CRYPTO_SHA2_ARM_CE=m
1045CONFIG_CRYPTO_SHA256_ARM=m
1046CONFIG_CRYPTO_SHA512_ARM=m 987CONFIG_CRYPTO_SHA512_ARM=m
1047CONFIG_CRYPTO_AES_ARM=m 988CONFIG_CRYPTO_AES_ARM=m
1048CONFIG_CRYPTO_AES_ARM_BS=m 989CONFIG_CRYPTO_AES_ARM_BS=m
1049CONFIG_CRYPTO_AES_ARM_CE=m 990CONFIG_CRYPTO_AES_ARM_CE=m
1050CONFIG_CRYPTO_CHACHA20_NEON=m
1051CONFIG_CRYPTO_CRC32_ARM_CE=m
1052CONFIG_CRYPTO_CRCT10DIF_ARM_CE=m
1053CONFIG_CRYPTO_GHASH_ARM_CE=m 991CONFIG_CRYPTO_GHASH_ARM_CE=m
1054CONFIG_CRYPTO_DEV_ATMEL_AES=m 992CONFIG_CRYPTO_CRC32_ARM_CE=m
1055CONFIG_CRYPTO_DEV_ATMEL_TDES=m 993CONFIG_CRYPTO_CHACHA20_NEON=m
1056CONFIG_CRYPTO_DEV_ATMEL_SHA=m
1057CONFIG_VIDEO_VIVID=m
1058CONFIG_VIRTIO=y
1059CONFIG_VIRTIO_PCI=y
1060CONFIG_VIRTIO_PCI_LEGACY=y
1061CONFIG_VIRTIO_MMIO=y
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index f09e9d66d605..dec130e7078c 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -544,7 +544,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
544 * Increment event counter and perform fixup for the pre-signal 544 * Increment event counter and perform fixup for the pre-signal
545 * frame. 545 * frame.
546 */ 546 */
547 rseq_signal_deliver(regs); 547 rseq_signal_deliver(ksig, regs);
548 548
549 /* 549 /*
550 * Set up the stack frame 550 * Set up the stack frame
@@ -666,7 +666,7 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
666 } else { 666 } else {
667 clear_thread_flag(TIF_NOTIFY_RESUME); 667 clear_thread_flag(TIF_NOTIFY_RESUME);
668 tracehook_notify_resume(regs); 668 tracehook_notify_resume(regs);
669 rseq_handle_notify_resume(regs); 669 rseq_handle_notify_resume(NULL, regs);
670 } 670 }
671 } 671 }
672 local_irq_disable(); 672 local_irq_disable();
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index c46a728df44e..25aac6ee2ab1 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -20,6 +20,7 @@ config ARCH_BCM_IPROC
20 select GPIOLIB 20 select GPIOLIB
21 select ARM_AMBA 21 select ARM_AMBA
22 select PINCTRL 22 select PINCTRL
23 select PCI_DOMAINS if PCI
23 help 24 help
24 This enables support for systems based on Broadcom IPROC architected SoCs. 25 This enables support for systems based on Broadcom IPROC architected SoCs.
25 The IPROC complex contains one or more ARM CPUs along with common 26 The IPROC complex contains one or more ARM CPUs along with common
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index e22fb40e34bc..6d5beb11bd96 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -774,7 +774,7 @@ static struct gpiod_lookup_table mmc_gpios_table = {
774 GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_CD_PIN, "cd", 774 GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_CD_PIN, "cd",
775 GPIO_ACTIVE_LOW), 775 GPIO_ACTIVE_LOW),
776 GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp", 776 GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp",
777 GPIO_ACTIVE_LOW), 777 GPIO_ACTIVE_HIGH),
778 }, 778 },
779}; 779};
780 780
diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index d0f62eacf59d..4adb901dd5eb 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -10,6 +10,7 @@ menuconfig ARCH_SOCFPGA
10 select HAVE_ARM_SCU 10 select HAVE_ARM_SCU
11 select HAVE_ARM_TWD if SMP 11 select HAVE_ARM_TWD if SMP
12 select MFD_SYSCON 12 select MFD_SYSCON
13 select PCI_DOMAINS if PCI
13 14
14if ARCH_SOCFPGA 15if ARCH_SOCFPGA
15config SOCFPGA_SUSPEND 16config SOCFPGA_SUSPEND
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 8073625371f5..07060e5b5864 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -59,6 +59,9 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
59 59
60static __read_mostly unsigned int xen_events_irq; 60static __read_mostly unsigned int xen_events_irq;
61 61
62uint32_t xen_start_flags;
63EXPORT_SYMBOL(xen_start_flags);
64
62int xen_remap_domain_gfn_array(struct vm_area_struct *vma, 65int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
63 unsigned long addr, 66 unsigned long addr,
64 xen_pfn_t *gfn, int nr, 67 xen_pfn_t *gfn, int nr,
@@ -293,9 +296,7 @@ void __init xen_early_init(void)
293 xen_setup_features(); 296 xen_setup_features();
294 297
295 if (xen_feature(XENFEAT_dom0)) 298 if (xen_feature(XENFEAT_dom0))
296 xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED; 299 xen_start_flags |= SIF_INITDOMAIN|SIF_PRIVILEGED;
297 else
298 xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED);
299 300
300 if (!console_set_on_cmdline && !xen_initial_domain()) 301 if (!console_set_on_cmdline && !xen_initial_domain())
301 add_preferred_console("hvc", 0, NULL); 302 add_preferred_console("hvc", 0, NULL);
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
index e6b059378dc0..67dac595dc72 100644
--- a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -309,8 +309,7 @@
309 interrupts = <0 99 4>; 309 interrupts = <0 99 4>;
310 resets = <&rst SPIM0_RESET>; 310 resets = <&rst SPIM0_RESET>;
311 reg-io-width = <4>; 311 reg-io-width = <4>;
312 num-chipselect = <4>; 312 num-cs = <4>;
313 bus-num = <0>;
314 status = "disabled"; 313 status = "disabled";
315 }; 314 };
316 315
@@ -322,8 +321,7 @@
322 interrupts = <0 100 4>; 321 interrupts = <0 100 4>;
323 resets = <&rst SPIM1_RESET>; 322 resets = <&rst SPIM1_RESET>;
324 reg-io-width = <4>; 323 reg-io-width = <4>;
325 num-chipselect = <4>; 324 num-cs = <4>;
326 bus-num = <0>;
327 status = "disabled"; 325 status = "disabled";
328 }; 326 };
329 327
diff --git a/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts b/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
index 4b3331fbfe39..dff9b15eb3c0 100644
--- a/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
@@ -66,9 +66,22 @@
66 66
67&ethmac { 67&ethmac {
68 status = "okay"; 68 status = "okay";
69 phy-mode = "rgmii";
70 pinctrl-0 = <&eth_rgmii_y_pins>; 69 pinctrl-0 = <&eth_rgmii_y_pins>;
71 pinctrl-names = "default"; 70 pinctrl-names = "default";
71 phy-handle = <&eth_phy0>;
72 phy-mode = "rgmii";
73
74 mdio {
75 compatible = "snps,dwmac-mdio";
76 #address-cells = <1>;
77 #size-cells = <0>;
78
79 eth_phy0: ethernet-phy@0 {
80 /* Realtek RTL8211F (0x001cc916) */
81 reg = <0>;
82 eee-broken-1000t;
83 };
84 };
72}; 85};
73 86
74&uart_A { 87&uart_A {
diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
index fee87737a201..67d7115e4eff 100644
--- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
@@ -132,7 +132,7 @@
132 132
133 sd_emmc_b: sd@5000 { 133 sd_emmc_b: sd@5000 {
134 compatible = "amlogic,meson-axg-mmc"; 134 compatible = "amlogic,meson-axg-mmc";
135 reg = <0x0 0x5000 0x0 0x2000>; 135 reg = <0x0 0x5000 0x0 0x800>;
136 interrupts = <GIC_SPI 217 IRQ_TYPE_EDGE_RISING>; 136 interrupts = <GIC_SPI 217 IRQ_TYPE_EDGE_RISING>;
137 status = "disabled"; 137 status = "disabled";
138 clocks = <&clkc CLKID_SD_EMMC_B>, 138 clocks = <&clkc CLKID_SD_EMMC_B>,
@@ -144,7 +144,7 @@
144 144
145 sd_emmc_c: mmc@7000 { 145 sd_emmc_c: mmc@7000 {
146 compatible = "amlogic,meson-axg-mmc"; 146 compatible = "amlogic,meson-axg-mmc";
147 reg = <0x0 0x7000 0x0 0x2000>; 147 reg = <0x0 0x7000 0x0 0x800>;
148 interrupts = <GIC_SPI 218 IRQ_TYPE_EDGE_RISING>; 148 interrupts = <GIC_SPI 218 IRQ_TYPE_EDGE_RISING>;
149 status = "disabled"; 149 status = "disabled";
150 clocks = <&clkc CLKID_SD_EMMC_C>, 150 clocks = <&clkc CLKID_SD_EMMC_C>,
diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
index 3c31e21cbed7..b8dc4dbb391b 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
@@ -35,6 +35,12 @@
35 no-map; 35 no-map;
36 }; 36 };
37 37
38 /* Alternate 3 MiB reserved for ARM Trusted Firmware (BL31) */
39 secmon_reserved_alt: secmon@5000000 {
40 reg = <0x0 0x05000000 0x0 0x300000>;
41 no-map;
42 };
43
38 linux,cma { 44 linux,cma {
39 compatible = "shared-dma-pool"; 45 compatible = "shared-dma-pool";
40 reusable; 46 reusable;
@@ -457,21 +463,21 @@
457 463
458 sd_emmc_a: mmc@70000 { 464 sd_emmc_a: mmc@70000 {
459 compatible = "amlogic,meson-gx-mmc", "amlogic,meson-gxbb-mmc"; 465 compatible = "amlogic,meson-gx-mmc", "amlogic,meson-gxbb-mmc";
460 reg = <0x0 0x70000 0x0 0x2000>; 466 reg = <0x0 0x70000 0x0 0x800>;
461 interrupts = <GIC_SPI 216 IRQ_TYPE_EDGE_RISING>; 467 interrupts = <GIC_SPI 216 IRQ_TYPE_EDGE_RISING>;
462 status = "disabled"; 468 status = "disabled";
463 }; 469 };
464 470
465 sd_emmc_b: mmc@72000 { 471 sd_emmc_b: mmc@72000 {
466 compatible = "amlogic,meson-gx-mmc", "amlogic,meson-gxbb-mmc"; 472 compatible = "amlogic,meson-gx-mmc", "amlogic,meson-gxbb-mmc";
467 reg = <0x0 0x72000 0x0 0x2000>; 473 reg = <0x0 0x72000 0x0 0x800>;
468 interrupts = <GIC_SPI 217 IRQ_TYPE_EDGE_RISING>; 474 interrupts = <GIC_SPI 217 IRQ_TYPE_EDGE_RISING>;
469 status = "disabled"; 475 status = "disabled";
470 }; 476 };
471 477
472 sd_emmc_c: mmc@74000 { 478 sd_emmc_c: mmc@74000 {
473 compatible = "amlogic,meson-gx-mmc", "amlogic,meson-gxbb-mmc"; 479 compatible = "amlogic,meson-gx-mmc", "amlogic,meson-gxbb-mmc";
474 reg = <0x0 0x74000 0x0 0x2000>; 480 reg = <0x0 0x74000 0x0 0x800>;
475 interrupts = <GIC_SPI 218 IRQ_TYPE_EDGE_RISING>; 481 interrupts = <GIC_SPI 218 IRQ_TYPE_EDGE_RISING>;
476 status = "disabled"; 482 status = "disabled";
477 }; 483 };
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
index eb327664a4d8..6aaafff674f9 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-mali.dtsi
@@ -6,7 +6,7 @@
6 6
7&apb { 7&apb {
8 mali: gpu@c0000 { 8 mali: gpu@c0000 {
9 compatible = "amlogic,meson-gxbb-mali", "arm,mali-450"; 9 compatible = "amlogic,meson-gxl-mali", "arm,mali-450";
10 reg = <0x0 0xc0000 0x0 0x40000>; 10 reg = <0x0 0xc0000 0x0 0x40000>;
11 interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>, 11 interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
12 <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>, 12 <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
index 3e3eb31748a3..f63bceb88caa 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts
@@ -234,9 +234,6 @@
234 234
235 bus-width = <4>; 235 bus-width = <4>;
236 cap-sd-highspeed; 236 cap-sd-highspeed;
237 sd-uhs-sdr12;
238 sd-uhs-sdr25;
239 sd-uhs-sdr50;
240 max-frequency = <100000000>; 237 max-frequency = <100000000>;
241 disable-wp; 238 disable-wp;
242 239
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
index 0cfd701809de..a1b31013ab6e 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-p212.dtsi
@@ -189,3 +189,10 @@
189&usb0 { 189&usb0 {
190 status = "okay"; 190 status = "okay";
191}; 191};
192
193&usb2_phy0 {
194 /*
195 * HDMI_5V is also used as supply for the USB VBUS.
196 */
197 phy-supply = <&hdmi_5v>;
198};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
index 27538eea547b..c87a80e9bcc6 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
@@ -13,14 +13,6 @@
13/ { 13/ {
14 compatible = "amlogic,meson-gxl"; 14 compatible = "amlogic,meson-gxl";
15 15
16 reserved-memory {
17 /* Alternate 3 MiB reserved for ARM Trusted Firmware (BL31) */
18 secmon_reserved_alt: secmon@5000000 {
19 reg = <0x0 0x05000000 0x0 0x300000>;
20 no-map;
21 };
22 };
23
24 soc { 16 soc {
25 usb0: usb@c9000000 { 17 usb0: usb@c9000000 {
26 status = "disabled"; 18 status = "disabled";
diff --git a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
index 4a2a6af8e752..4057197048dc 100644
--- a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
@@ -118,7 +118,7 @@
118 118
119 #interrupt-cells = <1>; 119 #interrupt-cells = <1>;
120 interrupt-map-mask = <0 0 0 0>; 120 interrupt-map-mask = <0 0 0 0>;
121 interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_NONE>; 121 interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 281 IRQ_TYPE_LEVEL_HIGH>;
122 122
123 linux,pci-domain = <0>; 123 linux,pci-domain = <0>;
124 124
@@ -149,7 +149,7 @@
149 149
150 #interrupt-cells = <1>; 150 #interrupt-cells = <1>;
151 interrupt-map-mask = <0 0 0 0>; 151 interrupt-map-mask = <0 0 0 0>;
152 interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_NONE>; 152 interrupt-map = <0 0 0 0 &gic 0 GIC_SPI 305 IRQ_TYPE_LEVEL_HIGH>;
153 153
154 linux,pci-domain = <4>; 154 linux,pci-domain = <4>;
155 155
@@ -566,7 +566,7 @@
566 reg = <0x66080000 0x100>; 566 reg = <0x66080000 0x100>;
567 #address-cells = <1>; 567 #address-cells = <1>;
568 #size-cells = <0>; 568 #size-cells = <0>;
569 interrupts = <GIC_SPI 394 IRQ_TYPE_NONE>; 569 interrupts = <GIC_SPI 394 IRQ_TYPE_LEVEL_HIGH>;
570 clock-frequency = <100000>; 570 clock-frequency = <100000>;
571 status = "disabled"; 571 status = "disabled";
572 }; 572 };
@@ -594,7 +594,7 @@
594 reg = <0x660b0000 0x100>; 594 reg = <0x660b0000 0x100>;
595 #address-cells = <1>; 595 #address-cells = <1>;
596 #size-cells = <0>; 596 #size-cells = <0>;
597 interrupts = <GIC_SPI 395 IRQ_TYPE_NONE>; 597 interrupts = <GIC_SPI 395 IRQ_TYPE_LEVEL_HIGH>;
598 clock-frequency = <100000>; 598 clock-frequency = <100000>;
599 status = "disabled"; 599 status = "disabled";
600 }; 600 };
diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
index eb6f08cdbd79..77efa28c4dd5 100644
--- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
+++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742k.dts
@@ -43,6 +43,10 @@
43 enet-phy-lane-swap; 43 enet-phy-lane-swap;
44}; 44};
45 45
46&sdio0 {
47 mmc-ddr-1_8v;
48};
49
46&uart2 { 50&uart2 {
47 status = "okay"; 51 status = "okay";
48}; 52};
diff --git a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
index 5084b037320f..55ba495ef56e 100644
--- a/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
+++ b/arch/arm64/boot/dts/broadcom/stingray/bcm958742t.dts
@@ -42,3 +42,7 @@
42&gphy0 { 42&gphy0 {
43 enet-phy-lane-swap; 43 enet-phy-lane-swap;
44}; 44};
45
46&sdio0 {
47 mmc-ddr-1_8v;
48};
diff --git a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
index 99aaff0b6d72..b203152ad67c 100644
--- a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
+++ b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
@@ -409,7 +409,7 @@
409 reg = <0x000b0000 0x100>; 409 reg = <0x000b0000 0x100>;
410 #address-cells = <1>; 410 #address-cells = <1>;
411 #size-cells = <0>; 411 #size-cells = <0>;
412 interrupts = <GIC_SPI 177 IRQ_TYPE_NONE>; 412 interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
413 clock-frequency = <100000>; 413 clock-frequency = <100000>;
414 status = "disabled"; 414 status = "disabled";
415 }; 415 };
@@ -453,7 +453,7 @@
453 reg = <0x000e0000 0x100>; 453 reg = <0x000e0000 0x100>;
454 #address-cells = <1>; 454 #address-cells = <1>;
455 #size-cells = <0>; 455 #size-cells = <0>;
456 interrupts = <GIC_SPI 178 IRQ_TYPE_NONE>; 456 interrupts = <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>;
457 clock-frequency = <100000>; 457 clock-frequency = <100000>;
458 status = "disabled"; 458 status = "disabled";
459 }; 459 };
diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
index c6999624ed8a..68c5a6c819ae 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
@@ -585,6 +585,8 @@
585 vmmc-supply = <&wlan_en>; 585 vmmc-supply = <&wlan_en>;
586 ti,non-removable; 586 ti,non-removable;
587 non-removable; 587 non-removable;
588 cap-power-off-card;
589 keep-power-in-suspend;
588 #address-cells = <0x1>; 590 #address-cells = <0x1>;
589 #size-cells = <0x0>; 591 #size-cells = <0x0>;
590 status = "ok"; 592 status = "ok";
diff --git a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
index edb4ee0b8896..7f12624f6c8e 100644
--- a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
@@ -322,6 +322,8 @@
322 dwmmc_2: dwmmc2@f723f000 { 322 dwmmc_2: dwmmc2@f723f000 {
323 bus-width = <0x4>; 323 bus-width = <0x4>;
324 non-removable; 324 non-removable;
325 cap-power-off-card;
326 keep-power-in-suspend;
325 vmmc-supply = <&reg_vdd_3v3>; 327 vmmc-supply = <&reg_vdd_3v3>;
326 mmc-pwrseq = <&wl1835_pwrseq>; 328 mmc-pwrseq = <&wl1835_pwrseq>;
327 329
diff --git a/arch/arm64/boot/dts/marvell/armada-cp110.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
index 7dabe25f6774..1c6ff8197a88 100644
--- a/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
@@ -149,7 +149,7 @@
149 149
150 CP110_LABEL(icu): interrupt-controller@1e0000 { 150 CP110_LABEL(icu): interrupt-controller@1e0000 {
151 compatible = "marvell,cp110-icu"; 151 compatible = "marvell,cp110-icu";
152 reg = <0x1e0000 0x10>; 152 reg = <0x1e0000 0x440>;
153 #interrupt-cells = <3>; 153 #interrupt-cells = <3>;
154 interrupt-controller; 154 interrupt-controller;
155 msi-parent = <&gicp>; 155 msi-parent = <&gicp>;
diff --git a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
index 0f829db33efe..4d5ef01f43a3 100644
--- a/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
+++ b/arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
@@ -75,7 +75,7 @@
75 75
76 serial@75b1000 { 76 serial@75b1000 {
77 label = "LS-UART0"; 77 label = "LS-UART0";
78 status = "okay"; 78 status = "disabled";
79 pinctrl-names = "default", "sleep"; 79 pinctrl-names = "default", "sleep";
80 pinctrl-0 = <&blsp2_uart2_4pins_default>; 80 pinctrl-0 = <&blsp2_uart2_4pins_default>;
81 pinctrl-1 = <&blsp2_uart2_4pins_sleep>; 81 pinctrl-1 = <&blsp2_uart2_4pins_sleep>;
diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 650f356f69ca..c2625d15a8c0 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -1191,14 +1191,14 @@
1191 1191
1192 port@0 { 1192 port@0 {
1193 reg = <0>; 1193 reg = <0>;
1194 etf_out: endpoint { 1194 etf_in: endpoint {
1195 slave-mode; 1195 slave-mode;
1196 remote-endpoint = <&funnel0_out>; 1196 remote-endpoint = <&funnel0_out>;
1197 }; 1197 };
1198 }; 1198 };
1199 port@1 { 1199 port@1 {
1200 reg = <0>; 1200 reg = <0>;
1201 etf_in: endpoint { 1201 etf_out: endpoint {
1202 remote-endpoint = <&replicator_in>; 1202 remote-endpoint = <&replicator_in>;
1203 }; 1203 };
1204 }; 1204 };
diff --git a/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts b/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts
index 9b4dc41703e3..ae3b5adf32df 100644
--- a/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts
+++ b/arch/arm64/boot/dts/socionext/uniphier-ld11-global.dts
@@ -54,7 +54,7 @@
54 sound { 54 sound {
55 compatible = "audio-graph-card"; 55 compatible = "audio-graph-card";
56 label = "UniPhier LD11"; 56 label = "UniPhier LD11";
57 widgets = "Headphone", "Headphone Jack"; 57 widgets = "Headphone", "Headphones";
58 dais = <&i2s_port2 58 dais = <&i2s_port2
59 &i2s_port3 59 &i2s_port3
60 &i2s_port4 60 &i2s_port4
diff --git a/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts b/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts
index fe6608ea3277..7919233c9ce2 100644
--- a/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts
+++ b/arch/arm64/boot/dts/socionext/uniphier-ld20-global.dts
@@ -54,7 +54,7 @@
54 sound { 54 sound {
55 compatible = "audio-graph-card"; 55 compatible = "audio-graph-card";
56 label = "UniPhier LD20"; 56 label = "UniPhier LD20";
57 widgets = "Headphone", "Headphone Jack"; 57 widgets = "Headphone", "Headphones";
58 dais = <&i2s_port2 58 dais = <&i2s_port2
59 &i2s_port3 59 &i2s_port3
60 &i2s_port4 60 &i2s_port4
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 3cfa8ca26738..f9a186f6af8a 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -47,6 +47,7 @@ CONFIG_ARCH_MVEBU=y
47CONFIG_ARCH_QCOM=y 47CONFIG_ARCH_QCOM=y
48CONFIG_ARCH_ROCKCHIP=y 48CONFIG_ARCH_ROCKCHIP=y
49CONFIG_ARCH_SEATTLE=y 49CONFIG_ARCH_SEATTLE=y
50CONFIG_ARCH_SYNQUACER=y
50CONFIG_ARCH_RENESAS=y 51CONFIG_ARCH_RENESAS=y
51CONFIG_ARCH_R8A7795=y 52CONFIG_ARCH_R8A7795=y
52CONFIG_ARCH_R8A7796=y 53CONFIG_ARCH_R8A7796=y
@@ -58,7 +59,6 @@ CONFIG_ARCH_R8A77995=y
58CONFIG_ARCH_STRATIX10=y 59CONFIG_ARCH_STRATIX10=y
59CONFIG_ARCH_TEGRA=y 60CONFIG_ARCH_TEGRA=y
60CONFIG_ARCH_SPRD=y 61CONFIG_ARCH_SPRD=y
61CONFIG_ARCH_SYNQUACER=y
62CONFIG_ARCH_THUNDER=y 62CONFIG_ARCH_THUNDER=y
63CONFIG_ARCH_THUNDER2=y 63CONFIG_ARCH_THUNDER2=y
64CONFIG_ARCH_UNIPHIER=y 64CONFIG_ARCH_UNIPHIER=y
@@ -67,25 +67,23 @@ CONFIG_ARCH_XGENE=y
67CONFIG_ARCH_ZX=y 67CONFIG_ARCH_ZX=y
68CONFIG_ARCH_ZYNQMP=y 68CONFIG_ARCH_ZYNQMP=y
69CONFIG_PCI=y 69CONFIG_PCI=y
70CONFIG_HOTPLUG_PCI_PCIE=y
71CONFIG_PCI_IOV=y 70CONFIG_PCI_IOV=y
72CONFIG_HOTPLUG_PCI=y 71CONFIG_HOTPLUG_PCI=y
73CONFIG_HOTPLUG_PCI_ACPI=y 72CONFIG_HOTPLUG_PCI_ACPI=y
74CONFIG_PCI_LAYERSCAPE=y
75CONFIG_PCI_HISI=y
76CONFIG_PCIE_QCOM=y
77CONFIG_PCIE_KIRIN=y
78CONFIG_PCIE_ARMADA_8K=y
79CONFIG_PCIE_HISI_STB=y
80CONFIG_PCI_AARDVARK=y 73CONFIG_PCI_AARDVARK=y
81CONFIG_PCI_TEGRA=y 74CONFIG_PCI_TEGRA=y
82CONFIG_PCIE_RCAR=y 75CONFIG_PCIE_RCAR=y
83CONFIG_PCIE_ROCKCHIP=y
84CONFIG_PCIE_ROCKCHIP_HOST=m
85CONFIG_PCI_HOST_GENERIC=y 76CONFIG_PCI_HOST_GENERIC=y
86CONFIG_PCI_XGENE=y 77CONFIG_PCI_XGENE=y
87CONFIG_PCI_HOST_THUNDER_PEM=y 78CONFIG_PCI_HOST_THUNDER_PEM=y
88CONFIG_PCI_HOST_THUNDER_ECAM=y 79CONFIG_PCI_HOST_THUNDER_ECAM=y
80CONFIG_PCIE_ROCKCHIP_HOST=m
81CONFIG_PCI_LAYERSCAPE=y
82CONFIG_PCI_HISI=y
83CONFIG_PCIE_QCOM=y
84CONFIG_PCIE_ARMADA_8K=y
85CONFIG_PCIE_KIRIN=y
86CONFIG_PCIE_HISI_STB=y
89CONFIG_ARM64_VA_BITS_48=y 87CONFIG_ARM64_VA_BITS_48=y
90CONFIG_SCHED_MC=y 88CONFIG_SCHED_MC=y
91CONFIG_NUMA=y 89CONFIG_NUMA=y
@@ -104,8 +102,6 @@ CONFIG_HIBERNATION=y
104CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y 102CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y
105CONFIG_ARM_CPUIDLE=y 103CONFIG_ARM_CPUIDLE=y
106CONFIG_CPU_FREQ=y 104CONFIG_CPU_FREQ=y
107CONFIG_CPU_FREQ_GOV_ATTR_SET=y
108CONFIG_CPU_FREQ_GOV_COMMON=y
109CONFIG_CPU_FREQ_STAT=y 105CONFIG_CPU_FREQ_STAT=y
110CONFIG_CPU_FREQ_GOV_POWERSAVE=m 106CONFIG_CPU_FREQ_GOV_POWERSAVE=m
111CONFIG_CPU_FREQ_GOV_USERSPACE=y 107CONFIG_CPU_FREQ_GOV_USERSPACE=y
@@ -113,11 +109,11 @@ CONFIG_CPU_FREQ_GOV_ONDEMAND=y
113CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m 109CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
114CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y 110CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
115CONFIG_CPUFREQ_DT=y 111CONFIG_CPUFREQ_DT=y
112CONFIG_ACPI_CPPC_CPUFREQ=m
116CONFIG_ARM_ARMADA_37XX_CPUFREQ=y 113CONFIG_ARM_ARMADA_37XX_CPUFREQ=y
117CONFIG_ARM_BIG_LITTLE_CPUFREQ=y 114CONFIG_ARM_BIG_LITTLE_CPUFREQ=y
118CONFIG_ARM_SCPI_CPUFREQ=y 115CONFIG_ARM_SCPI_CPUFREQ=y
119CONFIG_ARM_TEGRA186_CPUFREQ=y 116CONFIG_ARM_TEGRA186_CPUFREQ=y
120CONFIG_ACPI_CPPC_CPUFREQ=m
121CONFIG_NET=y 117CONFIG_NET=y
122CONFIG_PACKET=y 118CONFIG_PACKET=y
123CONFIG_UNIX=y 119CONFIG_UNIX=y
@@ -236,11 +232,6 @@ CONFIG_SMSC911X=y
236CONFIG_SNI_AVE=y 232CONFIG_SNI_AVE=y
237CONFIG_SNI_NETSEC=y 233CONFIG_SNI_NETSEC=y
238CONFIG_STMMAC_ETH=m 234CONFIG_STMMAC_ETH=m
239CONFIG_DWMAC_IPQ806X=m
240CONFIG_DWMAC_MESON=m
241CONFIG_DWMAC_ROCKCHIP=m
242CONFIG_DWMAC_SUNXI=m
243CONFIG_DWMAC_SUN8I=m
244CONFIG_MDIO_BUS_MUX_MMIOREG=y 235CONFIG_MDIO_BUS_MUX_MMIOREG=y
245CONFIG_AT803X_PHY=m 236CONFIG_AT803X_PHY=m
246CONFIG_MARVELL_PHY=m 237CONFIG_MARVELL_PHY=m
@@ -269,8 +260,8 @@ CONFIG_WL18XX=m
269CONFIG_WLCORE_SDIO=m 260CONFIG_WLCORE_SDIO=m
270CONFIG_INPUT_EVDEV=y 261CONFIG_INPUT_EVDEV=y
271CONFIG_KEYBOARD_ADC=m 262CONFIG_KEYBOARD_ADC=m
272CONFIG_KEYBOARD_CROS_EC=y
273CONFIG_KEYBOARD_GPIO=y 263CONFIG_KEYBOARD_GPIO=y
264CONFIG_KEYBOARD_CROS_EC=y
274CONFIG_INPUT_TOUCHSCREEN=y 265CONFIG_INPUT_TOUCHSCREEN=y
275CONFIG_TOUCHSCREEN_ATMEL_MXT=m 266CONFIG_TOUCHSCREEN_ATMEL_MXT=m
276CONFIG_INPUT_MISC=y 267CONFIG_INPUT_MISC=y
@@ -296,17 +287,13 @@ CONFIG_SERIAL_SAMSUNG=y
296CONFIG_SERIAL_SAMSUNG_CONSOLE=y 287CONFIG_SERIAL_SAMSUNG_CONSOLE=y
297CONFIG_SERIAL_TEGRA=y 288CONFIG_SERIAL_TEGRA=y
298CONFIG_SERIAL_SH_SCI=y 289CONFIG_SERIAL_SH_SCI=y
299CONFIG_SERIAL_SH_SCI_NR_UARTS=11
300CONFIG_SERIAL_SH_SCI_CONSOLE=y
301CONFIG_SERIAL_MSM=y 290CONFIG_SERIAL_MSM=y
302CONFIG_SERIAL_MSM_CONSOLE=y 291CONFIG_SERIAL_MSM_CONSOLE=y
303CONFIG_SERIAL_XILINX_PS_UART=y 292CONFIG_SERIAL_XILINX_PS_UART=y
304CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y 293CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y
305CONFIG_SERIAL_MVEBU_UART=y 294CONFIG_SERIAL_MVEBU_UART=y
306CONFIG_SERIAL_DEV_BUS=y 295CONFIG_SERIAL_DEV_BUS=y
307CONFIG_SERIAL_DEV_CTRL_TTYPORT=y
308CONFIG_VIRTIO_CONSOLE=y 296CONFIG_VIRTIO_CONSOLE=y
309CONFIG_I2C_HID=m
310CONFIG_I2C_CHARDEV=y 297CONFIG_I2C_CHARDEV=y
311CONFIG_I2C_MUX=y 298CONFIG_I2C_MUX=y
312CONFIG_I2C_MUX_PCA954x=y 299CONFIG_I2C_MUX_PCA954x=y
@@ -325,26 +312,26 @@ CONFIG_I2C_RCAR=y
325CONFIG_I2C_CROS_EC_TUNNEL=y 312CONFIG_I2C_CROS_EC_TUNNEL=y
326CONFIG_SPI=y 313CONFIG_SPI=y
327CONFIG_SPI_ARMADA_3700=y 314CONFIG_SPI_ARMADA_3700=y
328CONFIG_SPI_MESON_SPICC=m
329CONFIG_SPI_MESON_SPIFC=m
330CONFIG_SPI_BCM2835=m 315CONFIG_SPI_BCM2835=m
331CONFIG_SPI_BCM2835AUX=m 316CONFIG_SPI_BCM2835AUX=m
317CONFIG_SPI_MESON_SPICC=m
318CONFIG_SPI_MESON_SPIFC=m
332CONFIG_SPI_ORION=y 319CONFIG_SPI_ORION=y
333CONFIG_SPI_PL022=y 320CONFIG_SPI_PL022=y
334CONFIG_SPI_QUP=y
335CONFIG_SPI_ROCKCHIP=y 321CONFIG_SPI_ROCKCHIP=y
322CONFIG_SPI_QUP=y
336CONFIG_SPI_S3C64XX=y 323CONFIG_SPI_S3C64XX=y
337CONFIG_SPI_SPIDEV=m 324CONFIG_SPI_SPIDEV=m
338CONFIG_SPMI=y 325CONFIG_SPMI=y
339CONFIG_PINCTRL_IPQ8074=y
340CONFIG_PINCTRL_SINGLE=y 326CONFIG_PINCTRL_SINGLE=y
341CONFIG_PINCTRL_MAX77620=y 327CONFIG_PINCTRL_MAX77620=y
328CONFIG_PINCTRL_IPQ8074=y
342CONFIG_PINCTRL_MSM8916=y 329CONFIG_PINCTRL_MSM8916=y
343CONFIG_PINCTRL_MSM8994=y 330CONFIG_PINCTRL_MSM8994=y
344CONFIG_PINCTRL_MSM8996=y 331CONFIG_PINCTRL_MSM8996=y
345CONFIG_PINCTRL_MT7622=y
346CONFIG_PINCTRL_QDF2XXX=y 332CONFIG_PINCTRL_QDF2XXX=y
347CONFIG_PINCTRL_QCOM_SPMI_PMIC=y 333CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
334CONFIG_PINCTRL_MT7622=y
348CONFIG_GPIO_DWAPB=y 335CONFIG_GPIO_DWAPB=y
349CONFIG_GPIO_MB86S7X=y 336CONFIG_GPIO_MB86S7X=y
350CONFIG_GPIO_PL061=y 337CONFIG_GPIO_PL061=y
@@ -368,13 +355,13 @@ CONFIG_SENSORS_INA2XX=m
368CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y 355CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y
369CONFIG_CPU_THERMAL=y 356CONFIG_CPU_THERMAL=y
370CONFIG_THERMAL_EMULATION=y 357CONFIG_THERMAL_EMULATION=y
358CONFIG_ROCKCHIP_THERMAL=m
359CONFIG_RCAR_GEN3_THERMAL=y
371CONFIG_ARMADA_THERMAL=y 360CONFIG_ARMADA_THERMAL=y
372CONFIG_BRCMSTB_THERMAL=m 361CONFIG_BRCMSTB_THERMAL=m
373CONFIG_EXYNOS_THERMAL=y 362CONFIG_EXYNOS_THERMAL=y
374CONFIG_RCAR_GEN3_THERMAL=y
375CONFIG_QCOM_TSENS=y
376CONFIG_ROCKCHIP_THERMAL=m
377CONFIG_TEGRA_BPMP_THERMAL=m 363CONFIG_TEGRA_BPMP_THERMAL=m
364CONFIG_QCOM_TSENS=y
378CONFIG_UNIPHIER_THERMAL=y 365CONFIG_UNIPHIER_THERMAL=y
379CONFIG_WATCHDOG=y 366CONFIG_WATCHDOG=y
380CONFIG_S3C2410_WATCHDOG=y 367CONFIG_S3C2410_WATCHDOG=y
@@ -395,9 +382,9 @@ CONFIG_MFD_MAX77620=y
395CONFIG_MFD_SPMI_PMIC=y 382CONFIG_MFD_SPMI_PMIC=y
396CONFIG_MFD_RK808=y 383CONFIG_MFD_RK808=y
397CONFIG_MFD_SEC_CORE=y 384CONFIG_MFD_SEC_CORE=y
385CONFIG_REGULATOR_FIXED_VOLTAGE=y
398CONFIG_REGULATOR_AXP20X=y 386CONFIG_REGULATOR_AXP20X=y
399CONFIG_REGULATOR_FAN53555=y 387CONFIG_REGULATOR_FAN53555=y
400CONFIG_REGULATOR_FIXED_VOLTAGE=y
401CONFIG_REGULATOR_GPIO=y 388CONFIG_REGULATOR_GPIO=y
402CONFIG_REGULATOR_HI6421V530=y 389CONFIG_REGULATOR_HI6421V530=y
403CONFIG_REGULATOR_HI655X=y 390CONFIG_REGULATOR_HI655X=y
@@ -407,16 +394,15 @@ CONFIG_REGULATOR_QCOM_SMD_RPM=y
407CONFIG_REGULATOR_QCOM_SPMI=y 394CONFIG_REGULATOR_QCOM_SPMI=y
408CONFIG_REGULATOR_RK808=y 395CONFIG_REGULATOR_RK808=y
409CONFIG_REGULATOR_S2MPS11=y 396CONFIG_REGULATOR_S2MPS11=y
397CONFIG_RC_CORE=m
398CONFIG_RC_DECODERS=y
399CONFIG_RC_DEVICES=y
400CONFIG_IR_MESON=m
410CONFIG_MEDIA_SUPPORT=m 401CONFIG_MEDIA_SUPPORT=m
411CONFIG_MEDIA_CAMERA_SUPPORT=y 402CONFIG_MEDIA_CAMERA_SUPPORT=y
412CONFIG_MEDIA_ANALOG_TV_SUPPORT=y 403CONFIG_MEDIA_ANALOG_TV_SUPPORT=y
413CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y 404CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y
414CONFIG_MEDIA_CONTROLLER=y 405CONFIG_MEDIA_CONTROLLER=y
415CONFIG_MEDIA_RC_SUPPORT=y
416CONFIG_RC_CORE=m
417CONFIG_RC_DEVICES=y
418CONFIG_RC_DECODERS=y
419CONFIG_IR_MESON=m
420CONFIG_VIDEO_V4L2_SUBDEV_API=y 406CONFIG_VIDEO_V4L2_SUBDEV_API=y
421# CONFIG_DVB_NET is not set 407# CONFIG_DVB_NET is not set
422CONFIG_V4L_MEM2MEM_DRIVERS=y 408CONFIG_V4L_MEM2MEM_DRIVERS=y
@@ -441,8 +427,7 @@ CONFIG_ROCKCHIP_DW_HDMI=y
441CONFIG_ROCKCHIP_DW_MIPI_DSI=y 427CONFIG_ROCKCHIP_DW_MIPI_DSI=y
442CONFIG_ROCKCHIP_INNO_HDMI=y 428CONFIG_ROCKCHIP_INNO_HDMI=y
443CONFIG_DRM_RCAR_DU=m 429CONFIG_DRM_RCAR_DU=m
444CONFIG_DRM_RCAR_LVDS=y 430CONFIG_DRM_RCAR_LVDS=m
445CONFIG_DRM_RCAR_VSP=y
446CONFIG_DRM_TEGRA=m 431CONFIG_DRM_TEGRA=m
447CONFIG_DRM_PANEL_SIMPLE=m 432CONFIG_DRM_PANEL_SIMPLE=m
448CONFIG_DRM_I2C_ADV7511=m 433CONFIG_DRM_I2C_ADV7511=m
@@ -455,7 +440,6 @@ CONFIG_FB_ARMCLCD=y
455CONFIG_BACKLIGHT_GENERIC=m 440CONFIG_BACKLIGHT_GENERIC=m
456CONFIG_BACKLIGHT_PWM=m 441CONFIG_BACKLIGHT_PWM=m
457CONFIG_BACKLIGHT_LP855X=m 442CONFIG_BACKLIGHT_LP855X=m
458CONFIG_FRAMEBUFFER_CONSOLE=y
459CONFIG_LOGO=y 443CONFIG_LOGO=y
460# CONFIG_LOGO_LINUX_MONO is not set 444# CONFIG_LOGO_LINUX_MONO is not set
461# CONFIG_LOGO_LINUX_VGA16 is not set 445# CONFIG_LOGO_LINUX_VGA16 is not set
@@ -468,6 +452,7 @@ CONFIG_SND_SOC_RCAR=m
468CONFIG_SND_SOC_AK4613=m 452CONFIG_SND_SOC_AK4613=m
469CONFIG_SND_SIMPLE_CARD=m 453CONFIG_SND_SIMPLE_CARD=m
470CONFIG_SND_AUDIO_GRAPH_CARD=m 454CONFIG_SND_AUDIO_GRAPH_CARD=m
455CONFIG_I2C_HID=m
471CONFIG_USB=y 456CONFIG_USB=y
472CONFIG_USB_OTG=y 457CONFIG_USB_OTG=y
473CONFIG_USB_XHCI_HCD=y 458CONFIG_USB_XHCI_HCD=y
@@ -501,12 +486,12 @@ CONFIG_MMC_BLOCK_MINORS=32
501CONFIG_MMC_ARMMMCI=y 486CONFIG_MMC_ARMMMCI=y
502CONFIG_MMC_SDHCI=y 487CONFIG_MMC_SDHCI=y
503CONFIG_MMC_SDHCI_ACPI=y 488CONFIG_MMC_SDHCI_ACPI=y
504CONFIG_MMC_SDHCI_F_SDH30=y
505CONFIG_MMC_SDHCI_PLTFM=y 489CONFIG_MMC_SDHCI_PLTFM=y
506CONFIG_MMC_SDHCI_OF_ARASAN=y 490CONFIG_MMC_SDHCI_OF_ARASAN=y
507CONFIG_MMC_SDHCI_OF_ESDHC=y 491CONFIG_MMC_SDHCI_OF_ESDHC=y
508CONFIG_MMC_SDHCI_CADENCE=y 492CONFIG_MMC_SDHCI_CADENCE=y
509CONFIG_MMC_SDHCI_TEGRA=y 493CONFIG_MMC_SDHCI_TEGRA=y
494CONFIG_MMC_SDHCI_F_SDH30=y
510CONFIG_MMC_MESON_GX=y 495CONFIG_MMC_MESON_GX=y
511CONFIG_MMC_SDHCI_MSM=y 496CONFIG_MMC_SDHCI_MSM=y
512CONFIG_MMC_SPI=y 497CONFIG_MMC_SPI=y
@@ -524,11 +509,11 @@ CONFIG_LEDS_CLASS=y
524CONFIG_LEDS_GPIO=y 509CONFIG_LEDS_GPIO=y
525CONFIG_LEDS_PWM=y 510CONFIG_LEDS_PWM=y
526CONFIG_LEDS_SYSCON=y 511CONFIG_LEDS_SYSCON=y
512CONFIG_LEDS_TRIGGER_DISK=y
527CONFIG_LEDS_TRIGGER_HEARTBEAT=y 513CONFIG_LEDS_TRIGGER_HEARTBEAT=y
528CONFIG_LEDS_TRIGGER_CPU=y 514CONFIG_LEDS_TRIGGER_CPU=y
529CONFIG_LEDS_TRIGGER_DEFAULT_ON=y 515CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
530CONFIG_LEDS_TRIGGER_PANIC=y 516CONFIG_LEDS_TRIGGER_PANIC=y
531CONFIG_LEDS_TRIGGER_DISK=y
532CONFIG_EDAC=y 517CONFIG_EDAC=y
533CONFIG_EDAC_GHES=y 518CONFIG_EDAC_GHES=y
534CONFIG_RTC_CLASS=y 519CONFIG_RTC_CLASS=y
@@ -537,13 +522,13 @@ CONFIG_RTC_DRV_RK808=m
537CONFIG_RTC_DRV_S5M=y 522CONFIG_RTC_DRV_S5M=y
538CONFIG_RTC_DRV_DS3232=y 523CONFIG_RTC_DRV_DS3232=y
539CONFIG_RTC_DRV_EFI=y 524CONFIG_RTC_DRV_EFI=y
525CONFIG_RTC_DRV_CROS_EC=y
540CONFIG_RTC_DRV_S3C=y 526CONFIG_RTC_DRV_S3C=y
541CONFIG_RTC_DRV_PL031=y 527CONFIG_RTC_DRV_PL031=y
542CONFIG_RTC_DRV_SUN6I=y 528CONFIG_RTC_DRV_SUN6I=y
543CONFIG_RTC_DRV_ARMADA38X=y 529CONFIG_RTC_DRV_ARMADA38X=y
544CONFIG_RTC_DRV_TEGRA=y 530CONFIG_RTC_DRV_TEGRA=y
545CONFIG_RTC_DRV_XGENE=y 531CONFIG_RTC_DRV_XGENE=y
546CONFIG_RTC_DRV_CROS_EC=y
547CONFIG_DMADEVICES=y 532CONFIG_DMADEVICES=y
548CONFIG_DMA_BCM2835=m 533CONFIG_DMA_BCM2835=m
549CONFIG_K3_DMA=y 534CONFIG_K3_DMA=y
@@ -579,7 +564,6 @@ CONFIG_HWSPINLOCK_QCOM=y
579CONFIG_ARM_MHU=y 564CONFIG_ARM_MHU=y
580CONFIG_PLATFORM_MHU=y 565CONFIG_PLATFORM_MHU=y
581CONFIG_BCM2835_MBOX=y 566CONFIG_BCM2835_MBOX=y
582CONFIG_HI6220_MBOX=y
583CONFIG_QCOM_APCS_IPC=y 567CONFIG_QCOM_APCS_IPC=y
584CONFIG_ROCKCHIP_IOMMU=y 568CONFIG_ROCKCHIP_IOMMU=y
585CONFIG_TEGRA_IOMMU_SMMU=y 569CONFIG_TEGRA_IOMMU_SMMU=y
@@ -602,7 +586,6 @@ CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
602CONFIG_EXTCON_USB_GPIO=y 586CONFIG_EXTCON_USB_GPIO=y
603CONFIG_EXTCON_USBC_CROS_EC=y 587CONFIG_EXTCON_USBC_CROS_EC=y
604CONFIG_MEMORY=y 588CONFIG_MEMORY=y
605CONFIG_TEGRA_MC=y
606CONFIG_IIO=y 589CONFIG_IIO=y
607CONFIG_EXYNOS_ADC=y 590CONFIG_EXYNOS_ADC=y
608CONFIG_ROCKCHIP_SARADC=m 591CONFIG_ROCKCHIP_SARADC=m
@@ -618,27 +601,27 @@ CONFIG_PWM_RCAR=m
618CONFIG_PWM_ROCKCHIP=y 601CONFIG_PWM_ROCKCHIP=y
619CONFIG_PWM_SAMSUNG=y 602CONFIG_PWM_SAMSUNG=y
620CONFIG_PWM_TEGRA=m 603CONFIG_PWM_TEGRA=m
604CONFIG_PHY_XGENE=y
605CONFIG_PHY_SUN4I_USB=y
606CONFIG_PHY_HI6220_USB=y
621CONFIG_PHY_HISTB_COMBPHY=y 607CONFIG_PHY_HISTB_COMBPHY=y
622CONFIG_PHY_HISI_INNO_USB2=y 608CONFIG_PHY_HISI_INNO_USB2=y
623CONFIG_PHY_RCAR_GEN3_USB2=y
624CONFIG_PHY_RCAR_GEN3_USB3=m
625CONFIG_PHY_HI6220_USB=y
626CONFIG_PHY_QCOM_USB_HS=y
627CONFIG_PHY_SUN4I_USB=y
628CONFIG_PHY_MVEBU_CP110_COMPHY=y 609CONFIG_PHY_MVEBU_CP110_COMPHY=y
629CONFIG_PHY_QCOM_QMP=m 610CONFIG_PHY_QCOM_QMP=m
630CONFIG_PHY_ROCKCHIP_INNO_USB2=y 611CONFIG_PHY_QCOM_USB_HS=y
612CONFIG_PHY_RCAR_GEN3_USB2=y
613CONFIG_PHY_RCAR_GEN3_USB3=m
631CONFIG_PHY_ROCKCHIP_EMMC=y 614CONFIG_PHY_ROCKCHIP_EMMC=y
615CONFIG_PHY_ROCKCHIP_INNO_USB2=y
632CONFIG_PHY_ROCKCHIP_PCIE=m 616CONFIG_PHY_ROCKCHIP_PCIE=m
633CONFIG_PHY_ROCKCHIP_TYPEC=y 617CONFIG_PHY_ROCKCHIP_TYPEC=y
634CONFIG_PHY_XGENE=y
635CONFIG_PHY_TEGRA_XUSB=y 618CONFIG_PHY_TEGRA_XUSB=y
636CONFIG_QCOM_L2_PMU=y 619CONFIG_QCOM_L2_PMU=y
637CONFIG_QCOM_L3_PMU=y 620CONFIG_QCOM_L3_PMU=y
638CONFIG_MESON_EFUSE=m
639CONFIG_QCOM_QFPROM=y 621CONFIG_QCOM_QFPROM=y
640CONFIG_ROCKCHIP_EFUSE=y 622CONFIG_ROCKCHIP_EFUSE=y
641CONFIG_UNIPHIER_EFUSE=y 623CONFIG_UNIPHIER_EFUSE=y
624CONFIG_MESON_EFUSE=m
642CONFIG_TEE=y 625CONFIG_TEE=y
643CONFIG_OPTEE=y 626CONFIG_OPTEE=y
644CONFIG_ARM_SCPI_PROTOCOL=y 627CONFIG_ARM_SCPI_PROTOCOL=y
@@ -647,7 +630,6 @@ CONFIG_EFI_CAPSULE_LOADER=y
647CONFIG_ACPI=y 630CONFIG_ACPI=y
648CONFIG_ACPI_APEI=y 631CONFIG_ACPI_APEI=y
649CONFIG_ACPI_APEI_GHES=y 632CONFIG_ACPI_APEI_GHES=y
650CONFIG_ACPI_APEI_PCIEAER=y
651CONFIG_ACPI_APEI_MEMORY_FAILURE=y 633CONFIG_ACPI_APEI_MEMORY_FAILURE=y
652CONFIG_ACPI_APEI_EINJ=y 634CONFIG_ACPI_APEI_EINJ=y
653CONFIG_EXT2_FS=y 635CONFIG_EXT2_FS=y
@@ -682,7 +664,6 @@ CONFIG_DEBUG_INFO=y
682CONFIG_DEBUG_FS=y 664CONFIG_DEBUG_FS=y
683CONFIG_MAGIC_SYSRQ=y 665CONFIG_MAGIC_SYSRQ=y
684CONFIG_DEBUG_KERNEL=y 666CONFIG_DEBUG_KERNEL=y
685CONFIG_LOCKUP_DETECTOR=y
686# CONFIG_SCHED_DEBUG is not set 667# CONFIG_SCHED_DEBUG is not set
687# CONFIG_DEBUG_PREEMPT is not set 668# CONFIG_DEBUG_PREEMPT is not set
688# CONFIG_FTRACE is not set 669# CONFIG_FTRACE is not set
@@ -691,20 +672,15 @@ CONFIG_SECURITY=y
691CONFIG_CRYPTO_ECHAINIV=y 672CONFIG_CRYPTO_ECHAINIV=y
692CONFIG_CRYPTO_ANSI_CPRNG=y 673CONFIG_CRYPTO_ANSI_CPRNG=y
693CONFIG_ARM64_CRYPTO=y 674CONFIG_ARM64_CRYPTO=y
694CONFIG_CRYPTO_SHA256_ARM64=m
695CONFIG_CRYPTO_SHA512_ARM64=m
696CONFIG_CRYPTO_SHA1_ARM64_CE=y 675CONFIG_CRYPTO_SHA1_ARM64_CE=y
697CONFIG_CRYPTO_SHA2_ARM64_CE=y 676CONFIG_CRYPTO_SHA2_ARM64_CE=y
677CONFIG_CRYPTO_SHA512_ARM64_CE=m
678CONFIG_CRYPTO_SHA3_ARM64=m
679CONFIG_CRYPTO_SM3_ARM64_CE=m
698CONFIG_CRYPTO_GHASH_ARM64_CE=y 680CONFIG_CRYPTO_GHASH_ARM64_CE=y
699CONFIG_CRYPTO_CRCT10DIF_ARM64_CE=m 681CONFIG_CRYPTO_CRCT10DIF_ARM64_CE=m
700CONFIG_CRYPTO_CRC32_ARM64_CE=m 682CONFIG_CRYPTO_CRC32_ARM64_CE=m
701CONFIG_CRYPTO_AES_ARM64=m
702CONFIG_CRYPTO_AES_ARM64_CE=m
703CONFIG_CRYPTO_AES_ARM64_CE_CCM=y 683CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
704CONFIG_CRYPTO_AES_ARM64_CE_BLK=y 684CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
705CONFIG_CRYPTO_AES_ARM64_NEON_BLK=m
706CONFIG_CRYPTO_CHACHA20_NEON=m 685CONFIG_CRYPTO_CHACHA20_NEON=m
707CONFIG_CRYPTO_AES_ARM64_BS=m 686CONFIG_CRYPTO_AES_ARM64_BS=m
708CONFIG_CRYPTO_SHA512_ARM64_CE=m
709CONFIG_CRYPTO_SHA3_ARM64=m
710CONFIG_CRYPTO_SM3_ARM64_CE=m
diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c
index 253188fb8cb0..e3e50950a863 100644
--- a/arch/arm64/crypto/aes-glue.c
+++ b/arch/arm64/crypto/aes-glue.c
@@ -223,8 +223,8 @@ static int ctr_encrypt(struct skcipher_request *req)
223 kernel_neon_begin(); 223 kernel_neon_begin();
224 aes_ctr_encrypt(walk.dst.virt.addr, walk.src.virt.addr, 224 aes_ctr_encrypt(walk.dst.virt.addr, walk.src.virt.addr,
225 (u8 *)ctx->key_enc, rounds, blocks, walk.iv); 225 (u8 *)ctx->key_enc, rounds, blocks, walk.iv);
226 err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE);
227 kernel_neon_end(); 226 kernel_neon_end();
227 err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE);
228 } 228 }
229 if (walk.nbytes) { 229 if (walk.nbytes) {
230 u8 __aligned(8) tail[AES_BLOCK_SIZE]; 230 u8 __aligned(8) tail[AES_BLOCK_SIZE];
diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
index a91933b1e2e6..4b650ec1d7dd 100644
--- a/arch/arm64/include/asm/alternative.h
+++ b/arch/arm64/include/asm/alternative.h
@@ -28,7 +28,12 @@ typedef void (*alternative_cb_t)(struct alt_instr *alt,
28 __le32 *origptr, __le32 *updptr, int nr_inst); 28 __le32 *origptr, __le32 *updptr, int nr_inst);
29 29
30void __init apply_alternatives_all(void); 30void __init apply_alternatives_all(void);
31void apply_alternatives(void *start, size_t length); 31
32#ifdef CONFIG_MODULES
33void apply_alternatives_module(void *start, size_t length);
34#else
35static inline void apply_alternatives_module(void *start, size_t length) { }
36#endif
32 37
33#define ALTINSTR_ENTRY(feature,cb) \ 38#define ALTINSTR_ENTRY(feature,cb) \
34 " .word 661b - .\n" /* label */ \ 39 " .word 661b - .\n" /* label */ \
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index fda9a8ca48be..fe8777b12f86 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -306,6 +306,7 @@ struct kvm_vcpu_arch {
306#define KVM_ARM64_FP_ENABLED (1 << 1) /* guest FP regs loaded */ 306#define KVM_ARM64_FP_ENABLED (1 << 1) /* guest FP regs loaded */
307#define KVM_ARM64_FP_HOST (1 << 2) /* host FP regs loaded */ 307#define KVM_ARM64_FP_HOST (1 << 2) /* host FP regs loaded */
308#define KVM_ARM64_HOST_SVE_IN_USE (1 << 3) /* backup for host TIF_SVE */ 308#define KVM_ARM64_HOST_SVE_IN_USE (1 << 3) /* backup for host TIF_SVE */
309#define KVM_ARM64_HOST_SVE_ENABLED (1 << 4) /* SVE enabled for EL0 */
309 310
310#define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs) 311#define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs)
311 312
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 9f82d6b53851..1bdeca8918a6 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -224,10 +224,8 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
224 * Only if the new pte is valid and kernel, otherwise TLB maintenance 224 * Only if the new pte is valid and kernel, otherwise TLB maintenance
225 * or update_mmu_cache() have the necessary barriers. 225 * or update_mmu_cache() have the necessary barriers.
226 */ 226 */
227 if (pte_valid_not_user(pte)) { 227 if (pte_valid_not_user(pte))
228 dsb(ishst); 228 dsb(ishst);
229 isb();
230 }
231} 229}
232 230
233extern void __sync_icache_dcache(pte_t pteval); 231extern void __sync_icache_dcache(pte_t pteval);
@@ -434,7 +432,6 @@ static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
434{ 432{
435 WRITE_ONCE(*pmdp, pmd); 433 WRITE_ONCE(*pmdp, pmd);
436 dsb(ishst); 434 dsb(ishst);
437 isb();
438} 435}
439 436
440static inline void pmd_clear(pmd_t *pmdp) 437static inline void pmd_clear(pmd_t *pmdp)
@@ -485,7 +482,6 @@ static inline void set_pud(pud_t *pudp, pud_t pud)
485{ 482{
486 WRITE_ONCE(*pudp, pud); 483 WRITE_ONCE(*pudp, pud);
487 dsb(ishst); 484 dsb(ishst);
488 isb();
489} 485}
490 486
491static inline void pud_clear(pud_t *pudp) 487static inline void pud_clear(pud_t *pudp)
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index 6171178075dc..a8f84812c6e8 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -728,6 +728,17 @@ asm(
728 asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val)); \ 728 asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val)); \
729} while (0) 729} while (0)
730 730
731/*
732 * Modify bits in a sysreg. Bits in the clear mask are zeroed, then bits in the
733 * set mask are set. Other bits are left as-is.
734 */
735#define sysreg_clear_set(sysreg, clear, set) do { \
736 u64 __scs_val = read_sysreg(sysreg); \
737 u64 __scs_new = (__scs_val & ~(u64)(clear)) | (set); \
738 if (__scs_new != __scs_val) \
739 write_sysreg(__scs_new, sysreg); \
740} while (0)
741
731static inline void config_sctlr_el1(u32 clear, u32 set) 742static inline void config_sctlr_el1(u32 clear, u32 set)
732{ 743{
733 u32 val; 744 u32 val;
diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
index 5c4bce4ac381..36fb069fd049 100644
--- a/arch/arm64/kernel/alternative.c
+++ b/arch/arm64/kernel/alternative.c
@@ -122,7 +122,30 @@ static void patch_alternative(struct alt_instr *alt,
122 } 122 }
123} 123}
124 124
125static void __apply_alternatives(void *alt_region, bool use_linear_alias) 125/*
126 * We provide our own, private D-cache cleaning function so that we don't
127 * accidentally call into the cache.S code, which is patched by us at
128 * runtime.
129 */
130static void clean_dcache_range_nopatch(u64 start, u64 end)
131{
132 u64 cur, d_size, ctr_el0;
133
134 ctr_el0 = read_sanitised_ftr_reg(SYS_CTR_EL0);
135 d_size = 4 << cpuid_feature_extract_unsigned_field(ctr_el0,
136 CTR_DMINLINE_SHIFT);
137 cur = start & ~(d_size - 1);
138 do {
139 /*
140 * We must clean+invalidate to the PoC in order to avoid
141 * Cortex-A53 errata 826319, 827319, 824069 and 819472
142 * (this corresponds to ARM64_WORKAROUND_CLEAN_CACHE)
143 */
144 asm volatile("dc civac, %0" : : "r" (cur) : "memory");
145 } while (cur += d_size, cur < end);
146}
147
148static void __apply_alternatives(void *alt_region, bool is_module)
126{ 149{
127 struct alt_instr *alt; 150 struct alt_instr *alt;
128 struct alt_region *region = alt_region; 151 struct alt_region *region = alt_region;
@@ -145,7 +168,7 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias)
145 pr_info_once("patching kernel code\n"); 168 pr_info_once("patching kernel code\n");
146 169
147 origptr = ALT_ORIG_PTR(alt); 170 origptr = ALT_ORIG_PTR(alt);
148 updptr = use_linear_alias ? lm_alias(origptr) : origptr; 171 updptr = is_module ? origptr : lm_alias(origptr);
149 nr_inst = alt->orig_len / AARCH64_INSN_SIZE; 172 nr_inst = alt->orig_len / AARCH64_INSN_SIZE;
150 173
151 if (alt->cpufeature < ARM64_CB_PATCH) 174 if (alt->cpufeature < ARM64_CB_PATCH)
@@ -155,8 +178,20 @@ static void __apply_alternatives(void *alt_region, bool use_linear_alias)
155 178
156 alt_cb(alt, origptr, updptr, nr_inst); 179 alt_cb(alt, origptr, updptr, nr_inst);
157 180
158 flush_icache_range((uintptr_t)origptr, 181 if (!is_module) {
159 (uintptr_t)(origptr + nr_inst)); 182 clean_dcache_range_nopatch((u64)origptr,
183 (u64)(origptr + nr_inst));
184 }
185 }
186
187 /*
188 * The core module code takes care of cache maintenance in
189 * flush_module_icache().
190 */
191 if (!is_module) {
192 dsb(ish);
193 __flush_icache_all();
194 isb();
160 } 195 }
161} 196}
162 197
@@ -178,7 +213,7 @@ static int __apply_alternatives_multi_stop(void *unused)
178 isb(); 213 isb();
179 } else { 214 } else {
180 BUG_ON(alternatives_applied); 215 BUG_ON(alternatives_applied);
181 __apply_alternatives(&region, true); 216 __apply_alternatives(&region, false);
182 /* Barriers provided by the cache flushing */ 217 /* Barriers provided by the cache flushing */
183 WRITE_ONCE(alternatives_applied, 1); 218 WRITE_ONCE(alternatives_applied, 1);
184 } 219 }
@@ -192,12 +227,14 @@ void __init apply_alternatives_all(void)
192 stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask); 227 stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask);
193} 228}
194 229
195void apply_alternatives(void *start, size_t length) 230#ifdef CONFIG_MODULES
231void apply_alternatives_module(void *start, size_t length)
196{ 232{
197 struct alt_region region = { 233 struct alt_region region = {
198 .begin = start, 234 .begin = start,
199 .end = start + length, 235 .end = start + length,
200 }; 236 };
201 237
202 __apply_alternatives(&region, false); 238 __apply_alternatives(&region, true);
203} 239}
240#endif
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index d2856b129097..f24892a40d2c 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -937,7 +937,7 @@ static int __init parse_kpti(char *str)
937 __kpti_forced = enabled ? 1 : -1; 937 __kpti_forced = enabled ? 1 : -1;
938 return 0; 938 return 0;
939} 939}
940__setup("kpti=", parse_kpti); 940early_param("kpti", parse_kpti);
941#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ 941#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
942 942
943#ifdef CONFIG_ARM64_HW_AFDBM 943#ifdef CONFIG_ARM64_HW_AFDBM
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
index 155fd91e78f4..f0f27aeefb73 100644
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -448,9 +448,8 @@ int module_finalize(const Elf_Ehdr *hdr,
448 const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 448 const char *secstrs = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
449 449
450 for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) { 450 for (s = sechdrs, se = sechdrs + hdr->e_shnum; s < se; s++) {
451 if (strcmp(".altinstructions", secstrs + s->sh_name) == 0) { 451 if (strcmp(".altinstructions", secstrs + s->sh_name) == 0)
452 apply_alternatives((void *)s->sh_addr, s->sh_size); 452 apply_alternatives_module((void *)s->sh_addr, s->sh_size);
453 }
454#ifdef CONFIG_ARM64_MODULE_PLTS 453#ifdef CONFIG_ARM64_MODULE_PLTS
455 if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE) && 454 if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE) &&
456 !strcmp(".text.ftrace_trampoline", secstrs + s->sh_name)) 455 !strcmp(".text.ftrace_trampoline", secstrs + s->sh_name))
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index f3e2e3aec0b0..2faa9863d2e5 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -179,7 +179,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
179 * This is the secondary CPU boot entry. We're using this CPUs 179 * This is the secondary CPU boot entry. We're using this CPUs
180 * idle thread stack, but a set of temporary page tables. 180 * idle thread stack, but a set of temporary page tables.
181 */ 181 */
182asmlinkage void secondary_start_kernel(void) 182asmlinkage notrace void secondary_start_kernel(void)
183{ 183{
184 u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; 184 u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
185 struct mm_struct *mm = &init_mm; 185 struct mm_struct *mm = &init_mm;
diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c
index dc6ecfa5a2d2..aac7808ce216 100644
--- a/arch/arm64/kvm/fpsimd.c
+++ b/arch/arm64/kvm/fpsimd.c
@@ -5,13 +5,14 @@
5 * Copyright 2018 Arm Limited 5 * Copyright 2018 Arm Limited
6 * Author: Dave Martin <Dave.Martin@arm.com> 6 * Author: Dave Martin <Dave.Martin@arm.com>
7 */ 7 */
8#include <linux/bottom_half.h> 8#include <linux/irqflags.h>
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/thread_info.h> 10#include <linux/thread_info.h>
11#include <linux/kvm_host.h> 11#include <linux/kvm_host.h>
12#include <asm/kvm_asm.h> 12#include <asm/kvm_asm.h>
13#include <asm/kvm_host.h> 13#include <asm/kvm_host.h>
14#include <asm/kvm_mmu.h> 14#include <asm/kvm_mmu.h>
15#include <asm/sysreg.h>
15 16
16/* 17/*
17 * Called on entry to KVM_RUN unless this vcpu previously ran at least 18 * Called on entry to KVM_RUN unless this vcpu previously ran at least
@@ -61,10 +62,16 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu)
61{ 62{
62 BUG_ON(!current->mm); 63 BUG_ON(!current->mm);
63 64
64 vcpu->arch.flags &= ~(KVM_ARM64_FP_ENABLED | KVM_ARM64_HOST_SVE_IN_USE); 65 vcpu->arch.flags &= ~(KVM_ARM64_FP_ENABLED |
66 KVM_ARM64_HOST_SVE_IN_USE |
67 KVM_ARM64_HOST_SVE_ENABLED);
65 vcpu->arch.flags |= KVM_ARM64_FP_HOST; 68 vcpu->arch.flags |= KVM_ARM64_FP_HOST;
69
66 if (test_thread_flag(TIF_SVE)) 70 if (test_thread_flag(TIF_SVE))
67 vcpu->arch.flags |= KVM_ARM64_HOST_SVE_IN_USE; 71 vcpu->arch.flags |= KVM_ARM64_HOST_SVE_IN_USE;
72
73 if (read_sysreg(cpacr_el1) & CPACR_EL1_ZEN_EL0EN)
74 vcpu->arch.flags |= KVM_ARM64_HOST_SVE_ENABLED;
68} 75}
69 76
70/* 77/*
@@ -92,19 +99,30 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu)
92 */ 99 */
93void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu) 100void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
94{ 101{
95 local_bh_disable(); 102 unsigned long flags;
96 103
97 update_thread_flag(TIF_SVE, 104 local_irq_save(flags);
98 vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE);
99 105
100 if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) { 106 if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) {
101 /* Clean guest FP state to memory and invalidate cpu view */ 107 /* Clean guest FP state to memory and invalidate cpu view */
102 fpsimd_save(); 108 fpsimd_save();
103 fpsimd_flush_cpu_state(); 109 fpsimd_flush_cpu_state();
104 } else if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) { 110 } else if (system_supports_sve()) {
105 /* Ensure user trap controls are correctly restored */ 111 /*
106 fpsimd_bind_task_to_cpu(); 112 * The FPSIMD/SVE state in the CPU has not been touched, and we
113 * have SVE (and VHE): CPACR_EL1 (alias CPTR_EL2) has been
114 * reset to CPACR_EL1_DEFAULT by the Hyp code, disabling SVE
115 * for EL0. To avoid spurious traps, restore the trap state
116 * seen by kvm_arch_vcpu_load_fp():
117 */
118 if (vcpu->arch.flags & KVM_ARM64_HOST_SVE_ENABLED)
119 sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_ZEN_EL0EN);
120 else
121 sysreg_clear_set(CPACR_EL1, CPACR_EL1_ZEN_EL0EN, 0);
107 } 122 }
108 123
109 local_bh_enable(); 124 update_thread_flag(TIF_SVE,
125 vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE);
126
127 local_irq_restore(flags);
110} 128}
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 49e217ac7e1e..61e93f0b5482 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -583,13 +583,14 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size,
583 size >> PAGE_SHIFT); 583 size >> PAGE_SHIFT);
584 return NULL; 584 return NULL;
585 } 585 }
586 if (!coherent)
587 __dma_flush_area(page_to_virt(page), iosize);
588
589 addr = dma_common_contiguous_remap(page, size, VM_USERMAP, 586 addr = dma_common_contiguous_remap(page, size, VM_USERMAP,
590 prot, 587 prot,
591 __builtin_return_address(0)); 588 __builtin_return_address(0));
592 if (!addr) { 589 if (addr) {
590 memset(addr, 0, size);
591 if (!coherent)
592 __dma_flush_area(page_to_virt(page), iosize);
593 } else {
593 iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs); 594 iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs);
594 dma_release_from_contiguous(dev, page, 595 dma_release_from_contiguous(dev, page,
595 size >> PAGE_SHIFT); 596 size >> PAGE_SHIFT);
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 5f9a73a4452c..03646e6a2ef4 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -217,8 +217,9 @@ ENDPROC(idmap_cpu_replace_ttbr1)
217 217
218 .macro __idmap_kpti_put_pgtable_ent_ng, type 218 .macro __idmap_kpti_put_pgtable_ent_ng, type
219 orr \type, \type, #PTE_NG // Same bit for blocks and pages 219 orr \type, \type, #PTE_NG // Same bit for blocks and pages
220 str \type, [cur_\()\type\()p] // Update the entry and ensure it 220 str \type, [cur_\()\type\()p] // Update the entry and ensure
221 dc civac, cur_\()\type\()p // is visible to all CPUs. 221 dmb sy // that it is visible to all
222 dc civac, cur_\()\type\()p // CPUs.
222 .endm 223 .endm
223 224
224/* 225/*
diff --git a/arch/microblaze/Kconfig.debug b/arch/microblaze/Kconfig.debug
index 331a3bb66297..93a737c8d1a6 100644
--- a/arch/microblaze/Kconfig.debug
+++ b/arch/microblaze/Kconfig.debug
@@ -8,11 +8,4 @@ config TRACE_IRQFLAGS_SUPPORT
8 8
9source "lib/Kconfig.debug" 9source "lib/Kconfig.debug"
10 10
11config HEART_BEAT
12 bool "Heart beat function for kernel"
13 default n
14 help
15 This option turns on/off heart beat kernel functionality.
16 First GPIO node is taken.
17
18endmenu 11endmenu
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index d5384f6f36f7..ce9b7b786156 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -19,15 +19,10 @@ extern char cmd_line[COMMAND_LINE_SIZE];
19 19
20extern char *klimit; 20extern char *klimit;
21 21
22void microblaze_heartbeat(void);
23void microblaze_setup_heartbeat(void);
24
25# ifdef CONFIG_MMU 22# ifdef CONFIG_MMU
26extern void mmu_reset(void); 23extern void mmu_reset(void);
27# endif /* CONFIG_MMU */ 24# endif /* CONFIG_MMU */
28 25
29extern void of_platform_reset_gpio_probe(void);
30
31void time_init(void); 26void time_init(void);
32void init_IRQ(void); 27void init_IRQ(void);
33void machine_early_init(const char *cmdline, unsigned int ram, 28void machine_early_init(const char *cmdline, unsigned int ram,
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index 9774e1d9507b..a62d09420a47 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -38,6 +38,6 @@
38 38
39#endif /* __ASSEMBLY__ */ 39#endif /* __ASSEMBLY__ */
40 40
41#define __NR_syscalls 399 41#define __NR_syscalls 401
42 42
43#endif /* _ASM_MICROBLAZE_UNISTD_H */ 43#endif /* _ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/include/uapi/asm/unistd.h b/arch/microblaze/include/uapi/asm/unistd.h
index eb156f914793..7a9f16a76413 100644
--- a/arch/microblaze/include/uapi/asm/unistd.h
+++ b/arch/microblaze/include/uapi/asm/unistd.h
@@ -415,5 +415,7 @@
415#define __NR_pkey_alloc 396 415#define __NR_pkey_alloc 396
416#define __NR_pkey_free 397 416#define __NR_pkey_free 397
417#define __NR_statx 398 417#define __NR_statx 398
418#define __NR_io_pgetevents 399
419#define __NR_rseq 400
418 420
419#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */ 421#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile
index 7e99cf6984a1..dd71637437f4 100644
--- a/arch/microblaze/kernel/Makefile
+++ b/arch/microblaze/kernel/Makefile
@@ -8,7 +8,6 @@ ifdef CONFIG_FUNCTION_TRACER
8CFLAGS_REMOVE_timer.o = -pg 8CFLAGS_REMOVE_timer.o = -pg
9CFLAGS_REMOVE_intc.o = -pg 9CFLAGS_REMOVE_intc.o = -pg
10CFLAGS_REMOVE_early_printk.o = -pg 10CFLAGS_REMOVE_early_printk.o = -pg
11CFLAGS_REMOVE_heartbeat.o = -pg
12CFLAGS_REMOVE_ftrace.o = -pg 11CFLAGS_REMOVE_ftrace.o = -pg
13CFLAGS_REMOVE_process.o = -pg 12CFLAGS_REMOVE_process.o = -pg
14endif 13endif
@@ -17,12 +16,11 @@ extra-y := head.o vmlinux.lds
17 16
18obj-y += dma.o exceptions.o \ 17obj-y += dma.o exceptions.o \
19 hw_exception_handler.o irq.o \ 18 hw_exception_handler.o irq.o \
20 platform.o process.o prom.o ptrace.o \ 19 process.o prom.o ptrace.o \
21 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o 20 reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
22 21
23obj-y += cpu/ 22obj-y += cpu/
24 23
25obj-$(CONFIG_HEART_BEAT) += heartbeat.o
26obj-$(CONFIG_MODULES) += microblaze_ksyms.o module.o 24obj-$(CONFIG_MODULES) += microblaze_ksyms.o module.o
27obj-$(CONFIG_MMU) += misc.o 25obj-$(CONFIG_MMU) += misc.o
28obj-$(CONFIG_STACKTRACE) += stacktrace.o 26obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/arch/microblaze/kernel/heartbeat.c b/arch/microblaze/kernel/heartbeat.c
deleted file mode 100644
index 2022130139d2..000000000000
--- a/arch/microblaze/kernel/heartbeat.c
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2007-2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/sched.h>
12#include <linux/sched/loadavg.h>
13#include <linux/io.h>
14
15#include <asm/setup.h>
16#include <asm/page.h>
17#include <asm/prom.h>
18
19static unsigned int base_addr;
20
21void microblaze_heartbeat(void)
22{
23 static unsigned int cnt, period, dist;
24
25 if (base_addr) {
26 if (cnt == 0 || cnt == dist)
27 out_be32(base_addr, 1);
28 else if (cnt == 7 || cnt == dist + 7)
29 out_be32(base_addr, 0);
30
31 if (++cnt > period) {
32 cnt = 0;
33 /*
34 * The hyperbolic function below modifies the heartbeat
35 * period length in dependency of the current (5min)
36 * load. It goes through the points f(0)=126, f(1)=86,
37 * f(5)=51, f(inf)->30.
38 */
39 period = ((672 << FSHIFT) / (5 * avenrun[0] +
40 (7 << FSHIFT))) + 30;
41 dist = period / 4;
42 }
43 }
44}
45
46void microblaze_setup_heartbeat(void)
47{
48 struct device_node *gpio = NULL;
49 int *prop;
50 int j;
51 const char * const gpio_list[] = {
52 "xlnx,xps-gpio-1.00.a",
53 NULL
54 };
55
56 for (j = 0; gpio_list[j] != NULL; j++) {
57 gpio = of_find_compatible_node(NULL, NULL, gpio_list[j]);
58 if (gpio)
59 break;
60 }
61
62 if (gpio) {
63 base_addr = be32_to_cpup(of_get_property(gpio, "reg", NULL));
64 base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE);
65 pr_notice("Heartbeat GPIO at 0x%x\n", base_addr);
66
67 /* GPIO is configured as output */
68 prop = (int *) of_get_property(gpio, "xlnx,is-bidir", NULL);
69 if (prop)
70 out_be32(base_addr + 4, 0);
71 }
72}
diff --git a/arch/microblaze/kernel/platform.c b/arch/microblaze/kernel/platform.c
deleted file mode 100644
index 2540d60610d9..000000000000
--- a/arch/microblaze/kernel/platform.c
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright 2008 Michal Simek <monstr@monstr.eu>
3 *
4 * based on virtex.c file
5 *
6 * Copyright 2007 Secret Lab Technologies Ltd.
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 */
12
13#include <linux/init.h>
14#include <linux/of_platform.h>
15#include <asm/setup.h>
16
17static struct of_device_id xilinx_of_bus_ids[] __initdata = {
18 { .compatible = "simple-bus", },
19 { .compatible = "xlnx,compound", },
20 {}
21};
22
23static int __init microblaze_device_probe(void)
24{
25 of_platform_bus_probe(NULL, xilinx_of_bus_ids, NULL);
26 of_platform_reset_gpio_probe();
27 return 0;
28}
29device_initcall(microblaze_device_probe);
diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c
index bab4c8330ef4..fcbe1daf6316 100644
--- a/arch/microblaze/kernel/reset.c
+++ b/arch/microblaze/kernel/reset.c
@@ -18,7 +18,7 @@
18static int handle; /* reset pin handle */ 18static int handle; /* reset pin handle */
19static unsigned int reset_val; 19static unsigned int reset_val;
20 20
21void of_platform_reset_gpio_probe(void) 21static int of_platform_reset_gpio_probe(void)
22{ 22{
23 int ret; 23 int ret;
24 handle = of_get_named_gpio(of_find_node_by_path("/"), 24 handle = of_get_named_gpio(of_find_node_by_path("/"),
@@ -27,13 +27,13 @@ void of_platform_reset_gpio_probe(void)
27 if (!gpio_is_valid(handle)) { 27 if (!gpio_is_valid(handle)) {
28 pr_info("Skipping unavailable RESET gpio %d (%s)\n", 28 pr_info("Skipping unavailable RESET gpio %d (%s)\n",
29 handle, "reset"); 29 handle, "reset");
30 return; 30 return -ENODEV;
31 } 31 }
32 32
33 ret = gpio_request(handle, "reset"); 33 ret = gpio_request(handle, "reset");
34 if (ret < 0) { 34 if (ret < 0) {
35 pr_info("GPIO pin is already allocated\n"); 35 pr_info("GPIO pin is already allocated\n");
36 return; 36 return ret;
37 } 37 }
38 38
39 /* get current setup value */ 39 /* get current setup value */
@@ -51,11 +51,12 @@ void of_platform_reset_gpio_probe(void)
51 51
52 pr_info("RESET: Registered gpio device: %d, current val: %d\n", 52 pr_info("RESET: Registered gpio device: %d, current val: %d\n",
53 handle, reset_val); 53 handle, reset_val);
54 return; 54 return 0;
55err: 55err:
56 gpio_free(handle); 56 gpio_free(handle);
57 return; 57 return ret;
58} 58}
59device_initcall(of_platform_reset_gpio_probe);
59 60
60 61
61static void gpio_system_reset(void) 62static void gpio_system_reset(void)
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index 56bcf313121f..6ab650593792 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -400,3 +400,5 @@ ENTRY(sys_call_table)
400 .long sys_pkey_alloc 400 .long sys_pkey_alloc
401 .long sys_pkey_free 401 .long sys_pkey_free
402 .long sys_statx 402 .long sys_statx
403 .long sys_io_pgetevents
404 .long sys_rseq
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index 7de941cbbd94..a6683484b3a1 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -156,9 +156,6 @@ static inline void timer_ack(void)
156static irqreturn_t timer_interrupt(int irq, void *dev_id) 156static irqreturn_t timer_interrupt(int irq, void *dev_id)
157{ 157{
158 struct clock_event_device *evt = &clockevent_xilinx_timer; 158 struct clock_event_device *evt = &clockevent_xilinx_timer;
159#ifdef CONFIG_HEART_BEAT
160 microblaze_heartbeat();
161#endif
162 timer_ack(); 159 timer_ack();
163 evt->event_handler(evt); 160 evt->event_handler(evt);
164 return IRQ_HANDLED; 161 return IRQ_HANDLED;
@@ -318,10 +315,6 @@ static int __init xilinx_timer_init(struct device_node *timer)
318 return ret; 315 return ret;
319 } 316 }
320 317
321#ifdef CONFIG_HEART_BEAT
322 microblaze_setup_heartbeat();
323#endif
324
325 ret = xilinx_clocksource_init(); 318 ret = xilinx_clocksource_init();
326 if (ret) 319 if (ret)
327 return ret; 320 return ret;
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3f9deec70b92..08c10c518f83 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -65,6 +65,7 @@ config MIPS
65 select HAVE_OPROFILE 65 select HAVE_OPROFILE
66 select HAVE_PERF_EVENTS 66 select HAVE_PERF_EVENTS
67 select HAVE_REGS_AND_STACK_ACCESS_API 67 select HAVE_REGS_AND_STACK_ACCESS_API
68 select HAVE_RSEQ
68 select HAVE_STACKPROTECTOR 69 select HAVE_STACKPROTECTOR
69 select HAVE_SYSCALL_TRACEPOINTS 70 select HAVE_SYSCALL_TRACEPOINTS
70 select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP 71 select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP
diff --git a/arch/mips/ath79/mach-pb44.c b/arch/mips/ath79/mach-pb44.c
index 6b2c6f3baefa..75fb96ca61db 100644
--- a/arch/mips/ath79/mach-pb44.c
+++ b/arch/mips/ath79/mach-pb44.c
@@ -34,7 +34,7 @@
34#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL) 34#define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
35 35
36static struct gpiod_lookup_table pb44_i2c_gpiod_table = { 36static struct gpiod_lookup_table pb44_i2c_gpiod_table = {
37 .dev_id = "i2c-gpio", 37 .dev_id = "i2c-gpio.0",
38 .table = { 38 .table = {
39 GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA, 39 GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA,
40 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), 40 NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 6054d49e608e..8c9cbf13d32a 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -212,6 +212,12 @@ static int __init bcm47xx_cpu_fixes(void)
212 */ 212 */
213 if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706) 213 if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706)
214 cpu_wait = NULL; 214 cpu_wait = NULL;
215
216 /*
217 * BCM47XX Erratum "R10: PCIe Transactions Periodically Fail"
218 * Enable ExternalSync for sync instruction to take effect
219 */
220 set_c0_config7(MIPS_CONF7_ES);
215 break; 221 break;
216#endif 222#endif
217 } 223 }
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index a7d0b836f2f7..cea8ad864b3f 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -414,6 +414,8 @@ static inline type pfx##in##bwlq##p(unsigned long port) \
414 __val = *__addr; \ 414 __val = *__addr; \
415 slow; \ 415 slow; \
416 \ 416 \
417 /* prevent prefetching of coherent DMA data prematurely */ \
418 rmb(); \
417 return pfx##ioswab##bwlq(__addr, __val); \ 419 return pfx##ioswab##bwlq(__addr, __val); \
418} 420}
419 421
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index ae461d91cd1f..0bc270806ec5 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -681,6 +681,8 @@
681#define MIPS_CONF7_WII (_ULCAST_(1) << 31) 681#define MIPS_CONF7_WII (_ULCAST_(1) << 31)
682 682
683#define MIPS_CONF7_RPS (_ULCAST_(1) << 2) 683#define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
684/* ExternalSync */
685#define MIPS_CONF7_ES (_ULCAST_(1) << 8)
684 686
685#define MIPS_CONF7_IAR (_ULCAST_(1) << 10) 687#define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
686#define MIPS_CONF7_AR (_ULCAST_(1) << 16) 688#define MIPS_CONF7_AR (_ULCAST_(1) << 16)
@@ -2765,6 +2767,7 @@ __BUILD_SET_C0(status)
2765__BUILD_SET_C0(cause) 2767__BUILD_SET_C0(cause)
2766__BUILD_SET_C0(config) 2768__BUILD_SET_C0(config)
2767__BUILD_SET_C0(config5) 2769__BUILD_SET_C0(config5)
2770__BUILD_SET_C0(config7)
2768__BUILD_SET_C0(intcontrol) 2771__BUILD_SET_C0(intcontrol)
2769__BUILD_SET_C0(intctl) 2772__BUILD_SET_C0(intctl)
2770__BUILD_SET_C0(srsmap) 2773__BUILD_SET_C0(srsmap)
diff --git a/arch/mips/include/uapi/asm/unistd.h b/arch/mips/include/uapi/asm/unistd.h
index bb05e9916a5f..f25dd1d83fb7 100644
--- a/arch/mips/include/uapi/asm/unistd.h
+++ b/arch/mips/include/uapi/asm/unistd.h
@@ -388,17 +388,19 @@
388#define __NR_pkey_alloc (__NR_Linux + 364) 388#define __NR_pkey_alloc (__NR_Linux + 364)
389#define __NR_pkey_free (__NR_Linux + 365) 389#define __NR_pkey_free (__NR_Linux + 365)
390#define __NR_statx (__NR_Linux + 366) 390#define __NR_statx (__NR_Linux + 366)
391#define __NR_rseq (__NR_Linux + 367)
392#define __NR_io_pgetevents (__NR_Linux + 368)
391 393
392 394
393/* 395/*
394 * Offset of the last Linux o32 flavoured syscall 396 * Offset of the last Linux o32 flavoured syscall
395 */ 397 */
396#define __NR_Linux_syscalls 366 398#define __NR_Linux_syscalls 368
397 399
398#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 400#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
399 401
400#define __NR_O32_Linux 4000 402#define __NR_O32_Linux 4000
401#define __NR_O32_Linux_syscalls 366 403#define __NR_O32_Linux_syscalls 368
402 404
403#if _MIPS_SIM == _MIPS_SIM_ABI64 405#if _MIPS_SIM == _MIPS_SIM_ABI64
404 406
@@ -733,16 +735,18 @@
733#define __NR_pkey_alloc (__NR_Linux + 324) 735#define __NR_pkey_alloc (__NR_Linux + 324)
734#define __NR_pkey_free (__NR_Linux + 325) 736#define __NR_pkey_free (__NR_Linux + 325)
735#define __NR_statx (__NR_Linux + 326) 737#define __NR_statx (__NR_Linux + 326)
738#define __NR_rseq (__NR_Linux + 327)
739#define __NR_io_pgetevents (__NR_Linux + 328)
736 740
737/* 741/*
738 * Offset of the last Linux 64-bit flavoured syscall 742 * Offset of the last Linux 64-bit flavoured syscall
739 */ 743 */
740#define __NR_Linux_syscalls 326 744#define __NR_Linux_syscalls 328
741 745
742#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 746#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
743 747
744#define __NR_64_Linux 5000 748#define __NR_64_Linux 5000
745#define __NR_64_Linux_syscalls 326 749#define __NR_64_Linux_syscalls 328
746 750
747#if _MIPS_SIM == _MIPS_SIM_NABI32 751#if _MIPS_SIM == _MIPS_SIM_NABI32
748 752
@@ -1081,15 +1085,17 @@
1081#define __NR_pkey_alloc (__NR_Linux + 328) 1085#define __NR_pkey_alloc (__NR_Linux + 328)
1082#define __NR_pkey_free (__NR_Linux + 329) 1086#define __NR_pkey_free (__NR_Linux + 329)
1083#define __NR_statx (__NR_Linux + 330) 1087#define __NR_statx (__NR_Linux + 330)
1088#define __NR_rseq (__NR_Linux + 331)
1089#define __NR_io_pgetevents (__NR_Linux + 332)
1084 1090
1085/* 1091/*
1086 * Offset of the last N32 flavoured syscall 1092 * Offset of the last N32 flavoured syscall
1087 */ 1093 */
1088#define __NR_Linux_syscalls 330 1094#define __NR_Linux_syscalls 332
1089 1095
1090#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 1096#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
1091 1097
1092#define __NR_N32_Linux 6000 1098#define __NR_N32_Linux 6000
1093#define __NR_N32_Linux_syscalls 330 1099#define __NR_N32_Linux_syscalls 332
1094 1100
1095#endif /* _UAPI_ASM_UNISTD_H */ 1101#endif /* _UAPI_ASM_UNISTD_H */
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index 38a302919e6b..d7de8adcfcc8 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -79,6 +79,10 @@ FEXPORT(ret_from_fork)
79 jal schedule_tail # a0 = struct task_struct *prev 79 jal schedule_tail # a0 = struct task_struct *prev
80 80
81FEXPORT(syscall_exit) 81FEXPORT(syscall_exit)
82#ifdef CONFIG_DEBUG_RSEQ
83 move a0, sp
84 jal rseq_syscall
85#endif
82 local_irq_disable # make sure need_resched and 86 local_irq_disable # make sure need_resched and
83 # signals dont change between 87 # signals dont change between
84 # sampling and return 88 # sampling and return
@@ -141,6 +145,10 @@ work_notifysig: # deal with pending signals and
141 j resume_userspace_check 145 j resume_userspace_check
142 146
143FEXPORT(syscall_exit_partial) 147FEXPORT(syscall_exit_partial)
148#ifdef CONFIG_DEBUG_RSEQ
149 move a0, sp
150 jal rseq_syscall
151#endif
144 local_irq_disable # make sure need_resched doesn't 152 local_irq_disable # make sure need_resched doesn't
145 # change between and return 153 # change between and return
146 LONG_L a2, TI_FLAGS($28) # current->work 154 LONG_L a2, TI_FLAGS($28) # current->work
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index f2ee7e1e3342..cff52b283e03 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -119,10 +119,20 @@ NESTED(_mcount, PT_SIZE, ra)
119EXPORT_SYMBOL(_mcount) 119EXPORT_SYMBOL(_mcount)
120 PTR_LA t1, ftrace_stub 120 PTR_LA t1, ftrace_stub
121 PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */ 121 PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
122 bne t1, t2, static_trace 122 beq t1, t2, fgraph_trace
123 nop 123 nop
124 124
125 MCOUNT_SAVE_REGS
126
127 move a0, ra /* arg1: self return address */
128 jalr t2 /* (1) call *ftrace_trace_function */
129 move a1, AT /* arg2: parent's return address */
130
131 MCOUNT_RESTORE_REGS
132
133fgraph_trace:
125#ifdef CONFIG_FUNCTION_GRAPH_TRACER 134#ifdef CONFIG_FUNCTION_GRAPH_TRACER
135 PTR_LA t1, ftrace_stub
126 PTR_L t3, ftrace_graph_return 136 PTR_L t3, ftrace_graph_return
127 bne t1, t3, ftrace_graph_caller 137 bne t1, t3, ftrace_graph_caller
128 nop 138 nop
@@ -131,24 +141,11 @@ EXPORT_SYMBOL(_mcount)
131 bne t1, t3, ftrace_graph_caller 141 bne t1, t3, ftrace_graph_caller
132 nop 142 nop
133#endif 143#endif
134 b ftrace_stub
135#ifdef CONFIG_32BIT
136 addiu sp, sp, 8
137#else
138 nop
139#endif
140 144
141static_trace:
142 MCOUNT_SAVE_REGS
143
144 move a0, ra /* arg1: self return address */
145 jalr t2 /* (1) call *ftrace_trace_function */
146 move a1, AT /* arg2: parent's return address */
147
148 MCOUNT_RESTORE_REGS
149#ifdef CONFIG_32BIT 145#ifdef CONFIG_32BIT
150 addiu sp, sp, 8 146 addiu sp, sp, 8
151#endif 147#endif
148
152 .globl ftrace_stub 149 .globl ftrace_stub
153ftrace_stub: 150ftrace_stub:
154 RETURN_BACK 151 RETURN_BACK
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index a9a7d78803cd..91d3c8c46097 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -590,3 +590,5 @@ EXPORT(sys_call_table)
590 PTR sys_pkey_alloc 590 PTR sys_pkey_alloc
591 PTR sys_pkey_free /* 4365 */ 591 PTR sys_pkey_free /* 4365 */
592 PTR sys_statx 592 PTR sys_statx
593 PTR sys_rseq
594 PTR sys_io_pgetevents
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 65d5aeeb9bdb..358d9599983d 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -439,4 +439,6 @@ EXPORT(sys_call_table)
439 PTR sys_pkey_alloc 439 PTR sys_pkey_alloc
440 PTR sys_pkey_free /* 5325 */ 440 PTR sys_pkey_free /* 5325 */
441 PTR sys_statx 441 PTR sys_statx
442 PTR sys_rseq
443 PTR sys_io_pgetevents
442 .size sys_call_table,.-sys_call_table 444 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index cbf190ef9e8a..c65eaacc1abf 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -434,4 +434,6 @@ EXPORT(sysn32_call_table)
434 PTR sys_pkey_alloc 434 PTR sys_pkey_alloc
435 PTR sys_pkey_free 435 PTR sys_pkey_free
436 PTR sys_statx /* 6330 */ 436 PTR sys_statx /* 6330 */
437 PTR sys_rseq
438 PTR compat_sys_io_pgetevents
437 .size sysn32_call_table,.-sysn32_call_table 439 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 9ebe3e2403b1..73913f072e39 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -583,4 +583,6 @@ EXPORT(sys32_call_table)
583 PTR sys_pkey_alloc 583 PTR sys_pkey_alloc
584 PTR sys_pkey_free /* 4365 */ 584 PTR sys_pkey_free /* 4365 */
585 PTR sys_statx 585 PTR sys_statx
586 PTR sys_rseq
587 PTR compat_sys_io_pgetevents
586 .size sys32_call_table,.-sys32_call_table 588 .size sys32_call_table,.-sys32_call_table
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 9e224469c788..0a9cfe7a0372 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -801,6 +801,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
801 regs->regs[0] = 0; /* Don't deal with this again. */ 801 regs->regs[0] = 0; /* Don't deal with this again. */
802 } 802 }
803 803
804 rseq_signal_deliver(ksig, regs);
805
804 if (sig_uses_siginfo(&ksig->ka, abi)) 806 if (sig_uses_siginfo(&ksig->ka, abi))
805 ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn, 807 ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn,
806 ksig, regs, oldset); 808 ksig, regs, oldset);
@@ -868,6 +870,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
868 if (thread_info_flags & _TIF_NOTIFY_RESUME) { 870 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
869 clear_thread_flag(TIF_NOTIFY_RESUME); 871 clear_thread_flag(TIF_NOTIFY_RESUME);
870 tracehook_notify_resume(regs); 872 tracehook_notify_resume(regs);
873 rseq_handle_notify_resume(NULL, regs);
871 } 874 }
872 875
873 user_enter(); 876 user_enter();
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index c480770fabcd..17526bebcbd2 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -244,11 +244,11 @@ config PARISC_PAGE_SIZE_4KB
244 244
245config PARISC_PAGE_SIZE_16KB 245config PARISC_PAGE_SIZE_16KB
246 bool "16KB" 246 bool "16KB"
247 depends on PA8X00 247 depends on PA8X00 && BROKEN
248 248
249config PARISC_PAGE_SIZE_64KB 249config PARISC_PAGE_SIZE_64KB
250 bool "64KB" 250 bool "64KB"
251 depends on PA8X00 251 depends on PA8X00 && BROKEN
252 252
253endchoice 253endchoice
254 254
@@ -347,7 +347,7 @@ config NR_CPUS
347 int "Maximum number of CPUs (2-32)" 347 int "Maximum number of CPUs (2-32)"
348 range 2 32 348 range 2 32
349 depends on SMP 349 depends on SMP
350 default "32" 350 default "4"
351 351
352endmenu 352endmenu
353 353
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 714284ea6cc2..5ce030266e7d 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -65,10 +65,6 @@ endif
65# kernel. 65# kernel.
66cflags-y += -mdisable-fpregs 66cflags-y += -mdisable-fpregs
67 67
68# Without this, "ld -r" results in .text sections that are too big
69# (> 0x40000) for branches to reach stubs.
70cflags-y += -ffunction-sections
71
72# Use long jumps instead of long branches (needed if your linker fails to 68# Use long jumps instead of long branches (needed if your linker fails to
73# link a too big vmlinux executable). Not enabled for building modules. 69# link a too big vmlinux executable). Not enabled for building modules.
74ifdef CONFIG_MLONGCALLS 70ifdef CONFIG_MLONGCALLS
diff --git a/arch/parisc/include/asm/signal.h b/arch/parisc/include/asm/signal.h
index eeb5c8858663..715c96ba2ec8 100644
--- a/arch/parisc/include/asm/signal.h
+++ b/arch/parisc/include/asm/signal.h
@@ -21,14 +21,6 @@ typedef struct {
21 unsigned long sig[_NSIG_WORDS]; 21 unsigned long sig[_NSIG_WORDS];
22} sigset_t; 22} sigset_t;
23 23
24#ifndef __KERNEL__
25struct sigaction {
26 __sighandler_t sa_handler;
27 unsigned long sa_flags;
28 sigset_t sa_mask; /* mask last for extensibility */
29};
30#endif
31
32#include <asm/sigcontext.h> 24#include <asm/sigcontext.h>
33 25
34#endif /* !__ASSEMBLY */ 26#endif /* !__ASSEMBLY */
diff --git a/arch/parisc/include/uapi/asm/unistd.h b/arch/parisc/include/uapi/asm/unistd.h
index 4872e77aa96b..dc77c5a51db7 100644
--- a/arch/parisc/include/uapi/asm/unistd.h
+++ b/arch/parisc/include/uapi/asm/unistd.h
@@ -364,8 +364,9 @@
364#define __NR_preadv2 (__NR_Linux + 347) 364#define __NR_preadv2 (__NR_Linux + 347)
365#define __NR_pwritev2 (__NR_Linux + 348) 365#define __NR_pwritev2 (__NR_Linux + 348)
366#define __NR_statx (__NR_Linux + 349) 366#define __NR_statx (__NR_Linux + 349)
367#define __NR_io_pgetevents (__NR_Linux + 350)
367 368
368#define __NR_Linux_syscalls (__NR_statx + 1) 369#define __NR_Linux_syscalls (__NR_io_pgetevents + 1)
369 370
370 371
371#define __IGNORE_select /* newselect */ 372#define __IGNORE_select /* newselect */
diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index e0e1c9775c32..5eb979d04b90 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -154,17 +154,14 @@ int register_parisc_driver(struct parisc_driver *driver)
154{ 154{
155 /* FIXME: we need this because apparently the sti 155 /* FIXME: we need this because apparently the sti
156 * driver can be registered twice */ 156 * driver can be registered twice */
157 if(driver->drv.name) { 157 if (driver->drv.name) {
158 printk(KERN_WARNING 158 pr_warn("BUG: skipping previously registered driver %s\n",
159 "BUG: skipping previously registered driver %s\n", 159 driver->name);
160 driver->name);
161 return 1; 160 return 1;
162 } 161 }
163 162
164 if (!driver->probe) { 163 if (!driver->probe) {
165 printk(KERN_WARNING 164 pr_warn("BUG: driver %s has no probe routine\n", driver->name);
166 "BUG: driver %s has no probe routine\n",
167 driver->name);
168 return 1; 165 return 1;
169 } 166 }
170 167
@@ -491,12 +488,9 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
491 488
492 dev = create_parisc_device(mod_path); 489 dev = create_parisc_device(mod_path);
493 if (dev->id.hw_type != HPHW_FAULTY) { 490 if (dev->id.hw_type != HPHW_FAULTY) {
494 printk(KERN_ERR "Two devices have hardware path [%s]. " 491 pr_err("Two devices have hardware path [%s]. IODC data for second device: %7phN\n"
495 "IODC data for second device: " 492 "Rearranging GSC cards sometimes helps\n",
496 "%02x%02x%02x%02x%02x%02x\n" 493 parisc_pathname(dev), iodc_data);
497 "Rearranging GSC cards sometimes helps\n",
498 parisc_pathname(dev), iodc_data[0], iodc_data[1],
499 iodc_data[3], iodc_data[4], iodc_data[5], iodc_data[6]);
500 return NULL; 494 return NULL;
501 } 495 }
502 496
@@ -528,8 +522,7 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
528 * the keyboard controller 522 * the keyboard controller
529 */ 523 */
530 if ((hpa & 0xfff) == 0 && insert_resource(&iomem_resource, &dev->hpa)) 524 if ((hpa & 0xfff) == 0 && insert_resource(&iomem_resource, &dev->hpa))
531 printk("Unable to claim HPA %lx for device %s\n", 525 pr_warn("Unable to claim HPA %lx for device %s\n", hpa, name);
532 hpa, name);
533 526
534 return dev; 527 return dev;
535} 528}
@@ -875,7 +868,7 @@ static void print_parisc_device(struct parisc_device *dev)
875 static int count; 868 static int count;
876 869
877 print_pa_hwpath(dev, hw_path); 870 print_pa_hwpath(dev, hw_path);
878 printk(KERN_INFO "%d. %s at 0x%px [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }", 871 pr_info("%d. %s at 0x%px [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }",
879 ++count, dev->name, (void*) dev->hpa.start, hw_path, dev->id.hw_type, 872 ++count, dev->name, (void*) dev->hpa.start, hw_path, dev->id.hw_type,
880 dev->id.hversion_rev, dev->id.hversion, dev->id.sversion); 873 dev->id.hversion_rev, dev->id.hversion, dev->id.sversion);
881 874
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 6308749359e4..fe3f2a49d2b1 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -445,6 +445,7 @@
445 ENTRY_COMP(preadv2) 445 ENTRY_COMP(preadv2)
446 ENTRY_COMP(pwritev2) 446 ENTRY_COMP(pwritev2)
447 ENTRY_SAME(statx) 447 ENTRY_SAME(statx)
448 ENTRY_COMP(io_pgetevents) /* 350 */
448 449
449 450
450.ifne (. - 90b) - (__NR_Linux_syscalls * (91b - 90b)) 451.ifne (. - 90b) - (__NR_Linux_syscalls * (91b - 90b))
diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
index 143f90e2f9f3..2ef83d78eec4 100644
--- a/arch/parisc/kernel/unwind.c
+++ b/arch/parisc/kernel/unwind.c
@@ -25,7 +25,7 @@
25 25
26/* #define DEBUG 1 */ 26/* #define DEBUG 1 */
27#ifdef DEBUG 27#ifdef DEBUG
28#define dbg(x...) printk(x) 28#define dbg(x...) pr_debug(x)
29#else 29#else
30#define dbg(x...) 30#define dbg(x...)
31#endif 31#endif
@@ -182,7 +182,7 @@ int __init unwind_init(void)
182 start = (long)&__start___unwind[0]; 182 start = (long)&__start___unwind[0];
183 stop = (long)&__stop___unwind[0]; 183 stop = (long)&__stop___unwind[0];
184 184
185 printk("unwind_init: start = 0x%lx, end = 0x%lx, entries = %lu\n", 185 dbg("unwind_init: start = 0x%lx, end = 0x%lx, entries = %lu\n",
186 start, stop, 186 start, stop,
187 (stop - start) / sizeof(struct unwind_table_entry)); 187 (stop - start) / sizeof(struct unwind_table_entry));
188 188
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index bd06a3ccda31..2ea575cb3401 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -244,6 +244,7 @@ cpu-as-$(CONFIG_4xx) += -Wa,-m405
244cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec) 244cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
245cpu-as-$(CONFIG_E200) += -Wa,-me200 245cpu-as-$(CONFIG_E200) += -Wa,-me200
246cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 246cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4
247cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc)
247 248
248KBUILD_AFLAGS += $(cpu-as-y) 249KBUILD_AFLAGS += $(cpu-as-y)
249KBUILD_CFLAGS += $(cpu-as-y) 250KBUILD_CFLAGS += $(cpu-as-y)
diff --git a/arch/powerpc/include/asm/book3s/32/pgalloc.h b/arch/powerpc/include/asm/book3s/32/pgalloc.h
index 6a6673907e45..82e44b1a00ae 100644
--- a/arch/powerpc/include/asm/book3s/32/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/32/pgalloc.h
@@ -108,6 +108,7 @@ static inline void pgtable_free(void *table, unsigned index_size)
108} 108}
109 109
110#define check_pgt_cache() do { } while (0) 110#define check_pgt_cache() do { } while (0)
111#define get_hugepd_cache_index(x) (x)
111 112
112#ifdef CONFIG_SMP 113#ifdef CONFIG_SMP
113static inline void pgtable_free_tlb(struct mmu_gather *tlb, 114static inline void pgtable_free_tlb(struct mmu_gather *tlb,
@@ -137,7 +138,6 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,
137static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table, 138static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
138 unsigned long address) 139 unsigned long address)
139{ 140{
140 pgtable_page_dtor(table);
141 pgtable_free_tlb(tlb, page_address(table), 0); 141 pgtable_free_tlb(tlb, page_address(table), 0);
142} 142}
143#endif /* _ASM_POWERPC_BOOK3S_32_PGALLOC_H */ 143#endif /* _ASM_POWERPC_BOOK3S_32_PGALLOC_H */
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
index af5f2baac80f..a069dfcac9a9 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
@@ -49,6 +49,27 @@ static inline int hugepd_ok(hugepd_t hpd)
49} 49}
50#define is_hugepd(hpd) (hugepd_ok(hpd)) 50#define is_hugepd(hpd) (hugepd_ok(hpd))
51 51
52/*
53 * 16M and 16G huge page directory tables are allocated from slab cache
54 *
55 */
56#define H_16M_CACHE_INDEX (PAGE_SHIFT + H_PTE_INDEX_SIZE + H_PMD_INDEX_SIZE - 24)
57#define H_16G_CACHE_INDEX \
58 (PAGE_SHIFT + H_PTE_INDEX_SIZE + H_PMD_INDEX_SIZE + H_PUD_INDEX_SIZE - 34)
59
60static inline int get_hugepd_cache_index(int index)
61{
62 switch (index) {
63 case H_16M_CACHE_INDEX:
64 return HTLB_16M_INDEX;
65 case H_16G_CACHE_INDEX:
66 return HTLB_16G_INDEX;
67 default:
68 BUG();
69 }
70 /* should not reach */
71}
72
52#else /* !CONFIG_HUGETLB_PAGE */ 73#else /* !CONFIG_HUGETLB_PAGE */
53static inline int pmd_huge(pmd_t pmd) { return 0; } 74static inline int pmd_huge(pmd_t pmd) { return 0; }
54static inline int pud_huge(pud_t pud) { return 0; } 75static inline int pud_huge(pud_t pud) { return 0; }
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h
index fb4b3ba52339..d7ee249d6890 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h
@@ -45,8 +45,17 @@ static inline int hugepd_ok(hugepd_t hpd)
45{ 45{
46 return 0; 46 return 0;
47} 47}
48
48#define is_hugepd(pdep) 0 49#define is_hugepd(pdep) 0
49 50
51/*
52 * This should never get called
53 */
54static inline int get_hugepd_cache_index(int index)
55{
56 BUG();
57}
58
50#else /* !CONFIG_HUGETLB_PAGE */ 59#else /* !CONFIG_HUGETLB_PAGE */
51static inline int pmd_huge(pmd_t pmd) { return 0; } 60static inline int pmd_huge(pmd_t pmd) { return 0; }
52static inline int pud_huge(pud_t pud) { return 0; } 61static inline int pud_huge(pud_t pud) { return 0; }
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 63cee159022b..42aafba7a308 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -287,6 +287,11 @@ enum pgtable_index {
287 PMD_INDEX, 287 PMD_INDEX,
288 PUD_INDEX, 288 PUD_INDEX,
289 PGD_INDEX, 289 PGD_INDEX,
290 /*
291 * Below are used with 4k page size and hugetlb
292 */
293 HTLB_16M_INDEX,
294 HTLB_16G_INDEX,
290}; 295};
291 296
292extern unsigned long __vmalloc_start; 297extern unsigned long __vmalloc_start;
diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h
index 0f571e0ebca1..bd9ba8defd72 100644
--- a/arch/powerpc/include/asm/nmi.h
+++ b/arch/powerpc/include/asm/nmi.h
@@ -8,7 +8,7 @@ extern void arch_touch_nmi_watchdog(void);
8static inline void arch_touch_nmi_watchdog(void) {} 8static inline void arch_touch_nmi_watchdog(void) {}
9#endif 9#endif
10 10
11#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_STACKTRACE) 11#if defined(CONFIG_NMI_IPI) && defined(CONFIG_STACKTRACE)
12extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, 12extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask,
13 bool exclude_self); 13 bool exclude_self);
14#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 14#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
diff --git a/arch/powerpc/include/asm/nohash/32/pgalloc.h b/arch/powerpc/include/asm/nohash/32/pgalloc.h
index 1707781d2f20..8825953c225b 100644
--- a/arch/powerpc/include/asm/nohash/32/pgalloc.h
+++ b/arch/powerpc/include/asm/nohash/32/pgalloc.h
@@ -109,6 +109,7 @@ static inline void pgtable_free(void *table, unsigned index_size)
109} 109}
110 110
111#define check_pgt_cache() do { } while (0) 111#define check_pgt_cache() do { } while (0)
112#define get_hugepd_cache_index(x) (x)
112 113
113#ifdef CONFIG_SMP 114#ifdef CONFIG_SMP
114static inline void pgtable_free_tlb(struct mmu_gather *tlb, 115static inline void pgtable_free_tlb(struct mmu_gather *tlb,
@@ -139,7 +140,6 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
139 unsigned long address) 140 unsigned long address)
140{ 141{
141 tlb_flush_pgtable(tlb, address); 142 tlb_flush_pgtable(tlb, address);
142 pgtable_page_dtor(table);
143 pgtable_free_tlb(tlb, page_address(table), 0); 143 pgtable_free_tlb(tlb, page_address(table), 0);
144} 144}
145#endif /* _ASM_POWERPC_PGALLOC_32_H */ 145#endif /* _ASM_POWERPC_PGALLOC_32_H */
diff --git a/arch/powerpc/include/asm/nohash/64/pgalloc.h b/arch/powerpc/include/asm/nohash/64/pgalloc.h
index 0e693f322cb2..e2d62d033708 100644
--- a/arch/powerpc/include/asm/nohash/64/pgalloc.h
+++ b/arch/powerpc/include/asm/nohash/64/pgalloc.h
@@ -141,6 +141,7 @@ static inline void pgtable_free(void *table, int shift)
141 } 141 }
142} 142}
143 143
144#define get_hugepd_cache_index(x) (x)
144#ifdef CONFIG_SMP 145#ifdef CONFIG_SMP
145static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift) 146static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
146{ 147{
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index cfcf6a874cfa..01b5171ea189 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -393,3 +393,4 @@ SYSCALL(pkey_alloc)
393SYSCALL(pkey_free) 393SYSCALL(pkey_free)
394SYSCALL(pkey_mprotect) 394SYSCALL(pkey_mprotect)
395SYSCALL(rseq) 395SYSCALL(rseq)
396COMPAT_SYS(io_pgetevents)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 1e9708632dce..c19379f0a32e 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -12,7 +12,7 @@
12#include <uapi/asm/unistd.h> 12#include <uapi/asm/unistd.h>
13 13
14 14
15#define NR_syscalls 388 15#define NR_syscalls 389
16 16
17#define __NR__exit __NR_exit 17#define __NR__exit __NR_exit
18 18
diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h
index ac5ba55066dd..985534d0b448 100644
--- a/arch/powerpc/include/uapi/asm/unistd.h
+++ b/arch/powerpc/include/uapi/asm/unistd.h
@@ -399,5 +399,6 @@
399#define __NR_pkey_free 385 399#define __NR_pkey_free 385
400#define __NR_pkey_mprotect 386 400#define __NR_pkey_mprotect 386
401#define __NR_rseq 387 401#define __NR_rseq 387
402#define __NR_io_pgetevents 388
402 403
403#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ 404#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c
index 4be1c0de9406..96dd3d871986 100644
--- a/arch/powerpc/kernel/dt_cpu_ftrs.c
+++ b/arch/powerpc/kernel/dt_cpu_ftrs.c
@@ -711,7 +711,8 @@ static __init void cpufeatures_cpu_quirks(void)
711 cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_HV_ASSIST; 711 cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_HV_ASSIST;
712 cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_XER_SO_BUG; 712 cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_XER_SO_BUG;
713 cur_cpu_spec->cpu_features |= CPU_FTR_POWER9_DD2_1; 713 cur_cpu_spec->cpu_features |= CPU_FTR_POWER9_DD2_1;
714 } else /* DD2.1 and up have DD2_1 */ 714 } else if ((version & 0xffff0000) == 0x004e0000)
715 /* DD2.1 and up have DD2_1 */
715 cur_cpu_spec->cpu_features |= CPU_FTR_POWER9_DD2_1; 716 cur_cpu_spec->cpu_features |= CPU_FTR_POWER9_DD2_1;
716 717
717 if ((version & 0xffff0000) == 0x004e0000) { 718 if ((version & 0xffff0000) == 0x004e0000) {
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 4f861055a852..d63b488d34d7 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -285,9 +285,6 @@ pci_bus_to_hose(int bus)
285 * Note that the returned IO or memory base is a physical address 285 * Note that the returned IO or memory base is a physical address
286 */ 286 */
287 287
288#pragma GCC diagnostic push
289#pragma GCC diagnostic ignored "-Wpragmas"
290#pragma GCC diagnostic ignored "-Wattribute-alias"
291SYSCALL_DEFINE3(pciconfig_iobase, long, which, 288SYSCALL_DEFINE3(pciconfig_iobase, long, which,
292 unsigned long, bus, unsigned long, devfn) 289 unsigned long, bus, unsigned long, devfn)
293{ 290{
@@ -313,4 +310,3 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which,
313 310
314 return result; 311 return result;
315} 312}
316#pragma GCC diagnostic pop
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 812171c09f42..dff28f903512 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -203,9 +203,6 @@ void pcibios_setup_phb_io_space(struct pci_controller *hose)
203#define IOBASE_ISA_IO 3 203#define IOBASE_ISA_IO 3
204#define IOBASE_ISA_MEM 4 204#define IOBASE_ISA_MEM 4
205 205
206#pragma GCC diagnostic push
207#pragma GCC diagnostic ignored "-Wpragmas"
208#pragma GCC diagnostic ignored "-Wattribute-alias"
209SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus, 206SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
210 unsigned long, in_devfn) 207 unsigned long, in_devfn)
211{ 208{
@@ -259,7 +256,6 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
259 256
260 return -EOPNOTSUPP; 257 return -EOPNOTSUPP;
261} 258}
262#pragma GCC diagnostic pop
263 259
264#ifdef CONFIG_NUMA 260#ifdef CONFIG_NUMA
265int pcibus_to_node(struct pci_bus *bus) 261int pcibus_to_node(struct pci_bus *bus)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 7fb9f83dcde8..8afd146bc9c7 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1051,9 +1051,6 @@ struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
1051} 1051}
1052 1052
1053/* We assume to be passed big endian arguments */ 1053/* We assume to be passed big endian arguments */
1054#pragma GCC diagnostic push
1055#pragma GCC diagnostic ignored "-Wpragmas"
1056#pragma GCC diagnostic ignored "-Wattribute-alias"
1057SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs) 1054SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
1058{ 1055{
1059 struct rtas_args args; 1056 struct rtas_args args;
@@ -1140,7 +1137,6 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
1140 1137
1141 return 0; 1138 return 0;
1142} 1139}
1143#pragma GCC diagnostic pop
1144 1140
1145/* 1141/*
1146 * Call early during boot, before mem init, to retrieve the RTAS 1142 * Call early during boot, before mem init, to retrieve the RTAS
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 62b1a40d8957..40b44bb53a4e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -701,11 +701,18 @@ static int ppc_panic_event(struct notifier_block *this,
701 unsigned long event, void *ptr) 701 unsigned long event, void *ptr)
702{ 702{
703 /* 703 /*
704 * panic does a local_irq_disable, but we really
705 * want interrupts to be hard disabled.
706 */
707 hard_irq_disable();
708
709 /*
704 * If firmware-assisted dump has been registered then trigger 710 * If firmware-assisted dump has been registered then trigger
705 * firmware-assisted dump and let firmware handle everything else. 711 * firmware-assisted dump and let firmware handle everything else.
706 */ 712 */
707 crash_fadump(NULL, ptr); 713 crash_fadump(NULL, ptr);
708 ppc_md.panic(ptr); /* May not return */ 714 if (ppc_md.panic)
715 ppc_md.panic(ptr); /* May not return */
709 return NOTIFY_DONE; 716 return NOTIFY_DONE;
710} 717}
711 718
@@ -716,7 +723,8 @@ static struct notifier_block ppc_panic_block = {
716 723
717void __init setup_panic(void) 724void __init setup_panic(void)
718{ 725{
719 if (!ppc_md.panic) 726 /* PPC64 always does a hard irq disable in its panic handler */
727 if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic)
720 return; 728 return;
721 atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block); 729 atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
722} 730}
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 7a7ce8ad455e..225bc5f91049 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -387,6 +387,14 @@ void early_setup_secondary(void)
387 387
388#endif /* CONFIG_SMP */ 388#endif /* CONFIG_SMP */
389 389
390void panic_smp_self_stop(void)
391{
392 hard_irq_disable();
393 spin_begin();
394 while (1)
395 spin_cpu_relax();
396}
397
390#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC_CORE) 398#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC_CORE)
391static bool use_spinloop(void) 399static bool use_spinloop(void)
392{ 400{
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 17fe4339ba59..b3e8db376ecd 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -134,7 +134,7 @@ static void do_signal(struct task_struct *tsk)
134 /* Re-enable the breakpoints for the signal stack */ 134 /* Re-enable the breakpoints for the signal stack */
135 thread_change_pc(tsk, tsk->thread.regs); 135 thread_change_pc(tsk, tsk->thread.regs);
136 136
137 rseq_signal_deliver(tsk->thread.regs); 137 rseq_signal_deliver(&ksig, tsk->thread.regs);
138 138
139 if (is32) { 139 if (is32) {
140 if (ksig.ka.sa.sa_flags & SA_SIGINFO) 140 if (ksig.ka.sa.sa_flags & SA_SIGINFO)
@@ -170,7 +170,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
170 if (thread_info_flags & _TIF_NOTIFY_RESUME) { 170 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
171 clear_thread_flag(TIF_NOTIFY_RESUME); 171 clear_thread_flag(TIF_NOTIFY_RESUME);
172 tracehook_notify_resume(regs); 172 tracehook_notify_resume(regs);
173 rseq_handle_notify_resume(regs); 173 rseq_handle_notify_resume(NULL, regs);
174 } 174 }
175 175
176 user_enter(); 176 user_enter();
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 5eedbb282d42..e6474a45cef5 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -1038,9 +1038,6 @@ static int do_setcontext_tm(struct ucontext __user *ucp,
1038} 1038}
1039#endif 1039#endif
1040 1040
1041#pragma GCC diagnostic push
1042#pragma GCC diagnostic ignored "-Wpragmas"
1043#pragma GCC diagnostic ignored "-Wattribute-alias"
1044#ifdef CONFIG_PPC64 1041#ifdef CONFIG_PPC64
1045COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx, 1042COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
1046 struct ucontext __user *, new_ctx, int, ctx_size) 1043 struct ucontext __user *, new_ctx, int, ctx_size)
@@ -1134,7 +1131,6 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
1134 set_thread_flag(TIF_RESTOREALL); 1131 set_thread_flag(TIF_RESTOREALL);
1135 return 0; 1132 return 0;
1136} 1133}
1137#pragma GCC diagnostic pop
1138 1134
1139#ifdef CONFIG_PPC64 1135#ifdef CONFIG_PPC64
1140COMPAT_SYSCALL_DEFINE0(rt_sigreturn) 1136COMPAT_SYSCALL_DEFINE0(rt_sigreturn)
@@ -1231,9 +1227,6 @@ SYSCALL_DEFINE0(rt_sigreturn)
1231 return 0; 1227 return 0;
1232} 1228}
1233 1229
1234#pragma GCC diagnostic push
1235#pragma GCC diagnostic ignored "-Wpragmas"
1236#pragma GCC diagnostic ignored "-Wattribute-alias"
1237#ifdef CONFIG_PPC32 1230#ifdef CONFIG_PPC32
1238SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx, 1231SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx,
1239 int, ndbg, struct sig_dbg_op __user *, dbg) 1232 int, ndbg, struct sig_dbg_op __user *, dbg)
@@ -1337,7 +1330,6 @@ SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx,
1337 return 0; 1330 return 0;
1338} 1331}
1339#endif 1332#endif
1340#pragma GCC diagnostic pop
1341 1333
1342/* 1334/*
1343 * OK, we're invoking a handler 1335 * OK, we're invoking a handler
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index d42b60020389..83d51bf586c7 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -625,9 +625,6 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
625/* 625/*
626 * Handle {get,set,swap}_context operations 626 * Handle {get,set,swap}_context operations
627 */ 627 */
628#pragma GCC diagnostic push
629#pragma GCC diagnostic ignored "-Wpragmas"
630#pragma GCC diagnostic ignored "-Wattribute-alias"
631SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx, 628SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
632 struct ucontext __user *, new_ctx, long, ctx_size) 629 struct ucontext __user *, new_ctx, long, ctx_size)
633{ 630{
@@ -693,7 +690,6 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
693 set_thread_flag(TIF_RESTOREALL); 690 set_thread_flag(TIF_RESTOREALL);
694 return 0; 691 return 0;
695} 692}
696#pragma GCC diagnostic pop
697 693
698 694
699/* 695/*
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 5eadfffabe35..4794d6b4f4d2 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -600,9 +600,6 @@ static void nmi_stop_this_cpu(struct pt_regs *regs)
600 nmi_ipi_busy_count--; 600 nmi_ipi_busy_count--;
601 nmi_ipi_unlock(); 601 nmi_ipi_unlock();
602 602
603 /* Remove this CPU */
604 set_cpu_online(smp_processor_id(), false);
605
606 spin_begin(); 603 spin_begin();
607 while (1) 604 while (1)
608 spin_cpu_relax(); 605 spin_cpu_relax();
@@ -617,9 +614,6 @@ void smp_send_stop(void)
617 614
618static void stop_this_cpu(void *dummy) 615static void stop_this_cpu(void *dummy)
619{ 616{
620 /* Remove this CPU */
621 set_cpu_online(smp_processor_id(), false);
622
623 hard_irq_disable(); 617 hard_irq_disable();
624 spin_begin(); 618 spin_begin();
625 while (1) 619 while (1)
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 07e97f289c52..e2c50b55138f 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -196,7 +196,7 @@ save_stack_trace_tsk_reliable(struct task_struct *tsk,
196EXPORT_SYMBOL_GPL(save_stack_trace_tsk_reliable); 196EXPORT_SYMBOL_GPL(save_stack_trace_tsk_reliable);
197#endif /* CONFIG_HAVE_RELIABLE_STACKTRACE */ 197#endif /* CONFIG_HAVE_RELIABLE_STACKTRACE */
198 198
199#ifdef CONFIG_PPC_BOOK3S_64 199#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_NMI_IPI)
200static void handle_backtrace_ipi(struct pt_regs *regs) 200static void handle_backtrace_ipi(struct pt_regs *regs)
201{ 201{
202 nmi_cpu_backtrace(regs); 202 nmi_cpu_backtrace(regs);
@@ -242,4 +242,4 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
242{ 242{
243 nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace_ipi); 243 nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace_ipi);
244} 244}
245#endif /* CONFIG_PPC64 */ 245#endif /* defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_NMI_IPI) */
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index 083fa06962fd..466216506eb2 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -62,9 +62,6 @@ out:
62 return ret; 62 return ret;
63} 63}
64 64
65#pragma GCC diagnostic push
66#pragma GCC diagnostic ignored "-Wpragmas"
67#pragma GCC diagnostic ignored "-Wattribute-alias"
68SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len, 65SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
69 unsigned long, prot, unsigned long, flags, 66 unsigned long, prot, unsigned long, flags,
70 unsigned long, fd, unsigned long, pgoff) 67 unsigned long, fd, unsigned long, pgoff)
@@ -78,7 +75,6 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
78{ 75{
79 return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT); 76 return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT);
80} 77}
81#pragma GCC diagnostic pop
82 78
83#ifdef CONFIG_PPC32 79#ifdef CONFIG_PPC32
84/* 80/*
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 7c5f479c5c00..8a9a49c13865 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -337,7 +337,8 @@ static void free_hugepd_range(struct mmu_gather *tlb, hugepd_t *hpdp, int pdshif
337 if (shift >= pdshift) 337 if (shift >= pdshift)
338 hugepd_free(tlb, hugepte); 338 hugepd_free(tlb, hugepte);
339 else 339 else
340 pgtable_free_tlb(tlb, hugepte, pdshift - shift); 340 pgtable_free_tlb(tlb, hugepte,
341 get_hugepd_cache_index(pdshift - shift));
341} 342}
342 343
343static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud, 344static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
diff --git a/arch/powerpc/mm/pgtable-book3s64.c b/arch/powerpc/mm/pgtable-book3s64.c
index c1f4ca45c93a..4afbfbb64bfd 100644
--- a/arch/powerpc/mm/pgtable-book3s64.c
+++ b/arch/powerpc/mm/pgtable-book3s64.c
@@ -409,6 +409,18 @@ static inline void pgtable_free(void *table, int index)
409 case PUD_INDEX: 409 case PUD_INDEX:
410 kmem_cache_free(PGT_CACHE(PUD_CACHE_INDEX), table); 410 kmem_cache_free(PGT_CACHE(PUD_CACHE_INDEX), table);
411 break; 411 break;
412#if defined(CONFIG_PPC_4K_PAGES) && defined(CONFIG_HUGETLB_PAGE)
413 /* 16M hugepd directory at pud level */
414 case HTLB_16M_INDEX:
415 BUILD_BUG_ON(H_16M_CACHE_INDEX <= 0);
416 kmem_cache_free(PGT_CACHE(H_16M_CACHE_INDEX), table);
417 break;
418 /* 16G hugepd directory at the pgd level */
419 case HTLB_16G_INDEX:
420 BUILD_BUG_ON(H_16G_CACHE_INDEX <= 0);
421 kmem_cache_free(PGT_CACHE(H_16G_CACHE_INDEX), table);
422 break;
423#endif
412 /* We don't free pgd table via RCU callback */ 424 /* We don't free pgd table via RCU callback */
413 default: 425 default:
414 BUG(); 426 BUG();
diff --git a/arch/powerpc/mm/subpage-prot.c b/arch/powerpc/mm/subpage-prot.c
index 75cb646a79c3..9d16ee251fc0 100644
--- a/arch/powerpc/mm/subpage-prot.c
+++ b/arch/powerpc/mm/subpage-prot.c
@@ -186,9 +186,6 @@ static void subpage_mark_vma_nohuge(struct mm_struct *mm, unsigned long addr,
186 * in a 2-bit field won't allow writes to a page that is otherwise 186 * in a 2-bit field won't allow writes to a page that is otherwise
187 * write-protected. 187 * write-protected.
188 */ 188 */
189#pragma GCC diagnostic push
190#pragma GCC diagnostic ignored "-Wpragmas"
191#pragma GCC diagnostic ignored "-Wattribute-alias"
192SYSCALL_DEFINE3(subpage_prot, unsigned long, addr, 189SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
193 unsigned long, len, u32 __user *, map) 190 unsigned long, len, u32 __user *, map)
194{ 191{
@@ -272,4 +269,3 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
272 up_write(&mm->mmap_sem); 269 up_write(&mm->mmap_sem);
273 return err; 270 return err;
274} 271}
275#pragma GCC diagnostic pop
diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
index 67a6e86d3e7e..1135b43a597c 100644
--- a/arch/powerpc/mm/tlb-radix.c
+++ b/arch/powerpc/mm/tlb-radix.c
@@ -689,22 +689,17 @@ EXPORT_SYMBOL(radix__flush_tlb_kernel_range);
689static unsigned long tlb_single_page_flush_ceiling __read_mostly = 33; 689static unsigned long tlb_single_page_flush_ceiling __read_mostly = 33;
690static unsigned long tlb_local_single_page_flush_ceiling __read_mostly = POWER9_TLB_SETS_RADIX * 2; 690static unsigned long tlb_local_single_page_flush_ceiling __read_mostly = POWER9_TLB_SETS_RADIX * 2;
691 691
692void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start, 692static inline void __radix__flush_tlb_range(struct mm_struct *mm,
693 unsigned long end) 693 unsigned long start, unsigned long end,
694 bool flush_all_sizes)
694 695
695{ 696{
696 struct mm_struct *mm = vma->vm_mm;
697 unsigned long pid; 697 unsigned long pid;
698 unsigned int page_shift = mmu_psize_defs[mmu_virtual_psize].shift; 698 unsigned int page_shift = mmu_psize_defs[mmu_virtual_psize].shift;
699 unsigned long page_size = 1UL << page_shift; 699 unsigned long page_size = 1UL << page_shift;
700 unsigned long nr_pages = (end - start) >> page_shift; 700 unsigned long nr_pages = (end - start) >> page_shift;
701 bool local, full; 701 bool local, full;
702 702
703#ifdef CONFIG_HUGETLB_PAGE
704 if (is_vm_hugetlb_page(vma))
705 return radix__flush_hugetlb_tlb_range(vma, start, end);
706#endif
707
708 pid = mm->context.id; 703 pid = mm->context.id;
709 if (unlikely(pid == MMU_NO_CONTEXT)) 704 if (unlikely(pid == MMU_NO_CONTEXT))
710 return; 705 return;
@@ -738,37 +733,64 @@ is_local:
738 _tlbie_pid(pid, RIC_FLUSH_TLB); 733 _tlbie_pid(pid, RIC_FLUSH_TLB);
739 } 734 }
740 } else { 735 } else {
741 bool hflush = false; 736 bool hflush = flush_all_sizes;
737 bool gflush = flush_all_sizes;
742 unsigned long hstart, hend; 738 unsigned long hstart, hend;
739 unsigned long gstart, gend;
743 740
744#ifdef CONFIG_TRANSPARENT_HUGEPAGE 741 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
745 hstart = (start + HPAGE_PMD_SIZE - 1) >> HPAGE_PMD_SHIFT;
746 hend = end >> HPAGE_PMD_SHIFT;
747 if (hstart < hend) {
748 hstart <<= HPAGE_PMD_SHIFT;
749 hend <<= HPAGE_PMD_SHIFT;
750 hflush = true; 742 hflush = true;
743
744 if (hflush) {
745 hstart = (start + PMD_SIZE - 1) & PMD_MASK;
746 hend = end & PMD_MASK;
747 if (hstart == hend)
748 hflush = false;
749 }
750
751 if (gflush) {
752 gstart = (start + PUD_SIZE - 1) & PUD_MASK;
753 gend = end & PUD_MASK;
754 if (gstart == gend)
755 gflush = false;
751 } 756 }
752#endif
753 757
754 asm volatile("ptesync": : :"memory"); 758 asm volatile("ptesync": : :"memory");
755 if (local) { 759 if (local) {
756 __tlbiel_va_range(start, end, pid, page_size, mmu_virtual_psize); 760 __tlbiel_va_range(start, end, pid, page_size, mmu_virtual_psize);
757 if (hflush) 761 if (hflush)
758 __tlbiel_va_range(hstart, hend, pid, 762 __tlbiel_va_range(hstart, hend, pid,
759 HPAGE_PMD_SIZE, MMU_PAGE_2M); 763 PMD_SIZE, MMU_PAGE_2M);
764 if (gflush)
765 __tlbiel_va_range(gstart, gend, pid,
766 PUD_SIZE, MMU_PAGE_1G);
760 asm volatile("ptesync": : :"memory"); 767 asm volatile("ptesync": : :"memory");
761 } else { 768 } else {
762 __tlbie_va_range(start, end, pid, page_size, mmu_virtual_psize); 769 __tlbie_va_range(start, end, pid, page_size, mmu_virtual_psize);
763 if (hflush) 770 if (hflush)
764 __tlbie_va_range(hstart, hend, pid, 771 __tlbie_va_range(hstart, hend, pid,
765 HPAGE_PMD_SIZE, MMU_PAGE_2M); 772 PMD_SIZE, MMU_PAGE_2M);
773 if (gflush)
774 __tlbie_va_range(gstart, gend, pid,
775 PUD_SIZE, MMU_PAGE_1G);
766 fixup_tlbie(); 776 fixup_tlbie();
767 asm volatile("eieio; tlbsync; ptesync": : :"memory"); 777 asm volatile("eieio; tlbsync; ptesync": : :"memory");
768 } 778 }
769 } 779 }
770 preempt_enable(); 780 preempt_enable();
771} 781}
782
783void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
784 unsigned long end)
785
786{
787#ifdef CONFIG_HUGETLB_PAGE
788 if (is_vm_hugetlb_page(vma))
789 return radix__flush_hugetlb_tlb_range(vma, start, end);
790#endif
791
792 __radix__flush_tlb_range(vma->vm_mm, start, end, false);
793}
772EXPORT_SYMBOL(radix__flush_tlb_range); 794EXPORT_SYMBOL(radix__flush_tlb_range);
773 795
774static int radix_get_mmu_psize(int page_size) 796static int radix_get_mmu_psize(int page_size)
@@ -837,6 +859,8 @@ void radix__tlb_flush(struct mmu_gather *tlb)
837 int psize = 0; 859 int psize = 0;
838 struct mm_struct *mm = tlb->mm; 860 struct mm_struct *mm = tlb->mm;
839 int page_size = tlb->page_size; 861 int page_size = tlb->page_size;
862 unsigned long start = tlb->start;
863 unsigned long end = tlb->end;
840 864
841 /* 865 /*
842 * if page size is not something we understand, do a full mm flush 866 * if page size is not something we understand, do a full mm flush
@@ -847,15 +871,45 @@ void radix__tlb_flush(struct mmu_gather *tlb)
847 */ 871 */
848 if (tlb->fullmm) { 872 if (tlb->fullmm) {
849 __flush_all_mm(mm, true); 873 __flush_all_mm(mm, true);
874#if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLB_PAGE)
875 } else if (mm_tlb_flush_nested(mm)) {
876 /*
877 * If there is a concurrent invalidation that is clearing ptes,
878 * then it's possible this invalidation will miss one of those
879 * cleared ptes and miss flushing the TLB. If this invalidate
880 * returns before the other one flushes TLBs, that can result
881 * in it returning while there are still valid TLBs inside the
882 * range to be invalidated.
883 *
884 * See mm/memory.c:tlb_finish_mmu() for more details.
885 *
886 * The solution to this is ensure the entire range is always
887 * flushed here. The problem for powerpc is that the flushes
888 * are page size specific, so this "forced flush" would not
889 * do the right thing if there are a mix of page sizes in
890 * the range to be invalidated. So use __flush_tlb_range
891 * which invalidates all possible page sizes in the range.
892 *
893 * PWC flush probably is not be required because the core code
894 * shouldn't free page tables in this path, but accounting
895 * for the possibility makes us a bit more robust.
896 *
897 * need_flush_all is an uncommon case because page table
898 * teardown should be done with exclusive locks held (but
899 * after locks are dropped another invalidate could come
900 * in), it could be optimized further if necessary.
901 */
902 if (!tlb->need_flush_all)
903 __radix__flush_tlb_range(mm, start, end, true);
904 else
905 radix__flush_all_mm(mm);
906#endif
850 } else if ( (psize = radix_get_mmu_psize(page_size)) == -1) { 907 } else if ( (psize = radix_get_mmu_psize(page_size)) == -1) {
851 if (!tlb->need_flush_all) 908 if (!tlb->need_flush_all)
852 radix__flush_tlb_mm(mm); 909 radix__flush_tlb_mm(mm);
853 else 910 else
854 radix__flush_all_mm(mm); 911 radix__flush_all_mm(mm);
855 } else { 912 } else {
856 unsigned long start = tlb->start;
857 unsigned long end = tlb->end;
858
859 if (!tlb->need_flush_all) 913 if (!tlb->need_flush_all)
860 radix__flush_tlb_range_psize(mm, start, end, psize); 914 radix__flush_tlb_range_psize(mm, start, end, psize);
861 else 915 else
@@ -1043,6 +1097,8 @@ extern void radix_kvm_prefetch_workaround(struct mm_struct *mm)
1043 for (; sib <= cpu_last_thread_sibling(cpu) && !flush; sib++) { 1097 for (; sib <= cpu_last_thread_sibling(cpu) && !flush; sib++) {
1044 if (sib == cpu) 1098 if (sib == cpu)
1045 continue; 1099 continue;
1100 if (!cpu_possible(sib))
1101 continue;
1046 if (paca_ptrs[sib]->kvm_hstate.kvm_vcpu) 1102 if (paca_ptrs[sib]->kvm_hstate.kvm_vcpu)
1047 flush = true; 1103 flush = true;
1048 } 1104 }
diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c
index 7c968e46736f..12e6e4d30602 100644
--- a/arch/powerpc/platforms/powermac/time.c
+++ b/arch/powerpc/platforms/powermac/time.c
@@ -42,7 +42,11 @@
42#define DBG(x...) 42#define DBG(x...)
43#endif 43#endif
44 44
45/* Apparently the RTC stores seconds since 1 Jan 1904 */ 45/*
46 * Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and PMU
47 * times wrap in 2040. If we need to handle later times, the read_time functions
48 * need to be changed to interpret wrapped times as post-2040.
49 */
46#define RTC_OFFSET 2082844800 50#define RTC_OFFSET 2082844800
47 51
48/* 52/*
@@ -97,8 +101,11 @@ static time64_t cuda_get_time(void)
97 if (req.reply_len != 7) 101 if (req.reply_len != 7)
98 printk(KERN_ERR "cuda_get_time: got %d byte reply\n", 102 printk(KERN_ERR "cuda_get_time: got %d byte reply\n",
99 req.reply_len); 103 req.reply_len);
100 now = (req.reply[3] << 24) + (req.reply[4] << 16) 104 now = (u32)((req.reply[3] << 24) + (req.reply[4] << 16) +
101 + (req.reply[5] << 8) + req.reply[6]; 105 (req.reply[5] << 8) + req.reply[6]);
106 /* it's either after year 2040, or the RTC has gone backwards */
107 WARN_ON(now < RTC_OFFSET);
108
102 return now - RTC_OFFSET; 109 return now - RTC_OFFSET;
103} 110}
104 111
@@ -106,10 +113,10 @@ static time64_t cuda_get_time(void)
106 113
107static int cuda_set_rtc_time(struct rtc_time *tm) 114static int cuda_set_rtc_time(struct rtc_time *tm)
108{ 115{
109 time64_t nowtime; 116 u32 nowtime;
110 struct adb_request req; 117 struct adb_request req;
111 118
112 nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET; 119 nowtime = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
113 if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME, 120 if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
114 nowtime >> 24, nowtime >> 16, nowtime >> 8, 121 nowtime >> 24, nowtime >> 16, nowtime >> 8,
115 nowtime) < 0) 122 nowtime) < 0)
@@ -140,8 +147,12 @@ static time64_t pmu_get_time(void)
140 if (req.reply_len != 4) 147 if (req.reply_len != 4)
141 printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n", 148 printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n",
142 req.reply_len); 149 req.reply_len);
143 now = (req.reply[0] << 24) + (req.reply[1] << 16) 150 now = (u32)((req.reply[0] << 24) + (req.reply[1] << 16) +
144 + (req.reply[2] << 8) + req.reply[3]; 151 (req.reply[2] << 8) + req.reply[3]);
152
153 /* it's either after year 2040, or the RTC has gone backwards */
154 WARN_ON(now < RTC_OFFSET);
155
145 return now - RTC_OFFSET; 156 return now - RTC_OFFSET;
146} 157}
147 158
@@ -149,10 +160,10 @@ static time64_t pmu_get_time(void)
149 160
150static int pmu_set_rtc_time(struct rtc_time *tm) 161static int pmu_set_rtc_time(struct rtc_time *tm)
151{ 162{
152 time64_t nowtime; 163 u32 nowtime;
153 struct adb_request req; 164 struct adb_request req;
154 165
155 nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET; 166 nowtime = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
156 if (pmu_request(&req, NULL, 5, PMU_SET_RTC, nowtime >> 24, 167 if (pmu_request(&req, NULL, 5, PMU_SET_RTC, nowtime >> 24,
157 nowtime >> 16, nowtime >> 8, nowtime) < 0) 168 nowtime >> 16, nowtime >> 8, nowtime) < 0)
158 return -ENXIO; 169 return -ENXIO;
diff --git a/arch/s390/include/asm/css_chars.h b/arch/s390/include/asm/css_chars.h
index 0563fd3e8458..480bb02ccacd 100644
--- a/arch/s390/include/asm/css_chars.h
+++ b/arch/s390/include/asm/css_chars.h
@@ -6,36 +6,38 @@
6 6
7struct css_general_char { 7struct css_general_char {
8 u64 : 12; 8 u64 : 12;
9 u32 dynio : 1; /* bit 12 */ 9 u64 dynio : 1; /* bit 12 */
10 u32 : 4; 10 u64 : 4;
11 u32 eadm : 1; /* bit 17 */ 11 u64 eadm : 1; /* bit 17 */
12 u32 : 23; 12 u64 : 23;
13 u32 aif : 1; /* bit 41 */ 13 u64 aif : 1; /* bit 41 */
14 u32 : 3; 14 u64 : 3;
15 u32 mcss : 1; /* bit 45 */ 15 u64 mcss : 1; /* bit 45 */
16 u32 fcs : 1; /* bit 46 */ 16 u64 fcs : 1; /* bit 46 */
17 u32 : 1; 17 u64 : 1;
18 u32 ext_mb : 1; /* bit 48 */ 18 u64 ext_mb : 1; /* bit 48 */
19 u32 : 7; 19 u64 : 7;
20 u32 aif_tdd : 1; /* bit 56 */ 20 u64 aif_tdd : 1; /* bit 56 */
21 u32 : 1; 21 u64 : 1;
22 u32 qebsm : 1; /* bit 58 */ 22 u64 qebsm : 1; /* bit 58 */
23 u32 : 2; 23 u64 : 2;
24 u32 aiv : 1; /* bit 61 */ 24 u64 aiv : 1; /* bit 61 */
25 u32 : 5; 25 u64 : 2;
26 u32 aif_osa : 1; /* bit 67 */ 26
27 u32 : 12; 27 u64 : 3;
28 u32 eadm_rf : 1; /* bit 80 */ 28 u64 aif_osa : 1; /* bit 67 */
29 u32 : 1; 29 u64 : 12;
30 u32 cib : 1; /* bit 82 */ 30 u64 eadm_rf : 1; /* bit 80 */
31 u32 : 5; 31 u64 : 1;
32 u32 fcx : 1; /* bit 88 */ 32 u64 cib : 1; /* bit 82 */
33 u32 : 19; 33 u64 : 5;
34 u32 alt_ssi : 1; /* bit 108 */ 34 u64 fcx : 1; /* bit 88 */
35 u32 : 1; 35 u64 : 19;
36 u32 narf : 1; /* bit 110 */ 36 u64 alt_ssi : 1; /* bit 108 */
37 u32 : 12; 37 u64 : 1;
38 u32 util_str : 1;/* bit 123 */ 38 u64 narf : 1; /* bit 110 */
39 u64 : 12;
40 u64 util_str : 1;/* bit 123 */
39} __packed; 41} __packed;
40 42
41extern struct css_general_char css_general_characteristics; 43extern struct css_general_char css_general_characteristics;
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index f0a6ea22429d..a08e82856563 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -258,11 +258,6 @@ archscripts: scripts_basic
258archheaders: 258archheaders:
259 $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all 259 $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
260 260
261archprepare:
262ifeq ($(CONFIG_KEXEC_FILE),y)
263 $(Q)$(MAKE) $(build)=arch/x86/purgatory arch/x86/purgatory/kexec-purgatory.c
264endif
265
266### 261###
267# Kernel objects 262# Kernel objects
268 263
@@ -327,7 +322,6 @@ archclean:
327 $(Q)rm -rf $(objtree)/arch/x86_64 322 $(Q)rm -rf $(objtree)/arch/x86_64
328 $(Q)$(MAKE) $(clean)=$(boot) 323 $(Q)$(MAKE) $(clean)=$(boot)
329 $(Q)$(MAKE) $(clean)=arch/x86/tools 324 $(Q)$(MAKE) $(clean)=arch/x86/tools
330 $(Q)$(MAKE) $(clean)=arch/x86/purgatory
331 325
332define archhelp 326define archhelp
333 echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)' 327 echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)'
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index a8a8642d2b0b..e57665b4ba1c 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -118,7 +118,7 @@ __setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
118 void *romimage; 118 void *romimage;
119 119
120 status = efi_call_proto(efi_pci_io_protocol, attributes, pci, 120 status = efi_call_proto(efi_pci_io_protocol, attributes, pci,
121 EfiPciIoAttributeOperationGet, 0, 0, 121 EfiPciIoAttributeOperationGet, 0ULL,
122 &attributes); 122 &attributes);
123 if (status != EFI_SUCCESS) 123 if (status != EFI_SUCCESS)
124 return status; 124 return status;
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 92190879b228..3b2490b81918 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -164,7 +164,7 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags)
164 if (cached_flags & _TIF_NOTIFY_RESUME) { 164 if (cached_flags & _TIF_NOTIFY_RESUME) {
165 clear_thread_flag(TIF_NOTIFY_RESUME); 165 clear_thread_flag(TIF_NOTIFY_RESUME);
166 tracehook_notify_resume(regs); 166 tracehook_notify_resume(regs);
167 rseq_handle_notify_resume(regs); 167 rseq_handle_notify_resume(NULL, regs);
168 } 168 }
169 169
170 if (cached_flags & _TIF_USER_RETURN_NOTIFY) 170 if (cached_flags & _TIF_USER_RETURN_NOTIFY)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 2582881d19ce..c371bfee137a 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -477,7 +477,7 @@ ENTRY(entry_SYSENTER_32)
477 * whereas POPF does not.) 477 * whereas POPF does not.)
478 */ 478 */
479 addl $PT_EFLAGS-PT_DS, %esp /* point esp at pt_regs->flags */ 479 addl $PT_EFLAGS-PT_DS, %esp /* point esp at pt_regs->flags */
480 btr $X86_EFLAGS_IF_BIT, (%esp) 480 btrl $X86_EFLAGS_IF_BIT, (%esp)
481 popfl 481 popfl
482 482
483 /* 483 /*
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 9de7f1e1dede..7d0df78db727 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -84,13 +84,13 @@ ENTRY(entry_SYSENTER_compat)
84 pushq %rdx /* pt_regs->dx */ 84 pushq %rdx /* pt_regs->dx */
85 pushq %rcx /* pt_regs->cx */ 85 pushq %rcx /* pt_regs->cx */
86 pushq $-ENOSYS /* pt_regs->ax */ 86 pushq $-ENOSYS /* pt_regs->ax */
87 pushq %r8 /* pt_regs->r8 */ 87 pushq $0 /* pt_regs->r8 = 0 */
88 xorl %r8d, %r8d /* nospec r8 */ 88 xorl %r8d, %r8d /* nospec r8 */
89 pushq %r9 /* pt_regs->r9 */ 89 pushq $0 /* pt_regs->r9 = 0 */
90 xorl %r9d, %r9d /* nospec r9 */ 90 xorl %r9d, %r9d /* nospec r9 */
91 pushq %r10 /* pt_regs->r10 */ 91 pushq $0 /* pt_regs->r10 = 0 */
92 xorl %r10d, %r10d /* nospec r10 */ 92 xorl %r10d, %r10d /* nospec r10 */
93 pushq %r11 /* pt_regs->r11 */ 93 pushq $0 /* pt_regs->r11 = 0 */
94 xorl %r11d, %r11d /* nospec r11 */ 94 xorl %r11d, %r11d /* nospec r11 */
95 pushq %rbx /* pt_regs->rbx */ 95 pushq %rbx /* pt_regs->rbx */
96 xorl %ebx, %ebx /* nospec rbx */ 96 xorl %ebx, %ebx /* nospec rbx */
@@ -374,13 +374,13 @@ ENTRY(entry_INT80_compat)
374 pushq %rcx /* pt_regs->cx */ 374 pushq %rcx /* pt_regs->cx */
375 xorl %ecx, %ecx /* nospec cx */ 375 xorl %ecx, %ecx /* nospec cx */
376 pushq $-ENOSYS /* pt_regs->ax */ 376 pushq $-ENOSYS /* pt_regs->ax */
377 pushq $0 /* pt_regs->r8 = 0 */ 377 pushq %r8 /* pt_regs->r8 */
378 xorl %r8d, %r8d /* nospec r8 */ 378 xorl %r8d, %r8d /* nospec r8 */
379 pushq $0 /* pt_regs->r9 = 0 */ 379 pushq %r9 /* pt_regs->r9 */
380 xorl %r9d, %r9d /* nospec r9 */ 380 xorl %r9d, %r9d /* nospec r9 */
381 pushq $0 /* pt_regs->r10 = 0 */ 381 pushq %r10 /* pt_regs->r10*/
382 xorl %r10d, %r10d /* nospec r10 */ 382 xorl %r10d, %r10d /* nospec r10 */
383 pushq $0 /* pt_regs->r11 = 0 */ 383 pushq %r11 /* pt_regs->r11 */
384 xorl %r11d, %r11d /* nospec r11 */ 384 xorl %r11d, %r11d /* nospec r11 */
385 pushq %rbx /* pt_regs->rbx */ 385 pushq %rbx /* pt_regs->rbx */
386 xorl %ebx, %ebx /* nospec rbx */ 386 xorl %ebx, %ebx /* nospec rbx */
diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index 042b5e892ed1..14de0432d288 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -38,7 +38,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
38{ 38{
39 unsigned long mask; 39 unsigned long mask;
40 40
41 asm ("cmp %1,%2; sbb %0,%0;" 41 asm volatile ("cmp %1,%2; sbb %0,%0;"
42 :"=r" (mask) 42 :"=r" (mask)
43 :"g"(size),"r" (index) 43 :"g"(size),"r" (index)
44 :"cc"); 44 :"cc");
diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index ada6410fd2ec..fbd578daa66e 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
184 184
185static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) 185static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
186{ 186{
187 if (!pgtable_l5_enabled())
188 return;
189
187 BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); 190 BUG_ON((unsigned long)p4d & (PAGE_SIZE-1));
188 free_page((unsigned long)p4d); 191 free_page((unsigned long)p4d);
189} 192}
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 99ecde23c3ec..5715647fc4fe 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -898,7 +898,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
898#define pgd_page(pgd) pfn_to_page(pgd_pfn(pgd)) 898#define pgd_page(pgd) pfn_to_page(pgd_pfn(pgd))
899 899
900/* to find an entry in a page-table-directory. */ 900/* to find an entry in a page-table-directory. */
901static __always_inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address) 901static inline p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
902{ 902{
903 if (!pgtable_l5_enabled()) 903 if (!pgtable_l5_enabled())
904 return (p4d_t *)pgd; 904 return (p4d_t *)pgd;
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 0fdcd21dadbd..3c5385f9a88f 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -216,7 +216,7 @@ static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
216} 216}
217#endif 217#endif
218 218
219static __always_inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d) 219static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
220{ 220{
221 pgd_t pgd; 221 pgd_t pgd;
222 222
@@ -230,7 +230,7 @@ static __always_inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
230 *p4dp = native_make_p4d(native_pgd_val(pgd)); 230 *p4dp = native_make_p4d(native_pgd_val(pgd));
231} 231}
232 232
233static __always_inline void native_p4d_clear(p4d_t *p4d) 233static inline void native_p4d_clear(p4d_t *p4d)
234{ 234{
235 native_set_p4d(p4d, native_make_p4d(0)); 235 native_set_p4d(p4d, native_make_p4d(0));
236} 236}
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 425e6b8b9547..6aa8499e1f62 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -114,6 +114,7 @@
114#define VMX_MISC_PREEMPTION_TIMER_RATE_MASK 0x0000001f 114#define VMX_MISC_PREEMPTION_TIMER_RATE_MASK 0x0000001f
115#define VMX_MISC_SAVE_EFER_LMA 0x00000020 115#define VMX_MISC_SAVE_EFER_LMA 0x00000020
116#define VMX_MISC_ACTIVITY_HLT 0x00000040 116#define VMX_MISC_ACTIVITY_HLT 0x00000040
117#define VMX_MISC_ZERO_LEN_INS 0x40000000
117 118
118/* VMFUNC functions */ 119/* VMFUNC functions */
119#define VMX_VMFUNC_EPTP_SWITCHING 0x00000001 120#define VMX_VMFUNC_EPTP_SWITCHING 0x00000001
@@ -351,11 +352,13 @@ enum vmcs_field {
351#define VECTORING_INFO_VALID_MASK INTR_INFO_VALID_MASK 352#define VECTORING_INFO_VALID_MASK INTR_INFO_VALID_MASK
352 353
353#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */ 354#define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */
355#define INTR_TYPE_RESERVED (1 << 8) /* reserved */
354#define INTR_TYPE_NMI_INTR (2 << 8) /* NMI */ 356#define INTR_TYPE_NMI_INTR (2 << 8) /* NMI */
355#define INTR_TYPE_HARD_EXCEPTION (3 << 8) /* processor exception */ 357#define INTR_TYPE_HARD_EXCEPTION (3 << 8) /* processor exception */
356#define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */ 358#define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */
357#define INTR_TYPE_PRIV_SW_EXCEPTION (5 << 8) /* ICE breakpoint - undocumented */ 359#define INTR_TYPE_PRIV_SW_EXCEPTION (5 << 8) /* ICE breakpoint - undocumented */
358#define INTR_TYPE_SOFT_EXCEPTION (6 << 8) /* software exception */ 360#define INTR_TYPE_SOFT_EXCEPTION (6 << 8) /* software exception */
361#define INTR_TYPE_OTHER_EVENT (7 << 8) /* other event */
359 362
360/* GUEST_INTERRUPTIBILITY_INFO flags. */ 363/* GUEST_INTERRUPTIBILITY_INFO flags. */
361#define GUEST_INTR_STATE_STI 0x00000001 364#define GUEST_INTR_STATE_STI 0x00000001
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index efaf2d4f9c3c..d492752f79e1 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -26,6 +26,7 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/crash_dump.h> 27#include <linux/crash_dump.h>
28#include <linux/reboot.h> 28#include <linux/reboot.h>
29#include <linux/memory.h>
29 30
30#include <asm/uv/uv_mmrs.h> 31#include <asm/uv/uv_mmrs.h>
31#include <asm/uv/uv_hub.h> 32#include <asm/uv/uv_hub.h>
@@ -392,6 +393,51 @@ extern int uv_hub_info_version(void)
392} 393}
393EXPORT_SYMBOL(uv_hub_info_version); 394EXPORT_SYMBOL(uv_hub_info_version);
394 395
396/* Default UV memory block size is 2GB */
397static unsigned long mem_block_size = (2UL << 30);
398
399/* Kernel parameter to specify UV mem block size */
400static int parse_mem_block_size(char *ptr)
401{
402 unsigned long size = memparse(ptr, NULL);
403
404 /* Size will be rounded down by set_block_size() below */
405 mem_block_size = size;
406 return 0;
407}
408early_param("uv_memblksize", parse_mem_block_size);
409
410static __init int adj_blksize(u32 lgre)
411{
412 unsigned long base = (unsigned long)lgre << UV_GAM_RANGE_SHFT;
413 unsigned long size;
414
415 for (size = mem_block_size; size > MIN_MEMORY_BLOCK_SIZE; size >>= 1)
416 if (IS_ALIGNED(base, size))
417 break;
418
419 if (size >= mem_block_size)
420 return 0;
421
422 mem_block_size = size;
423 return 1;
424}
425
426static __init void set_block_size(void)
427{
428 unsigned int order = ffs(mem_block_size);
429
430 if (order) {
431 /* adjust for ffs return of 1..64 */
432 set_memory_block_size_order(order - 1);
433 pr_info("UV: mem_block_size set to 0x%lx\n", mem_block_size);
434 } else {
435 /* bad or zero value, default to 1UL << 31 (2GB) */
436 pr_err("UV: mem_block_size error with 0x%lx\n", mem_block_size);
437 set_memory_block_size_order(31);
438 }
439}
440
395/* Build GAM range lookup table: */ 441/* Build GAM range lookup table: */
396static __init void build_uv_gr_table(void) 442static __init void build_uv_gr_table(void)
397{ 443{
@@ -1180,23 +1226,30 @@ static void __init decode_gam_rng_tbl(unsigned long ptr)
1180 << UV_GAM_RANGE_SHFT); 1226 << UV_GAM_RANGE_SHFT);
1181 int order = 0; 1227 int order = 0;
1182 char suffix[] = " KMGTPE"; 1228 char suffix[] = " KMGTPE";
1229 int flag = ' ';
1183 1230
1184 while (size > 9999 && order < sizeof(suffix)) { 1231 while (size > 9999 && order < sizeof(suffix)) {
1185 size /= 1024; 1232 size /= 1024;
1186 order++; 1233 order++;
1187 } 1234 }
1188 1235
1236 /* adjust max block size to current range start */
1237 if (gre->type == 1 || gre->type == 2)
1238 if (adj_blksize(lgre))
1239 flag = '*';
1240
1189 if (!index) { 1241 if (!index) {
1190 pr_info("UV: GAM Range Table...\n"); 1242 pr_info("UV: GAM Range Table...\n");
1191 pr_info("UV: # %20s %14s %5s %4s %5s %3s %2s\n", "Range", "", "Size", "Type", "NASID", "SID", "PN"); 1243 pr_info("UV: # %20s %14s %6s %4s %5s %3s %2s\n", "Range", "", "Size", "Type", "NASID", "SID", "PN");
1192 } 1244 }
1193 pr_info("UV: %2d: 0x%014lx-0x%014lx %5lu%c %3d %04x %02x %02x\n", 1245 pr_info("UV: %2d: 0x%014lx-0x%014lx%c %5lu%c %3d %04x %02x %02x\n",
1194 index++, 1246 index++,
1195 (unsigned long)lgre << UV_GAM_RANGE_SHFT, 1247 (unsigned long)lgre << UV_GAM_RANGE_SHFT,
1196 (unsigned long)gre->limit << UV_GAM_RANGE_SHFT, 1248 (unsigned long)gre->limit << UV_GAM_RANGE_SHFT,
1197 size, suffix[order], 1249 flag, size, suffix[order],
1198 gre->type, gre->nasid, gre->sockid, gre->pnode); 1250 gre->type, gre->nasid, gre->sockid, gre->pnode);
1199 1251
1252 /* update to next range start */
1200 lgre = gre->limit; 1253 lgre = gre->limit;
1201 if (sock_min > gre->sockid) 1254 if (sock_min > gre->sockid)
1202 sock_min = gre->sockid; 1255 sock_min = gre->sockid;
@@ -1427,6 +1480,7 @@ static void __init uv_system_init_hub(void)
1427 1480
1428 build_socket_tables(); 1481 build_socket_tables();
1429 build_uv_gr_table(); 1482 build_uv_gr_table();
1483 set_block_size();
1430 uv_init_hub_info(&hub_info); 1484 uv_init_hub_info(&hub_info);
1431 uv_possible_blades = num_possible_nodes(); 1485 uv_possible_blades = num_possible_nodes();
1432 if (!_node_to_pnode) 1486 if (!_node_to_pnode)
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index cd0fda1fff6d..404df26b7de8 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -27,6 +27,7 @@
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/set_memory.h> 28#include <asm/set_memory.h>
29#include <asm/intel-family.h> 29#include <asm/intel-family.h>
30#include <asm/hypervisor.h>
30 31
31static void __init spectre_v2_select_mitigation(void); 32static void __init spectre_v2_select_mitigation(void);
32static void __init ssb_select_mitigation(void); 33static void __init ssb_select_mitigation(void);
@@ -664,6 +665,9 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr
664 if (boot_cpu_has(X86_FEATURE_PTI)) 665 if (boot_cpu_has(X86_FEATURE_PTI))
665 return sprintf(buf, "Mitigation: PTI\n"); 666 return sprintf(buf, "Mitigation: PTI\n");
666 667
668 if (hypervisor_is_type(X86_HYPER_XEN_PV))
669 return sprintf(buf, "Unknown (XEN PV detected, hypervisor mitigation required)\n");
670
667 break; 671 break;
668 672
669 case X86_BUG_SPECTRE_V1: 673 case X86_BUG_SPECTRE_V1:
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index 38354c66df81..0c5fcbd998cf 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -671,7 +671,7 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, int cpu, u8 node_id)
671 num_sharing_cache = ((eax >> 14) & 0xfff) + 1; 671 num_sharing_cache = ((eax >> 14) & 0xfff) + 1;
672 672
673 if (num_sharing_cache) { 673 if (num_sharing_cache) {
674 int bits = get_count_order(num_sharing_cache) - 1; 674 int bits = get_count_order(num_sharing_cache);
675 675
676 per_cpu(cpu_llc_id, cpu) = c->apicid >> bits; 676 per_cpu(cpu_llc_id, cpu) = c->apicid >> bits;
677 } 677 }
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 0df7151cfef4..eb4cb3efd20e 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1,3 +1,6 @@
1/* cpu_feature_enabled() cannot be used this early */
2#define USE_EARLY_PGTABLE_L5
3
1#include <linux/bootmem.h> 4#include <linux/bootmem.h>
2#include <linux/linkage.h> 5#include <linux/linkage.h>
3#include <linux/bitops.h> 6#include <linux/bitops.h>
diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
index 5bbd06f38ff6..f34d89c01edc 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
@@ -160,6 +160,11 @@ static struct severity {
160 SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_INSTR), 160 SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_INSTR),
161 USER 161 USER
162 ), 162 ),
163 MCESEV(
164 PANIC, "Data load in unrecoverable area of kernel",
165 SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR|MCACOD_DATA),
166 KERNEL
167 ),
163#endif 168#endif
164 MCESEV( 169 MCESEV(
165 PANIC, "Action required: unknown MCACOD", 170 PANIC, "Action required: unknown MCACOD",
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index e4cf6ff1c2e1..c102ad51025e 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -772,23 +772,25 @@ EXPORT_SYMBOL_GPL(machine_check_poll);
772static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, 772static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp,
773 struct pt_regs *regs) 773 struct pt_regs *regs)
774{ 774{
775 int i, ret = 0;
776 char *tmp; 775 char *tmp;
776 int i;
777 777
778 for (i = 0; i < mca_cfg.banks; i++) { 778 for (i = 0; i < mca_cfg.banks; i++) {
779 m->status = mce_rdmsrl(msr_ops.status(i)); 779 m->status = mce_rdmsrl(msr_ops.status(i));
780 if (m->status & MCI_STATUS_VAL) { 780 if (!(m->status & MCI_STATUS_VAL))
781 __set_bit(i, validp); 781 continue;
782 if (quirk_no_way_out) 782
783 quirk_no_way_out(i, m, regs); 783 __set_bit(i, validp);
784 } 784 if (quirk_no_way_out)
785 quirk_no_way_out(i, m, regs);
785 786
786 if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) { 787 if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
788 mce_read_aux(m, i);
787 *msg = tmp; 789 *msg = tmp;
788 ret = 1; 790 return 1;
789 } 791 }
790 } 792 }
791 return ret; 793 return 0;
792} 794}
793 795
794/* 796/*
@@ -1205,13 +1207,18 @@ void do_machine_check(struct pt_regs *regs, long error_code)
1205 lmce = m.mcgstatus & MCG_STATUS_LMCES; 1207 lmce = m.mcgstatus & MCG_STATUS_LMCES;
1206 1208
1207 /* 1209 /*
1210 * Local machine check may already know that we have to panic.
1211 * Broadcast machine check begins rendezvous in mce_start()
1208 * Go through all banks in exclusion of the other CPUs. This way we 1212 * Go through all banks in exclusion of the other CPUs. This way we
1209 * don't report duplicated events on shared banks because the first one 1213 * don't report duplicated events on shared banks because the first one
1210 * to see it will clear it. If this is a Local MCE, then no need to 1214 * to see it will clear it.
1211 * perform rendezvous.
1212 */ 1215 */
1213 if (!lmce) 1216 if (lmce) {
1217 if (no_way_out)
1218 mce_panic("Fatal local machine check", &m, msg);
1219 } else {
1214 order = mce_start(&no_way_out); 1220 order = mce_start(&no_way_out);
1221 }
1215 1222
1216 for (i = 0; i < cfg->banks; i++) { 1223 for (i = 0; i < cfg->banks; i++) {
1217 __clear_bit(i, toclear); 1224 __clear_bit(i, toclear);
@@ -1287,12 +1294,17 @@ void do_machine_check(struct pt_regs *regs, long error_code)
1287 no_way_out = worst >= MCE_PANIC_SEVERITY; 1294 no_way_out = worst >= MCE_PANIC_SEVERITY;
1288 } else { 1295 } else {
1289 /* 1296 /*
1290 * Local MCE skipped calling mce_reign() 1297 * If there was a fatal machine check we should have
1291 * If we found a fatal error, we need to panic here. 1298 * already called mce_panic earlier in this function.
1299 * Since we re-read the banks, we might have found
1300 * something new. Check again to see if we found a
1301 * fatal error. We call "mce_severity()" again to
1302 * make sure we have the right "msg".
1292 */ 1303 */
1293 if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) 1304 if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) {
1294 mce_panic("Machine check from unknown source", 1305 mce_severity(&m, cfg->tolerant, &msg, true);
1295 NULL, NULL); 1306 mce_panic("Local fatal machine check!", &m, msg);
1307 }
1296 } 1308 }
1297 1309
1298 /* 1310 /*
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 1c2cfa0644aa..97ccf4c3b45b 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -190,8 +190,11 @@ static void save_microcode_patch(void *data, unsigned int size)
190 p = memdup_patch(data, size); 190 p = memdup_patch(data, size);
191 if (!p) 191 if (!p)
192 pr_err("Error allocating buffer %p\n", data); 192 pr_err("Error allocating buffer %p\n", data);
193 else 193 else {
194 list_replace(&iter->plist, &p->plist); 194 list_replace(&iter->plist, &p->plist);
195 kfree(iter->data);
196 kfree(iter);
197 }
195 } 198 }
196 } 199 }
197 200
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index d1f25c831447..c88c23c658c1 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1248,6 +1248,7 @@ void __init e820__memblock_setup(void)
1248{ 1248{
1249 int i; 1249 int i;
1250 u64 end; 1250 u64 end;
1251 u64 addr = 0;
1251 1252
1252 /* 1253 /*
1253 * The bootstrap memblock region count maximum is 128 entries 1254 * The bootstrap memblock region count maximum is 128 entries
@@ -1264,13 +1265,21 @@ void __init e820__memblock_setup(void)
1264 struct e820_entry *entry = &e820_table->entries[i]; 1265 struct e820_entry *entry = &e820_table->entries[i];
1265 1266
1266 end = entry->addr + entry->size; 1267 end = entry->addr + entry->size;
1268 if (addr < entry->addr)
1269 memblock_reserve(addr, entry->addr - addr);
1270 addr = end;
1267 if (end != (resource_size_t)end) 1271 if (end != (resource_size_t)end)
1268 continue; 1272 continue;
1269 1273
1274 /*
1275 * all !E820_TYPE_RAM ranges (including gap ranges) are put
1276 * into memblock.reserved to make sure that struct pages in
1277 * such regions are not left uninitialized after bootup.
1278 */
1270 if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN) 1279 if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
1271 continue; 1280 memblock_reserve(entry->addr, entry->size);
1272 1281 else
1273 memblock_add(entry->addr, entry->size); 1282 memblock_add(entry->addr, entry->size);
1274 } 1283 }
1275 1284
1276 /* Throw away partial pages: */ 1285 /* Throw away partial pages: */
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index a21d6ace648e..8047379e575a 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -44,7 +44,7 @@ static unsigned int __initdata next_early_pgt;
44pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); 44pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);
45 45
46#ifdef CONFIG_X86_5LEVEL 46#ifdef CONFIG_X86_5LEVEL
47unsigned int __pgtable_l5_enabled __initdata; 47unsigned int __pgtable_l5_enabled __ro_after_init;
48unsigned int pgdir_shift __ro_after_init = 39; 48unsigned int pgdir_shift __ro_after_init = 39;
49EXPORT_SYMBOL(pgdir_shift); 49EXPORT_SYMBOL(pgdir_shift);
50unsigned int ptrs_per_p4d __ro_after_init = 1; 50unsigned int ptrs_per_p4d __ro_after_init = 1;
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 697a4ce04308..736348ead421 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -645,12 +645,19 @@ static void quirk_intel_brickland_xeon_ras_cap(struct pci_dev *pdev)
645/* Skylake */ 645/* Skylake */
646static void quirk_intel_purley_xeon_ras_cap(struct pci_dev *pdev) 646static void quirk_intel_purley_xeon_ras_cap(struct pci_dev *pdev)
647{ 647{
648 u32 capid0; 648 u32 capid0, capid5;
649 649
650 pci_read_config_dword(pdev, 0x84, &capid0); 650 pci_read_config_dword(pdev, 0x84, &capid0);
651 pci_read_config_dword(pdev, 0x98, &capid5);
651 652
652 if ((capid0 & 0xc0) == 0xc0) 653 /*
654 * CAPID0{7:6} indicate whether this is an advanced RAS SKU
655 * CAPID5{8:5} indicate that various NVDIMM usage modes are
656 * enabled, so memory machine check recovery is also enabled.
657 */
658 if ((capid0 & 0xc0) == 0xc0 || (capid5 & 0x1e0))
653 static_branch_inc(&mcsafe_key); 659 static_branch_inc(&mcsafe_key);
660
654} 661}
655DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x0ec3, quirk_intel_brickland_xeon_ras_cap); 662DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x0ec3, quirk_intel_brickland_xeon_ras_cap);
656DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2fc0, quirk_intel_brickland_xeon_ras_cap); 663DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2fc0, quirk_intel_brickland_xeon_ras_cap);
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 445ca11ff863..92a3b312a53c 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -692,7 +692,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
692 * Increment event counter and perform fixup for the pre-signal 692 * Increment event counter and perform fixup for the pre-signal
693 * frame. 693 * frame.
694 */ 694 */
695 rseq_signal_deliver(regs); 695 rseq_signal_deliver(ksig, regs);
696 696
697 /* Set up the stack frame */ 697 /* Set up the stack frame */
698 if (is_ia32_frame(ksig)) { 698 if (is_ia32_frame(ksig)) {
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index a535dd64de63..e6db475164ed 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -835,16 +835,18 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
835 char *str = (trapnr == X86_TRAP_MF) ? "fpu exception" : 835 char *str = (trapnr == X86_TRAP_MF) ? "fpu exception" :
836 "simd exception"; 836 "simd exception";
837 837
838 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, SIGFPE) == NOTIFY_STOP)
839 return;
840 cond_local_irq_enable(regs); 838 cond_local_irq_enable(regs);
841 839
842 if (!user_mode(regs)) { 840 if (!user_mode(regs)) {
843 if (!fixup_exception(regs, trapnr)) { 841 if (fixup_exception(regs, trapnr))
844 task->thread.error_code = error_code; 842 return;
845 task->thread.trap_nr = trapnr; 843
844 task->thread.error_code = error_code;
845 task->thread.trap_nr = trapnr;
846
847 if (notify_die(DIE_TRAP, str, regs, error_code,
848 trapnr, SIGFPE) != NOTIFY_STOP)
846 die(str, regs, error_code); 849 die(str, regs, error_code);
847 }
848 return; 850 return;
849 } 851 }
850 852
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 58d8d800875d..deb576b23b7c 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -293,7 +293,7 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool
293 insn_init(insn, auprobe->insn, sizeof(auprobe->insn), x86_64); 293 insn_init(insn, auprobe->insn, sizeof(auprobe->insn), x86_64);
294 /* has the side-effect of processing the entire instruction */ 294 /* has the side-effect of processing the entire instruction */
295 insn_get_length(insn); 295 insn_get_length(insn);
296 if (WARN_ON_ONCE(!insn_complete(insn))) 296 if (!insn_complete(insn))
297 return -ENOEXEC; 297 return -ENOEXEC;
298 298
299 if (is_prefix_bad(insn)) 299 if (is_prefix_bad(insn))
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 559a12b6184d..1689f433f3a0 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1705,6 +1705,17 @@ static inline bool nested_cpu_has_vmwrite_any_field(struct kvm_vcpu *vcpu)
1705 MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS; 1705 MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS;
1706} 1706}
1707 1707
1708static inline bool nested_cpu_has_zero_length_injection(struct kvm_vcpu *vcpu)
1709{
1710 return to_vmx(vcpu)->nested.msrs.misc_low & VMX_MISC_ZERO_LEN_INS;
1711}
1712
1713static inline bool nested_cpu_supports_monitor_trap_flag(struct kvm_vcpu *vcpu)
1714{
1715 return to_vmx(vcpu)->nested.msrs.procbased_ctls_high &
1716 CPU_BASED_MONITOR_TRAP_FLAG;
1717}
1718
1708static inline bool nested_cpu_has(struct vmcs12 *vmcs12, u32 bit) 1719static inline bool nested_cpu_has(struct vmcs12 *vmcs12, u32 bit)
1709{ 1720{
1710 return vmcs12->cpu_based_vm_exec_control & bit; 1721 return vmcs12->cpu_based_vm_exec_control & bit;
@@ -11620,6 +11631,62 @@ static int check_vmentry_prereqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
11620 !nested_cr3_valid(vcpu, vmcs12->host_cr3)) 11631 !nested_cr3_valid(vcpu, vmcs12->host_cr3))
11621 return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD; 11632 return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD;
11622 11633
11634 /*
11635 * From the Intel SDM, volume 3:
11636 * Fields relevant to VM-entry event injection must be set properly.
11637 * These fields are the VM-entry interruption-information field, the
11638 * VM-entry exception error code, and the VM-entry instruction length.
11639 */
11640 if (vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK) {
11641 u32 intr_info = vmcs12->vm_entry_intr_info_field;
11642 u8 vector = intr_info & INTR_INFO_VECTOR_MASK;
11643 u32 intr_type = intr_info & INTR_INFO_INTR_TYPE_MASK;
11644 bool has_error_code = intr_info & INTR_INFO_DELIVER_CODE_MASK;
11645 bool should_have_error_code;
11646 bool urg = nested_cpu_has2(vmcs12,
11647 SECONDARY_EXEC_UNRESTRICTED_GUEST);
11648 bool prot_mode = !urg || vmcs12->guest_cr0 & X86_CR0_PE;
11649
11650 /* VM-entry interruption-info field: interruption type */
11651 if (intr_type == INTR_TYPE_RESERVED ||
11652 (intr_type == INTR_TYPE_OTHER_EVENT &&
11653 !nested_cpu_supports_monitor_trap_flag(vcpu)))
11654 return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
11655
11656 /* VM-entry interruption-info field: vector */
11657 if ((intr_type == INTR_TYPE_NMI_INTR && vector != NMI_VECTOR) ||
11658 (intr_type == INTR_TYPE_HARD_EXCEPTION && vector > 31) ||
11659 (intr_type == INTR_TYPE_OTHER_EVENT && vector != 0))
11660 return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
11661
11662 /* VM-entry interruption-info field: deliver error code */
11663 should_have_error_code =
11664 intr_type == INTR_TYPE_HARD_EXCEPTION && prot_mode &&
11665 x86_exception_has_error_code(vector);
11666 if (has_error_code != should_have_error_code)
11667 return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
11668
11669 /* VM-entry exception error code */
11670 if (has_error_code &&
11671 vmcs12->vm_entry_exception_error_code & GENMASK(31, 15))
11672 return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
11673
11674 /* VM-entry interruption-info field: reserved bits */
11675 if (intr_info & INTR_INFO_RESVD_BITS_MASK)
11676 return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
11677
11678 /* VM-entry instruction length */
11679 switch (intr_type) {
11680 case INTR_TYPE_SOFT_EXCEPTION:
11681 case INTR_TYPE_SOFT_INTR:
11682 case INTR_TYPE_PRIV_SW_EXCEPTION:
11683 if ((vmcs12->vm_entry_instruction_len > 15) ||
11684 (vmcs12->vm_entry_instruction_len == 0 &&
11685 !nested_cpu_has_zero_length_injection(vcpu)))
11686 return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
11687 }
11688 }
11689
11623 return 0; 11690 return 0;
11624} 11691}
11625 11692
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 331993c49dae..257f27620bc2 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -110,6 +110,15 @@ static inline bool is_la57_mode(struct kvm_vcpu *vcpu)
110#endif 110#endif
111} 111}
112 112
113static inline bool x86_exception_has_error_code(unsigned int vector)
114{
115 static u32 exception_has_error_code = BIT(DF_VECTOR) | BIT(TS_VECTOR) |
116 BIT(NP_VECTOR) | BIT(SS_VECTOR) | BIT(GP_VECTOR) |
117 BIT(PF_VECTOR) | BIT(AC_VECTOR);
118
119 return (1U << vector) & exception_has_error_code;
120}
121
113static inline bool mmu_is_nested(struct kvm_vcpu *vcpu) 122static inline bool mmu_is_nested(struct kvm_vcpu *vcpu)
114{ 123{
115 return vcpu->arch.walk_mmu == &vcpu->arch.nested_mmu; 124 return vcpu->arch.walk_mmu == &vcpu->arch.nested_mmu;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9a84a0d08727..2aafa6ab6103 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -641,11 +641,6 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
641 return 0; 641 return 0;
642} 642}
643 643
644static const char nx_warning[] = KERN_CRIT
645"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
646static const char smep_warning[] = KERN_CRIT
647"unable to execute userspace code (SMEP?) (uid: %d)\n";
648
649static void 644static void
650show_fault_oops(struct pt_regs *regs, unsigned long error_code, 645show_fault_oops(struct pt_regs *regs, unsigned long error_code,
651 unsigned long address) 646 unsigned long address)
@@ -664,20 +659,18 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
664 pte = lookup_address_in_pgd(pgd, address, &level); 659 pte = lookup_address_in_pgd(pgd, address, &level);
665 660
666 if (pte && pte_present(*pte) && !pte_exec(*pte)) 661 if (pte && pte_present(*pte) && !pte_exec(*pte))
667 printk(nx_warning, from_kuid(&init_user_ns, current_uid())); 662 pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
663 from_kuid(&init_user_ns, current_uid()));
668 if (pte && pte_present(*pte) && pte_exec(*pte) && 664 if (pte && pte_present(*pte) && pte_exec(*pte) &&
669 (pgd_flags(*pgd) & _PAGE_USER) && 665 (pgd_flags(*pgd) & _PAGE_USER) &&
670 (__read_cr4() & X86_CR4_SMEP)) 666 (__read_cr4() & X86_CR4_SMEP))
671 printk(smep_warning, from_kuid(&init_user_ns, current_uid())); 667 pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",
668 from_kuid(&init_user_ns, current_uid()));
672 } 669 }
673 670
674 printk(KERN_ALERT "BUG: unable to handle kernel "); 671 pr_alert("BUG: unable to handle kernel %s at %px\n",
675 if (address < PAGE_SIZE) 672 address < PAGE_SIZE ? "NULL pointer dereference" : "paging request",
676 printk(KERN_CONT "NULL pointer dereference"); 673 (void *)address);
677 else
678 printk(KERN_CONT "paging request");
679
680 printk(KERN_CONT " at %px\n", (void *) address);
681 674
682 dump_pagetable(address); 675 dump_pagetable(address);
683} 676}
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 045f492d5f68..a688617c727e 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1350,16 +1350,28 @@ int kern_addr_valid(unsigned long addr)
1350/* Amount of ram needed to start using large blocks */ 1350/* Amount of ram needed to start using large blocks */
1351#define MEM_SIZE_FOR_LARGE_BLOCK (64UL << 30) 1351#define MEM_SIZE_FOR_LARGE_BLOCK (64UL << 30)
1352 1352
1353/* Adjustable memory block size */
1354static unsigned long set_memory_block_size;
1355int __init set_memory_block_size_order(unsigned int order)
1356{
1357 unsigned long size = 1UL << order;
1358
1359 if (size > MEM_SIZE_FOR_LARGE_BLOCK || size < MIN_MEMORY_BLOCK_SIZE)
1360 return -EINVAL;
1361
1362 set_memory_block_size = size;
1363 return 0;
1364}
1365
1353static unsigned long probe_memory_block_size(void) 1366static unsigned long probe_memory_block_size(void)
1354{ 1367{
1355 unsigned long boot_mem_end = max_pfn << PAGE_SHIFT; 1368 unsigned long boot_mem_end = max_pfn << PAGE_SHIFT;
1356 unsigned long bz; 1369 unsigned long bz;
1357 1370
1358 /* If this is UV system, always set 2G block size */ 1371 /* If memory block size has been set, then use it */
1359 if (is_uv_system()) { 1372 bz = set_memory_block_size;
1360 bz = MAX_BLOCK_SIZE; 1373 if (bz)
1361 goto done; 1374 goto done;
1362 }
1363 1375
1364 /* Use regular block if RAM is smaller than MEM_SIZE_FOR_LARGE_BLOCK */ 1376 /* Use regular block if RAM is smaller than MEM_SIZE_FOR_LARGE_BLOCK */
1365 if (boot_mem_end < MEM_SIZE_FOR_LARGE_BLOCK) { 1377 if (boot_mem_end < MEM_SIZE_FOR_LARGE_BLOCK) {
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index e01f7ceb9e7a..77873ce700ae 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -166,14 +166,14 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
166 pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE); 166 pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE);
167 set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]); 167 set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]);
168 168
169 if (!(pgd_val(*pgd) & _PAGE_PRESENT)) 169 if (!pgd_present(*pgd))
170 continue; 170 continue;
171 171
172 for (i = 0; i < PTRS_PER_P4D; i++) { 172 for (i = 0; i < PTRS_PER_P4D; i++) {
173 p4d = p4d_offset(pgd, 173 p4d = p4d_offset(pgd,
174 pgd_idx * PGDIR_SIZE + i * P4D_SIZE); 174 pgd_idx * PGDIR_SIZE + i * P4D_SIZE);
175 175
176 if (!(p4d_val(*p4d) & _PAGE_PRESENT)) 176 if (!p4d_present(*p4d))
177 continue; 177 continue;
178 178
179 pud = (pud_t *)p4d_page_vaddr(*p4d); 179 pud = (pud_t *)p4d_page_vaddr(*p4d);
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index c9081c6671f0..3b5318505c69 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -65,6 +65,13 @@ __read_mostly int xen_have_vector_callback;
65EXPORT_SYMBOL_GPL(xen_have_vector_callback); 65EXPORT_SYMBOL_GPL(xen_have_vector_callback);
66 66
67/* 67/*
68 * NB: needs to live in .data because it's used by xen_prepare_pvh which runs
69 * before clearing the bss.
70 */
71uint32_t xen_start_flags __attribute__((section(".data"))) = 0;
72EXPORT_SYMBOL(xen_start_flags);
73
74/*
68 * Point at some empty memory to start with. We map the real shared_info 75 * Point at some empty memory to start with. We map the real shared_info
69 * page as soon as fixmap is up and running. 76 * page as soon as fixmap is up and running.
70 */ 77 */
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 357969a3697c..8d4e2e1ae60b 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1203,6 +1203,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
1203 return; 1203 return;
1204 1204
1205 xen_domain_type = XEN_PV_DOMAIN; 1205 xen_domain_type = XEN_PV_DOMAIN;
1206 xen_start_flags = xen_start_info->flags;
1206 1207
1207 xen_setup_features(); 1208 xen_setup_features();
1208 1209
diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c
index aa1c6a6831a9..c85d1a88f476 100644
--- a/arch/x86/xen/enlighten_pvh.c
+++ b/arch/x86/xen/enlighten_pvh.c
@@ -97,6 +97,7 @@ void __init xen_prepare_pvh(void)
97 } 97 }
98 98
99 xen_pvh = 1; 99 xen_pvh = 1;
100 xen_start_flags = pvh_start_info.flags;
100 101
101 msr = cpuid_ebx(xen_cpuid_base() + 2); 102 msr = cpuid_ebx(xen_cpuid_base() + 2);
102 pfn = __pa(hypercall_page); 103 pfn = __pa(hypercall_page);
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 2e20ae2fa2d6..e3b18ad49889 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -32,6 +32,7 @@
32#include <xen/interface/vcpu.h> 32#include <xen/interface/vcpu.h>
33#include <xen/interface/xenpmu.h> 33#include <xen/interface/xenpmu.h>
34 34
35#include <asm/spec-ctrl.h>
35#include <asm/xen/interface.h> 36#include <asm/xen/interface.h>
36#include <asm/xen/hypercall.h> 37#include <asm/xen/hypercall.h>
37 38
@@ -70,6 +71,8 @@ static void cpu_bringup(void)
70 cpu_data(cpu).x86_max_cores = 1; 71 cpu_data(cpu).x86_max_cores = 1;
71 set_cpu_sibling_map(cpu); 72 set_cpu_sibling_map(cpu);
72 73
74 speculative_store_bypass_ht_init();
75
73 xen_setup_cpu_clockevents(); 76 xen_setup_cpu_clockevents();
74 77
75 notify_cpu_starting(cpu); 78 notify_cpu_starting(cpu);
@@ -250,6 +253,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
250 } 253 }
251 set_cpu_sibling_map(0); 254 set_cpu_sibling_map(0);
252 255
256 speculative_store_bypass_ht_init();
257
253 xen_pmu_init(0); 258 xen_pmu_init(0);
254 259
255 if (xen_smp_intr_init(0) || xen_smp_intr_init_pv(0)) 260 if (xen_smp_intr_init(0) || xen_smp_intr_init_pv(0))
diff --git a/block/bio.c b/block/bio.c
index 9710e275f230..67eff5eddc49 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1807,9 +1807,6 @@ again:
1807 if (!bio_integrity_endio(bio)) 1807 if (!bio_integrity_endio(bio))
1808 return; 1808 return;
1809 1809
1810 if (WARN_ONCE(bio->bi_next, "driver left bi_next not NULL"))
1811 bio->bi_next = NULL;
1812
1813 /* 1810 /*
1814 * Need to have a real endio function for chained bios, otherwise 1811 * Need to have a real endio function for chained bios, otherwise
1815 * various corner cases will break (like stacking block devices that 1812 * various corner cases will break (like stacking block devices that
diff --git a/block/blk-core.c b/block/blk-core.c
index cf0ee764b908..f84a9b7b6f5a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -273,10 +273,6 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
273 bio_advance(bio, nbytes); 273 bio_advance(bio, nbytes);
274 274
275 /* don't actually finish bio if it's part of flush sequence */ 275 /* don't actually finish bio if it's part of flush sequence */
276 /*
277 * XXX this code looks suspicious - it's not consistent with advancing
278 * req->bio in caller
279 */
280 if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ)) 276 if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ))
281 bio_endio(bio); 277 bio_endio(bio);
282} 278}
@@ -3081,10 +3077,8 @@ bool blk_update_request(struct request *req, blk_status_t error,
3081 struct bio *bio = req->bio; 3077 struct bio *bio = req->bio;
3082 unsigned bio_bytes = min(bio->bi_iter.bi_size, nr_bytes); 3078 unsigned bio_bytes = min(bio->bi_iter.bi_size, nr_bytes);
3083 3079
3084 if (bio_bytes == bio->bi_iter.bi_size) { 3080 if (bio_bytes == bio->bi_iter.bi_size)
3085 req->bio = bio->bi_next; 3081 req->bio = bio->bi_next;
3086 bio->bi_next = NULL;
3087 }
3088 3082
3089 /* Completion has already been traced */ 3083 /* Completion has already been traced */
3090 bio_clear_flag(bio, BIO_TRACE_COMPLETION); 3084 bio_clear_flag(bio, BIO_TRACE_COMPLETION);
@@ -3479,6 +3473,10 @@ static void __blk_rq_prep_clone(struct request *dst, struct request *src)
3479 dst->cpu = src->cpu; 3473 dst->cpu = src->cpu;
3480 dst->__sector = blk_rq_pos(src); 3474 dst->__sector = blk_rq_pos(src);
3481 dst->__data_len = blk_rq_bytes(src); 3475 dst->__data_len = blk_rq_bytes(src);
3476 if (src->rq_flags & RQF_SPECIAL_PAYLOAD) {
3477 dst->rq_flags |= RQF_SPECIAL_PAYLOAD;
3478 dst->special_vec = src->special_vec;
3479 }
3482 dst->nr_phys_segments = src->nr_phys_segments; 3480 dst->nr_phys_segments = src->nr_phys_segments;
3483 dst->ioprio = src->ioprio; 3481 dst->ioprio = src->ioprio;
3484 dst->extra_len = src->extra_len; 3482 dst->extra_len = src->extra_len;
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index ffa622366922..1c4532e92938 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -356,7 +356,7 @@ static const char *const blk_mq_rq_state_name_array[] = {
356 356
357static const char *blk_mq_rq_state_name(enum mq_rq_state rq_state) 357static const char *blk_mq_rq_state_name(enum mq_rq_state rq_state)
358{ 358{
359 if (WARN_ON_ONCE((unsigned int)rq_state > 359 if (WARN_ON_ONCE((unsigned int)rq_state >=
360 ARRAY_SIZE(blk_mq_rq_state_name_array))) 360 ARRAY_SIZE(blk_mq_rq_state_name_array)))
361 return "(?)"; 361 return "(?)";
362 return blk_mq_rq_state_name_array[rq_state]; 362 return blk_mq_rq_state_name_array[rq_state];
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 70c65bb6c013..95919268564b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -781,7 +781,6 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved)
781 WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER); 781 WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER);
782 } 782 }
783 783
784 req->rq_flags &= ~RQF_TIMED_OUT;
785 blk_add_timer(req); 784 blk_add_timer(req);
786} 785}
787 786
@@ -1076,6 +1075,9 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx,
1076 1075
1077#define BLK_MQ_RESOURCE_DELAY 3 /* ms units */ 1076#define BLK_MQ_RESOURCE_DELAY 3 /* ms units */
1078 1077
1078/*
1079 * Returns true if we did some work AND can potentially do more.
1080 */
1079bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, 1081bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
1080 bool got_budget) 1082 bool got_budget)
1081{ 1083{
@@ -1206,8 +1208,17 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
1206 blk_mq_run_hw_queue(hctx, true); 1208 blk_mq_run_hw_queue(hctx, true);
1207 else if (needs_restart && (ret == BLK_STS_RESOURCE)) 1209 else if (needs_restart && (ret == BLK_STS_RESOURCE))
1208 blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY); 1210 blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY);
1211
1212 return false;
1209 } 1213 }
1210 1214
1215 /*
1216 * If the host/device is unable to accept more work, inform the
1217 * caller of that.
1218 */
1219 if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE)
1220 return false;
1221
1211 return (queued + errors) != 0; 1222 return (queued + errors) != 0;
1212} 1223}
1213 1224
diff --git a/block/blk-softirq.c b/block/blk-softirq.c
index 01e2b353a2b9..15c1f5e12eb8 100644
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
@@ -144,6 +144,7 @@ do_local:
144 144
145 local_irq_restore(flags); 145 local_irq_restore(flags);
146} 146}
147EXPORT_SYMBOL(__blk_complete_request);
147 148
148/** 149/**
149 * blk_complete_request - end I/O on a request 150 * blk_complete_request - end I/O on a request
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 4b8a48d48ba1..f2cfd56e1606 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -210,6 +210,7 @@ void blk_add_timer(struct request *req)
210 if (!req->timeout) 210 if (!req->timeout)
211 req->timeout = q->rq_timeout; 211 req->timeout = q->rq_timeout;
212 212
213 req->rq_flags &= ~RQF_TIMED_OUT;
213 blk_rq_set_deadline(req, jiffies + req->timeout); 214 blk_rq_set_deadline(req, jiffies + req->timeout);
214 215
215 /* 216 /*
diff --git a/block/sed-opal.c b/block/sed-opal.c
index 945f4b8610e0..e0de4dd448b3 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -877,7 +877,7 @@ static size_t response_get_string(const struct parsed_resp *resp, int n,
877 return 0; 877 return 0;
878 } 878 }
879 879
880 if (n > resp->num) { 880 if (n >= resp->num) {
881 pr_debug("Response has %d tokens. Can't access %d\n", 881 pr_debug("Response has %d tokens. Can't access %d\n",
882 resp->num, n); 882 resp->num, n);
883 return 0; 883 return 0;
@@ -916,7 +916,7 @@ static u64 response_get_u64(const struct parsed_resp *resp, int n)
916 return 0; 916 return 0;
917 } 917 }
918 918
919 if (n > resp->num) { 919 if (n >= resp->num) {
920 pr_debug("Response has %d tokens. Can't access %d\n", 920 pr_debug("Response has %d tokens. Can't access %d\n",
921 resp->num, n); 921 resp->num, n);
922 return 0; 922 return 0;
diff --git a/certs/blacklist.h b/certs/blacklist.h
index 150d82da8e99..1efd6fa0dc60 100644
--- a/certs/blacklist.h
+++ b/certs/blacklist.h
@@ -1,3 +1,3 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2 2
3extern const char __initdata *const blacklist_hashes[]; 3extern const char __initconst *const blacklist_hashes[];
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 49fa8582138b..314c52c967e5 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1060,12 +1060,19 @@ void af_alg_async_cb(struct crypto_async_request *_req, int err)
1060} 1060}
1061EXPORT_SYMBOL_GPL(af_alg_async_cb); 1061EXPORT_SYMBOL_GPL(af_alg_async_cb);
1062 1062
1063__poll_t af_alg_poll_mask(struct socket *sock, __poll_t events) 1063/**
1064 * af_alg_poll - poll system call handler
1065 */
1066__poll_t af_alg_poll(struct file *file, struct socket *sock,
1067 poll_table *wait)
1064{ 1068{
1065 struct sock *sk = sock->sk; 1069 struct sock *sk = sock->sk;
1066 struct alg_sock *ask = alg_sk(sk); 1070 struct alg_sock *ask = alg_sk(sk);
1067 struct af_alg_ctx *ctx = ask->private; 1071 struct af_alg_ctx *ctx = ask->private;
1068 __poll_t mask = 0; 1072 __poll_t mask;
1073
1074 sock_poll_wait(file, sk_sleep(sk), wait);
1075 mask = 0;
1069 1076
1070 if (!ctx->more || ctx->used) 1077 if (!ctx->more || ctx->used)
1071 mask |= EPOLLIN | EPOLLRDNORM; 1078 mask |= EPOLLIN | EPOLLRDNORM;
@@ -1075,7 +1082,7 @@ __poll_t af_alg_poll_mask(struct socket *sock, __poll_t events)
1075 1082
1076 return mask; 1083 return mask;
1077} 1084}
1078EXPORT_SYMBOL_GPL(af_alg_poll_mask); 1085EXPORT_SYMBOL_GPL(af_alg_poll);
1079 1086
1080/** 1087/**
1081 * af_alg_alloc_areq - allocate struct af_alg_async_req 1088 * af_alg_alloc_areq - allocate struct af_alg_async_req
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 825524f27438..c40a8c7ee8ae 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -375,7 +375,7 @@ static struct proto_ops algif_aead_ops = {
375 .sendmsg = aead_sendmsg, 375 .sendmsg = aead_sendmsg,
376 .sendpage = af_alg_sendpage, 376 .sendpage = af_alg_sendpage,
377 .recvmsg = aead_recvmsg, 377 .recvmsg = aead_recvmsg,
378 .poll_mask = af_alg_poll_mask, 378 .poll = af_alg_poll,
379}; 379};
380 380
381static int aead_check_key(struct socket *sock) 381static int aead_check_key(struct socket *sock)
@@ -471,7 +471,7 @@ static struct proto_ops algif_aead_ops_nokey = {
471 .sendmsg = aead_sendmsg_nokey, 471 .sendmsg = aead_sendmsg_nokey,
472 .sendpage = aead_sendpage_nokey, 472 .sendpage = aead_sendpage_nokey,
473 .recvmsg = aead_recvmsg_nokey, 473 .recvmsg = aead_recvmsg_nokey,
474 .poll_mask = af_alg_poll_mask, 474 .poll = af_alg_poll,
475}; 475};
476 476
477static void *aead_bind(const char *name, u32 type, u32 mask) 477static void *aead_bind(const char *name, u32 type, u32 mask)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 4c04eb9888ad..cfdaab2b7d76 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -206,7 +206,7 @@ static struct proto_ops algif_skcipher_ops = {
206 .sendmsg = skcipher_sendmsg, 206 .sendmsg = skcipher_sendmsg,
207 .sendpage = af_alg_sendpage, 207 .sendpage = af_alg_sendpage,
208 .recvmsg = skcipher_recvmsg, 208 .recvmsg = skcipher_recvmsg,
209 .poll_mask = af_alg_poll_mask, 209 .poll = af_alg_poll,
210}; 210};
211 211
212static int skcipher_check_key(struct socket *sock) 212static int skcipher_check_key(struct socket *sock)
@@ -302,7 +302,7 @@ static struct proto_ops algif_skcipher_ops_nokey = {
302 .sendmsg = skcipher_sendmsg_nokey, 302 .sendmsg = skcipher_sendmsg_nokey,
303 .sendpage = skcipher_sendpage_nokey, 303 .sendpage = skcipher_sendpage_nokey,
304 .recvmsg = skcipher_recvmsg_nokey, 304 .recvmsg = skcipher_recvmsg_nokey,
305 .poll_mask = af_alg_poll_mask, 305 .poll = af_alg_poll,
306}; 306};
307 307
308static void *skcipher_bind(const char *name, u32 type, u32 mask) 308static void *skcipher_bind(const char *name, u32 type, u32 mask)
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 7d81e6bb461a..b6cabac4b62b 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -249,6 +249,15 @@ int x509_note_signature(void *context, size_t hdrlen,
249 return -EINVAL; 249 return -EINVAL;
250 } 250 }
251 251
252 if (strcmp(ctx->cert->sig->pkey_algo, "rsa") == 0) {
253 /* Discard the BIT STRING metadata */
254 if (vlen < 1 || *(const u8 *)value != 0)
255 return -EBADMSG;
256
257 value++;
258 vlen--;
259 }
260
252 ctx->cert->raw_sig = value; 261 ctx->cert->raw_sig = value;
253 ctx->cert->raw_sig_size = vlen; 262 ctx->cert->raw_sig_size = vlen;
254 return 0; 263 return 0;
diff --git a/crypto/morus640.c b/crypto/morus640.c
index 9fbcde307daf..5eede3749e64 100644
--- a/crypto/morus640.c
+++ b/crypto/morus640.c
@@ -274,8 +274,9 @@ static void crypto_morus640_decrypt_chunk(struct morus640_state *state, u8 *dst,
274 union morus640_block_in tail; 274 union morus640_block_in tail;
275 275
276 memcpy(tail.bytes, src, size); 276 memcpy(tail.bytes, src, size);
277 memset(tail.bytes + size, 0, MORUS640_BLOCK_SIZE - size);
277 278
278 crypto_morus640_load_a(&m, src); 279 crypto_morus640_load_a(&m, tail.bytes);
279 crypto_morus640_core(state, &m); 280 crypto_morus640_core(state, &m);
280 crypto_morus640_store_a(tail.bytes, &m); 281 crypto_morus640_store_a(tail.bytes, &m);
281 memset(tail.bytes + size, 0, MORUS640_BLOCK_SIZE - size); 282 memset(tail.bytes + size, 0, MORUS640_BLOCK_SIZE - size);
diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c
index 264ec12c0b9c..7f6735d9003f 100644
--- a/crypto/sha3_generic.c
+++ b/crypto/sha3_generic.c
@@ -152,7 +152,7 @@ static SHA3_INLINE void keccakf_round(u64 st[25])
152 st[24] ^= bc[ 4]; 152 st[24] ^= bc[ 4];
153} 153}
154 154
155static void __optimize("O3") keccakf(u64 st[25]) 155static void keccakf(u64 st[25])
156{ 156{
157 int round; 157 int round;
158 158
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 38a286975c31..f8fecfec5df9 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -22,6 +22,7 @@
22#include <linux/pm_domain.h> 22#include <linux/pm_domain.h>
23#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
24#include <linux/pwm.h> 24#include <linux/pwm.h>
25#include <linux/suspend.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26 27
27#include "internal.h" 28#include "internal.h"
@@ -946,9 +947,10 @@ static void lpss_iosf_exit_d3_state(void)
946 mutex_unlock(&lpss_iosf_mutex); 947 mutex_unlock(&lpss_iosf_mutex);
947} 948}
948 949
949static int acpi_lpss_suspend(struct device *dev, bool wakeup) 950static int acpi_lpss_suspend(struct device *dev, bool runtime)
950{ 951{
951 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); 952 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
953 bool wakeup = runtime || device_may_wakeup(dev);
952 int ret; 954 int ret;
953 955
954 if (pdata->dev_desc->flags & LPSS_SAVE_CTX) 956 if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
@@ -961,13 +963,14 @@ static int acpi_lpss_suspend(struct device *dev, bool wakeup)
961 * wrong status for devices being about to be powered off. See 963 * wrong status for devices being about to be powered off. See
962 * lpss_iosf_enter_d3_state() for further information. 964 * lpss_iosf_enter_d3_state() for further information.
963 */ 965 */
964 if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available()) 966 if ((runtime || !pm_suspend_via_firmware()) &&
967 lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
965 lpss_iosf_enter_d3_state(); 968 lpss_iosf_enter_d3_state();
966 969
967 return ret; 970 return ret;
968} 971}
969 972
970static int acpi_lpss_resume(struct device *dev) 973static int acpi_lpss_resume(struct device *dev, bool runtime)
971{ 974{
972 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); 975 struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
973 int ret; 976 int ret;
@@ -976,7 +979,8 @@ static int acpi_lpss_resume(struct device *dev)
976 * This call is kept first to be in symmetry with 979 * This call is kept first to be in symmetry with
977 * acpi_lpss_runtime_suspend() one. 980 * acpi_lpss_runtime_suspend() one.
978 */ 981 */
979 if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available()) 982 if ((runtime || !pm_resume_via_firmware()) &&
983 lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
980 lpss_iosf_exit_d3_state(); 984 lpss_iosf_exit_d3_state();
981 985
982 ret = acpi_dev_resume(dev); 986 ret = acpi_dev_resume(dev);
@@ -1000,12 +1004,12 @@ static int acpi_lpss_suspend_late(struct device *dev)
1000 return 0; 1004 return 0;
1001 1005
1002 ret = pm_generic_suspend_late(dev); 1006 ret = pm_generic_suspend_late(dev);
1003 return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev)); 1007 return ret ? ret : acpi_lpss_suspend(dev, false);
1004} 1008}
1005 1009
1006static int acpi_lpss_resume_early(struct device *dev) 1010static int acpi_lpss_resume_early(struct device *dev)
1007{ 1011{
1008 int ret = acpi_lpss_resume(dev); 1012 int ret = acpi_lpss_resume(dev, false);
1009 1013
1010 return ret ? ret : pm_generic_resume_early(dev); 1014 return ret ? ret : pm_generic_resume_early(dev);
1011} 1015}
@@ -1020,7 +1024,7 @@ static int acpi_lpss_runtime_suspend(struct device *dev)
1020 1024
1021static int acpi_lpss_runtime_resume(struct device *dev) 1025static int acpi_lpss_runtime_resume(struct device *dev)
1022{ 1026{
1023 int ret = acpi_lpss_resume(dev); 1027 int ret = acpi_lpss_resume(dev, true);
1024 1028
1025 return ret ? ret : pm_generic_runtime_resume(dev); 1029 return ret ? ret : pm_generic_runtime_resume(dev);
1026} 1030}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index bb94cf0731fe..442a9e24f439 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -2037,6 +2037,17 @@ static inline void acpi_ec_query_exit(void)
2037 } 2037 }
2038} 2038}
2039 2039
2040static const struct dmi_system_id acpi_ec_no_wakeup[] = {
2041 {
2042 .ident = "Thinkpad X1 Carbon 6th",
2043 .matches = {
2044 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2045 DMI_MATCH(DMI_PRODUCT_NAME, "20KGS3JF01"),
2046 },
2047 },
2048 { },
2049};
2050
2040int __init acpi_ec_init(void) 2051int __init acpi_ec_init(void)
2041{ 2052{
2042 int result; 2053 int result;
@@ -2047,6 +2058,15 @@ int __init acpi_ec_init(void)
2047 if (result) 2058 if (result)
2048 return result; 2059 return result;
2049 2060
2061 /*
2062 * Disable EC wakeup on following systems to prevent periodic
2063 * wakeup from EC GPE.
2064 */
2065 if (dmi_check_system(acpi_ec_no_wakeup)) {
2066 ec_no_wakeup = true;
2067 pr_debug("Disabling EC wakeup on suspend-to-idle\n");
2068 }
2069
2050 /* Drivers must be started after acpi_ec_query_init() */ 2070 /* Drivers must be started after acpi_ec_query_init() */
2051 dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver); 2071 dsdt_fail = acpi_bus_register_driver(&acpi_ec_driver);
2052 /* 2072 /*
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 7ca41bf023c9..8df9abfa947b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -45,6 +45,8 @@
45#include <linux/uaccess.h> 45#include <linux/uaccess.h>
46#include <linux/io-64-nonatomic-lo-hi.h> 46#include <linux/io-64-nonatomic-lo-hi.h>
47 47
48#include "acpica/accommon.h"
49#include "acpica/acnamesp.h"
48#include "internal.h" 50#include "internal.h"
49 51
50#define _COMPONENT ACPI_OS_SERVICES 52#define _COMPONENT ACPI_OS_SERVICES
@@ -1490,6 +1492,76 @@ int acpi_check_region(resource_size_t start, resource_size_t n,
1490} 1492}
1491EXPORT_SYMBOL(acpi_check_region); 1493EXPORT_SYMBOL(acpi_check_region);
1492 1494
1495static acpi_status acpi_deactivate_mem_region(acpi_handle handle, u32 level,
1496 void *_res, void **return_value)
1497{
1498 struct acpi_mem_space_context **mem_ctx;
1499 union acpi_operand_object *handler_obj;
1500 union acpi_operand_object *region_obj2;
1501 union acpi_operand_object *region_obj;
1502 struct resource *res = _res;
1503 acpi_status status;
1504
1505 region_obj = acpi_ns_get_attached_object(handle);
1506 if (!region_obj)
1507 return AE_OK;
1508
1509 handler_obj = region_obj->region.handler;
1510 if (!handler_obj)
1511 return AE_OK;
1512
1513 if (region_obj->region.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
1514 return AE_OK;
1515
1516 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE))
1517 return AE_OK;
1518
1519 region_obj2 = acpi_ns_get_secondary_object(region_obj);
1520 if (!region_obj2)
1521 return AE_OK;
1522
1523 mem_ctx = (void *)&region_obj2->extra.region_context;
1524
1525 if (!(mem_ctx[0]->address >= res->start &&
1526 mem_ctx[0]->address < res->end))
1527 return AE_OK;
1528
1529 status = handler_obj->address_space.setup(region_obj,
1530 ACPI_REGION_DEACTIVATE,
1531 NULL, (void **)mem_ctx);
1532 if (ACPI_SUCCESS(status))
1533 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
1534
1535 return status;
1536}
1537
1538/**
1539 * acpi_release_memory - Release any mappings done to a memory region
1540 * @handle: Handle to namespace node
1541 * @res: Memory resource
1542 * @level: A level that terminates the search
1543 *
1544 * Walks through @handle and unmaps all SystemMemory Operation Regions that
1545 * overlap with @res and that have already been activated (mapped).
1546 *
1547 * This is a helper that allows drivers to place special requirements on memory
1548 * region that may overlap with operation regions, primarily allowing them to
1549 * safely map the region as non-cached memory.
1550 *
1551 * The unmapped Operation Regions will be automatically remapped next time they
1552 * are called, so the drivers do not need to do anything else.
1553 */
1554acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
1555 u32 level)
1556{
1557 if (!(res->flags & IORESOURCE_MEM))
1558 return AE_TYPE;
1559
1560 return acpi_walk_namespace(ACPI_TYPE_REGION, handle, level,
1561 acpi_deactivate_mem_region, NULL, res, NULL);
1562}
1563EXPORT_SYMBOL_GPL(acpi_release_memory);
1564
1493/* 1565/*
1494 * Let drivers know whether the resource checks are effective 1566 * Let drivers know whether the resource checks are effective
1495 */ 1567 */
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index b074f242a435..704f44295810 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -8,10 +8,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \
8 topology.o container.o property.o cacheinfo.o \ 8 topology.o container.o property.o cacheinfo.o \
9 devcon.o 9 devcon.o
10obj-$(CONFIG_DEVTMPFS) += devtmpfs.o 10obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
11obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
12obj-y += power/ 11obj-y += power/
13obj-$(CONFIG_HAS_DMA) += dma-mapping.o
14obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
15obj-$(CONFIG_ISA_BUS_API) += isa.o 12obj-$(CONFIG_ISA_BUS_API) += isa.o
16obj-y += firmware_loader/ 13obj-y += firmware_loader/
17obj-$(CONFIG_NUMA) += node.o 14obj-$(CONFIG_NUMA) += node.o
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 36622b52e419..df3e1a44707a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -236,6 +236,13 @@ struct device_link *device_link_add(struct device *consumer,
236 link->rpm_active = true; 236 link->rpm_active = true;
237 } 237 }
238 pm_runtime_new_link(consumer); 238 pm_runtime_new_link(consumer);
239 /*
240 * If the link is being added by the consumer driver at probe
241 * time, balance the decrementation of the supplier's runtime PM
242 * usage counter after consumer probe in driver_probe_device().
243 */
244 if (consumer->links.status == DL_DEV_PROBING)
245 pm_runtime_get_noresume(supplier);
239 } 246 }
240 get_device(supplier); 247 get_device(supplier);
241 link->supplier = supplier; 248 link->supplier = supplier;
@@ -255,12 +262,12 @@ struct device_link *device_link_add(struct device *consumer,
255 switch (consumer->links.status) { 262 switch (consumer->links.status) {
256 case DL_DEV_PROBING: 263 case DL_DEV_PROBING:
257 /* 264 /*
258 * Balance the decrementation of the supplier's 265 * Some callers expect the link creation during
259 * runtime PM usage counter after consumer probe 266 * consumer driver probe to resume the supplier
260 * in driver_probe_device(). 267 * even without DL_FLAG_RPM_ACTIVE.
261 */ 268 */
262 if (flags & DL_FLAG_PM_RUNTIME) 269 if (flags & DL_FLAG_PM_RUNTIME)
263 pm_runtime_get_sync(supplier); 270 pm_runtime_resume(supplier);
264 271
265 link->status = DL_STATE_CONSUMER_PROBE; 272 link->status = DL_STATE_CONSUMER_PROBE;
266 break; 273 break;
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 4925af5c4cf0..c298de8a8308 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2487,10 +2487,9 @@ EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
2487 * power domain corresponding to a DT node's "required-opps" property. 2487 * power domain corresponding to a DT node's "required-opps" property.
2488 * 2488 *
2489 * @dev: Device for which the performance-state needs to be found. 2489 * @dev: Device for which the performance-state needs to be found.
2490 * @opp_node: DT node where the "required-opps" property is present. This can be 2490 * @np: DT node where the "required-opps" property is present. This can be
2491 * the device node itself (if it doesn't have an OPP table) or a node 2491 * the device node itself (if it doesn't have an OPP table) or a node
2492 * within the OPP table of a device (if device has an OPP table). 2492 * within the OPP table of a device (if device has an OPP table).
2493 * @state: Pointer to return performance state.
2494 * 2493 *
2495 * Returns performance state corresponding to the "required-opps" property of 2494 * Returns performance state corresponding to the "required-opps" property of
2496 * a DT node. This calls platform specific genpd->opp_to_performance_state() 2495 * a DT node. This calls platform specific genpd->opp_to_performance_state()
@@ -2499,7 +2498,7 @@ EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states);
2499 * Returns performance state on success and 0 on failure. 2498 * Returns performance state on success and 0 on failure.
2500 */ 2499 */
2501unsigned int of_genpd_opp_to_performance_state(struct device *dev, 2500unsigned int of_genpd_opp_to_performance_state(struct device *dev,
2502 struct device_node *opp_node) 2501 struct device_node *np)
2503{ 2502{
2504 struct generic_pm_domain *genpd; 2503 struct generic_pm_domain *genpd;
2505 struct dev_pm_opp *opp; 2504 struct dev_pm_opp *opp;
@@ -2514,7 +2513,7 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev,
2514 2513
2515 genpd_lock(genpd); 2514 genpd_lock(genpd);
2516 2515
2517 opp = of_dev_pm_opp_find_required_opp(&genpd->dev, opp_node); 2516 opp = of_dev_pm_opp_find_required_opp(&genpd->dev, np);
2518 if (IS_ERR(opp)) { 2517 if (IS_ERR(opp)) {
2519 dev_err(dev, "Failed to find required OPP: %ld\n", 2518 dev_err(dev, "Failed to find required OPP: %ld\n",
2520 PTR_ERR(opp)); 2519 PTR_ERR(opp));
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index a47e4987ee46..d146fedc38bb 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -1244,8 +1244,8 @@ drbd_request_prepare(struct drbd_device *device, struct bio *bio, unsigned long
1244 _drbd_start_io_acct(device, req); 1244 _drbd_start_io_acct(device, req);
1245 1245
1246 /* process discards always from our submitter thread */ 1246 /* process discards always from our submitter thread */
1247 if ((bio_op(bio) & REQ_OP_WRITE_ZEROES) || 1247 if (bio_op(bio) == REQ_OP_WRITE_ZEROES ||
1248 (bio_op(bio) & REQ_OP_DISCARD)) 1248 bio_op(bio) == REQ_OP_DISCARD)
1249 goto queue_for_submitter_thread; 1249 goto queue_for_submitter_thread;
1250 1250
1251 if (rw == WRITE && req->private_bio && req->i.size 1251 if (rw == WRITE && req->private_bio && req->i.size
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3b7083b8ecbb..74a05561b620 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -76,6 +76,7 @@ struct link_dead_args {
76#define NBD_HAS_CONFIG_REF 4 76#define NBD_HAS_CONFIG_REF 4
77#define NBD_BOUND 5 77#define NBD_BOUND 5
78#define NBD_DESTROY_ON_DISCONNECT 6 78#define NBD_DESTROY_ON_DISCONNECT 6
79#define NBD_DISCONNECT_ON_CLOSE 7
79 80
80struct nbd_config { 81struct nbd_config {
81 u32 flags; 82 u32 flags;
@@ -138,6 +139,7 @@ static void nbd_config_put(struct nbd_device *nbd);
138static void nbd_connect_reply(struct genl_info *info, int index); 139static void nbd_connect_reply(struct genl_info *info, int index);
139static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info); 140static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info);
140static void nbd_dead_link_work(struct work_struct *work); 141static void nbd_dead_link_work(struct work_struct *work);
142static void nbd_disconnect_and_put(struct nbd_device *nbd);
141 143
142static inline struct device *nbd_to_dev(struct nbd_device *nbd) 144static inline struct device *nbd_to_dev(struct nbd_device *nbd)
143{ 145{
@@ -1305,6 +1307,12 @@ out:
1305static void nbd_release(struct gendisk *disk, fmode_t mode) 1307static void nbd_release(struct gendisk *disk, fmode_t mode)
1306{ 1308{
1307 struct nbd_device *nbd = disk->private_data; 1309 struct nbd_device *nbd = disk->private_data;
1310 struct block_device *bdev = bdget_disk(disk, 0);
1311
1312 if (test_bit(NBD_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) &&
1313 bdev->bd_openers == 0)
1314 nbd_disconnect_and_put(nbd);
1315
1308 nbd_config_put(nbd); 1316 nbd_config_put(nbd);
1309 nbd_put(nbd); 1317 nbd_put(nbd);
1310} 1318}
@@ -1705,6 +1713,10 @@ again:
1705 &config->runtime_flags); 1713 &config->runtime_flags);
1706 put_dev = true; 1714 put_dev = true;
1707 } 1715 }
1716 if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1717 set_bit(NBD_DISCONNECT_ON_CLOSE,
1718 &config->runtime_flags);
1719 }
1708 } 1720 }
1709 1721
1710 if (info->attrs[NBD_ATTR_SOCKETS]) { 1722 if (info->attrs[NBD_ATTR_SOCKETS]) {
@@ -1749,6 +1761,17 @@ out:
1749 return ret; 1761 return ret;
1750} 1762}
1751 1763
1764static void nbd_disconnect_and_put(struct nbd_device *nbd)
1765{
1766 mutex_lock(&nbd->config_lock);
1767 nbd_disconnect(nbd);
1768 nbd_clear_sock(nbd);
1769 mutex_unlock(&nbd->config_lock);
1770 if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1771 &nbd->config->runtime_flags))
1772 nbd_config_put(nbd);
1773}
1774
1752static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info) 1775static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1753{ 1776{
1754 struct nbd_device *nbd; 1777 struct nbd_device *nbd;
@@ -1781,13 +1804,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
1781 nbd_put(nbd); 1804 nbd_put(nbd);
1782 return 0; 1805 return 0;
1783 } 1806 }
1784 mutex_lock(&nbd->config_lock); 1807 nbd_disconnect_and_put(nbd);
1785 nbd_disconnect(nbd);
1786 nbd_clear_sock(nbd);
1787 mutex_unlock(&nbd->config_lock);
1788 if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
1789 &nbd->config->runtime_flags))
1790 nbd_config_put(nbd);
1791 nbd_config_put(nbd); 1808 nbd_config_put(nbd);
1792 nbd_put(nbd); 1809 nbd_put(nbd);
1793 return 0; 1810 return 0;
@@ -1798,7 +1815,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1798 struct nbd_device *nbd = NULL; 1815 struct nbd_device *nbd = NULL;
1799 struct nbd_config *config; 1816 struct nbd_config *config;
1800 int index; 1817 int index;
1801 int ret = -EINVAL; 1818 int ret = 0;
1802 bool put_dev = false; 1819 bool put_dev = false;
1803 1820
1804 if (!netlink_capable(skb, CAP_SYS_ADMIN)) 1821 if (!netlink_capable(skb, CAP_SYS_ADMIN))
@@ -1838,6 +1855,7 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1838 !nbd->task_recv) { 1855 !nbd->task_recv) {
1839 dev_err(nbd_to_dev(nbd), 1856 dev_err(nbd_to_dev(nbd),
1840 "not configured, cannot reconfigure\n"); 1857 "not configured, cannot reconfigure\n");
1858 ret = -EINVAL;
1841 goto out; 1859 goto out;
1842 } 1860 }
1843 1861
@@ -1862,6 +1880,14 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
1862 &config->runtime_flags)) 1880 &config->runtime_flags))
1863 refcount_inc(&nbd->refs); 1881 refcount_inc(&nbd->refs);
1864 } 1882 }
1883
1884 if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) {
1885 set_bit(NBD_DISCONNECT_ON_CLOSE,
1886 &config->runtime_flags);
1887 } else {
1888 clear_bit(NBD_DISCONNECT_ON_CLOSE,
1889 &config->runtime_flags);
1890 }
1865 } 1891 }
1866 1892
1867 if (info->attrs[NBD_ATTR_SOCKETS]) { 1893 if (info->attrs[NBD_ATTR_SOCKETS]) {
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 7948049f6c43..042c778e5a4e 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -1365,7 +1365,7 @@ static blk_qc_t null_queue_bio(struct request_queue *q, struct bio *bio)
1365static enum blk_eh_timer_return null_rq_timed_out_fn(struct request *rq) 1365static enum blk_eh_timer_return null_rq_timed_out_fn(struct request *rq)
1366{ 1366{
1367 pr_info("null: rq %p timed out\n", rq); 1367 pr_info("null: rq %p timed out\n", rq);
1368 blk_mq_complete_request(rq); 1368 __blk_complete_request(rq);
1369 return BLK_EH_DONE; 1369 return BLK_EH_DONE;
1370} 1370}
1371 1371
diff --git a/drivers/bluetooth/hci_nokia.c b/drivers/bluetooth/hci_nokia.c
index 14d159e2042d..2dc33e65d2d0 100644
--- a/drivers/bluetooth/hci_nokia.c
+++ b/drivers/bluetooth/hci_nokia.c
@@ -29,7 +29,7 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/unaligned/le_struct.h> 32#include <asm/unaligned.h>
33#include <net/bluetooth/bluetooth.h> 33#include <net/bluetooth/bluetooth.h>
34#include <net/bluetooth/hci_core.h> 34#include <net/bluetooth/hci_core.h>
35 35
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 1cc29629d238..c9bac9dc4637 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -23,11 +23,14 @@
23#include <linux/of_address.h> 23#include <linux/of_address.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/iopoll.h>
26 27
27#include <linux/platform_data/ti-sysc.h> 28#include <linux/platform_data/ti-sysc.h>
28 29
29#include <dt-bindings/bus/ti-sysc.h> 30#include <dt-bindings/bus/ti-sysc.h>
30 31
32#define MAX_MODULE_SOFTRESET_WAIT 10000
33
31static const char * const reg_names[] = { "rev", "sysc", "syss", }; 34static const char * const reg_names[] = { "rev", "sysc", "syss", };
32 35
33enum sysc_clocks { 36enum sysc_clocks {
@@ -88,6 +91,11 @@ struct sysc {
88 struct delayed_work idle_work; 91 struct delayed_work idle_work;
89}; 92};
90 93
94void sysc_write(struct sysc *ddata, int offset, u32 value)
95{
96 writel_relaxed(value, ddata->module_va + offset);
97}
98
91static u32 sysc_read(struct sysc *ddata, int offset) 99static u32 sysc_read(struct sysc *ddata, int offset)
92{ 100{
93 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { 101 if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) {
@@ -169,9 +177,9 @@ static int sysc_get_clocks(struct sysc *ddata)
169 const char *name; 177 const char *name;
170 int nr_fck = 0, nr_ick = 0, i, error = 0; 178 int nr_fck = 0, nr_ick = 0, i, error = 0;
171 179
172 ddata->clock_roles = devm_kzalloc(ddata->dev, 180 ddata->clock_roles = devm_kcalloc(ddata->dev,
173 sizeof(*ddata->clock_roles) *
174 SYSC_MAX_CLOCKS, 181 SYSC_MAX_CLOCKS,
182 sizeof(*ddata->clock_roles),
175 GFP_KERNEL); 183 GFP_KERNEL);
176 if (!ddata->clock_roles) 184 if (!ddata->clock_roles)
177 return -ENOMEM; 185 return -ENOMEM;
@@ -200,8 +208,8 @@ static int sysc_get_clocks(struct sysc *ddata)
200 return -EINVAL; 208 return -EINVAL;
201 } 209 }
202 210
203 ddata->clocks = devm_kzalloc(ddata->dev, 211 ddata->clocks = devm_kcalloc(ddata->dev,
204 sizeof(*ddata->clocks) * ddata->nr_clocks, 212 ddata->nr_clocks, sizeof(*ddata->clocks),
205 GFP_KERNEL); 213 GFP_KERNEL);
206 if (!ddata->clocks) 214 if (!ddata->clocks)
207 return -ENOMEM; 215 return -ENOMEM;
@@ -943,6 +951,36 @@ static void sysc_init_revision_quirks(struct sysc *ddata)
943 } 951 }
944} 952}
945 953
954static int sysc_reset(struct sysc *ddata)
955{
956 int offset = ddata->offsets[SYSC_SYSCONFIG];
957 int val;
958
959 if (ddata->legacy_mode || offset < 0 ||
960 ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
961 return 0;
962
963 /*
964 * Currently only support reset status in sysstatus.
965 * Warn and return error in all other cases
966 */
967 if (!ddata->cfg.syss_mask) {
968 dev_err(ddata->dev, "No ti,syss-mask. Reset failed\n");
969 return -EINVAL;
970 }
971
972 val = sysc_read(ddata, offset);
973 val |= (0x1 << ddata->cap->regbits->srst_shift);
974 sysc_write(ddata, offset, val);
975
976 /* Poll on reset status */
977 offset = ddata->offsets[SYSC_SYSSTATUS];
978
979 return readl_poll_timeout(ddata->module_va + offset, val,
980 (val & ddata->cfg.syss_mask) == 0x0,
981 100, MAX_MODULE_SOFTRESET_WAIT);
982}
983
946/* At this point the module is configured enough to read the revision */ 984/* At this point the module is configured enough to read the revision */
947static int sysc_init_module(struct sysc *ddata) 985static int sysc_init_module(struct sysc *ddata)
948{ 986{
@@ -960,6 +998,14 @@ static int sysc_init_module(struct sysc *ddata)
960 return 0; 998 return 0;
961 } 999 }
962 1000
1001 error = sysc_reset(ddata);
1002 if (error) {
1003 dev_err(ddata->dev, "Reset failed with %d\n", error);
1004 pm_runtime_put_sync(ddata->dev);
1005
1006 return error;
1007 }
1008
963 ddata->revision = sysc_read_revision(ddata); 1009 ddata->revision = sysc_read_revision(ddata);
964 pm_runtime_put_sync(ddata->dev); 1010 pm_runtime_put_sync(ddata->dev);
965 1011
@@ -1552,6 +1598,23 @@ static const struct sysc_capabilities sysc_omap4_usb_host_fs = {
1552 .regbits = &sysc_regbits_omap4_usb_host_fs, 1598 .regbits = &sysc_regbits_omap4_usb_host_fs,
1553}; 1599};
1554 1600
1601static const struct sysc_regbits sysc_regbits_dra7_mcan = {
1602 .dmadisable_shift = -ENODEV,
1603 .midle_shift = -ENODEV,
1604 .sidle_shift = -ENODEV,
1605 .clkact_shift = -ENODEV,
1606 .enwkup_shift = 4,
1607 .srst_shift = 0,
1608 .emufree_shift = -ENODEV,
1609 .autoidle_shift = -ENODEV,
1610};
1611
1612static const struct sysc_capabilities sysc_dra7_mcan = {
1613 .type = TI_SYSC_DRA7_MCAN,
1614 .sysc_mask = SYSC_DRA7_MCAN_ENAWAKEUP | SYSC_OMAP4_SOFTRESET,
1615 .regbits = &sysc_regbits_dra7_mcan,
1616};
1617
1555static int sysc_init_pdata(struct sysc *ddata) 1618static int sysc_init_pdata(struct sysc *ddata)
1556{ 1619{
1557 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); 1620 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev);
@@ -1743,6 +1806,7 @@ static const struct of_device_id sysc_match[] = {
1743 { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, }, 1806 { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, },
1744 { .compatible = "ti,sysc-usb-host-fs", 1807 { .compatible = "ti,sysc-usb-host-fs",
1745 .data = &sysc_omap4_usb_host_fs, }, 1808 .data = &sysc_omap4_usb_host_fs, },
1809 { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, },
1746 { }, 1810 { },
1747}; 1811};
1748MODULE_DEVICE_TABLE(of, sysc_match); 1812MODULE_DEVICE_TABLE(of, sysc_match);
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 91bb98c42a1c..aaf9e5afaad4 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -516,11 +516,18 @@ EXPORT_SYMBOL_GPL(hwrng_register);
516 516
517void hwrng_unregister(struct hwrng *rng) 517void hwrng_unregister(struct hwrng *rng)
518{ 518{
519 int err;
520
519 mutex_lock(&rng_mutex); 521 mutex_lock(&rng_mutex);
520 522
521 list_del(&rng->list); 523 list_del(&rng->list);
522 if (current_rng == rng) 524 if (current_rng == rng) {
523 enable_best_rng(); 525 err = enable_best_rng();
526 if (err) {
527 drop_current_rng();
528 cur_rng_set_by_user = 0;
529 }
530 }
524 531
525 if (list_empty(&rng_list)) { 532 if (list_empty(&rng_list)) {
526 mutex_unlock(&rng_mutex); 533 mutex_unlock(&rng_mutex);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index a8fb0020ba5c..cd888d4ee605 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -402,7 +402,8 @@ static struct poolinfo {
402/* 402/*
403 * Static global variables 403 * Static global variables
404 */ 404 */
405static DECLARE_WAIT_QUEUE_HEAD(random_wait); 405static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
406static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
406static struct fasync_struct *fasync; 407static struct fasync_struct *fasync;
407 408
408static DEFINE_SPINLOCK(random_ready_list_lock); 409static DEFINE_SPINLOCK(random_ready_list_lock);
@@ -721,8 +722,8 @@ retry:
721 722
722 /* should we wake readers? */ 723 /* should we wake readers? */
723 if (entropy_bits >= random_read_wakeup_bits && 724 if (entropy_bits >= random_read_wakeup_bits &&
724 wq_has_sleeper(&random_wait)) { 725 wq_has_sleeper(&random_read_wait)) {
725 wake_up_interruptible_poll(&random_wait, POLLIN); 726 wake_up_interruptible(&random_read_wait);
726 kill_fasync(&fasync, SIGIO, POLL_IN); 727 kill_fasync(&fasync, SIGIO, POLL_IN);
727 } 728 }
728 /* If the input pool is getting full, send some 729 /* If the input pool is getting full, send some
@@ -1396,7 +1397,7 @@ retry:
1396 trace_debit_entropy(r->name, 8 * ibytes); 1397 trace_debit_entropy(r->name, 8 * ibytes);
1397 if (ibytes && 1398 if (ibytes &&
1398 (r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) { 1399 (r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) {
1399 wake_up_interruptible_poll(&random_wait, POLLOUT); 1400 wake_up_interruptible(&random_write_wait);
1400 kill_fasync(&fasync, SIGIO, POLL_OUT); 1401 kill_fasync(&fasync, SIGIO, POLL_OUT);
1401 } 1402 }
1402 1403
@@ -1838,7 +1839,7 @@ _random_read(int nonblock, char __user *buf, size_t nbytes)
1838 if (nonblock) 1839 if (nonblock)
1839 return -EAGAIN; 1840 return -EAGAIN;
1840 1841
1841 wait_event_interruptible(random_wait, 1842 wait_event_interruptible(random_read_wait,
1842 ENTROPY_BITS(&input_pool) >= 1843 ENTROPY_BITS(&input_pool) >=
1843 random_read_wakeup_bits); 1844 random_read_wakeup_bits);
1844 if (signal_pending(current)) 1845 if (signal_pending(current))
@@ -1875,17 +1876,14 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
1875 return ret; 1876 return ret;
1876} 1877}
1877 1878
1878static struct wait_queue_head *
1879random_get_poll_head(struct file *file, __poll_t events)
1880{
1881 return &random_wait;
1882}
1883
1884static __poll_t 1879static __poll_t
1885random_poll_mask(struct file *file, __poll_t events) 1880random_poll(struct file *file, poll_table * wait)
1886{ 1881{
1887 __poll_t mask = 0; 1882 __poll_t mask;
1888 1883
1884 poll_wait(file, &random_read_wait, wait);
1885 poll_wait(file, &random_write_wait, wait);
1886 mask = 0;
1889 if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits) 1887 if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)
1890 mask |= EPOLLIN | EPOLLRDNORM; 1888 mask |= EPOLLIN | EPOLLRDNORM;
1891 if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits) 1889 if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits)
@@ -1992,8 +1990,7 @@ static int random_fasync(int fd, struct file *filp, int on)
1992const struct file_operations random_fops = { 1990const struct file_operations random_fops = {
1993 .read = random_read, 1991 .read = random_read,
1994 .write = random_write, 1992 .write = random_write,
1995 .get_poll_head = random_get_poll_head, 1993 .poll = random_poll,
1996 .poll_mask = random_poll_mask,
1997 .unlocked_ioctl = random_ioctl, 1994 .unlocked_ioctl = random_ioctl,
1998 .fasync = random_fasync, 1995 .fasync = random_fasync,
1999 .llseek = noop_llseek, 1996 .llseek = noop_llseek,
@@ -2326,7 +2323,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
2326 * We'll be woken up again once below random_write_wakeup_thresh, 2323 * We'll be woken up again once below random_write_wakeup_thresh,
2327 * or when the calling thread is about to terminate. 2324 * or when the calling thread is about to terminate.
2328 */ 2325 */
2329 wait_event_interruptible(random_wait, kthread_should_stop() || 2326 wait_event_interruptible(random_write_wait, kthread_should_stop() ||
2330 ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits); 2327 ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);
2331 mix_pool_bytes(poolp, buffer, count); 2328 mix_pool_bytes(poolp, buffer, count);
2332 credit_entropy_bits(poolp, entropy); 2329 credit_entropy_bits(poolp, entropy);
diff --git a/drivers/clk/ti/clk-7xx.c b/drivers/clk/ti/clk-7xx.c
index fb249a1637a5..71a122b2dc67 100644
--- a/drivers/clk/ti/clk-7xx.c
+++ b/drivers/clk/ti/clk-7xx.c
@@ -708,6 +708,7 @@ static const struct omap_clkctrl_reg_data dra7_wkupaon_clkctrl_regs[] __initcons
708 { DRA7_COUNTER_32K_CLKCTRL, NULL, 0, "wkupaon_iclk_mux" }, 708 { DRA7_COUNTER_32K_CLKCTRL, NULL, 0, "wkupaon_iclk_mux" },
709 { DRA7_UART10_CLKCTRL, dra7_uart10_bit_data, CLKF_SW_SUP, "wkupaon_cm:clk:0060:24" }, 709 { DRA7_UART10_CLKCTRL, dra7_uart10_bit_data, CLKF_SW_SUP, "wkupaon_cm:clk:0060:24" },
710 { DRA7_DCAN1_CLKCTRL, dra7_dcan1_bit_data, CLKF_SW_SUP, "wkupaon_cm:clk:0068:24" }, 710 { DRA7_DCAN1_CLKCTRL, dra7_dcan1_bit_data, CLKF_SW_SUP, "wkupaon_cm:clk:0068:24" },
711 { DRA7_ADC_CLKCTRL, NULL, CLKF_SW_SUP, "mcan_clk"},
711 { 0 }, 712 { 0 },
712}; 713};
713 714
diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
index e5cdc3af684c..2717f88c7904 100644
--- a/drivers/clocksource/timer-stm32.c
+++ b/drivers/clocksource/timer-stm32.c
@@ -304,8 +304,10 @@ static int __init stm32_timer_init(struct device_node *node)
304 304
305 to->private_data = kzalloc(sizeof(struct stm32_timer_private), 305 to->private_data = kzalloc(sizeof(struct stm32_timer_private),
306 GFP_KERNEL); 306 GFP_KERNEL);
307 if (!to->private_data) 307 if (!to->private_data) {
308 ret = -ENOMEM;
308 goto deinit; 309 goto deinit;
310 }
309 311
310 rstc = of_reset_control_get(node, NULL); 312 rstc = of_reset_control_get(node, NULL);
311 if (!IS_ERR(rstc)) { 313 if (!IS_ERR(rstc)) {
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 1de5ec8d5ea3..ece120da3353 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -294,6 +294,7 @@ struct pstate_funcs {
294static struct pstate_funcs pstate_funcs __read_mostly; 294static struct pstate_funcs pstate_funcs __read_mostly;
295 295
296static int hwp_active __read_mostly; 296static int hwp_active __read_mostly;
297static int hwp_mode_bdw __read_mostly;
297static bool per_cpu_limits __read_mostly; 298static bool per_cpu_limits __read_mostly;
298static bool hwp_boost __read_mostly; 299static bool hwp_boost __read_mostly;
299 300
@@ -1413,7 +1414,15 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
1413 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); 1414 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo();
1414 cpu->pstate.scaling = pstate_funcs.get_scaling(); 1415 cpu->pstate.scaling = pstate_funcs.get_scaling();
1415 cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; 1416 cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;
1416 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; 1417
1418 if (hwp_active && !hwp_mode_bdw) {
1419 unsigned int phy_max, current_max;
1420
1421 intel_pstate_get_hwp_max(cpu->cpu, &phy_max, &current_max);
1422 cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling;
1423 } else {
1424 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
1425 }
1417 1426
1418 if (pstate_funcs.get_aperf_mperf_shift) 1427 if (pstate_funcs.get_aperf_mperf_shift)
1419 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); 1428 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift();
@@ -2467,28 +2476,36 @@ static inline bool intel_pstate_has_acpi_ppc(void) { return false; }
2467static inline void intel_pstate_request_control_from_smm(void) {} 2476static inline void intel_pstate_request_control_from_smm(void) {}
2468#endif /* CONFIG_ACPI */ 2477#endif /* CONFIG_ACPI */
2469 2478
2479#define INTEL_PSTATE_HWP_BROADWELL 0x01
2480
2481#define ICPU_HWP(model, hwp_mode) \
2482 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_HWP, hwp_mode }
2483
2470static const struct x86_cpu_id hwp_support_ids[] __initconst = { 2484static const struct x86_cpu_id hwp_support_ids[] __initconst = {
2471 { X86_VENDOR_INTEL, 6, X86_MODEL_ANY, X86_FEATURE_HWP }, 2485 ICPU_HWP(INTEL_FAM6_BROADWELL_X, INTEL_PSTATE_HWP_BROADWELL),
2486 ICPU_HWP(INTEL_FAM6_BROADWELL_XEON_D, INTEL_PSTATE_HWP_BROADWELL),
2487 ICPU_HWP(X86_MODEL_ANY, 0),
2472 {} 2488 {}
2473}; 2489};
2474 2490
2475static int __init intel_pstate_init(void) 2491static int __init intel_pstate_init(void)
2476{ 2492{
2493 const struct x86_cpu_id *id;
2477 int rc; 2494 int rc;
2478 2495
2479 if (no_load) 2496 if (no_load)
2480 return -ENODEV; 2497 return -ENODEV;
2481 2498
2482 if (x86_match_cpu(hwp_support_ids)) { 2499 id = x86_match_cpu(hwp_support_ids);
2500 if (id) {
2483 copy_cpu_funcs(&core_funcs); 2501 copy_cpu_funcs(&core_funcs);
2484 if (!no_hwp) { 2502 if (!no_hwp) {
2485 hwp_active++; 2503 hwp_active++;
2504 hwp_mode_bdw = id->driver_data;
2486 intel_pstate.attr = hwp_cpufreq_attrs; 2505 intel_pstate.attr = hwp_cpufreq_attrs;
2487 goto hwp_cpu_matched; 2506 goto hwp_cpu_matched;
2488 } 2507 }
2489 } else { 2508 } else {
2490 const struct x86_cpu_id *id;
2491
2492 id = x86_match_cpu(intel_pstate_cpu_ids); 2509 id = x86_match_cpu(intel_pstate_cpu_ids);
2493 if (!id) 2510 if (!id)
2494 return -ENODEV; 2511 return -ENODEV;
diff --git a/drivers/cpufreq/qcom-cpufreq-kryo.c b/drivers/cpufreq/qcom-cpufreq-kryo.c
index d049fe4b80c4..29389accf3e9 100644
--- a/drivers/cpufreq/qcom-cpufreq-kryo.c
+++ b/drivers/cpufreq/qcom-cpufreq-kryo.c
@@ -42,6 +42,8 @@ enum _msm8996_version {
42 NUM_OF_MSM8996_VERSIONS, 42 NUM_OF_MSM8996_VERSIONS,
43}; 43};
44 44
45struct platform_device *cpufreq_dt_pdev, *kryo_cpufreq_pdev;
46
45static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void) 47static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)
46{ 48{
47 size_t len; 49 size_t len;
@@ -74,7 +76,6 @@ static enum _msm8996_version __init qcom_cpufreq_kryo_get_msm_id(void)
74static int qcom_cpufreq_kryo_probe(struct platform_device *pdev) 76static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
75{ 77{
76 struct opp_table *opp_tables[NR_CPUS] = {0}; 78 struct opp_table *opp_tables[NR_CPUS] = {0};
77 struct platform_device *cpufreq_dt_pdev;
78 enum _msm8996_version msm8996_version; 79 enum _msm8996_version msm8996_version;
79 struct nvmem_cell *speedbin_nvmem; 80 struct nvmem_cell *speedbin_nvmem;
80 struct device_node *np; 81 struct device_node *np;
@@ -86,8 +87,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
86 int ret; 87 int ret;
87 88
88 cpu_dev = get_cpu_device(0); 89 cpu_dev = get_cpu_device(0);
89 if (NULL == cpu_dev) 90 if (!cpu_dev)
90 ret = -ENODEV; 91 return -ENODEV;
91 92
92 msm8996_version = qcom_cpufreq_kryo_get_msm_id(); 93 msm8996_version = qcom_cpufreq_kryo_get_msm_id();
93 if (NUM_OF_MSM8996_VERSIONS == msm8996_version) { 94 if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
@@ -96,8 +97,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
96 } 97 }
97 98
98 np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); 99 np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
99 if (IS_ERR(np)) 100 if (!np)
100 return PTR_ERR(np); 101 return -ENOENT;
101 102
102 ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu"); 103 ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu");
103 if (!ret) { 104 if (!ret) {
@@ -115,6 +116,8 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
115 116
116 speedbin = nvmem_cell_read(speedbin_nvmem, &len); 117 speedbin = nvmem_cell_read(speedbin_nvmem, &len);
117 nvmem_cell_put(speedbin_nvmem); 118 nvmem_cell_put(speedbin_nvmem);
119 if (IS_ERR(speedbin))
120 return PTR_ERR(speedbin);
118 121
119 switch (msm8996_version) { 122 switch (msm8996_version) {
120 case MSM8996_V3: 123 case MSM8996_V3:
@@ -127,6 +130,7 @@ static int qcom_cpufreq_kryo_probe(struct platform_device *pdev)
127 BUG(); 130 BUG();
128 break; 131 break;
129 } 132 }
133 kfree(speedbin);
130 134
131 for_each_possible_cpu(cpu) { 135 for_each_possible_cpu(cpu) {
132 cpu_dev = get_cpu_device(cpu); 136 cpu_dev = get_cpu_device(cpu);
@@ -162,8 +166,15 @@ free_opp:
162 return ret; 166 return ret;
163} 167}
164 168
169static int qcom_cpufreq_kryo_remove(struct platform_device *pdev)
170{
171 platform_device_unregister(cpufreq_dt_pdev);
172 return 0;
173}
174
165static struct platform_driver qcom_cpufreq_kryo_driver = { 175static struct platform_driver qcom_cpufreq_kryo_driver = {
166 .probe = qcom_cpufreq_kryo_probe, 176 .probe = qcom_cpufreq_kryo_probe,
177 .remove = qcom_cpufreq_kryo_remove,
167 .driver = { 178 .driver = {
168 .name = "qcom-cpufreq-kryo", 179 .name = "qcom-cpufreq-kryo",
169 }, 180 },
@@ -198,8 +209,9 @@ static int __init qcom_cpufreq_kryo_init(void)
198 if (unlikely(ret < 0)) 209 if (unlikely(ret < 0))
199 return ret; 210 return ret;
200 211
201 ret = PTR_ERR_OR_ZERO(platform_device_register_simple( 212 kryo_cpufreq_pdev = platform_device_register_simple(
202 "qcom-cpufreq-kryo", -1, NULL, 0)); 213 "qcom-cpufreq-kryo", -1, NULL, 0);
214 ret = PTR_ERR_OR_ZERO(kryo_cpufreq_pdev);
203 if (0 == ret) 215 if (0 == ret)
204 return 0; 216 return 0;
205 217
@@ -208,5 +220,12 @@ static int __init qcom_cpufreq_kryo_init(void)
208} 220}
209module_init(qcom_cpufreq_kryo_init); 221module_init(qcom_cpufreq_kryo_init);
210 222
223static void __init qcom_cpufreq_kryo_exit(void)
224{
225 platform_device_unregister(kryo_cpufreq_pdev);
226 platform_driver_unregister(&qcom_cpufreq_kryo_driver);
227}
228module_exit(qcom_cpufreq_kryo_exit);
229
211MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Kryo CPUfreq driver"); 230MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Kryo CPUfreq driver");
212MODULE_LICENSE("GPL v2"); 231MODULE_LICENSE("GPL v2");
diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c
index 00c7aab8e7d0..afebbd87c4aa 100644
--- a/drivers/crypto/chelsio/chtls/chtls_io.c
+++ b/drivers/crypto/chelsio/chtls/chtls_io.c
@@ -1548,15 +1548,14 @@ skip_copy:
1548 tp->urg_data = 0; 1548 tp->urg_data = 0;
1549 1549
1550 if ((avail + offset) >= skb->len) { 1550 if ((avail + offset) >= skb->len) {
1551 if (likely(skb))
1552 chtls_free_skb(sk, skb);
1553 buffers_freed++;
1554 if (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_TLS_HDR) { 1551 if (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_TLS_HDR) {
1555 tp->copied_seq += skb->len; 1552 tp->copied_seq += skb->len;
1556 hws->rcvpld = skb->hdr_len; 1553 hws->rcvpld = skb->hdr_len;
1557 } else { 1554 } else {
1558 tp->copied_seq += hws->rcvpld; 1555 tp->copied_seq += hws->rcvpld;
1559 } 1556 }
1557 chtls_free_skb(sk, skb);
1558 buffers_freed++;
1560 hws->copied_seq = 0; 1559 hws->copied_seq = 0;
1561 if (copied >= target && 1560 if (copied >= target &&
1562 !skb_peek(&sk->sk_receive_queue)) 1561 !skb_peek(&sk->sk_receive_queue))
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 903d9c473749..45276abf03aa 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -86,6 +86,7 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
86{ 86{
87 struct dax_device *dax_dev; 87 struct dax_device *dax_dev;
88 bool dax_enabled = false; 88 bool dax_enabled = false;
89 struct request_queue *q;
89 pgoff_t pgoff; 90 pgoff_t pgoff;
90 int err, id; 91 int err, id;
91 void *kaddr; 92 void *kaddr;
@@ -99,6 +100,13 @@ bool __bdev_dax_supported(struct block_device *bdev, int blocksize)
99 return false; 100 return false;
100 } 101 }
101 102
103 q = bdev_get_queue(bdev);
104 if (!q || !blk_queue_dax(q)) {
105 pr_debug("%s: error: request queue doesn't support dax\n",
106 bdevname(bdev, buf));
107 return false;
108 }
109
102 err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff); 110 err = bdev_dax_pgoff(bdev, 0, PAGE_SIZE, &pgoff);
103 if (err) { 111 if (err) {
104 pr_debug("%s: error: unaligned partition for dax\n", 112 pr_debug("%s: error: unaligned partition for dax\n",
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 951b6c79f166..624a11cb07e2 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -47,6 +47,7 @@ DEFINE_DMI_ATTR_WITH_SHOW(product_name, 0444, DMI_PRODUCT_NAME);
47DEFINE_DMI_ATTR_WITH_SHOW(product_version, 0444, DMI_PRODUCT_VERSION); 47DEFINE_DMI_ATTR_WITH_SHOW(product_version, 0444, DMI_PRODUCT_VERSION);
48DEFINE_DMI_ATTR_WITH_SHOW(product_serial, 0400, DMI_PRODUCT_SERIAL); 48DEFINE_DMI_ATTR_WITH_SHOW(product_serial, 0400, DMI_PRODUCT_SERIAL);
49DEFINE_DMI_ATTR_WITH_SHOW(product_uuid, 0400, DMI_PRODUCT_UUID); 49DEFINE_DMI_ATTR_WITH_SHOW(product_uuid, 0400, DMI_PRODUCT_UUID);
50DEFINE_DMI_ATTR_WITH_SHOW(product_sku, 0444, DMI_PRODUCT_SKU);
50DEFINE_DMI_ATTR_WITH_SHOW(product_family, 0444, DMI_PRODUCT_FAMILY); 51DEFINE_DMI_ATTR_WITH_SHOW(product_family, 0444, DMI_PRODUCT_FAMILY);
51DEFINE_DMI_ATTR_WITH_SHOW(board_vendor, 0444, DMI_BOARD_VENDOR); 52DEFINE_DMI_ATTR_WITH_SHOW(board_vendor, 0444, DMI_BOARD_VENDOR);
52DEFINE_DMI_ATTR_WITH_SHOW(board_name, 0444, DMI_BOARD_NAME); 53DEFINE_DMI_ATTR_WITH_SHOW(board_name, 0444, DMI_BOARD_NAME);
@@ -193,6 +194,7 @@ static void __init dmi_id_init_attr_table(void)
193 ADD_DMI_ATTR(product_serial, DMI_PRODUCT_SERIAL); 194 ADD_DMI_ATTR(product_serial, DMI_PRODUCT_SERIAL);
194 ADD_DMI_ATTR(product_uuid, DMI_PRODUCT_UUID); 195 ADD_DMI_ATTR(product_uuid, DMI_PRODUCT_UUID);
195 ADD_DMI_ATTR(product_family, DMI_PRODUCT_FAMILY); 196 ADD_DMI_ATTR(product_family, DMI_PRODUCT_FAMILY);
197 ADD_DMI_ATTR(product_sku, DMI_PRODUCT_SKU);
196 ADD_DMI_ATTR(board_vendor, DMI_BOARD_VENDOR); 198 ADD_DMI_ATTR(board_vendor, DMI_BOARD_VENDOR);
197 ADD_DMI_ATTR(board_name, DMI_BOARD_NAME); 199 ADD_DMI_ATTR(board_name, DMI_BOARD_NAME);
198 ADD_DMI_ATTR(board_version, DMI_BOARD_VERSION); 200 ADD_DMI_ATTR(board_version, DMI_BOARD_VERSION);
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 54e66adef252..f2483548cde9 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -447,6 +447,7 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
447 dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6); 447 dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6);
448 dmi_save_ident(dm, DMI_PRODUCT_SERIAL, 7); 448 dmi_save_ident(dm, DMI_PRODUCT_SERIAL, 7);
449 dmi_save_uuid(dm, DMI_PRODUCT_UUID, 8); 449 dmi_save_uuid(dm, DMI_PRODUCT_UUID, 8);
450 dmi_save_ident(dm, DMI_PRODUCT_SKU, 25);
450 dmi_save_ident(dm, DMI_PRODUCT_FAMILY, 26); 451 dmi_save_ident(dm, DMI_PRODUCT_FAMILY, 26);
451 break; 452 break;
452 case 2: /* Base Board Information */ 453 case 2: /* Base Board Information */
diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index caa37a6dd9d4..a90b0b8fc69a 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -64,7 +64,7 @@ static void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg)
64 efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; 64 efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID;
65 efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; 65 efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID;
66 efi_status_t status; 66 efi_status_t status;
67 efi_physical_addr_t log_location, log_last_entry; 67 efi_physical_addr_t log_location = 0, log_last_entry = 0;
68 struct linux_efi_tpm_eventlog *log_tbl = NULL; 68 struct linux_efi_tpm_eventlog *log_tbl = NULL;
69 unsigned long first_entry_addr, last_entry_addr; 69 unsigned long first_entry_addr, last_entry_addr;
70 size_t log_size, last_entry_size; 70 size_t log_size, last_entry_size;
diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 6692888f04cf..a200a2174611 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -21,6 +21,10 @@
21#define MBOX_DATA28(msg) ((msg) & ~0xf) 21#define MBOX_DATA28(msg) ((msg) & ~0xf)
22#define MBOX_CHAN_PROPERTY 8 22#define MBOX_CHAN_PROPERTY 8
23 23
24#define MAX_RPI_FW_PROP_BUF_SIZE 32
25
26static struct platform_device *rpi_hwmon;
27
24struct rpi_firmware { 28struct rpi_firmware {
25 struct mbox_client cl; 29 struct mbox_client cl;
26 struct mbox_chan *chan; /* The property channel. */ 30 struct mbox_chan *chan; /* The property channel. */
@@ -143,18 +147,22 @@ int rpi_firmware_property(struct rpi_firmware *fw,
143 /* Single tags are very small (generally 8 bytes), so the 147 /* Single tags are very small (generally 8 bytes), so the
144 * stack should be safe. 148 * stack should be safe.
145 */ 149 */
146 u8 data[buf_size + sizeof(struct rpi_firmware_property_tag_header)]; 150 u8 data[sizeof(struct rpi_firmware_property_tag_header) +
151 MAX_RPI_FW_PROP_BUF_SIZE];
147 struct rpi_firmware_property_tag_header *header = 152 struct rpi_firmware_property_tag_header *header =
148 (struct rpi_firmware_property_tag_header *)data; 153 (struct rpi_firmware_property_tag_header *)data;
149 int ret; 154 int ret;
150 155
156 if (WARN_ON(buf_size > sizeof(data) - sizeof(*header)))
157 return -EINVAL;
158
151 header->tag = tag; 159 header->tag = tag;
152 header->buf_size = buf_size; 160 header->buf_size = buf_size;
153 header->req_resp_size = 0; 161 header->req_resp_size = 0;
154 memcpy(data + sizeof(struct rpi_firmware_property_tag_header), 162 memcpy(data + sizeof(struct rpi_firmware_property_tag_header),
155 tag_data, buf_size); 163 tag_data, buf_size);
156 164
157 ret = rpi_firmware_property_list(fw, &data, sizeof(data)); 165 ret = rpi_firmware_property_list(fw, &data, buf_size + sizeof(*header));
158 memcpy(tag_data, 166 memcpy(tag_data,
159 data + sizeof(struct rpi_firmware_property_tag_header), 167 data + sizeof(struct rpi_firmware_property_tag_header),
160 buf_size); 168 buf_size);
@@ -183,6 +191,20 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
183 } 191 }
184} 192}
185 193
194static void
195rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
196{
197 u32 packet;
198 int ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_THROTTLED,
199 &packet, sizeof(packet));
200
201 if (ret)
202 return;
203
204 rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
205 -1, NULL, 0);
206}
207
186static int rpi_firmware_probe(struct platform_device *pdev) 208static int rpi_firmware_probe(struct platform_device *pdev)
187{ 209{
188 struct device *dev = &pdev->dev; 210 struct device *dev = &pdev->dev;
@@ -209,6 +231,7 @@ static int rpi_firmware_probe(struct platform_device *pdev)
209 platform_set_drvdata(pdev, fw); 231 platform_set_drvdata(pdev, fw);
210 232
211 rpi_firmware_print_firmware_revision(fw); 233 rpi_firmware_print_firmware_revision(fw);
234 rpi_register_hwmon_driver(dev, fw);
212 235
213 return 0; 236 return 0;
214} 237}
@@ -217,6 +240,8 @@ static int rpi_firmware_remove(struct platform_device *pdev)
217{ 240{
218 struct rpi_firmware *fw = platform_get_drvdata(pdev); 241 struct rpi_firmware *fw = platform_get_drvdata(pdev);
219 242
243 platform_device_unregister(rpi_hwmon);
244 rpi_hwmon = NULL;
220 mbox_free_channel(fw->chan); 245 mbox_free_channel(fw->chan);
221 246
222 return 0; 247 return 0;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 3317d1536f4f..6e5284e6c028 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2158,10 +2158,18 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
2158 switch (asic_type) { 2158 switch (asic_type) {
2159#if defined(CONFIG_DRM_AMD_DC) 2159#if defined(CONFIG_DRM_AMD_DC)
2160 case CHIP_BONAIRE: 2160 case CHIP_BONAIRE:
2161 case CHIP_HAWAII:
2162 case CHIP_KAVERI: 2161 case CHIP_KAVERI:
2163 case CHIP_KABINI: 2162 case CHIP_KABINI:
2164 case CHIP_MULLINS: 2163 case CHIP_MULLINS:
2164 /*
2165 * We have systems in the wild with these ASICs that require
2166 * LVDS and VGA support which is not supported with DC.
2167 *
2168 * Fallback to the non-DC driver here by default so as not to
2169 * cause regressions.
2170 */
2171 return amdgpu_dc > 0;
2172 case CHIP_HAWAII:
2165 case CHIP_CARRIZO: 2173 case CHIP_CARRIZO:
2166 case CHIP_STONEY: 2174 case CHIP_STONEY:
2167 case CHIP_POLARIS10: 2175 case CHIP_POLARIS10:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 39ec6b8890a1..e74d620d9699 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -376,7 +376,7 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
376 struct amdgpu_device *adev = ring->adev; 376 struct amdgpu_device *adev = ring->adev;
377 uint64_t index; 377 uint64_t index;
378 378
379 if (ring != &adev->uvd.inst[ring->me].ring) { 379 if (ring->funcs->type != AMDGPU_RING_TYPE_UVD) {
380 ring->fence_drv.cpu_addr = &adev->wb.wb[ring->fence_offs]; 380 ring->fence_drv.cpu_addr = &adev->wb.wb[ring->fence_offs];
381 ring->fence_drv.gpu_addr = adev->wb.gpu_addr + (ring->fence_offs * 4); 381 ring->fence_drv.gpu_addr = adev->wb.gpu_addr + (ring->fence_offs * 4);
382 } else { 382 } else {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 5e4e1bd90383..3526efa8960e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -762,8 +762,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
762 domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); 762 domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
763 if (domain == AMDGPU_GEM_DOMAIN_VRAM) { 763 if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
764 adev->vram_pin_size += amdgpu_bo_size(bo); 764 adev->vram_pin_size += amdgpu_bo_size(bo);
765 if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) 765 adev->invisible_pin_size += amdgpu_vram_mgr_bo_invisible_size(bo);
766 adev->invisible_pin_size += amdgpu_bo_size(bo);
767 } else if (domain == AMDGPU_GEM_DOMAIN_GTT) { 766 } else if (domain == AMDGPU_GEM_DOMAIN_GTT) {
768 adev->gart_pin_size += amdgpu_bo_size(bo); 767 adev->gart_pin_size += amdgpu_bo_size(bo);
769 } 768 }
@@ -790,25 +789,22 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
790 bo->pin_count--; 789 bo->pin_count--;
791 if (bo->pin_count) 790 if (bo->pin_count)
792 return 0; 791 return 0;
793 for (i = 0; i < bo->placement.num_placement; i++) {
794 bo->placements[i].lpfn = 0;
795 bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
796 }
797 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
798 if (unlikely(r)) {
799 dev_err(adev->dev, "%p validate failed for unpin\n", bo);
800 goto error;
801 }
802 792
803 if (bo->tbo.mem.mem_type == TTM_PL_VRAM) { 793 if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
804 adev->vram_pin_size -= amdgpu_bo_size(bo); 794 adev->vram_pin_size -= amdgpu_bo_size(bo);
805 if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) 795 adev->invisible_pin_size -= amdgpu_vram_mgr_bo_invisible_size(bo);
806 adev->invisible_pin_size -= amdgpu_bo_size(bo);
807 } else if (bo->tbo.mem.mem_type == TTM_PL_TT) { 796 } else if (bo->tbo.mem.mem_type == TTM_PL_TT) {
808 adev->gart_pin_size -= amdgpu_bo_size(bo); 797 adev->gart_pin_size -= amdgpu_bo_size(bo);
809 } 798 }
810 799
811error: 800 for (i = 0; i < bo->placement.num_placement; i++) {
801 bo->placements[i].lpfn = 0;
802 bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
803 }
804 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
805 if (unlikely(r))
806 dev_err(adev->dev, "%p validate failed for unpin\n", bo);
807
812 return r; 808 return r;
813} 809}
814 810
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
index e969c879d87e..e5da4654b630 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
@@ -73,6 +73,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_mem_reg *mem);
73uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man); 73uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man);
74int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man); 74int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man);
75 75
76u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo);
76uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man); 77uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man);
77uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man); 78uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man);
78 79
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index bcf68f80bbf0..3ff08e326838 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -130,7 +130,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
130 unsigned version_major, version_minor, family_id; 130 unsigned version_major, version_minor, family_id;
131 int i, j, r; 131 int i, j, r;
132 132
133 INIT_DELAYED_WORK(&adev->uvd.inst->idle_work, amdgpu_uvd_idle_work_handler); 133 INIT_DELAYED_WORK(&adev->uvd.idle_work, amdgpu_uvd_idle_work_handler);
134 134
135 switch (adev->asic_type) { 135 switch (adev->asic_type) {
136#ifdef CONFIG_DRM_AMDGPU_CIK 136#ifdef CONFIG_DRM_AMDGPU_CIK
@@ -314,12 +314,12 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
314 void *ptr; 314 void *ptr;
315 int i, j; 315 int i, j;
316 316
317 cancel_delayed_work_sync(&adev->uvd.idle_work);
318
317 for (j = 0; j < adev->uvd.num_uvd_inst; ++j) { 319 for (j = 0; j < adev->uvd.num_uvd_inst; ++j) {
318 if (adev->uvd.inst[j].vcpu_bo == NULL) 320 if (adev->uvd.inst[j].vcpu_bo == NULL)
319 continue; 321 continue;
320 322
321 cancel_delayed_work_sync(&adev->uvd.inst[j].idle_work);
322
323 /* only valid for physical mode */ 323 /* only valid for physical mode */
324 if (adev->asic_type < CHIP_POLARIS10) { 324 if (adev->asic_type < CHIP_POLARIS10) {
325 for (i = 0; i < adev->uvd.max_handles; ++i) 325 for (i = 0; i < adev->uvd.max_handles; ++i)
@@ -1145,7 +1145,7 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
1145static void amdgpu_uvd_idle_work_handler(struct work_struct *work) 1145static void amdgpu_uvd_idle_work_handler(struct work_struct *work)
1146{ 1146{
1147 struct amdgpu_device *adev = 1147 struct amdgpu_device *adev =
1148 container_of(work, struct amdgpu_device, uvd.inst->idle_work.work); 1148 container_of(work, struct amdgpu_device, uvd.idle_work.work);
1149 unsigned fences = 0, i, j; 1149 unsigned fences = 0, i, j;
1150 1150
1151 for (i = 0; i < adev->uvd.num_uvd_inst; ++i) { 1151 for (i = 0; i < adev->uvd.num_uvd_inst; ++i) {
@@ -1167,7 +1167,7 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work)
1167 AMD_CG_STATE_GATE); 1167 AMD_CG_STATE_GATE);
1168 } 1168 }
1169 } else { 1169 } else {
1170 schedule_delayed_work(&adev->uvd.inst->idle_work, UVD_IDLE_TIMEOUT); 1170 schedule_delayed_work(&adev->uvd.idle_work, UVD_IDLE_TIMEOUT);
1171 } 1171 }
1172} 1172}
1173 1173
@@ -1179,7 +1179,7 @@ void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring)
1179 if (amdgpu_sriov_vf(adev)) 1179 if (amdgpu_sriov_vf(adev))
1180 return; 1180 return;
1181 1181
1182 set_clocks = !cancel_delayed_work_sync(&adev->uvd.inst->idle_work); 1182 set_clocks = !cancel_delayed_work_sync(&adev->uvd.idle_work);
1183 if (set_clocks) { 1183 if (set_clocks) {
1184 if (adev->pm.dpm_enabled) { 1184 if (adev->pm.dpm_enabled) {
1185 amdgpu_dpm_enable_uvd(adev, true); 1185 amdgpu_dpm_enable_uvd(adev, true);
@@ -1196,7 +1196,7 @@ void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring)
1196void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring) 1196void amdgpu_uvd_ring_end_use(struct amdgpu_ring *ring)
1197{ 1197{
1198 if (!amdgpu_sriov_vf(ring->adev)) 1198 if (!amdgpu_sriov_vf(ring->adev))
1199 schedule_delayed_work(&ring->adev->uvd.inst->idle_work, UVD_IDLE_TIMEOUT); 1199 schedule_delayed_work(&ring->adev->uvd.idle_work, UVD_IDLE_TIMEOUT);
1200} 1200}
1201 1201
1202/** 1202/**
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
index b1579fba134c..8b23a1b00c76 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
@@ -44,7 +44,6 @@ struct amdgpu_uvd_inst {
44 void *saved_bo; 44 void *saved_bo;
45 atomic_t handles[AMDGPU_MAX_UVD_HANDLES]; 45 atomic_t handles[AMDGPU_MAX_UVD_HANDLES];
46 struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES]; 46 struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES];
47 struct delayed_work idle_work;
48 struct amdgpu_ring ring; 47 struct amdgpu_ring ring;
49 struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS]; 48 struct amdgpu_ring ring_enc[AMDGPU_MAX_UVD_ENC_RINGS];
50 struct amdgpu_irq_src irq; 49 struct amdgpu_irq_src irq;
@@ -62,6 +61,7 @@ struct amdgpu_uvd {
62 bool address_64_bit; 61 bool address_64_bit;
63 bool use_ctx_buf; 62 bool use_ctx_buf;
64 struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES]; 63 struct amdgpu_uvd_inst inst[AMDGPU_MAX_UVD_INSTANCES];
64 struct delayed_work idle_work;
65}; 65};
66 66
67int amdgpu_uvd_sw_init(struct amdgpu_device *adev); 67int amdgpu_uvd_sw_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 127e87b470ff..1b4ad9b2a755 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -52,7 +52,7 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
52 unsigned long bo_size; 52 unsigned long bo_size;
53 const char *fw_name; 53 const char *fw_name;
54 const struct common_firmware_header *hdr; 54 const struct common_firmware_header *hdr;
55 unsigned version_major, version_minor, family_id; 55 unsigned char fw_check;
56 int r; 56 int r;
57 57
58 INIT_DELAYED_WORK(&adev->vcn.idle_work, amdgpu_vcn_idle_work_handler); 58 INIT_DELAYED_WORK(&adev->vcn.idle_work, amdgpu_vcn_idle_work_handler);
@@ -83,12 +83,33 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
83 83
84 hdr = (const struct common_firmware_header *)adev->vcn.fw->data; 84 hdr = (const struct common_firmware_header *)adev->vcn.fw->data;
85 adev->vcn.fw_version = le32_to_cpu(hdr->ucode_version); 85 adev->vcn.fw_version = le32_to_cpu(hdr->ucode_version);
86 family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
87 version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
88 version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
89 DRM_INFO("Found VCN firmware Version: %hu.%hu Family ID: %hu\n",
90 version_major, version_minor, family_id);
91 86
87 /* Bit 20-23, it is encode major and non-zero for new naming convention.
88 * This field is part of version minor and DRM_DISABLED_FLAG in old naming
89 * convention. Since the l:wq!atest version minor is 0x5B and DRM_DISABLED_FLAG
90 * is zero in old naming convention, this field is always zero so far.
91 * These four bits are used to tell which naming convention is present.
92 */
93 fw_check = (le32_to_cpu(hdr->ucode_version) >> 20) & 0xf;
94 if (fw_check) {
95 unsigned int dec_ver, enc_major, enc_minor, vep, fw_rev;
96
97 fw_rev = le32_to_cpu(hdr->ucode_version) & 0xfff;
98 enc_minor = (le32_to_cpu(hdr->ucode_version) >> 12) & 0xff;
99 enc_major = fw_check;
100 dec_ver = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xf;
101 vep = (le32_to_cpu(hdr->ucode_version) >> 28) & 0xf;
102 DRM_INFO("Found VCN firmware Version ENC: %hu.%hu DEC: %hu VEP: %hu Revision: %hu\n",
103 enc_major, enc_minor, dec_ver, vep, fw_rev);
104 } else {
105 unsigned int version_major, version_minor, family_id;
106
107 family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
108 version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
109 version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
110 DRM_INFO("Found VCN firmware Version: %hu.%hu Family ID: %hu\n",
111 version_major, version_minor, family_id);
112 }
92 113
93 bo_size = AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8) 114 bo_size = AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8)
94 + AMDGPU_VCN_STACK_SIZE + AMDGPU_VCN_HEAP_SIZE 115 + AMDGPU_VCN_STACK_SIZE + AMDGPU_VCN_HEAP_SIZE
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b0eb2f537392..edf16b2b957a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1463,7 +1463,9 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
1463 uint64_t count; 1463 uint64_t count;
1464 1464
1465 max_entries = min(max_entries, 16ull * 1024ull); 1465 max_entries = min(max_entries, 16ull * 1024ull);
1466 for (count = 1; count < max_entries; ++count) { 1466 for (count = 1;
1467 count < max_entries / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
1468 ++count) {
1467 uint64_t idx = pfn + count; 1469 uint64_t idx = pfn + count;
1468 1470
1469 if (pages_addr[idx] != 1471 if (pages_addr[idx] !=
@@ -1476,7 +1478,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
1476 dma_addr = pages_addr; 1478 dma_addr = pages_addr;
1477 } else { 1479 } else {
1478 addr = pages_addr[pfn]; 1480 addr = pages_addr[pfn];
1479 max_entries = count; 1481 max_entries = count * (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
1480 } 1482 }
1481 1483
1482 } else if (flags & AMDGPU_PTE_VALID) { 1484 } else if (flags & AMDGPU_PTE_VALID) {
@@ -1491,7 +1493,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
1491 if (r) 1493 if (r)
1492 return r; 1494 return r;
1493 1495
1494 pfn += last - start + 1; 1496 pfn += (last - start + 1) / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
1495 if (nodes && nodes->size == pfn) { 1497 if (nodes && nodes->size == pfn) {
1496 pfn = 0; 1498 pfn = 0;
1497 ++nodes; 1499 ++nodes;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 9aca653bec07..b6333f92ba45 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -97,6 +97,38 @@ static u64 amdgpu_vram_mgr_vis_size(struct amdgpu_device *adev,
97} 97}
98 98
99/** 99/**
100 * amdgpu_vram_mgr_bo_invisible_size - CPU invisible BO size
101 *
102 * @bo: &amdgpu_bo buffer object (must be in VRAM)
103 *
104 * Returns:
105 * How much of the given &amdgpu_bo buffer object lies in CPU invisible VRAM.
106 */
107u64 amdgpu_vram_mgr_bo_invisible_size(struct amdgpu_bo *bo)
108{
109 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
110 struct ttm_mem_reg *mem = &bo->tbo.mem;
111 struct drm_mm_node *nodes = mem->mm_node;
112 unsigned pages = mem->num_pages;
113 u64 usage = 0;
114
115 if (adev->gmc.visible_vram_size == adev->gmc.real_vram_size)
116 return 0;
117
118 if (mem->start >= adev->gmc.visible_vram_size >> PAGE_SHIFT)
119 return amdgpu_bo_size(bo);
120
121 while (nodes && pages) {
122 usage += nodes->size << PAGE_SHIFT;
123 usage -= amdgpu_vram_mgr_vis_size(adev, nodes);
124 pages -= nodes->size;
125 ++nodes;
126 }
127
128 return usage;
129}
130
131/**
100 * amdgpu_vram_mgr_new - allocate new ranges 132 * amdgpu_vram_mgr_new - allocate new ranges
101 * 133 *
102 * @man: TTM memory type manager 134 * @man: TTM memory type manager
@@ -135,7 +167,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,
135 num_nodes = DIV_ROUND_UP(mem->num_pages, pages_per_node); 167 num_nodes = DIV_ROUND_UP(mem->num_pages, pages_per_node);
136 } 168 }
137 169
138 nodes = kcalloc(num_nodes, sizeof(*nodes), GFP_KERNEL); 170 nodes = kvmalloc_array(num_nodes, sizeof(*nodes),
171 GFP_KERNEL | __GFP_ZERO);
139 if (!nodes) 172 if (!nodes)
140 return -ENOMEM; 173 return -ENOMEM;
141 174
@@ -190,7 +223,7 @@ error:
190 drm_mm_remove_node(&nodes[i]); 223 drm_mm_remove_node(&nodes[i]);
191 spin_unlock(&mgr->lock); 224 spin_unlock(&mgr->lock);
192 225
193 kfree(nodes); 226 kvfree(nodes);
194 return r == -ENOSPC ? 0 : r; 227 return r == -ENOSPC ? 0 : r;
195} 228}
196 229
@@ -229,7 +262,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
229 atomic64_sub(usage, &mgr->usage); 262 atomic64_sub(usage, &mgr->usage);
230 atomic64_sub(vis_usage, &mgr->vis_usage); 263 atomic64_sub(vis_usage, &mgr->vis_usage);
231 264
232 kfree(mem->mm_node); 265 kvfree(mem->mm_node);
233 mem->mm_node = NULL; 266 mem->mm_node = NULL;
234} 267}
235 268
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index f9add85157e7..3a8d6356afc2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3928,10 +3928,11 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,
3928 if (acrtc->base.state->event) 3928 if (acrtc->base.state->event)
3929 prepare_flip_isr(acrtc); 3929 prepare_flip_isr(acrtc);
3930 3930
3931 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
3932
3931 surface_updates->surface = dc_stream_get_status(acrtc_state->stream)->plane_states[0]; 3933 surface_updates->surface = dc_stream_get_status(acrtc_state->stream)->plane_states[0];
3932 surface_updates->flip_addr = &addr; 3934 surface_updates->flip_addr = &addr;
3933 3935
3934
3935 dc_commit_updates_for_stream(adev->dm.dc, 3936 dc_commit_updates_for_stream(adev->dm.dc,
3936 surface_updates, 3937 surface_updates,
3937 1, 3938 1,
@@ -3944,9 +3945,6 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,
3944 __func__, 3945 __func__,
3945 addr.address.grph.addr.high_part, 3946 addr.address.grph.addr.high_part,
3946 addr.address.grph.addr.low_part); 3947 addr.address.grph.addr.low_part);
3947
3948
3949 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
3950} 3948}
3951 3949
3952/* 3950/*
@@ -4206,6 +4204,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
4206 struct drm_connector *connector; 4204 struct drm_connector *connector;
4207 struct drm_connector_state *old_con_state, *new_con_state; 4205 struct drm_connector_state *old_con_state, *new_con_state;
4208 struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state; 4206 struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
4207 int crtc_disable_count = 0;
4209 4208
4210 drm_atomic_helper_update_legacy_modeset_state(dev, state); 4209 drm_atomic_helper_update_legacy_modeset_state(dev, state);
4211 4210
@@ -4410,6 +4409,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
4410 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc); 4409 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
4411 bool modeset_needed; 4410 bool modeset_needed;
4412 4411
4412 if (old_crtc_state->active && !new_crtc_state->active)
4413 crtc_disable_count++;
4414
4413 dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); 4415 dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
4414 dm_old_crtc_state = to_dm_crtc_state(old_crtc_state); 4416 dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
4415 modeset_needed = modeset_required( 4417 modeset_needed = modeset_required(
@@ -4463,11 +4465,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
4463 * so we can put the GPU into runtime suspend if we're not driving any 4465 * so we can put the GPU into runtime suspend if we're not driving any
4464 * displays anymore 4466 * displays anymore
4465 */ 4467 */
4468 for (i = 0; i < crtc_disable_count; i++)
4469 pm_runtime_put_autosuspend(dev->dev);
4466 pm_runtime_mark_last_busy(dev->dev); 4470 pm_runtime_mark_last_busy(dev->dev);
4467 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
4468 if (old_crtc_state->active && !new_crtc_state->active)
4469 pm_runtime_put_autosuspend(dev->dev);
4470 }
4471} 4471}
4472 4472
4473 4473
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c
index dbe4b1f66784..22364875a943 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c
@@ -1090,7 +1090,7 @@ static int vega10_disable_se_edc_config(struct pp_hwmgr *hwmgr)
1090static int vega10_enable_psm_gc_edc_config(struct pp_hwmgr *hwmgr) 1090static int vega10_enable_psm_gc_edc_config(struct pp_hwmgr *hwmgr)
1091{ 1091{
1092 struct amdgpu_device *adev = hwmgr->adev; 1092 struct amdgpu_device *adev = hwmgr->adev;
1093 int result; 1093 int result = 0;
1094 uint32_t num_se = 0; 1094 uint32_t num_se = 0;
1095 uint32_t count, data; 1095 uint32_t count, data;
1096 1096
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 8d20faa198cf..0a788d76ed5f 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -278,7 +278,6 @@ static int malidp_init(struct drm_device *drm)
278 278
279static void malidp_fini(struct drm_device *drm) 279static void malidp_fini(struct drm_device *drm)
280{ 280{
281 drm_atomic_helper_shutdown(drm);
282 drm_mode_config_cleanup(drm); 281 drm_mode_config_cleanup(drm);
283} 282}
284 283
@@ -646,6 +645,7 @@ vblank_fail:
646 malidp_de_irq_fini(drm); 645 malidp_de_irq_fini(drm);
647 drm->irq_enabled = false; 646 drm->irq_enabled = false;
648irq_init_fail: 647irq_init_fail:
648 drm_atomic_helper_shutdown(drm);
649 component_unbind_all(dev, drm); 649 component_unbind_all(dev, drm);
650bind_fail: 650bind_fail:
651 of_node_put(malidp->crtc.port); 651 of_node_put(malidp->crtc.port);
@@ -681,6 +681,7 @@ static void malidp_unbind(struct device *dev)
681 malidp_se_irq_fini(drm); 681 malidp_se_irq_fini(drm);
682 malidp_de_irq_fini(drm); 682 malidp_de_irq_fini(drm);
683 drm->irq_enabled = false; 683 drm->irq_enabled = false;
684 drm_atomic_helper_shutdown(drm);
684 component_unbind_all(dev, drm); 685 component_unbind_all(dev, drm);
685 of_node_put(malidp->crtc.port); 686 of_node_put(malidp->crtc.port);
686 malidp->crtc.port = NULL; 687 malidp->crtc.port = NULL;
diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index d789b46dc817..069783e715f1 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -634,7 +634,8 @@ const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES] = {
634 .vsync_irq = MALIDP500_DE_IRQ_VSYNC, 634 .vsync_irq = MALIDP500_DE_IRQ_VSYNC,
635 }, 635 },
636 .se_irq_map = { 636 .se_irq_map = {
637 .irq_mask = MALIDP500_SE_IRQ_CONF_MODE, 637 .irq_mask = MALIDP500_SE_IRQ_CONF_MODE |
638 MALIDP500_SE_IRQ_GLOBAL,
638 .vsync_irq = 0, 639 .vsync_irq = 0,
639 }, 640 },
640 .dc_irq_map = { 641 .dc_irq_map = {
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 7a44897c50fe..29409a65d864 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -23,6 +23,7 @@
23 23
24/* Layer specific register offsets */ 24/* Layer specific register offsets */
25#define MALIDP_LAYER_FORMAT 0x000 25#define MALIDP_LAYER_FORMAT 0x000
26#define LAYER_FORMAT_MASK 0x3f
26#define MALIDP_LAYER_CONTROL 0x004 27#define MALIDP_LAYER_CONTROL 0x004
27#define LAYER_ENABLE (1 << 0) 28#define LAYER_ENABLE (1 << 0)
28#define LAYER_FLOWCFG_MASK 7 29#define LAYER_FLOWCFG_MASK 7
@@ -235,8 +236,8 @@ static int malidp_de_plane_check(struct drm_plane *plane,
235 if (state->rotation & MALIDP_ROTATED_MASK) { 236 if (state->rotation & MALIDP_ROTATED_MASK) {
236 int val; 237 int val;
237 238
238 val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_h, 239 val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_w,
239 state->crtc_w, 240 state->crtc_h,
240 fb->format->format); 241 fb->format->format);
241 if (val < 0) 242 if (val < 0)
242 return val; 243 return val;
@@ -337,7 +338,9 @@ static void malidp_de_plane_update(struct drm_plane *plane,
337 dest_w = plane->state->crtc_w; 338 dest_w = plane->state->crtc_w;
338 dest_h = plane->state->crtc_h; 339 dest_h = plane->state->crtc_h;
339 340
340 malidp_hw_write(mp->hwdev, ms->format, mp->layer->base); 341 val = malidp_hw_read(mp->hwdev, mp->layer->base);
342 val = (val & ~LAYER_FORMAT_MASK) | ms->format;
343 malidp_hw_write(mp->hwdev, val, mp->layer->base);
341 344
342 for (i = 0; i < ms->n_planes; i++) { 345 for (i = 0; i < ms->n_planes; i++) {
343 /* calculate the offset for the layer's plane registers */ 346 /* calculate the offset for the layer's plane registers */
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 73c875db45f4..47e0992f3908 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -839,7 +839,7 @@ static int atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane)
839 return ret; 839 return ret;
840 } 840 }
841 841
842 if (desc->layout.xstride && desc->layout.pstride) { 842 if (desc->layout.xstride[0] && desc->layout.pstride[0]) {
843 int ret; 843 int ret;
844 844
845 ret = drm_plane_create_rotation_property(&plane->base, 845 ret = drm_plane_create_rotation_property(&plane->base,
diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
index 7ab36042a822..250effa0e6b8 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -36,8 +36,11 @@
36 36
37#define SII8620_BURST_BUF_LEN 288 37#define SII8620_BURST_BUF_LEN 288
38#define VAL_RX_HDMI_CTRL2_DEFVAL VAL_RX_HDMI_CTRL2_IDLE_CNT(3) 38#define VAL_RX_HDMI_CTRL2_DEFVAL VAL_RX_HDMI_CTRL2_IDLE_CNT(3)
39#define MHL1_MAX_LCLK 225000 39
40#define MHL3_MAX_LCLK 600000 40#define MHL1_MAX_PCLK 75000
41#define MHL1_MAX_PCLK_PP_MODE 150000
42#define MHL3_MAX_PCLK 200000
43#define MHL3_MAX_PCLK_PP_MODE 300000
41 44
42enum sii8620_mode { 45enum sii8620_mode {
43 CM_DISCONNECTED, 46 CM_DISCONNECTED,
@@ -80,6 +83,9 @@ struct sii8620 {
80 u8 devcap[MHL_DCAP_SIZE]; 83 u8 devcap[MHL_DCAP_SIZE];
81 u8 xdevcap[MHL_XDC_SIZE]; 84 u8 xdevcap[MHL_XDC_SIZE];
82 u8 avif[HDMI_INFOFRAME_SIZE(AVI)]; 85 u8 avif[HDMI_INFOFRAME_SIZE(AVI)];
86 bool feature_complete;
87 bool devcap_read;
88 bool sink_detected;
83 struct edid *edid; 89 struct edid *edid;
84 unsigned int gen2_write_burst:1; 90 unsigned int gen2_write_burst:1;
85 enum sii8620_mt_state mt_state; 91 enum sii8620_mt_state mt_state;
@@ -476,7 +482,7 @@ static void sii8620_update_array(u8 *dst, u8 *src, int count)
476 } 482 }
477} 483}
478 484
479static void sii8620_sink_detected(struct sii8620 *ctx, int ret) 485static void sii8620_identify_sink(struct sii8620 *ctx)
480{ 486{
481 static const char * const sink_str[] = { 487 static const char * const sink_str[] = {
482 [SINK_NONE] = "NONE", 488 [SINK_NONE] = "NONE",
@@ -487,7 +493,7 @@ static void sii8620_sink_detected(struct sii8620 *ctx, int ret)
487 char sink_name[20]; 493 char sink_name[20];
488 struct device *dev = ctx->dev; 494 struct device *dev = ctx->dev;
489 495
490 if (ret < 0) 496 if (!ctx->sink_detected || !ctx->devcap_read)
491 return; 497 return;
492 498
493 sii8620_fetch_edid(ctx); 499 sii8620_fetch_edid(ctx);
@@ -496,6 +502,7 @@ static void sii8620_sink_detected(struct sii8620 *ctx, int ret)
496 sii8620_mhl_disconnected(ctx); 502 sii8620_mhl_disconnected(ctx);
497 return; 503 return;
498 } 504 }
505 sii8620_set_upstream_edid(ctx);
499 506
500 if (drm_detect_hdmi_monitor(ctx->edid)) 507 if (drm_detect_hdmi_monitor(ctx->edid))
501 ctx->sink_type = SINK_HDMI; 508 ctx->sink_type = SINK_HDMI;
@@ -508,53 +515,6 @@ static void sii8620_sink_detected(struct sii8620 *ctx, int ret)
508 sink_str[ctx->sink_type], sink_name); 515 sink_str[ctx->sink_type], sink_name);
509} 516}
510 517
511static void sii8620_hsic_init(struct sii8620 *ctx)
512{
513 if (!sii8620_is_mhl3(ctx))
514 return;
515
516 sii8620_write(ctx, REG_FCGC,
517 BIT_FCGC_HSIC_HOSTMODE | BIT_FCGC_HSIC_ENABLE);
518 sii8620_setbits(ctx, REG_HRXCTRL3,
519 BIT_HRXCTRL3_HRX_STAY_RESET | BIT_HRXCTRL3_STATUS_EN, ~0);
520 sii8620_setbits(ctx, REG_TTXNUMB, MSK_TTXNUMB_TTX_NUMBPS, 4);
521 sii8620_setbits(ctx, REG_TRXCTRL, BIT_TRXCTRL_TRX_FROM_SE_COC, ~0);
522 sii8620_setbits(ctx, REG_HTXCTRL, BIT_HTXCTRL_HTX_DRVCONN1, 0);
523 sii8620_setbits(ctx, REG_KEEPER, MSK_KEEPER_MODE, VAL_KEEPER_MODE_HOST);
524 sii8620_write_seq_static(ctx,
525 REG_TDMLLCTL, 0,
526 REG_UTSRST, BIT_UTSRST_HRX_SRST | BIT_UTSRST_HTX_SRST |
527 BIT_UTSRST_KEEPER_SRST | BIT_UTSRST_FC_SRST,
528 REG_UTSRST, BIT_UTSRST_HRX_SRST | BIT_UTSRST_HTX_SRST,
529 REG_HRXINTL, 0xff,
530 REG_HRXINTH, 0xff,
531 REG_TTXINTL, 0xff,
532 REG_TTXINTH, 0xff,
533 REG_TRXINTL, 0xff,
534 REG_TRXINTH, 0xff,
535 REG_HTXINTL, 0xff,
536 REG_HTXINTH, 0xff,
537 REG_FCINTR0, 0xff,
538 REG_FCINTR1, 0xff,
539 REG_FCINTR2, 0xff,
540 REG_FCINTR3, 0xff,
541 REG_FCINTR4, 0xff,
542 REG_FCINTR5, 0xff,
543 REG_FCINTR6, 0xff,
544 REG_FCINTR7, 0xff
545 );
546}
547
548static void sii8620_edid_read(struct sii8620 *ctx, int ret)
549{
550 if (ret < 0)
551 return;
552
553 sii8620_set_upstream_edid(ctx);
554 sii8620_hsic_init(ctx);
555 sii8620_enable_hpd(ctx);
556}
557
558static void sii8620_mr_devcap(struct sii8620 *ctx) 518static void sii8620_mr_devcap(struct sii8620 *ctx)
559{ 519{
560 u8 dcap[MHL_DCAP_SIZE]; 520 u8 dcap[MHL_DCAP_SIZE];
@@ -570,6 +530,8 @@ static void sii8620_mr_devcap(struct sii8620 *ctx)
570 dcap[MHL_DCAP_ADOPTER_ID_H], dcap[MHL_DCAP_ADOPTER_ID_L], 530 dcap[MHL_DCAP_ADOPTER_ID_H], dcap[MHL_DCAP_ADOPTER_ID_L],
571 dcap[MHL_DCAP_DEVICE_ID_H], dcap[MHL_DCAP_DEVICE_ID_L]); 531 dcap[MHL_DCAP_DEVICE_ID_H], dcap[MHL_DCAP_DEVICE_ID_L]);
572 sii8620_update_array(ctx->devcap, dcap, MHL_DCAP_SIZE); 532 sii8620_update_array(ctx->devcap, dcap, MHL_DCAP_SIZE);
533 ctx->devcap_read = true;
534 sii8620_identify_sink(ctx);
573} 535}
574 536
575static void sii8620_mr_xdevcap(struct sii8620 *ctx) 537static void sii8620_mr_xdevcap(struct sii8620 *ctx)
@@ -807,6 +769,7 @@ static void sii8620_burst_rx_all(struct sii8620 *ctx)
807static void sii8620_fetch_edid(struct sii8620 *ctx) 769static void sii8620_fetch_edid(struct sii8620 *ctx)
808{ 770{
809 u8 lm_ddc, ddc_cmd, int3, cbus; 771 u8 lm_ddc, ddc_cmd, int3, cbus;
772 unsigned long timeout;
810 int fetched, i; 773 int fetched, i;
811 int edid_len = EDID_LENGTH; 774 int edid_len = EDID_LENGTH;
812 u8 *edid; 775 u8 *edid;
@@ -856,23 +819,31 @@ static void sii8620_fetch_edid(struct sii8620 *ctx)
856 REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK 819 REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK
857 ); 820 );
858 821
859 do { 822 int3 = 0;
860 int3 = sii8620_readb(ctx, REG_INTR3); 823 timeout = jiffies + msecs_to_jiffies(200);
824 for (;;) {
861 cbus = sii8620_readb(ctx, REG_CBUS_STATUS); 825 cbus = sii8620_readb(ctx, REG_CBUS_STATUS);
862 826 if (~cbus & BIT_CBUS_STATUS_CBUS_CONNECTED) {
863 if (int3 & BIT_DDC_CMD_DONE) 827 kfree(edid);
864 break; 828 edid = NULL;
865 829 goto end;
866 if (!(cbus & BIT_CBUS_STATUS_CBUS_CONNECTED)) { 830 }
831 if (int3 & BIT_DDC_CMD_DONE) {
832 if (sii8620_readb(ctx, REG_DDC_DOUT_CNT)
833 >= FETCH_SIZE)
834 break;
835 } else {
836 int3 = sii8620_readb(ctx, REG_INTR3);
837 }
838 if (time_is_before_jiffies(timeout)) {
839 ctx->error = -ETIMEDOUT;
840 dev_err(ctx->dev, "timeout during EDID read\n");
867 kfree(edid); 841 kfree(edid);
868 edid = NULL; 842 edid = NULL;
869 goto end; 843 goto end;
870 } 844 }
871 } while (1);
872
873 sii8620_readb(ctx, REG_DDC_STATUS);
874 while (sii8620_readb(ctx, REG_DDC_DOUT_CNT) < FETCH_SIZE)
875 usleep_range(10, 20); 845 usleep_range(10, 20);
846 }
876 847
877 sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE); 848 sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE);
878 if (fetched + FETCH_SIZE == EDID_LENGTH) { 849 if (fetched + FETCH_SIZE == EDID_LENGTH) {
@@ -971,8 +942,17 @@ static int sii8620_hw_on(struct sii8620 *ctx)
971 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); 942 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
972 if (ret) 943 if (ret)
973 return ret; 944 return ret;
945
974 usleep_range(10000, 20000); 946 usleep_range(10000, 20000);
975 return clk_prepare_enable(ctx->clk_xtal); 947 ret = clk_prepare_enable(ctx->clk_xtal);
948 if (ret)
949 return ret;
950
951 msleep(100);
952 gpiod_set_value(ctx->gpio_reset, 0);
953 msleep(100);
954
955 return 0;
976} 956}
977 957
978static int sii8620_hw_off(struct sii8620 *ctx) 958static int sii8620_hw_off(struct sii8620 *ctx)
@@ -982,17 +962,6 @@ static int sii8620_hw_off(struct sii8620 *ctx)
982 return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); 962 return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
983} 963}
984 964
985static void sii8620_hw_reset(struct sii8620 *ctx)
986{
987 usleep_range(10000, 20000);
988 gpiod_set_value(ctx->gpio_reset, 0);
989 usleep_range(5000, 20000);
990 gpiod_set_value(ctx->gpio_reset, 1);
991 usleep_range(10000, 20000);
992 gpiod_set_value(ctx->gpio_reset, 0);
993 msleep(300);
994}
995
996static void sii8620_cbus_reset(struct sii8620 *ctx) 965static void sii8620_cbus_reset(struct sii8620 *ctx)
997{ 966{
998 sii8620_write(ctx, REG_PWD_SRST, BIT_PWD_SRST_CBUS_RST 967 sii8620_write(ctx, REG_PWD_SRST, BIT_PWD_SRST_CBUS_RST
@@ -1048,20 +1017,11 @@ static void sii8620_stop_video(struct sii8620 *ctx)
1048 1017
1049static void sii8620_set_format(struct sii8620 *ctx) 1018static void sii8620_set_format(struct sii8620 *ctx)
1050{ 1019{
1051 u8 out_fmt;
1052
1053 if (sii8620_is_mhl3(ctx)) { 1020 if (sii8620_is_mhl3(ctx)) {
1054 sii8620_setbits(ctx, REG_M3_P0CTRL, 1021 sii8620_setbits(ctx, REG_M3_P0CTRL,
1055 BIT_M3_P0CTRL_MHL3_P0_PIXEL_MODE_PACKED, 1022 BIT_M3_P0CTRL_MHL3_P0_PIXEL_MODE_PACKED,
1056 ctx->use_packed_pixel ? ~0 : 0); 1023 ctx->use_packed_pixel ? ~0 : 0);
1057 } else { 1024 } else {
1058 if (ctx->use_packed_pixel)
1059 sii8620_write_seq_static(ctx,
1060 REG_VID_MODE, BIT_VID_MODE_M1080P,
1061 REG_MHL_TOP_CTL, BIT_MHL_TOP_CTL_MHL_PP_SEL | 1,
1062 REG_MHLTX_CTL6, 0x60
1063 );
1064 else
1065 sii8620_write_seq_static(ctx, 1025 sii8620_write_seq_static(ctx,
1066 REG_VID_MODE, 0, 1026 REG_VID_MODE, 0,
1067 REG_MHL_TOP_CTL, 1, 1027 REG_MHL_TOP_CTL, 1,
@@ -1069,15 +1029,9 @@ static void sii8620_set_format(struct sii8620 *ctx)
1069 ); 1029 );
1070 } 1030 }
1071 1031
1072 if (ctx->use_packed_pixel)
1073 out_fmt = VAL_TPI_FORMAT(YCBCR422, FULL) |
1074 BIT_TPI_OUTPUT_CSCMODE709;
1075 else
1076 out_fmt = VAL_TPI_FORMAT(RGB, FULL);
1077
1078 sii8620_write_seq(ctx, 1032 sii8620_write_seq(ctx,
1079 REG_TPI_INPUT, VAL_TPI_FORMAT(RGB, FULL), 1033 REG_TPI_INPUT, VAL_TPI_FORMAT(RGB, FULL),
1080 REG_TPI_OUTPUT, out_fmt, 1034 REG_TPI_OUTPUT, VAL_TPI_FORMAT(RGB, FULL),
1081 ); 1035 );
1082} 1036}
1083 1037
@@ -1216,7 +1170,7 @@ static void sii8620_start_video(struct sii8620 *ctx)
1216 int clk = ctx->pixel_clock * (ctx->use_packed_pixel ? 2 : 3); 1170 int clk = ctx->pixel_clock * (ctx->use_packed_pixel ? 2 : 3);
1217 int i; 1171 int i;
1218 1172
1219 for (i = 0; i < ARRAY_SIZE(clk_spec); ++i) 1173 for (i = 0; i < ARRAY_SIZE(clk_spec) - 1; ++i)
1220 if (clk < clk_spec[i].max_clk) 1174 if (clk < clk_spec[i].max_clk)
1221 break; 1175 break;
1222 1176
@@ -1534,6 +1488,16 @@ static void sii8620_set_mode(struct sii8620 *ctx, enum sii8620_mode mode)
1534 ); 1488 );
1535} 1489}
1536 1490
1491static void sii8620_hpd_unplugged(struct sii8620 *ctx)
1492{
1493 sii8620_disable_hpd(ctx);
1494 ctx->sink_type = SINK_NONE;
1495 ctx->sink_detected = false;
1496 ctx->feature_complete = false;
1497 kfree(ctx->edid);
1498 ctx->edid = NULL;
1499}
1500
1537static void sii8620_disconnect(struct sii8620 *ctx) 1501static void sii8620_disconnect(struct sii8620 *ctx)
1538{ 1502{
1539 sii8620_disable_gen2_write_burst(ctx); 1503 sii8620_disable_gen2_write_burst(ctx);
@@ -1561,7 +1525,7 @@ static void sii8620_disconnect(struct sii8620 *ctx)
1561 REG_MHL_DP_CTL6, 0x2A, 1525 REG_MHL_DP_CTL6, 0x2A,
1562 REG_MHL_DP_CTL7, 0x03 1526 REG_MHL_DP_CTL7, 0x03
1563 ); 1527 );
1564 sii8620_disable_hpd(ctx); 1528 sii8620_hpd_unplugged(ctx);
1565 sii8620_write_seq_static(ctx, 1529 sii8620_write_seq_static(ctx,
1566 REG_M3_CTRL, VAL_M3_CTRL_MHL3_VALUE, 1530 REG_M3_CTRL, VAL_M3_CTRL_MHL3_VALUE,
1567 REG_MHL_COC_CTL1, 0x07, 1531 REG_MHL_COC_CTL1, 0x07,
@@ -1609,10 +1573,8 @@ static void sii8620_disconnect(struct sii8620 *ctx)
1609 memset(ctx->xstat, 0, sizeof(ctx->xstat)); 1573 memset(ctx->xstat, 0, sizeof(ctx->xstat));
1610 memset(ctx->devcap, 0, sizeof(ctx->devcap)); 1574 memset(ctx->devcap, 0, sizeof(ctx->devcap));
1611 memset(ctx->xdevcap, 0, sizeof(ctx->xdevcap)); 1575 memset(ctx->xdevcap, 0, sizeof(ctx->xdevcap));
1576 ctx->devcap_read = false;
1612 ctx->cbus_status = 0; 1577 ctx->cbus_status = 0;
1613 ctx->sink_type = SINK_NONE;
1614 kfree(ctx->edid);
1615 ctx->edid = NULL;
1616 sii8620_mt_cleanup(ctx); 1578 sii8620_mt_cleanup(ctx);
1617} 1579}
1618 1580
@@ -1703,9 +1665,6 @@ static void sii8620_status_changed_path(struct sii8620 *ctx)
1703 sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE), 1665 sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE),
1704 MHL_DST_LM_CLK_MODE_NORMAL 1666 MHL_DST_LM_CLK_MODE_NORMAL
1705 | MHL_DST_LM_PATH_ENABLED); 1667 | MHL_DST_LM_PATH_ENABLED);
1706 if (!sii8620_is_mhl3(ctx))
1707 sii8620_mt_read_devcap(ctx, false);
1708 sii8620_mt_set_cont(ctx, sii8620_sink_detected);
1709 } else { 1668 } else {
1710 sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE), 1669 sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE),
1711 MHL_DST_LM_CLK_MODE_NORMAL); 1670 MHL_DST_LM_CLK_MODE_NORMAL);
@@ -1722,9 +1681,14 @@ static void sii8620_msc_mr_write_stat(struct sii8620 *ctx)
1722 sii8620_update_array(ctx->stat, st, MHL_DST_SIZE); 1681 sii8620_update_array(ctx->stat, st, MHL_DST_SIZE);
1723 sii8620_update_array(ctx->xstat, xst, MHL_XDS_SIZE); 1682 sii8620_update_array(ctx->xstat, xst, MHL_XDS_SIZE);
1724 1683
1725 if (ctx->stat[MHL_DST_CONNECTED_RDY] & MHL_DST_CONN_DCAP_RDY) 1684 if (ctx->stat[MHL_DST_CONNECTED_RDY] & st[MHL_DST_CONNECTED_RDY] &
1685 MHL_DST_CONN_DCAP_RDY) {
1726 sii8620_status_dcap_ready(ctx); 1686 sii8620_status_dcap_ready(ctx);
1727 1687
1688 if (!sii8620_is_mhl3(ctx))
1689 sii8620_mt_read_devcap(ctx, false);
1690 }
1691
1728 if (st[MHL_DST_LINK_MODE] & MHL_DST_LM_PATH_ENABLED) 1692 if (st[MHL_DST_LINK_MODE] & MHL_DST_LM_PATH_ENABLED)
1729 sii8620_status_changed_path(ctx); 1693 sii8620_status_changed_path(ctx);
1730} 1694}
@@ -1808,8 +1772,11 @@ static void sii8620_msc_mr_set_int(struct sii8620 *ctx)
1808 } 1772 }
1809 if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_REQ) 1773 if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_REQ)
1810 sii8620_send_features(ctx); 1774 sii8620_send_features(ctx);
1811 if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_COMPLETE) 1775 if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_COMPLETE) {
1812 sii8620_edid_read(ctx, 0); 1776 ctx->feature_complete = true;
1777 if (ctx->edid)
1778 sii8620_enable_hpd(ctx);
1779 }
1813} 1780}
1814 1781
1815static struct sii8620_mt_msg *sii8620_msc_msg_first(struct sii8620 *ctx) 1782static struct sii8620_mt_msg *sii8620_msc_msg_first(struct sii8620 *ctx)
@@ -1884,6 +1851,15 @@ static void sii8620_irq_msc(struct sii8620 *ctx)
1884 if (stat & BIT_CBUS_MSC_MR_WRITE_STAT) 1851 if (stat & BIT_CBUS_MSC_MR_WRITE_STAT)
1885 sii8620_msc_mr_write_stat(ctx); 1852 sii8620_msc_mr_write_stat(ctx);
1886 1853
1854 if (stat & BIT_CBUS_HPD_CHG) {
1855 if (ctx->cbus_status & BIT_CBUS_STATUS_CBUS_HPD) {
1856 ctx->sink_detected = true;
1857 sii8620_identify_sink(ctx);
1858 } else {
1859 sii8620_hpd_unplugged(ctx);
1860 }
1861 }
1862
1887 if (stat & BIT_CBUS_MSC_MR_SET_INT) 1863 if (stat & BIT_CBUS_MSC_MR_SET_INT)
1888 sii8620_msc_mr_set_int(ctx); 1864 sii8620_msc_mr_set_int(ctx);
1889 1865
@@ -1931,14 +1907,6 @@ static void sii8620_irq_edid(struct sii8620 *ctx)
1931 ctx->mt_state = MT_STATE_DONE; 1907 ctx->mt_state = MT_STATE_DONE;
1932} 1908}
1933 1909
1934static void sii8620_scdt_high(struct sii8620 *ctx)
1935{
1936 sii8620_write_seq_static(ctx,
1937 REG_INTR8_MASK, BIT_CEA_NEW_AVI | BIT_CEA_NEW_VSI,
1938 REG_TPI_SC, BIT_TPI_SC_TPI_OUTPUT_MODE_0_HDMI,
1939 );
1940}
1941
1942static void sii8620_irq_scdt(struct sii8620 *ctx) 1910static void sii8620_irq_scdt(struct sii8620 *ctx)
1943{ 1911{
1944 u8 stat = sii8620_readb(ctx, REG_INTR5); 1912 u8 stat = sii8620_readb(ctx, REG_INTR5);
@@ -1946,53 +1914,13 @@ static void sii8620_irq_scdt(struct sii8620 *ctx)
1946 if (stat & BIT_INTR_SCDT_CHANGE) { 1914 if (stat & BIT_INTR_SCDT_CHANGE) {
1947 u8 cstat = sii8620_readb(ctx, REG_TMDS_CSTAT_P3); 1915 u8 cstat = sii8620_readb(ctx, REG_TMDS_CSTAT_P3);
1948 1916
1949 if (cstat & BIT_TMDS_CSTAT_P3_SCDT) { 1917 if (cstat & BIT_TMDS_CSTAT_P3_SCDT)
1950 if (ctx->sink_type == SINK_HDMI) 1918 sii8620_start_video(ctx);
1951 /* enable infoframe interrupt */
1952 sii8620_scdt_high(ctx);
1953 else
1954 sii8620_start_video(ctx);
1955 }
1956 } 1919 }
1957 1920
1958 sii8620_write(ctx, REG_INTR5, stat); 1921 sii8620_write(ctx, REG_INTR5, stat);
1959} 1922}
1960 1923
1961static void sii8620_new_vsi(struct sii8620 *ctx)
1962{
1963 u8 vsif[11];
1964
1965 sii8620_write(ctx, REG_RX_HDMI_CTRL2,
1966 VAL_RX_HDMI_CTRL2_DEFVAL |
1967 BIT_RX_HDMI_CTRL2_VSI_MON_SEL_VSI);
1968 sii8620_read_buf(ctx, REG_RX_HDMI_MON_PKT_HEADER1, vsif,
1969 ARRAY_SIZE(vsif));
1970}
1971
1972static void sii8620_new_avi(struct sii8620 *ctx)
1973{
1974 sii8620_write(ctx, REG_RX_HDMI_CTRL2, VAL_RX_HDMI_CTRL2_DEFVAL);
1975 sii8620_read_buf(ctx, REG_RX_HDMI_MON_PKT_HEADER1, ctx->avif,
1976 ARRAY_SIZE(ctx->avif));
1977}
1978
1979static void sii8620_irq_infr(struct sii8620 *ctx)
1980{
1981 u8 stat = sii8620_readb(ctx, REG_INTR8)
1982 & (BIT_CEA_NEW_VSI | BIT_CEA_NEW_AVI);
1983
1984 sii8620_write(ctx, REG_INTR8, stat);
1985
1986 if (stat & BIT_CEA_NEW_VSI)
1987 sii8620_new_vsi(ctx);
1988
1989 if (stat & BIT_CEA_NEW_AVI)
1990 sii8620_new_avi(ctx);
1991
1992 if (stat & (BIT_CEA_NEW_VSI | BIT_CEA_NEW_AVI))
1993 sii8620_start_video(ctx);
1994}
1995
1996static void sii8620_got_xdevcap(struct sii8620 *ctx, int ret) 1924static void sii8620_got_xdevcap(struct sii8620 *ctx, int ret)
1997{ 1925{
1998 if (ret < 0) 1926 if (ret < 0)
@@ -2043,11 +1971,11 @@ static void sii8620_irq_ddc(struct sii8620 *ctx)
2043 1971
2044 if (stat & BIT_DDC_CMD_DONE) { 1972 if (stat & BIT_DDC_CMD_DONE) {
2045 sii8620_write(ctx, REG_INTR3_MASK, 0); 1973 sii8620_write(ctx, REG_INTR3_MASK, 0);
2046 if (sii8620_is_mhl3(ctx)) 1974 if (sii8620_is_mhl3(ctx) && !ctx->feature_complete)
2047 sii8620_mt_set_int(ctx, MHL_INT_REG(RCHANGE), 1975 sii8620_mt_set_int(ctx, MHL_INT_REG(RCHANGE),
2048 MHL_INT_RC_FEAT_REQ); 1976 MHL_INT_RC_FEAT_REQ);
2049 else 1977 else
2050 sii8620_edid_read(ctx, 0); 1978 sii8620_enable_hpd(ctx);
2051 } 1979 }
2052 sii8620_write(ctx, REG_INTR3, stat); 1980 sii8620_write(ctx, REG_INTR3, stat);
2053} 1981}
@@ -2074,7 +2002,6 @@ static irqreturn_t sii8620_irq_thread(int irq, void *data)
2074 { BIT_FAST_INTR_STAT_EDID, sii8620_irq_edid }, 2002 { BIT_FAST_INTR_STAT_EDID, sii8620_irq_edid },
2075 { BIT_FAST_INTR_STAT_DDC, sii8620_irq_ddc }, 2003 { BIT_FAST_INTR_STAT_DDC, sii8620_irq_ddc },
2076 { BIT_FAST_INTR_STAT_SCDT, sii8620_irq_scdt }, 2004 { BIT_FAST_INTR_STAT_SCDT, sii8620_irq_scdt },
2077 { BIT_FAST_INTR_STAT_INFR, sii8620_irq_infr },
2078 }; 2005 };
2079 struct sii8620 *ctx = data; 2006 struct sii8620 *ctx = data;
2080 u8 stats[LEN_FAST_INTR_STAT]; 2007 u8 stats[LEN_FAST_INTR_STAT];
@@ -2112,7 +2039,6 @@ static void sii8620_cable_in(struct sii8620 *ctx)
2112 dev_err(dev, "Error powering on, %d.\n", ret); 2039 dev_err(dev, "Error powering on, %d.\n", ret);
2113 return; 2040 return;
2114 } 2041 }
2115 sii8620_hw_reset(ctx);
2116 2042
2117 sii8620_read_buf(ctx, REG_VND_IDL, ver, ARRAY_SIZE(ver)); 2043 sii8620_read_buf(ctx, REG_VND_IDL, ver, ARRAY_SIZE(ver));
2118 ret = sii8620_clear_error(ctx); 2044 ret = sii8620_clear_error(ctx);
@@ -2268,17 +2194,43 @@ static void sii8620_detach(struct drm_bridge *bridge)
2268 rc_unregister_device(ctx->rc_dev); 2194 rc_unregister_device(ctx->rc_dev);
2269} 2195}
2270 2196
2197static int sii8620_is_packing_required(struct sii8620 *ctx,
2198 const struct drm_display_mode *mode)
2199{
2200 int max_pclk, max_pclk_pp_mode;
2201
2202 if (sii8620_is_mhl3(ctx)) {
2203 max_pclk = MHL3_MAX_PCLK;
2204 max_pclk_pp_mode = MHL3_MAX_PCLK_PP_MODE;
2205 } else {
2206 max_pclk = MHL1_MAX_PCLK;
2207 max_pclk_pp_mode = MHL1_MAX_PCLK_PP_MODE;
2208 }
2209
2210 if (mode->clock < max_pclk)
2211 return 0;
2212 else if (mode->clock < max_pclk_pp_mode)
2213 return 1;
2214 else
2215 return -1;
2216}
2217
2271static enum drm_mode_status sii8620_mode_valid(struct drm_bridge *bridge, 2218static enum drm_mode_status sii8620_mode_valid(struct drm_bridge *bridge,
2272 const struct drm_display_mode *mode) 2219 const struct drm_display_mode *mode)
2273{ 2220{
2274 struct sii8620 *ctx = bridge_to_sii8620(bridge); 2221 struct sii8620 *ctx = bridge_to_sii8620(bridge);
2222 int pack_required = sii8620_is_packing_required(ctx, mode);
2275 bool can_pack = ctx->devcap[MHL_DCAP_VID_LINK_MODE] & 2223 bool can_pack = ctx->devcap[MHL_DCAP_VID_LINK_MODE] &
2276 MHL_DCAP_VID_LINK_PPIXEL; 2224 MHL_DCAP_VID_LINK_PPIXEL;
2277 unsigned int max_pclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK :
2278 MHL1_MAX_LCLK;
2279 max_pclk /= can_pack ? 2 : 3;
2280 2225
2281 return (mode->clock > max_pclk) ? MODE_CLOCK_HIGH : MODE_OK; 2226 switch (pack_required) {
2227 case 0:
2228 return MODE_OK;
2229 case 1:
2230 return (can_pack) ? MODE_OK : MODE_CLOCK_HIGH;
2231 default:
2232 return MODE_CLOCK_HIGH;
2233 }
2282} 2234}
2283 2235
2284static bool sii8620_mode_fixup(struct drm_bridge *bridge, 2236static bool sii8620_mode_fixup(struct drm_bridge *bridge,
@@ -2286,43 +2238,16 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
2286 struct drm_display_mode *adjusted_mode) 2238 struct drm_display_mode *adjusted_mode)
2287{ 2239{
2288 struct sii8620 *ctx = bridge_to_sii8620(bridge); 2240 struct sii8620 *ctx = bridge_to_sii8620(bridge);
2289 int max_lclk;
2290 bool ret = true;
2291 2241
2292 mutex_lock(&ctx->lock); 2242 mutex_lock(&ctx->lock);
2293 2243
2294 max_lclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK : MHL1_MAX_LCLK; 2244 ctx->use_packed_pixel = sii8620_is_packing_required(ctx, adjusted_mode);
2295 if (max_lclk > 3 * adjusted_mode->clock) { 2245 ctx->video_code = drm_match_cea_mode(adjusted_mode);
2296 ctx->use_packed_pixel = 0; 2246 ctx->pixel_clock = adjusted_mode->clock;
2297 goto end; 2247
2298 }
2299 if ((ctx->devcap[MHL_DCAP_VID_LINK_MODE] & MHL_DCAP_VID_LINK_PPIXEL) &&
2300 max_lclk > 2 * adjusted_mode->clock) {
2301 ctx->use_packed_pixel = 1;
2302 goto end;
2303 }
2304 ret = false;
2305end:
2306 if (ret) {
2307 u8 vic = drm_match_cea_mode(adjusted_mode);
2308
2309 if (!vic) {
2310 union hdmi_infoframe frm;
2311 u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
2312
2313 /* FIXME: We need the connector here */
2314 drm_hdmi_vendor_infoframe_from_display_mode(
2315 &frm.vendor.hdmi, NULL, adjusted_mode);
2316 vic = frm.vendor.hdmi.vic;
2317 if (vic >= ARRAY_SIZE(mhl_vic))
2318 vic = 0;
2319 vic = mhl_vic[vic];
2320 }
2321 ctx->video_code = vic;
2322 ctx->pixel_clock = adjusted_mode->clock;
2323 }
2324 mutex_unlock(&ctx->lock); 2248 mutex_unlock(&ctx->lock);
2325 return ret; 2249
2250 return true;
2326} 2251}
2327 2252
2328static const struct drm_bridge_funcs sii8620_bridge_funcs = { 2253static const struct drm_bridge_funcs sii8620_bridge_funcs = {
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index b553a6f2ff0e..7af748ed1c58 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -369,13 +369,6 @@ EXPORT_SYMBOL(drm_dev_exit);
369 */ 369 */
370void drm_dev_unplug(struct drm_device *dev) 370void drm_dev_unplug(struct drm_device *dev)
371{ 371{
372 drm_dev_unregister(dev);
373
374 mutex_lock(&drm_global_mutex);
375 if (dev->open_count == 0)
376 drm_dev_put(dev);
377 mutex_unlock(&drm_global_mutex);
378
379 /* 372 /*
380 * After synchronizing any critical read section is guaranteed to see 373 * After synchronizing any critical read section is guaranteed to see
381 * the new value of ->unplugged, and any critical section which might 374 * the new value of ->unplugged, and any critical section which might
@@ -384,6 +377,13 @@ void drm_dev_unplug(struct drm_device *dev)
384 */ 377 */
385 dev->unplugged = true; 378 dev->unplugged = true;
386 synchronize_srcu(&drm_unplug_srcu); 379 synchronize_srcu(&drm_unplug_srcu);
380
381 drm_dev_unregister(dev);
382
383 mutex_lock(&drm_global_mutex);
384 if (dev->open_count == 0)
385 drm_dev_put(dev);
386 mutex_unlock(&drm_global_mutex);
387} 387}
388EXPORT_SYMBOL(drm_dev_unplug); 388EXPORT_SYMBOL(drm_dev_unplug);
389 389
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 34c125e2d90c..52f3b91d14fd 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -340,14 +340,21 @@ struct drm_i915_file_private {
340 340
341 unsigned int bsd_engine; 341 unsigned int bsd_engine;
342 342
343/* Client can have a maximum of 3 contexts banned before 343/*
344 * it is denied of creating new contexts. As one context 344 * Every context ban increments per client ban score. Also
345 * ban needs 4 consecutive hangs, and more if there is 345 * hangs in short succession increments ban score. If ban threshold
346 * progress in between, this is a last resort stop gap measure 346 * is reached, client is considered banned and submitting more work
347 * to limit the badly behaving clients access to gpu. 347 * will fail. This is a stop gap measure to limit the badly behaving
348 * clients access to gpu. Note that unbannable contexts never increment
349 * the client ban score.
348 */ 350 */
349#define I915_MAX_CLIENT_CONTEXT_BANS 3 351#define I915_CLIENT_SCORE_HANG_FAST 1
350 atomic_t context_bans; 352#define I915_CLIENT_FAST_HANG_JIFFIES (60 * HZ)
353#define I915_CLIENT_SCORE_CONTEXT_BAN 3
354#define I915_CLIENT_SCORE_BANNED 9
355 /** ban_score: Accumulated score of all ctx bans and fast hangs. */
356 atomic_t ban_score;
357 unsigned long hang_timestamp;
351}; 358};
352 359
353/* Interface history: 360/* Interface history:
@@ -2238,9 +2245,6 @@ static inline struct scatterlist *____sg_next(struct scatterlist *sg)
2238 **/ 2245 **/
2239static inline struct scatterlist *__sg_next(struct scatterlist *sg) 2246static inline struct scatterlist *__sg_next(struct scatterlist *sg)
2240{ 2247{
2241#ifdef CONFIG_DEBUG_SG
2242 BUG_ON(sg->sg_magic != SG_MAGIC);
2243#endif
2244 return sg_is_last(sg) ? NULL : ____sg_next(sg); 2248 return sg_is_last(sg) ? NULL : ____sg_next(sg);
2245} 2249}
2246 2250
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 3704f4c0c2c9..d44ad7bc1e94 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2933,32 +2933,54 @@ i915_gem_object_pwrite_gtt(struct drm_i915_gem_object *obj,
2933 return 0; 2933 return 0;
2934} 2934}
2935 2935
2936static void i915_gem_client_mark_guilty(struct drm_i915_file_private *file_priv,
2937 const struct i915_gem_context *ctx)
2938{
2939 unsigned int score;
2940 unsigned long prev_hang;
2941
2942 if (i915_gem_context_is_banned(ctx))
2943 score = I915_CLIENT_SCORE_CONTEXT_BAN;
2944 else
2945 score = 0;
2946
2947 prev_hang = xchg(&file_priv->hang_timestamp, jiffies);
2948 if (time_before(jiffies, prev_hang + I915_CLIENT_FAST_HANG_JIFFIES))
2949 score += I915_CLIENT_SCORE_HANG_FAST;
2950
2951 if (score) {
2952 atomic_add(score, &file_priv->ban_score);
2953
2954 DRM_DEBUG_DRIVER("client %s: gained %u ban score, now %u\n",
2955 ctx->name, score,
2956 atomic_read(&file_priv->ban_score));
2957 }
2958}
2959
2936static void i915_gem_context_mark_guilty(struct i915_gem_context *ctx) 2960static void i915_gem_context_mark_guilty(struct i915_gem_context *ctx)
2937{ 2961{
2938 bool banned; 2962 unsigned int score;
2963 bool banned, bannable;
2939 2964
2940 atomic_inc(&ctx->guilty_count); 2965 atomic_inc(&ctx->guilty_count);
2941 2966
2942 banned = false; 2967 bannable = i915_gem_context_is_bannable(ctx);
2943 if (i915_gem_context_is_bannable(ctx)) { 2968 score = atomic_add_return(CONTEXT_SCORE_GUILTY, &ctx->ban_score);
2944 unsigned int score; 2969 banned = score >= CONTEXT_SCORE_BAN_THRESHOLD;
2945 2970
2946 score = atomic_add_return(CONTEXT_SCORE_GUILTY, 2971 DRM_DEBUG_DRIVER("context %s: guilty %d, score %u, ban %s\n",
2947 &ctx->ban_score); 2972 ctx->name, atomic_read(&ctx->guilty_count),
2948 banned = score >= CONTEXT_SCORE_BAN_THRESHOLD; 2973 score, yesno(banned && bannable));
2949 2974
2950 DRM_DEBUG_DRIVER("context %s marked guilty (score %d) banned? %s\n", 2975 /* Cool contexts don't accumulate client ban score */
2951 ctx->name, score, yesno(banned)); 2976 if (!bannable)
2952 }
2953 if (!banned)
2954 return; 2977 return;
2955 2978
2956 i915_gem_context_set_banned(ctx); 2979 if (banned)
2957 if (!IS_ERR_OR_NULL(ctx->file_priv)) { 2980 i915_gem_context_set_banned(ctx);
2958 atomic_inc(&ctx->file_priv->context_bans); 2981
2959 DRM_DEBUG_DRIVER("client %s has had %d context banned\n", 2982 if (!IS_ERR_OR_NULL(ctx->file_priv))
2960 ctx->name, atomic_read(&ctx->file_priv->context_bans)); 2983 i915_gem_client_mark_guilty(ctx->file_priv, ctx);
2961 }
2962} 2984}
2963 2985
2964static void i915_gem_context_mark_innocent(struct i915_gem_context *ctx) 2986static void i915_gem_context_mark_innocent(struct i915_gem_context *ctx)
@@ -5736,6 +5758,7 @@ int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file)
5736 INIT_LIST_HEAD(&file_priv->mm.request_list); 5758 INIT_LIST_HEAD(&file_priv->mm.request_list);
5737 5759
5738 file_priv->bsd_engine = -1; 5760 file_priv->bsd_engine = -1;
5761 file_priv->hang_timestamp = jiffies;
5739 5762
5740 ret = i915_gem_context_open(i915, file); 5763 ret = i915_gem_context_open(i915, file);
5741 if (ret) 5764 if (ret)
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 33f8a4b3c981..060335d3d9e0 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -652,7 +652,7 @@ int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv)
652 652
653static bool client_is_banned(struct drm_i915_file_private *file_priv) 653static bool client_is_banned(struct drm_i915_file_private *file_priv)
654{ 654{
655 return atomic_read(&file_priv->context_bans) > I915_MAX_CLIENT_CONTEXT_BANS; 655 return atomic_read(&file_priv->ban_score) >= I915_CLIENT_SCORE_BANNED;
656} 656}
657 657
658int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, 658int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index f627a8c47c58..22df17c8ca9b 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -489,7 +489,9 @@ eb_validate_vma(struct i915_execbuffer *eb,
489} 489}
490 490
491static int 491static int
492eb_add_vma(struct i915_execbuffer *eb, unsigned int i, struct i915_vma *vma) 492eb_add_vma(struct i915_execbuffer *eb,
493 unsigned int i, unsigned batch_idx,
494 struct i915_vma *vma)
493{ 495{
494 struct drm_i915_gem_exec_object2 *entry = &eb->exec[i]; 496 struct drm_i915_gem_exec_object2 *entry = &eb->exec[i];
495 int err; 497 int err;
@@ -522,6 +524,24 @@ eb_add_vma(struct i915_execbuffer *eb, unsigned int i, struct i915_vma *vma)
522 eb->flags[i] = entry->flags; 524 eb->flags[i] = entry->flags;
523 vma->exec_flags = &eb->flags[i]; 525 vma->exec_flags = &eb->flags[i];
524 526
527 /*
528 * SNA is doing fancy tricks with compressing batch buffers, which leads
529 * to negative relocation deltas. Usually that works out ok since the
530 * relocate address is still positive, except when the batch is placed
531 * very low in the GTT. Ensure this doesn't happen.
532 *
533 * Note that actual hangs have only been observed on gen7, but for
534 * paranoia do it everywhere.
535 */
536 if (i == batch_idx) {
537 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
538 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
539 if (eb->reloc_cache.has_fence)
540 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
541
542 eb->batch = vma;
543 }
544
525 err = 0; 545 err = 0;
526 if (eb_pin_vma(eb, entry, vma)) { 546 if (eb_pin_vma(eb, entry, vma)) {
527 if (entry->offset != vma->node.start) { 547 if (entry->offset != vma->node.start) {
@@ -716,7 +736,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
716{ 736{
717 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma; 737 struct radix_tree_root *handles_vma = &eb->ctx->handles_vma;
718 struct drm_i915_gem_object *obj; 738 struct drm_i915_gem_object *obj;
719 unsigned int i; 739 unsigned int i, batch;
720 int err; 740 int err;
721 741
722 if (unlikely(i915_gem_context_is_closed(eb->ctx))) 742 if (unlikely(i915_gem_context_is_closed(eb->ctx)))
@@ -728,6 +748,8 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
728 INIT_LIST_HEAD(&eb->relocs); 748 INIT_LIST_HEAD(&eb->relocs);
729 INIT_LIST_HEAD(&eb->unbound); 749 INIT_LIST_HEAD(&eb->unbound);
730 750
751 batch = eb_batch_index(eb);
752
731 for (i = 0; i < eb->buffer_count; i++) { 753 for (i = 0; i < eb->buffer_count; i++) {
732 u32 handle = eb->exec[i].handle; 754 u32 handle = eb->exec[i].handle;
733 struct i915_lut_handle *lut; 755 struct i915_lut_handle *lut;
@@ -770,33 +792,16 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
770 lut->handle = handle; 792 lut->handle = handle;
771 793
772add_vma: 794add_vma:
773 err = eb_add_vma(eb, i, vma); 795 err = eb_add_vma(eb, i, batch, vma);
774 if (unlikely(err)) 796 if (unlikely(err))
775 goto err_vma; 797 goto err_vma;
776 798
777 GEM_BUG_ON(vma != eb->vma[i]); 799 GEM_BUG_ON(vma != eb->vma[i]);
778 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]); 800 GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
801 GEM_BUG_ON(drm_mm_node_allocated(&vma->node) &&
802 eb_vma_misplaced(&eb->exec[i], vma, eb->flags[i]));
779 } 803 }
780 804
781 /* take note of the batch buffer before we might reorder the lists */
782 i = eb_batch_index(eb);
783 eb->batch = eb->vma[i];
784 GEM_BUG_ON(eb->batch->exec_flags != &eb->flags[i]);
785
786 /*
787 * SNA is doing fancy tricks with compressing batch buffers, which leads
788 * to negative relocation deltas. Usually that works out ok since the
789 * relocate address is still positive, except when the batch is placed
790 * very low in the GTT. Ensure this doesn't happen.
791 *
792 * Note that actual hangs have only been observed on gen7, but for
793 * paranoia do it everywhere.
794 */
795 if (!(eb->flags[i] & EXEC_OBJECT_PINNED))
796 eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
797 if (eb->reloc_cache.has_fence)
798 eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
799
800 eb->args->flags |= __EXEC_VALIDATED; 805 eb->args->flags |= __EXEC_VALIDATED;
801 return eb_reserve(eb); 806 return eb_reserve(eb);
802 807
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index f9bc3aaa90d0..4a02747ac658 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1893,9 +1893,17 @@ static void i9xx_pipestat_irq_ack(struct drm_i915_private *dev_priv,
1893 1893
1894 /* 1894 /*
1895 * Clear the PIPE*STAT regs before the IIR 1895 * Clear the PIPE*STAT regs before the IIR
1896 *
1897 * Toggle the enable bits to make sure we get an
1898 * edge in the ISR pipe event bit if we don't clear
1899 * all the enabled status bits. Otherwise the edge
1900 * triggered IIR on i965/g4x wouldn't notice that
1901 * an interrupt is still pending.
1896 */ 1902 */
1897 if (pipe_stats[pipe]) 1903 if (pipe_stats[pipe]) {
1898 I915_WRITE(reg, enable_mask | pipe_stats[pipe]); 1904 I915_WRITE(reg, pipe_stats[pipe]);
1905 I915_WRITE(reg, enable_mask);
1906 }
1899 } 1907 }
1900 spin_unlock(&dev_priv->irq_lock); 1908 spin_unlock(&dev_priv->irq_lock);
1901} 1909}
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f11bb213ec07..7720569f2024 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2425,12 +2425,17 @@ enum i915_power_well_id {
2425#define _3D_CHICKEN _MMIO(0x2084) 2425#define _3D_CHICKEN _MMIO(0x2084)
2426#define _3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB (1 << 10) 2426#define _3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB (1 << 10)
2427#define _3D_CHICKEN2 _MMIO(0x208c) 2427#define _3D_CHICKEN2 _MMIO(0x208c)
2428
2429#define FF_SLICE_CHICKEN _MMIO(0x2088)
2430#define FF_SLICE_CHICKEN_CL_PROVOKING_VERTEX_FIX (1 << 1)
2431
2428/* Disables pipelining of read flushes past the SF-WIZ interface. 2432/* Disables pipelining of read flushes past the SF-WIZ interface.
2429 * Required on all Ironlake steppings according to the B-Spec, but the 2433 * Required on all Ironlake steppings according to the B-Spec, but the
2430 * particular danger of not doing so is not specified. 2434 * particular danger of not doing so is not specified.
2431 */ 2435 */
2432# define _3D_CHICKEN2_WM_READ_PIPELINED (1 << 14) 2436# define _3D_CHICKEN2_WM_READ_PIPELINED (1 << 14)
2433#define _3D_CHICKEN3 _MMIO(0x2090) 2437#define _3D_CHICKEN3 _MMIO(0x2090)
2438#define _3D_CHICKEN_SF_PROVOKING_VERTEX_FIX (1 << 12)
2434#define _3D_CHICKEN_SF_DISABLE_OBJEND_CULL (1 << 10) 2439#define _3D_CHICKEN_SF_DISABLE_OBJEND_CULL (1 << 10)
2435#define _3D_CHICKEN3_AA_LINE_QUALITY_FIX_ENABLE (1 << 5) 2440#define _3D_CHICKEN3_AA_LINE_QUALITY_FIX_ENABLE (1 << 5)
2436#define _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL (1 << 5) 2441#define _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL (1 << 5)
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index de0e22322c76..072b326d5ee0 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -304,6 +304,9 @@ intel_crt_mode_valid(struct drm_connector *connector,
304 int max_dotclk = dev_priv->max_dotclk_freq; 304 int max_dotclk = dev_priv->max_dotclk_freq;
305 int max_clock; 305 int max_clock;
306 306
307 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
308 return MODE_NO_DBLESCAN;
309
307 if (mode->clock < 25000) 310 if (mode->clock < 25000)
308 return MODE_CLOCK_LOW; 311 return MODE_CLOCK_LOW;
309 312
@@ -337,6 +340,12 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
337 struct intel_crtc_state *pipe_config, 340 struct intel_crtc_state *pipe_config,
338 struct drm_connector_state *conn_state) 341 struct drm_connector_state *conn_state)
339{ 342{
343 struct drm_display_mode *adjusted_mode =
344 &pipe_config->base.adjusted_mode;
345
346 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
347 return false;
348
340 return true; 349 return true;
341} 350}
342 351
@@ -344,6 +353,12 @@ static bool pch_crt_compute_config(struct intel_encoder *encoder,
344 struct intel_crtc_state *pipe_config, 353 struct intel_crtc_state *pipe_config,
345 struct drm_connector_state *conn_state) 354 struct drm_connector_state *conn_state)
346{ 355{
356 struct drm_display_mode *adjusted_mode =
357 &pipe_config->base.adjusted_mode;
358
359 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
360 return false;
361
347 pipe_config->has_pch_encoder = true; 362 pipe_config->has_pch_encoder = true;
348 363
349 return true; 364 return true;
@@ -354,6 +369,11 @@ static bool hsw_crt_compute_config(struct intel_encoder *encoder,
354 struct drm_connector_state *conn_state) 369 struct drm_connector_state *conn_state)
355{ 370{
356 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 371 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
372 struct drm_display_mode *adjusted_mode =
373 &pipe_config->base.adjusted_mode;
374
375 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
376 return false;
357 377
358 pipe_config->has_pch_encoder = true; 378 pipe_config->has_pch_encoder = true;
359 379
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index dee3a8e659f1..2cc6faa1daa8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -14469,12 +14469,22 @@ static enum drm_mode_status
14469intel_mode_valid(struct drm_device *dev, 14469intel_mode_valid(struct drm_device *dev,
14470 const struct drm_display_mode *mode) 14470 const struct drm_display_mode *mode)
14471{ 14471{
14472 /*
14473 * Can't reject DBLSCAN here because Xorg ddxen can add piles
14474 * of DBLSCAN modes to the output's mode list when they detect
14475 * the scaling mode property on the connector. And they don't
14476 * ask the kernel to validate those modes in any way until
14477 * modeset time at which point the client gets a protocol error.
14478 * So in order to not upset those clients we silently ignore the
14479 * DBLSCAN flag on such connectors. For other connectors we will
14480 * reject modes with the DBLSCAN flag in encoder->compute_config().
14481 * And we always reject DBLSCAN modes in connector->mode_valid()
14482 * as we never want such modes on the connector's mode list.
14483 */
14484
14472 if (mode->vscan > 1) 14485 if (mode->vscan > 1)
14473 return MODE_NO_VSCAN; 14486 return MODE_NO_VSCAN;
14474 14487
14475 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
14476 return MODE_NO_DBLESCAN;
14477
14478 if (mode->flags & DRM_MODE_FLAG_HSKEW) 14488 if (mode->flags & DRM_MODE_FLAG_HSKEW)
14479 return MODE_H_ILLEGAL; 14489 return MODE_H_ILLEGAL;
14480 14490
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 8320f0e8e3be..16faea30114a 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -420,6 +420,9 @@ intel_dp_mode_valid(struct drm_connector *connector,
420 int max_rate, mode_rate, max_lanes, max_link_clock; 420 int max_rate, mode_rate, max_lanes, max_link_clock;
421 int max_dotclk; 421 int max_dotclk;
422 422
423 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
424 return MODE_NO_DBLESCAN;
425
423 max_dotclk = intel_dp_downstream_max_dotclock(intel_dp); 426 max_dotclk = intel_dp_downstream_max_dotclock(intel_dp);
424 427
425 if (intel_dp_is_edp(intel_dp) && fixed_mode) { 428 if (intel_dp_is_edp(intel_dp) && fixed_mode) {
@@ -1862,7 +1865,10 @@ intel_dp_compute_config(struct intel_encoder *encoder,
1862 conn_state->scaling_mode); 1865 conn_state->scaling_mode);
1863 } 1866 }
1864 1867
1865 if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && 1868 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
1869 return false;
1870
1871 if (HAS_GMCH_DISPLAY(dev_priv) &&
1866 adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) 1872 adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
1867 return false; 1873 return false;
1868 1874
@@ -2784,16 +2790,6 @@ static void g4x_disable_dp(struct intel_encoder *encoder,
2784 const struct drm_connector_state *old_conn_state) 2790 const struct drm_connector_state *old_conn_state)
2785{ 2791{
2786 intel_disable_dp(encoder, old_crtc_state, old_conn_state); 2792 intel_disable_dp(encoder, old_crtc_state, old_conn_state);
2787
2788 /* disable the port before the pipe on g4x */
2789 intel_dp_link_down(encoder, old_crtc_state);
2790}
2791
2792static void ilk_disable_dp(struct intel_encoder *encoder,
2793 const struct intel_crtc_state *old_crtc_state,
2794 const struct drm_connector_state *old_conn_state)
2795{
2796 intel_disable_dp(encoder, old_crtc_state, old_conn_state);
2797} 2793}
2798 2794
2799static void vlv_disable_dp(struct intel_encoder *encoder, 2795static void vlv_disable_dp(struct intel_encoder *encoder,
@@ -2807,13 +2803,19 @@ static void vlv_disable_dp(struct intel_encoder *encoder,
2807 intel_disable_dp(encoder, old_crtc_state, old_conn_state); 2803 intel_disable_dp(encoder, old_crtc_state, old_conn_state);
2808} 2804}
2809 2805
2810static void ilk_post_disable_dp(struct intel_encoder *encoder, 2806static void g4x_post_disable_dp(struct intel_encoder *encoder,
2811 const struct intel_crtc_state *old_crtc_state, 2807 const struct intel_crtc_state *old_crtc_state,
2812 const struct drm_connector_state *old_conn_state) 2808 const struct drm_connector_state *old_conn_state)
2813{ 2809{
2814 struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base); 2810 struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
2815 enum port port = encoder->port; 2811 enum port port = encoder->port;
2816 2812
2813 /*
2814 * Bspec does not list a specific disable sequence for g4x DP.
2815 * Follow the ilk+ sequence (disable pipe before the port) for
2816 * g4x DP as it does not suffer from underruns like the normal
2817 * g4x modeset sequence (disable pipe after the port).
2818 */
2817 intel_dp_link_down(encoder, old_crtc_state); 2819 intel_dp_link_down(encoder, old_crtc_state);
2818 2820
2819 /* Only ilk+ has port A */ 2821 /* Only ilk+ has port A */
@@ -6337,7 +6339,7 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
6337 drm_connector_init(dev, connector, &intel_dp_connector_funcs, type); 6339 drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
6338 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); 6340 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
6339 6341
6340 if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) 6342 if (!HAS_GMCH_DISPLAY(dev_priv))
6341 connector->interlace_allowed = true; 6343 connector->interlace_allowed = true;
6342 connector->doublescan_allowed = 0; 6344 connector->doublescan_allowed = 0;
6343 6345
@@ -6436,15 +6438,11 @@ bool intel_dp_init(struct drm_i915_private *dev_priv,
6436 intel_encoder->enable = vlv_enable_dp; 6438 intel_encoder->enable = vlv_enable_dp;
6437 intel_encoder->disable = vlv_disable_dp; 6439 intel_encoder->disable = vlv_disable_dp;
6438 intel_encoder->post_disable = vlv_post_disable_dp; 6440 intel_encoder->post_disable = vlv_post_disable_dp;
6439 } else if (INTEL_GEN(dev_priv) >= 5) {
6440 intel_encoder->pre_enable = g4x_pre_enable_dp;
6441 intel_encoder->enable = g4x_enable_dp;
6442 intel_encoder->disable = ilk_disable_dp;
6443 intel_encoder->post_disable = ilk_post_disable_dp;
6444 } else { 6441 } else {
6445 intel_encoder->pre_enable = g4x_pre_enable_dp; 6442 intel_encoder->pre_enable = g4x_pre_enable_dp;
6446 intel_encoder->enable = g4x_enable_dp; 6443 intel_encoder->enable = g4x_enable_dp;
6447 intel_encoder->disable = g4x_disable_dp; 6444 intel_encoder->disable = g4x_disable_dp;
6445 intel_encoder->post_disable = g4x_post_disable_dp;
6448 } 6446 }
6449 6447
6450 intel_dig_port->dp.output_reg = output_reg; 6448 intel_dig_port->dp.output_reg = output_reg;
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index 9e6956c08688..5890500a3a8b 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -48,6 +48,9 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
48 bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc, 48 bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc,
49 DP_DPCD_QUIRK_LIMITED_M_N); 49 DP_DPCD_QUIRK_LIMITED_M_N);
50 50
51 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
52 return false;
53
51 pipe_config->has_pch_encoder = false; 54 pipe_config->has_pch_encoder = false;
52 bpp = 24; 55 bpp = 24;
53 if (intel_dp->compliance.test_data.bpc) { 56 if (intel_dp->compliance.test_data.bpc) {
@@ -366,6 +369,9 @@ intel_dp_mst_mode_valid(struct drm_connector *connector,
366 if (!intel_dp) 369 if (!intel_dp)
367 return MODE_ERROR; 370 return MODE_ERROR;
368 371
372 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
373 return MODE_NO_DBLESCAN;
374
369 max_link_clock = intel_dp_max_link_rate(intel_dp); 375 max_link_clock = intel_dp_max_link_rate(intel_dp);
370 max_lanes = intel_dp_max_lane_count(intel_dp); 376 max_lanes = intel_dp_max_lane_count(intel_dp);
371 377
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index cf39ca90d887..f349b3920199 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -326,6 +326,9 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
326 conn_state->scaling_mode); 326 conn_state->scaling_mode);
327 } 327 }
328 328
329 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
330 return false;
331
329 /* DSI uses short packets for sync events, so clear mode flags for DSI */ 332 /* DSI uses short packets for sync events, so clear mode flags for DSI */
330 adjusted_mode->flags = 0; 333 adjusted_mode->flags = 0;
331 334
@@ -1266,6 +1269,9 @@ intel_dsi_mode_valid(struct drm_connector *connector,
1266 1269
1267 DRM_DEBUG_KMS("\n"); 1270 DRM_DEBUG_KMS("\n");
1268 1271
1272 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1273 return MODE_NO_DBLESCAN;
1274
1269 if (fixed_mode) { 1275 if (fixed_mode) {
1270 if (mode->hdisplay > fixed_mode->hdisplay) 1276 if (mode->hdisplay > fixed_mode->hdisplay)
1271 return MODE_PANEL; 1277 return MODE_PANEL;
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index a70d767313aa..61d908e0df0e 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -219,6 +219,9 @@ intel_dvo_mode_valid(struct drm_connector *connector,
219 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 219 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
220 int target_clock = mode->clock; 220 int target_clock = mode->clock;
221 221
222 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
223 return MODE_NO_DBLESCAN;
224
222 /* XXX: Validate clock range */ 225 /* XXX: Validate clock range */
223 226
224 if (fixed_mode) { 227 if (fixed_mode) {
@@ -254,6 +257,9 @@ static bool intel_dvo_compute_config(struct intel_encoder *encoder,
254 if (fixed_mode) 257 if (fixed_mode)
255 intel_fixed_panel_mode(fixed_mode, adjusted_mode); 258 intel_fixed_panel_mode(fixed_mode, adjusted_mode);
256 259
260 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
261 return false;
262
257 return true; 263 return true;
258} 264}
259 265
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index ee929f31f7db..d8cb53ef4351 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1557,6 +1557,9 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
1557 bool force_dvi = 1557 bool force_dvi =
1558 READ_ONCE(to_intel_digital_connector_state(connector->state)->force_audio) == HDMI_AUDIO_OFF_DVI; 1558 READ_ONCE(to_intel_digital_connector_state(connector->state)->force_audio) == HDMI_AUDIO_OFF_DVI;
1559 1559
1560 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1561 return MODE_NO_DBLESCAN;
1562
1560 clock = mode->clock; 1563 clock = mode->clock;
1561 1564
1562 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING) 1565 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
@@ -1677,6 +1680,9 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
1677 int desired_bpp; 1680 int desired_bpp;
1678 bool force_dvi = intel_conn_state->force_audio == HDMI_AUDIO_OFF_DVI; 1681 bool force_dvi = intel_conn_state->force_audio == HDMI_AUDIO_OFF_DVI;
1679 1682
1683 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
1684 return false;
1685
1680 pipe_config->has_hdmi_sink = !force_dvi && intel_hdmi->has_hdmi_sink; 1686 pipe_config->has_hdmi_sink = !force_dvi && intel_hdmi->has_hdmi_sink;
1681 1687
1682 if (pipe_config->has_hdmi_sink) 1688 if (pipe_config->has_hdmi_sink)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 15434cad5430..7c4c8fb1dae4 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1545,11 +1545,21 @@ static u32 *gen9_init_indirectctx_bb(struct intel_engine_cs *engine, u32 *batch)
1545 /* WaFlushCoherentL3CacheLinesAtContextSwitch:skl,bxt,glk */ 1545 /* WaFlushCoherentL3CacheLinesAtContextSwitch:skl,bxt,glk */
1546 batch = gen8_emit_flush_coherentl3_wa(engine, batch); 1546 batch = gen8_emit_flush_coherentl3_wa(engine, batch);
1547 1547
1548 *batch++ = MI_LOAD_REGISTER_IMM(3);
1549
1548 /* WaDisableGatherAtSetShaderCommonSlice:skl,bxt,kbl,glk */ 1550 /* WaDisableGatherAtSetShaderCommonSlice:skl,bxt,kbl,glk */
1549 *batch++ = MI_LOAD_REGISTER_IMM(1);
1550 *batch++ = i915_mmio_reg_offset(COMMON_SLICE_CHICKEN2); 1551 *batch++ = i915_mmio_reg_offset(COMMON_SLICE_CHICKEN2);
1551 *batch++ = _MASKED_BIT_DISABLE( 1552 *batch++ = _MASKED_BIT_DISABLE(
1552 GEN9_DISABLE_GATHER_AT_SET_SHADER_COMMON_SLICE); 1553 GEN9_DISABLE_GATHER_AT_SET_SHADER_COMMON_SLICE);
1554
1555 /* BSpec: 11391 */
1556 *batch++ = i915_mmio_reg_offset(FF_SLICE_CHICKEN);
1557 *batch++ = _MASKED_BIT_ENABLE(FF_SLICE_CHICKEN_CL_PROVOKING_VERTEX_FIX);
1558
1559 /* BSpec: 11299 */
1560 *batch++ = i915_mmio_reg_offset(_3D_CHICKEN3);
1561 *batch++ = _MASKED_BIT_ENABLE(_3D_CHICKEN_SF_PROVOKING_VERTEX_FIX);
1562
1553 *batch++ = MI_NOOP; 1563 *batch++ = MI_NOOP;
1554 1564
1555 /* WaClearSlmSpaceAtContextSwitch:kbl */ 1565 /* WaClearSlmSpaceAtContextSwitch:kbl */
@@ -2641,10 +2651,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
2641 context_size += LRC_HEADER_PAGES * PAGE_SIZE; 2651 context_size += LRC_HEADER_PAGES * PAGE_SIZE;
2642 2652
2643 ctx_obj = i915_gem_object_create(ctx->i915, context_size); 2653 ctx_obj = i915_gem_object_create(ctx->i915, context_size);
2644 if (IS_ERR(ctx_obj)) { 2654 if (IS_ERR(ctx_obj))
2645 ret = PTR_ERR(ctx_obj); 2655 return PTR_ERR(ctx_obj);
2646 goto error_deref_obj;
2647 }
2648 2656
2649 vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL); 2657 vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
2650 if (IS_ERR(vma)) { 2658 if (IS_ERR(vma)) {
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index d278f24ba6ae..48f618dc9abb 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -380,6 +380,8 @@ intel_lvds_mode_valid(struct drm_connector *connector,
380 struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode; 380 struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
381 int max_pixclk = to_i915(connector->dev)->max_dotclk_freq; 381 int max_pixclk = to_i915(connector->dev)->max_dotclk_freq;
382 382
383 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
384 return MODE_NO_DBLESCAN;
383 if (mode->hdisplay > fixed_mode->hdisplay) 385 if (mode->hdisplay > fixed_mode->hdisplay)
384 return MODE_PANEL; 386 return MODE_PANEL;
385 if (mode->vdisplay > fixed_mode->vdisplay) 387 if (mode->vdisplay > fixed_mode->vdisplay)
@@ -429,6 +431,9 @@ static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
429 intel_fixed_panel_mode(intel_connector->panel.fixed_mode, 431 intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
430 adjusted_mode); 432 adjusted_mode);
431 433
434 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
435 return false;
436
432 if (HAS_PCH_SPLIT(dev_priv)) { 437 if (HAS_PCH_SPLIT(dev_priv)) {
433 pipe_config->has_pch_encoder = true; 438 pipe_config->has_pch_encoder = true;
434 439
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 25005023c243..26975df4e593 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1160,6 +1160,9 @@ static bool intel_sdvo_compute_config(struct intel_encoder *encoder,
1160 adjusted_mode); 1160 adjusted_mode);
1161 } 1161 }
1162 1162
1163 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
1164 return false;
1165
1163 /* 1166 /*
1164 * Make the CRTC code factor in the SDVO pixel multiplier. The 1167 * Make the CRTC code factor in the SDVO pixel multiplier. The
1165 * SDVO device will factor out the multiplier during mode_set. 1168 * SDVO device will factor out the multiplier during mode_set.
@@ -1621,6 +1624,9 @@ intel_sdvo_mode_valid(struct drm_connector *connector,
1621 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); 1624 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1622 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 1625 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
1623 1626
1627 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1628 return MODE_NO_DBLESCAN;
1629
1624 if (intel_sdvo->pixel_clock_min > mode->clock) 1630 if (intel_sdvo->pixel_clock_min > mode->clock)
1625 return MODE_CLOCK_LOW; 1631 return MODE_CLOCK_LOW;
1626 1632
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 885fc3809f7f..b55b5c157e38 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -850,6 +850,9 @@ intel_tv_mode_valid(struct drm_connector *connector,
850 const struct tv_mode *tv_mode = intel_tv_mode_find(connector->state); 850 const struct tv_mode *tv_mode = intel_tv_mode_find(connector->state);
851 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq; 851 int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
852 852
853 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
854 return MODE_NO_DBLESCAN;
855
853 if (mode->clock > max_dotclk) 856 if (mode->clock > max_dotclk)
854 return MODE_CLOCK_HIGH; 857 return MODE_CLOCK_HIGH;
855 858
@@ -877,16 +880,21 @@ intel_tv_compute_config(struct intel_encoder *encoder,
877 struct drm_connector_state *conn_state) 880 struct drm_connector_state *conn_state)
878{ 881{
879 const struct tv_mode *tv_mode = intel_tv_mode_find(conn_state); 882 const struct tv_mode *tv_mode = intel_tv_mode_find(conn_state);
883 struct drm_display_mode *adjusted_mode =
884 &pipe_config->base.adjusted_mode;
880 885
881 if (!tv_mode) 886 if (!tv_mode)
882 return false; 887 return false;
883 888
884 pipe_config->base.adjusted_mode.crtc_clock = tv_mode->clock; 889 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
890 return false;
891
892 adjusted_mode->crtc_clock = tv_mode->clock;
885 DRM_DEBUG_KMS("forcing bpc to 8 for TV\n"); 893 DRM_DEBUG_KMS("forcing bpc to 8 for TV\n");
886 pipe_config->pipe_bpp = 8*3; 894 pipe_config->pipe_bpp = 8*3;
887 895
888 /* TV has it's own notion of sync and other mode flags, so clear them. */ 896 /* TV has it's own notion of sync and other mode flags, so clear them. */
889 pipe_config->base.adjusted_mode.flags = 0; 897 adjusted_mode->flags = 0;
890 898
891 /* 899 /*
892 * FIXME: We don't check whether the input mode is actually what we want 900 * FIXME: We don't check whether the input mode is actually what we want
diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 32b1a6cdecfc..d3443125e661 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -197,8 +197,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
197 priv->io_base = regs; 197 priv->io_base = regs;
198 198
199 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi"); 199 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi");
200 if (!res) 200 if (!res) {
201 return -EINVAL; 201 ret = -EINVAL;
202 goto free_drm;
203 }
202 /* Simply ioremap since it may be a shared register zone */ 204 /* Simply ioremap since it may be a shared register zone */
203 regs = devm_ioremap(dev, res->start, resource_size(res)); 205 regs = devm_ioremap(dev, res->start, resource_size(res));
204 if (!regs) { 206 if (!regs) {
@@ -215,8 +217,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
215 } 217 }
216 218
217 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); 219 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc");
218 if (!res) 220 if (!res) {
219 return -EINVAL; 221 ret = -EINVAL;
222 goto free_drm;
223 }
220 /* Simply ioremap since it may be a shared register zone */ 224 /* Simply ioremap since it may be a shared register zone */
221 regs = devm_ioremap(dev, res->start, resource_size(res)); 225 regs = devm_ioremap(dev, res->start, resource_size(res));
222 if (!regs) { 226 if (!regs) {
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index 291c08117ab6..397143b639c6 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -132,7 +132,7 @@ curs507a_new_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
132 132
133 nvif_object_map(&wndw->wimm.base.user, NULL, 0); 133 nvif_object_map(&wndw->wimm.base.user, NULL, 0);
134 wndw->immd = func; 134 wndw->immd = func;
135 wndw->ctxdma.parent = &disp->core->chan.base.user; 135 wndw->ctxdma.parent = NULL;
136 return 0; 136 return 0;
137} 137}
138 138
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 224963b533a6..c5a9bc1af5af 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -444,14 +444,17 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state)
444 if (ret) 444 if (ret)
445 return ret; 445 return ret;
446 446
447 ctxdma = nv50_wndw_ctxdma_new(wndw, fb); 447 if (wndw->ctxdma.parent) {
448 if (IS_ERR(ctxdma)) { 448 ctxdma = nv50_wndw_ctxdma_new(wndw, fb);
449 nouveau_bo_unpin(fb->nvbo); 449 if (IS_ERR(ctxdma)) {
450 return PTR_ERR(ctxdma); 450 nouveau_bo_unpin(fb->nvbo);
451 return PTR_ERR(ctxdma);
452 }
453
454 asyw->image.handle[0] = ctxdma->object.handle;
451 } 455 }
452 456
453 asyw->state.fence = reservation_object_get_excl_rcu(fb->nvbo->bo.resv); 457 asyw->state.fence = reservation_object_get_excl_rcu(fb->nvbo->bo.resv);
454 asyw->image.handle[0] = ctxdma->object.handle;
455 asyw->image.offset[0] = fb->nvbo->bo.offset; 458 asyw->image.offset[0] = fb->nvbo->bo.offset;
456 459
457 if (wndw->func->prepare) { 460 if (wndw->func->prepare) {
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index b8cda9449241..768207fbbae3 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -623,7 +623,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
623 struct qxl_cursor_cmd *cmd; 623 struct qxl_cursor_cmd *cmd;
624 struct qxl_cursor *cursor; 624 struct qxl_cursor *cursor;
625 struct drm_gem_object *obj; 625 struct drm_gem_object *obj;
626 struct qxl_bo *cursor_bo = NULL, *user_bo = NULL; 626 struct qxl_bo *cursor_bo = NULL, *user_bo = NULL, *old_cursor_bo = NULL;
627 int ret; 627 int ret;
628 void *user_ptr; 628 void *user_ptr;
629 int size = 64*64*4; 629 int size = 64*64*4;
@@ -677,7 +677,7 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
677 cursor_bo, 0); 677 cursor_bo, 0);
678 cmd->type = QXL_CURSOR_SET; 678 cmd->type = QXL_CURSOR_SET;
679 679
680 qxl_bo_unref(&qcrtc->cursor_bo); 680 old_cursor_bo = qcrtc->cursor_bo;
681 qcrtc->cursor_bo = cursor_bo; 681 qcrtc->cursor_bo = cursor_bo;
682 cursor_bo = NULL; 682 cursor_bo = NULL;
683 } else { 683 } else {
@@ -697,6 +697,9 @@ static void qxl_cursor_atomic_update(struct drm_plane *plane,
697 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false); 697 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
698 qxl_release_fence_buffer_objects(release); 698 qxl_release_fence_buffer_objects(release);
699 699
700 if (old_cursor_bo)
701 qxl_bo_unref(&old_cursor_bo);
702
700 qxl_bo_unref(&cursor_bo); 703 qxl_bo_unref(&cursor_bo);
701 704
702 return; 705 return;
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index 08747fc3ee71..8232b39e16ca 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -17,7 +17,6 @@
17#include <drm/drm_encoder.h> 17#include <drm/drm_encoder.h>
18#include <drm/drm_modes.h> 18#include <drm/drm_modes.h>
19#include <drm/drm_of.h> 19#include <drm/drm_of.h>
20#include <drm/drm_panel.h>
21 20
22#include <uapi/drm/drm_mode.h> 21#include <uapi/drm/drm_mode.h>
23 22
@@ -418,9 +417,6 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon,
418static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, 417static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
419 const struct drm_display_mode *mode) 418 const struct drm_display_mode *mode)
420{ 419{
421 struct drm_panel *panel = tcon->panel;
422 struct drm_connector *connector = panel->connector;
423 struct drm_display_info display_info = connector->display_info;
424 unsigned int bp, hsync, vsync; 420 unsigned int bp, hsync, vsync;
425 u8 clk_delay; 421 u8 clk_delay;
426 u32 val = 0; 422 u32 val = 0;
@@ -478,27 +474,6 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
478 if (mode->flags & DRM_MODE_FLAG_PVSYNC) 474 if (mode->flags & DRM_MODE_FLAG_PVSYNC)
479 val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; 475 val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
480 476
481 /*
482 * On A20 and similar SoCs, the only way to achieve Positive Edge
483 * (Rising Edge), is setting dclk clock phase to 2/3(240°).
484 * By default TCON works in Negative Edge(Falling Edge),
485 * this is why phase is set to 0 in that case.
486 * Unfortunately there's no way to logically invert dclk through
487 * IO_POL register.
488 * The only acceptable way to work, triple checked with scope,
489 * is using clock phase set to 0° for Negative Edge and set to 240°
490 * for Positive Edge.
491 * On A33 and similar SoCs there would be a 90° phase option,
492 * but it divides also dclk by 2.
493 * Following code is a way to avoid quirks all around TCON
494 * and DOTCLOCK drivers.
495 */
496 if (display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE)
497 clk_set_phase(tcon->dclk, 240);
498
499 if (display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE)
500 clk_set_phase(tcon->dclk, 0);
501
502 regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, 477 regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG,
503 SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSITIVE, 478 SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSITIVE,
504 val); 479 val);
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index 7b8e17b03cb8..6bf4da7ad63a 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -124,6 +124,8 @@ static const struct hid_device_id hammer_devices[] = {
124 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) }, 124 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) },
125 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 125 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
126 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WAND) }, 126 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WAND) },
127 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
128 USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_WHISKERS) },
127 { } 129 { }
128}; 130};
129MODULE_DEVICE_TABLE(hid, hammer_devices); 131MODULE_DEVICE_TABLE(hid, hammer_devices);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index a85634fe033f..c7981ddd8776 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -452,6 +452,7 @@
452#define USB_DEVICE_ID_GOOGLE_TOUCH_ROSE 0x5028 452#define USB_DEVICE_ID_GOOGLE_TOUCH_ROSE 0x5028
453#define USB_DEVICE_ID_GOOGLE_STAFF 0x502b 453#define USB_DEVICE_ID_GOOGLE_STAFF 0x502b
454#define USB_DEVICE_ID_GOOGLE_WAND 0x502d 454#define USB_DEVICE_ID_GOOGLE_WAND 0x502d
455#define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030
455 456
456#define USB_VENDOR_ID_GOTOP 0x08f2 457#define USB_VENDOR_ID_GOTOP 0x08f2
457#define USB_DEVICE_ID_SUPER_Q2 0x007f 458#define USB_DEVICE_ID_SUPER_Q2 0x007f
diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
index cb86cc834201..0422ec2b13d2 100644
--- a/drivers/hid/hid-steam.c
+++ b/drivers/hid/hid-steam.c
@@ -573,7 +573,7 @@ static bool steam_is_valve_interface(struct hid_device *hdev)
573 573
574static int steam_client_ll_parse(struct hid_device *hdev) 574static int steam_client_ll_parse(struct hid_device *hdev)
575{ 575{
576 struct steam_device *steam = hid_get_drvdata(hdev); 576 struct steam_device *steam = hdev->driver_data;
577 577
578 return hid_parse_report(hdev, steam->hdev->dev_rdesc, 578 return hid_parse_report(hdev, steam->hdev->dev_rdesc,
579 steam->hdev->dev_rsize); 579 steam->hdev->dev_rsize);
@@ -590,7 +590,7 @@ static void steam_client_ll_stop(struct hid_device *hdev)
590 590
591static int steam_client_ll_open(struct hid_device *hdev) 591static int steam_client_ll_open(struct hid_device *hdev)
592{ 592{
593 struct steam_device *steam = hid_get_drvdata(hdev); 593 struct steam_device *steam = hdev->driver_data;
594 int ret; 594 int ret;
595 595
596 ret = hid_hw_open(steam->hdev); 596 ret = hid_hw_open(steam->hdev);
@@ -605,7 +605,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
605 605
606static void steam_client_ll_close(struct hid_device *hdev) 606static void steam_client_ll_close(struct hid_device *hdev)
607{ 607{
608 struct steam_device *steam = hid_get_drvdata(hdev); 608 struct steam_device *steam = hdev->driver_data;
609 609
610 mutex_lock(&steam->mutex); 610 mutex_lock(&steam->mutex);
611 steam->client_opened = false; 611 steam->client_opened = false;
@@ -623,7 +623,7 @@ static int steam_client_ll_raw_request(struct hid_device *hdev,
623 size_t count, unsigned char report_type, 623 size_t count, unsigned char report_type,
624 int reqtype) 624 int reqtype)
625{ 625{
626 struct steam_device *steam = hid_get_drvdata(hdev); 626 struct steam_device *steam = hdev->driver_data;
627 627
628 return hid_hw_raw_request(steam->hdev, reportnum, buf, count, 628 return hid_hw_raw_request(steam->hdev, reportnum, buf, count,
629 report_type, reqtype); 629 report_type, reqtype);
@@ -710,7 +710,7 @@ static int steam_probe(struct hid_device *hdev,
710 ret = PTR_ERR(steam->client_hdev); 710 ret = PTR_ERR(steam->client_hdev);
711 goto client_hdev_fail; 711 goto client_hdev_fail;
712 } 712 }
713 hid_set_drvdata(steam->client_hdev, steam); 713 steam->client_hdev->driver_data = steam;
714 714
715 /* 715 /*
716 * With the real steam controller interface, do not connect hidraw. 716 * With the real steam controller interface, do not connect hidraw.
diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
index 582e449be9fe..a2c53ea3b5ed 100644
--- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c
+++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c
@@ -205,8 +205,7 @@ static void ish_remove(struct pci_dev *pdev)
205 kfree(ishtp_dev); 205 kfree(ishtp_dev);
206} 206}
207 207
208#ifdef CONFIG_PM 208static struct device __maybe_unused *ish_resume_device;
209static struct device *ish_resume_device;
210 209
211/* 50ms to get resume response */ 210/* 50ms to get resume response */
212#define WAIT_FOR_RESUME_ACK_MS 50 211#define WAIT_FOR_RESUME_ACK_MS 50
@@ -220,7 +219,7 @@ static struct device *ish_resume_device;
220 * in that case a simple resume message is enough, others we need 219 * in that case a simple resume message is enough, others we need
221 * a reset sequence. 220 * a reset sequence.
222 */ 221 */
223static void ish_resume_handler(struct work_struct *work) 222static void __maybe_unused ish_resume_handler(struct work_struct *work)
224{ 223{
225 struct pci_dev *pdev = to_pci_dev(ish_resume_device); 224 struct pci_dev *pdev = to_pci_dev(ish_resume_device);
226 struct ishtp_device *dev = pci_get_drvdata(pdev); 225 struct ishtp_device *dev = pci_get_drvdata(pdev);
@@ -262,7 +261,7 @@ static void ish_resume_handler(struct work_struct *work)
262 * 261 *
263 * Return: 0 to the pm core 262 * Return: 0 to the pm core
264 */ 263 */
265static int ish_suspend(struct device *device) 264static int __maybe_unused ish_suspend(struct device *device)
266{ 265{
267 struct pci_dev *pdev = to_pci_dev(device); 266 struct pci_dev *pdev = to_pci_dev(device);
268 struct ishtp_device *dev = pci_get_drvdata(pdev); 267 struct ishtp_device *dev = pci_get_drvdata(pdev);
@@ -288,7 +287,7 @@ static int ish_suspend(struct device *device)
288 return 0; 287 return 0;
289} 288}
290 289
291static DECLARE_WORK(resume_work, ish_resume_handler); 290static __maybe_unused DECLARE_WORK(resume_work, ish_resume_handler);
292/** 291/**
293 * ish_resume() - ISH resume callback 292 * ish_resume() - ISH resume callback
294 * @device: device pointer 293 * @device: device pointer
@@ -297,7 +296,7 @@ static DECLARE_WORK(resume_work, ish_resume_handler);
297 * 296 *
298 * Return: 0 to the pm core 297 * Return: 0 to the pm core
299 */ 298 */
300static int ish_resume(struct device *device) 299static int __maybe_unused ish_resume(struct device *device)
301{ 300{
302 struct pci_dev *pdev = to_pci_dev(device); 301 struct pci_dev *pdev = to_pci_dev(device);
303 struct ishtp_device *dev = pci_get_drvdata(pdev); 302 struct ishtp_device *dev = pci_get_drvdata(pdev);
@@ -311,21 +310,14 @@ static int ish_resume(struct device *device)
311 return 0; 310 return 0;
312} 311}
313 312
314static const struct dev_pm_ops ish_pm_ops = { 313static SIMPLE_DEV_PM_OPS(ish_pm_ops, ish_suspend, ish_resume);
315 .suspend = ish_suspend,
316 .resume = ish_resume,
317};
318#define ISHTP_ISH_PM_OPS (&ish_pm_ops)
319#else
320#define ISHTP_ISH_PM_OPS NULL
321#endif /* CONFIG_PM */
322 314
323static struct pci_driver ish_driver = { 315static struct pci_driver ish_driver = {
324 .name = KBUILD_MODNAME, 316 .name = KBUILD_MODNAME,
325 .id_table = ish_pci_tbl, 317 .id_table = ish_pci_tbl,
326 .probe = ish_probe, 318 .probe = ish_probe,
327 .remove = ish_remove, 319 .remove = ish_remove,
328 .driver.pm = ISHTP_ISH_PM_OPS, 320 .driver.pm = &ish_pm_ops,
329}; 321};
330 322
331module_pci_driver(ish_driver); 323module_pci_driver(ish_driver);
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index c101369b51de..d6797535fff9 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -395,6 +395,14 @@ static void wacom_usage_mapping(struct hid_device *hdev,
395 } 395 }
396 } 396 }
397 397
398 /* 2nd-generation Intuos Pro Large has incorrect Y maximum */
399 if (hdev->vendor == USB_VENDOR_ID_WACOM &&
400 hdev->product == 0x0358 &&
401 WACOM_PEN_FIELD(field) &&
402 wacom_equivalent_usage(usage->hid) == HID_GD_Y) {
403 field->logical_maximum = 43200;
404 }
405
398 switch (usage->hid) { 406 switch (usage->hid) {
399 case HID_GD_X: 407 case HID_GD_X:
400 features->x_max = field->logical_maximum; 408 features->x_max = field->logical_maximum;
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index f10840ad465c..195154178aff 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1298,6 +1298,16 @@ config SENSORS_PWM_FAN
1298 This driver can also be built as a module. If so, the module 1298 This driver can also be built as a module. If so, the module
1299 will be called pwm-fan. 1299 will be called pwm-fan.
1300 1300
1301config SENSORS_RASPBERRYPI_HWMON
1302 tristate "Raspberry Pi voltage monitor"
1303 depends on RASPBERRYPI_FIRMWARE || (COMPILE_TEST && !RASPBERRYPI_FIRMWARE)
1304 help
1305 If you say yes here you get support for voltage sensor on the
1306 Raspberry Pi.
1307
1308 This driver can also be built as a module. If so, the module
1309 will be called raspberrypi-hwmon.
1310
1301config SENSORS_SHT15 1311config SENSORS_SHT15
1302 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." 1312 tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
1303 depends on GPIOLIB || COMPILE_TEST 1313 depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index e7d52a36e6c4..a9297703fd6e 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -141,6 +141,7 @@ obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
141obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 141obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
142obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o 142obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o
143obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o 143obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o
144obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o
144obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o 145obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o
145obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o 146obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
146obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o 147obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o
diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index bf3bb7e1adab..9d3ef879dc51 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1074,6 +1074,13 @@ static struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initdata = {
1074 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Vostro 3360"), 1074 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Vostro 3360"),
1075 }, 1075 },
1076 }, 1076 },
1077 {
1078 .ident = "Dell XPS13 9333",
1079 .matches = {
1080 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
1081 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "XPS13 9333"),
1082 },
1083 },
1077 { } 1084 { }
1078}; 1085};
1079 1086
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 155d4d1d1585..f9d1349c3286 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -4175,7 +4175,7 @@ static int nct6775_probe(struct platform_device *pdev)
4175 * The temperature is already monitored if the respective bit in <mask> 4175 * The temperature is already monitored if the respective bit in <mask>
4176 * is set. 4176 * is set.
4177 */ 4177 */
4178 for (i = 0; i < 32; i++) { 4178 for (i = 0; i < 31; i++) {
4179 if (!(data->temp_mask & BIT(i + 1))) 4179 if (!(data->temp_mask & BIT(i + 1)))
4180 continue; 4180 continue;
4181 if (!reg_temp_alternate[i]) 4181 if (!reg_temp_alternate[i])
diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
new file mode 100644
index 000000000000..fb4e4a6bb1f6
--- /dev/null
+++ b/drivers/hwmon/raspberrypi-hwmon.c
@@ -0,0 +1,166 @@
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Raspberry Pi voltage sensor driver
4 *
5 * Based on firmware/raspberrypi.c by Noralf Trønnes
6 *
7 * Copyright (C) 2018 Stefan Wahren <stefan.wahren@i2se.com>
8 */
9#include <linux/device.h>
10#include <linux/err.h>
11#include <linux/hwmon.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14#include <linux/slab.h>
15#include <linux/workqueue.h>
16#include <soc/bcm2835/raspberrypi-firmware.h>
17
18#define UNDERVOLTAGE_STICKY_BIT BIT(16)
19
20struct rpi_hwmon_data {
21 struct device *hwmon_dev;
22 struct rpi_firmware *fw;
23 u32 last_throttled;
24 struct delayed_work get_values_poll_work;
25};
26
27static void rpi_firmware_get_throttled(struct rpi_hwmon_data *data)
28{
29 u32 new_uv, old_uv, value;
30 int ret;
31
32 /* Request firmware to clear sticky bits */
33 value = 0xffff;
34
35 ret = rpi_firmware_property(data->fw, RPI_FIRMWARE_GET_THROTTLED,
36 &value, sizeof(value));
37 if (ret) {
38 dev_err_once(data->hwmon_dev, "Failed to get throttled (%d)\n",
39 ret);
40 return;
41 }
42
43 new_uv = value & UNDERVOLTAGE_STICKY_BIT;
44 old_uv = data->last_throttled & UNDERVOLTAGE_STICKY_BIT;
45 data->last_throttled = value;
46
47 if (new_uv == old_uv)
48 return;
49
50 if (new_uv)
51 dev_crit(data->hwmon_dev, "Undervoltage detected!\n");
52 else
53 dev_info(data->hwmon_dev, "Voltage normalised\n");
54
55 sysfs_notify(&data->hwmon_dev->kobj, NULL, "in0_lcrit_alarm");
56}
57
58static void get_values_poll(struct work_struct *work)
59{
60 struct rpi_hwmon_data *data;
61
62 data = container_of(work, struct rpi_hwmon_data,
63 get_values_poll_work.work);
64
65 rpi_firmware_get_throttled(data);
66
67 /*
68 * We can't run faster than the sticky shift (100ms) since we get
69 * flipping in the sticky bits that are cleared.
70 */
71 schedule_delayed_work(&data->get_values_poll_work, 2 * HZ);
72}
73
74static int rpi_read(struct device *dev, enum hwmon_sensor_types type,
75 u32 attr, int channel, long *val)
76{
77 struct rpi_hwmon_data *data = dev_get_drvdata(dev);
78
79 *val = !!(data->last_throttled & UNDERVOLTAGE_STICKY_BIT);
80 return 0;
81}
82
83static umode_t rpi_is_visible(const void *_data, enum hwmon_sensor_types type,
84 u32 attr, int channel)
85{
86 return 0444;
87}
88
89static const u32 rpi_in_config[] = {
90 HWMON_I_LCRIT_ALARM,
91 0
92};
93
94static const struct hwmon_channel_info rpi_in = {
95 .type = hwmon_in,
96 .config = rpi_in_config,
97};
98
99static const struct hwmon_channel_info *rpi_info[] = {
100 &rpi_in,
101 NULL
102};
103
104static const struct hwmon_ops rpi_hwmon_ops = {
105 .is_visible = rpi_is_visible,
106 .read = rpi_read,
107};
108
109static const struct hwmon_chip_info rpi_chip_info = {
110 .ops = &rpi_hwmon_ops,
111 .info = rpi_info,
112};
113
114static int rpi_hwmon_probe(struct platform_device *pdev)
115{
116 struct device *dev = &pdev->dev;
117 struct rpi_hwmon_data *data;
118 int ret;
119
120 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
121 if (!data)
122 return -ENOMEM;
123
124 /* Parent driver assure that firmware is correct */
125 data->fw = dev_get_drvdata(dev->parent);
126
127 /* Init throttled */
128 ret = rpi_firmware_property(data->fw, RPI_FIRMWARE_GET_THROTTLED,
129 &data->last_throttled,
130 sizeof(data->last_throttled));
131
132 data->hwmon_dev = devm_hwmon_device_register_with_info(dev, "rpi_volt",
133 data,
134 &rpi_chip_info,
135 NULL);
136
137 INIT_DELAYED_WORK(&data->get_values_poll_work, get_values_poll);
138 platform_set_drvdata(pdev, data);
139
140 if (!PTR_ERR_OR_ZERO(data->hwmon_dev))
141 schedule_delayed_work(&data->get_values_poll_work, 2 * HZ);
142
143 return PTR_ERR_OR_ZERO(data->hwmon_dev);
144}
145
146static int rpi_hwmon_remove(struct platform_device *pdev)
147{
148 struct rpi_hwmon_data *data = platform_get_drvdata(pdev);
149
150 cancel_delayed_work_sync(&data->get_values_poll_work);
151
152 return 0;
153}
154
155static struct platform_driver rpi_hwmon_driver = {
156 .probe = rpi_hwmon_probe,
157 .remove = rpi_hwmon_remove,
158 .driver = {
159 .name = "raspberrypi-hwmon",
160 },
161};
162module_platform_driver(rpi_hwmon_driver);
163
164MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
165MODULE_DESCRIPTION("Raspberry Pi voltage sensor driver");
166MODULE_LICENSE("GPL v2");
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 4a34f311e1ff..6ec65adaba49 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -647,10 +647,10 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
647 if (bit_adap->getscl == NULL) 647 if (bit_adap->getscl == NULL)
648 adap->quirks = &i2c_bit_quirk_no_clk_stretch; 648 adap->quirks = &i2c_bit_quirk_no_clk_stretch;
649 649
650 /* Bring bus to a known state. Looks like STOP if bus is not free yet */ 650 /*
651 setscl(bit_adap, 1); 651 * We tried forcing SCL/SDA to an initial state here. But that caused a
652 udelay(bit_adap->udelay); 652 * regression, sadly. Check Bugzilla #200045 for details.
653 setsda(bit_adap, 1); 653 */
654 654
655 ret = add_adapter(adap); 655 ret = add_adapter(adap);
656 if (ret < 0) 656 if (ret < 0)
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 005e6e0330c2..66f85bbf3591 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -279,9 +279,9 @@ static int i2c_gpio_probe(struct platform_device *pdev)
279 * required for an I2C bus. 279 * required for an I2C bus.
280 */ 280 */
281 if (pdata->scl_is_open_drain) 281 if (pdata->scl_is_open_drain)
282 gflags = GPIOD_OUT_LOW; 282 gflags = GPIOD_OUT_HIGH;
283 else 283 else
284 gflags = GPIOD_OUT_LOW_OPEN_DRAIN; 284 gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
285 priv->scl = i2c_gpio_get_desc(dev, "scl", 1, gflags); 285 priv->scl = i2c_gpio_get_desc(dev, "scl", 1, gflags);
286 if (IS_ERR(priv->scl)) 286 if (IS_ERR(priv->scl))
287 return PTR_ERR(priv->scl); 287 return PTR_ERR(priv->scl);
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index f3f683041e7f..51970bae3c4a 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -465,15 +465,18 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
465 465
466 status = i2c_transfer(adapter, msg, num); 466 status = i2c_transfer(adapter, msg, num);
467 if (status < 0) 467 if (status < 0)
468 return status; 468 goto cleanup;
469 if (status != num) 469 if (status != num) {
470 return -EIO; 470 status = -EIO;
471 goto cleanup;
472 }
473 status = 0;
471 474
472 /* Check PEC if last message is a read */ 475 /* Check PEC if last message is a read */
473 if (i && (msg[num-1].flags & I2C_M_RD)) { 476 if (i && (msg[num-1].flags & I2C_M_RD)) {
474 status = i2c_smbus_check_pec(partial_pec, &msg[num-1]); 477 status = i2c_smbus_check_pec(partial_pec, &msg[num-1]);
475 if (status < 0) 478 if (status < 0)
476 return status; 479 goto cleanup;
477 } 480 }
478 481
479 if (read_write == I2C_SMBUS_READ) 482 if (read_write == I2C_SMBUS_READ)
@@ -499,12 +502,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
499 break; 502 break;
500 } 503 }
501 504
505cleanup:
502 if (msg[0].flags & I2C_M_DMA_SAFE) 506 if (msg[0].flags & I2C_M_DMA_SAFE)
503 kfree(msg[0].buf); 507 kfree(msg[0].buf);
504 if (msg[1].flags & I2C_M_DMA_SAFE) 508 if (msg[1].flags & I2C_M_DMA_SAFE)
505 kfree(msg[1].buf); 509 kfree(msg[1].buf);
506 510
507 return 0; 511 return status;
508} 512}
509 513
510/** 514/**
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 7e3d82cff3d5..c149c9c360fc 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1053,7 +1053,7 @@ static irqreturn_t mma8452_interrupt(int irq, void *p)
1053 if (src < 0) 1053 if (src < 0)
1054 return IRQ_NONE; 1054 return IRQ_NONE;
1055 1055
1056 if (!(src & data->chip_info->enabled_events)) 1056 if (!(src & (data->chip_info->enabled_events | MMA8452_INT_DRDY)))
1057 return IRQ_NONE; 1057 return IRQ_NONE;
1058 1058
1059 if (src & MMA8452_INT_DRDY) { 1059 if (src & MMA8452_INT_DRDY) {
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index f9c0624505a2..42618fe4f83e 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -959,6 +959,8 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
959 } 959 }
960 960
961 irq_type = irqd_get_trigger_type(desc); 961 irq_type = irqd_get_trigger_type(desc);
962 if (!irq_type)
963 irq_type = IRQF_TRIGGER_RISING;
962 if (irq_type == IRQF_TRIGGER_RISING) 964 if (irq_type == IRQF_TRIGGER_RISING)
963 st->irq_mask = INV_MPU6050_ACTIVE_HIGH; 965 st->irq_mask = INV_MPU6050_ACTIVE_HIGH;
964 else if (irq_type == IRQF_TRIGGER_FALLING) 966 else if (irq_type == IRQF_TRIGGER_FALLING)
diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
index 34d42a2504c9..df5b2a0da96c 100644
--- a/drivers/iio/light/tsl2772.c
+++ b/drivers/iio/light/tsl2772.c
@@ -582,6 +582,8 @@ static int tsl2772_als_calibrate(struct iio_dev *indio_dev)
582 "%s: failed to get lux\n", __func__); 582 "%s: failed to get lux\n", __func__);
583 return lux_val; 583 return lux_val;
584 } 584 }
585 if (lux_val == 0)
586 return -ERANGE;
585 587
586 ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) / 588 ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) /
587 lux_val; 589 lux_val;
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 5ec3e41b65f2..fe87d27779d9 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -415,10 +415,9 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
415 } 415 }
416 comp_humidity = bmp280_compensate_humidity(data, adc_humidity); 416 comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
417 417
418 *val = comp_humidity; 418 *val = comp_humidity * 1000 / 1024;
419 *val2 = 1024;
420 419
421 return IIO_VAL_FRACTIONAL; 420 return IIO_VAL_INT;
422} 421}
423 422
424static int bmp280_read_raw(struct iio_dev *indio_dev, 423static int bmp280_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 3ae2339dd27a..2094d136513d 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -736,10 +736,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
736 if (ret) 736 if (ret)
737 return ret; 737 return ret;
738 738
739 if (!file->ucontext &&
740 (command != IB_USER_VERBS_CMD_GET_CONTEXT || extended))
741 return -EINVAL;
742
743 if (extended) { 739 if (extended) {
744 if (count < (sizeof(hdr) + sizeof(ex_hdr))) 740 if (count < (sizeof(hdr) + sizeof(ex_hdr)))
745 return -EINVAL; 741 return -EINVAL;
@@ -759,6 +755,16 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
759 goto out; 755 goto out;
760 } 756 }
761 757
758 /*
759 * Must be after the ib_dev check, as once the RCU clears ib_dev ==
760 * NULL means ucontext == NULL
761 */
762 if (!file->ucontext &&
763 (command != IB_USER_VERBS_CMD_GET_CONTEXT || extended)) {
764 ret = -EINVAL;
765 goto out;
766 }
767
762 if (!verify_command_mask(ib_dev, command, extended)) { 768 if (!verify_command_mask(ib_dev, command, extended)) {
763 ret = -EOPNOTSUPP; 769 ret = -EOPNOTSUPP;
764 goto out; 770 goto out;
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 0b56828c1319..9d6beb948535 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1562,11 +1562,12 @@ EXPORT_SYMBOL(ib_destroy_qp);
1562 1562
1563/* Completion queues */ 1563/* Completion queues */
1564 1564
1565struct ib_cq *ib_create_cq(struct ib_device *device, 1565struct ib_cq *__ib_create_cq(struct ib_device *device,
1566 ib_comp_handler comp_handler, 1566 ib_comp_handler comp_handler,
1567 void (*event_handler)(struct ib_event *, void *), 1567 void (*event_handler)(struct ib_event *, void *),
1568 void *cq_context, 1568 void *cq_context,
1569 const struct ib_cq_init_attr *cq_attr) 1569 const struct ib_cq_init_attr *cq_attr,
1570 const char *caller)
1570{ 1571{
1571 struct ib_cq *cq; 1572 struct ib_cq *cq;
1572 1573
@@ -1580,12 +1581,13 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
1580 cq->cq_context = cq_context; 1581 cq->cq_context = cq_context;
1581 atomic_set(&cq->usecnt, 0); 1582 atomic_set(&cq->usecnt, 0);
1582 cq->res.type = RDMA_RESTRACK_CQ; 1583 cq->res.type = RDMA_RESTRACK_CQ;
1584 cq->res.kern_name = caller;
1583 rdma_restrack_add(&cq->res); 1585 rdma_restrack_add(&cq->res);
1584 } 1586 }
1585 1587
1586 return cq; 1588 return cq;
1587} 1589}
1588EXPORT_SYMBOL(ib_create_cq); 1590EXPORT_SYMBOL(__ib_create_cq);
1589 1591
1590int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period) 1592int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period)
1591{ 1593{
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index ed1f253faf97..c7c85c22e4e3 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -486,8 +486,11 @@ int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
486 } 486 }
487 487
488 if (flags & IB_MR_REREG_ACCESS) { 488 if (flags & IB_MR_REREG_ACCESS) {
489 if (ib_access_writable(mr_access_flags) && !mmr->umem->writable) 489 if (ib_access_writable(mr_access_flags) &&
490 return -EPERM; 490 !mmr->umem->writable) {
491 err = -EPERM;
492 goto release_mpt_entry;
493 }
491 494
492 err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry, 495 err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
493 convert_access(mr_access_flags)); 496 convert_access(mr_access_flags));
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index e52dd21519b4..e3e330f59c2c 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3199,8 +3199,8 @@ static int flow_counters_set_data(struct ib_counters *ibcounters,
3199 if (!mcounters->hw_cntrs_hndl) { 3199 if (!mcounters->hw_cntrs_hndl) {
3200 mcounters->hw_cntrs_hndl = mlx5_fc_create( 3200 mcounters->hw_cntrs_hndl = mlx5_fc_create(
3201 to_mdev(ibcounters->device)->mdev, false); 3201 to_mdev(ibcounters->device)->mdev, false);
3202 if (!mcounters->hw_cntrs_hndl) { 3202 if (IS_ERR(mcounters->hw_cntrs_hndl)) {
3203 ret = -ENOMEM; 3203 ret = PTR_ERR(mcounters->hw_cntrs_hndl);
3204 goto free; 3204 goto free;
3205 } 3205 }
3206 hw_hndl = true; 3206 hw_hndl = true;
@@ -3546,29 +3546,35 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
3546 return ERR_PTR(-ENOMEM); 3546 return ERR_PTR(-ENOMEM);
3547 3547
3548 err = ib_copy_from_udata(ucmd, udata, required_ucmd_sz); 3548 err = ib_copy_from_udata(ucmd, udata, required_ucmd_sz);
3549 if (err) { 3549 if (err)
3550 kfree(ucmd); 3550 goto free_ucmd;
3551 return ERR_PTR(err);
3552 }
3553 } 3551 }
3554 3552
3555 if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO) 3553 if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO) {
3556 return ERR_PTR(-ENOMEM); 3554 err = -ENOMEM;
3555 goto free_ucmd;
3556 }
3557 3557
3558 if (domain != IB_FLOW_DOMAIN_USER || 3558 if (domain != IB_FLOW_DOMAIN_USER ||
3559 flow_attr->port > dev->num_ports || 3559 flow_attr->port > dev->num_ports ||
3560 (flow_attr->flags & ~(IB_FLOW_ATTR_FLAGS_DONT_TRAP | 3560 (flow_attr->flags & ~(IB_FLOW_ATTR_FLAGS_DONT_TRAP |
3561 IB_FLOW_ATTR_FLAGS_EGRESS))) 3561 IB_FLOW_ATTR_FLAGS_EGRESS))) {
3562 return ERR_PTR(-EINVAL); 3562 err = -EINVAL;
3563 goto free_ucmd;
3564 }
3563 3565
3564 if (is_egress && 3566 if (is_egress &&
3565 (flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT || 3567 (flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
3566 flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT)) 3568 flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT)) {
3567 return ERR_PTR(-EINVAL); 3569 err = -EINVAL;
3570 goto free_ucmd;
3571 }
3568 3572
3569 dst = kzalloc(sizeof(*dst), GFP_KERNEL); 3573 dst = kzalloc(sizeof(*dst), GFP_KERNEL);
3570 if (!dst) 3574 if (!dst) {
3571 return ERR_PTR(-ENOMEM); 3575 err = -ENOMEM;
3576 goto free_ucmd;
3577 }
3572 3578
3573 mutex_lock(&dev->flow_db->lock); 3579 mutex_lock(&dev->flow_db->lock);
3574 3580
@@ -3637,8 +3643,8 @@ destroy_ft:
3637unlock: 3643unlock:
3638 mutex_unlock(&dev->flow_db->lock); 3644 mutex_unlock(&dev->flow_db->lock);
3639 kfree(dst); 3645 kfree(dst);
3646free_ucmd:
3640 kfree(ucmd); 3647 kfree(ucmd);
3641 kfree(handler);
3642 return ERR_PTR(err); 3648 return ERR_PTR(err);
3643} 3649}
3644 3650
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index f7ac8fc9b531..f07b8df96f43 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -1957,6 +1957,9 @@ int qedr_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1957 } 1957 }
1958 1958
1959 if (attr_mask & (IB_QP_AV | IB_QP_PATH_MTU)) { 1959 if (attr_mask & (IB_QP_AV | IB_QP_PATH_MTU)) {
1960 if (rdma_protocol_iwarp(&dev->ibdev, 1))
1961 return -EINVAL;
1962
1960 if (attr_mask & IB_QP_PATH_MTU) { 1963 if (attr_mask & IB_QP_PATH_MTU) {
1961 if (attr->path_mtu < IB_MTU_256 || 1964 if (attr->path_mtu < IB_MTU_256 ||
1962 attr->path_mtu > IB_MTU_4096) { 1965 attr->path_mtu > IB_MTU_4096) {
diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
index f30eeba3f772..8be27238a86e 100644
--- a/drivers/infiniband/sw/rxe/rxe_req.c
+++ b/drivers/infiniband/sw/rxe/rxe_req.c
@@ -645,6 +645,9 @@ next_wqe:
645 } else { 645 } else {
646 goto exit; 646 goto exit;
647 } 647 }
648 if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
649 qp->sq_sig_type == IB_SIGNAL_ALL_WR)
650 rxe_run_task(&qp->comp.task, 1);
648 qp->req.wqe_index = next_index(qp->sq.queue, 651 qp->req.wqe_index = next_index(qp->sq.queue,
649 qp->req.wqe_index); 652 qp->req.wqe_index);
650 goto next_wqe; 653 goto next_wqe;
@@ -709,6 +712,7 @@ next_wqe:
709 712
710 if (fill_packet(qp, wqe, &pkt, skb, payload)) { 713 if (fill_packet(qp, wqe, &pkt, skb, payload)) {
711 pr_debug("qp#%d Error during fill packet\n", qp_num(qp)); 714 pr_debug("qp#%d Error during fill packet\n", qp_num(qp));
715 kfree_skb(skb);
712 goto err; 716 goto err;
713 } 717 }
714 718
@@ -740,7 +744,6 @@ next_wqe:
740 goto next_wqe; 744 goto next_wqe;
741 745
742err: 746err:
743 kfree_skb(skb);
744 wqe->status = IB_WC_LOC_PROT_ERR; 747 wqe->status = IB_WC_LOC_PROT_ERR;
745 wqe->state = wqe_state_error; 748 wqe->state = wqe_state_error;
746 __rxe_do_task(&qp->comp.task); 749 __rxe_do_task(&qp->comp.task);
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index cf30523c6ef6..6c7326c93721 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -131,8 +131,10 @@ EXPORT_SYMBOL(input_mt_destroy_slots);
131 * inactive, or if the tool type is changed, a new tracking id is 131 * inactive, or if the tool type is changed, a new tracking id is
132 * assigned to the slot. The tool type is only reported if the 132 * assigned to the slot. The tool type is only reported if the
133 * corresponding absbit field is set. 133 * corresponding absbit field is set.
134 *
135 * Returns true if contact is active.
134 */ 136 */
135void input_mt_report_slot_state(struct input_dev *dev, 137bool input_mt_report_slot_state(struct input_dev *dev,
136 unsigned int tool_type, bool active) 138 unsigned int tool_type, bool active)
137{ 139{
138 struct input_mt *mt = dev->mt; 140 struct input_mt *mt = dev->mt;
@@ -140,22 +142,24 @@ void input_mt_report_slot_state(struct input_dev *dev,
140 int id; 142 int id;
141 143
142 if (!mt) 144 if (!mt)
143 return; 145 return false;
144 146
145 slot = &mt->slots[mt->slot]; 147 slot = &mt->slots[mt->slot];
146 slot->frame = mt->frame; 148 slot->frame = mt->frame;
147 149
148 if (!active) { 150 if (!active) {
149 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); 151 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
150 return; 152 return false;
151 } 153 }
152 154
153 id = input_mt_get_value(slot, ABS_MT_TRACKING_ID); 155 id = input_mt_get_value(slot, ABS_MT_TRACKING_ID);
154 if (id < 0 || input_mt_get_value(slot, ABS_MT_TOOL_TYPE) != tool_type) 156 if (id < 0)
155 id = input_mt_new_trkid(mt); 157 id = input_mt_new_trkid(mt);
156 158
157 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id); 159 input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id);
158 input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type); 160 input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type);
161
162 return true;
159} 163}
160EXPORT_SYMBOL(input_mt_report_slot_state); 164EXPORT_SYMBOL(input_mt_report_slot_state);
161 165
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 48e36acbeb49..cd620e009bad 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -125,7 +125,7 @@ static const struct xpad_device {
125 u8 mapping; 125 u8 mapping;
126 u8 xtype; 126 u8 xtype;
127} xpad_device[] = { 127} xpad_device[] = {
128 { 0x0079, 0x18d4, "GPD Win 2 Controller", 0, XTYPE_XBOX360 }, 128 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
129 { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, 129 { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX },
130 { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, 130 { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX },
131 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, 131 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c
index f6e643b589b6..e8dae6195b30 100644
--- a/drivers/input/keyboard/goldfish_events.c
+++ b/drivers/input/keyboard/goldfish_events.c
@@ -45,7 +45,7 @@ struct event_dev {
45static irqreturn_t events_interrupt(int irq, void *dev_id) 45static irqreturn_t events_interrupt(int irq, void *dev_id)
46{ 46{
47 struct event_dev *edev = dev_id; 47 struct event_dev *edev = dev_id;
48 unsigned type, code, value; 48 unsigned int type, code, value;
49 49
50 type = __raw_readl(edev->addr + REG_READ); 50 type = __raw_readl(edev->addr + REG_READ);
51 code = __raw_readl(edev->addr + REG_READ); 51 code = __raw_readl(edev->addr + REG_READ);
@@ -57,7 +57,7 @@ static irqreturn_t events_interrupt(int irq, void *dev_id)
57} 57}
58 58
59static void events_import_bits(struct event_dev *edev, 59static void events_import_bits(struct event_dev *edev,
60 unsigned long bits[], unsigned type, size_t count) 60 unsigned long bits[], unsigned int type, size_t count)
61{ 61{
62 void __iomem *addr = edev->addr; 62 void __iomem *addr = edev->addr;
63 int i, j; 63 int i, j;
@@ -99,6 +99,7 @@ static void events_import_abs_params(struct event_dev *edev)
99 99
100 for (j = 0; j < ARRAY_SIZE(val); j++) { 100 for (j = 0; j < ARRAY_SIZE(val); j++) {
101 int offset = (i * ARRAY_SIZE(val) + j) * sizeof(u32); 101 int offset = (i * ARRAY_SIZE(val) + j) * sizeof(u32);
102
102 val[j] = __raw_readl(edev->addr + REG_DATA + offset); 103 val[j] = __raw_readl(edev->addr + REG_DATA + offset);
103 } 104 }
104 105
@@ -112,7 +113,7 @@ static int events_probe(struct platform_device *pdev)
112 struct input_dev *input_dev; 113 struct input_dev *input_dev;
113 struct event_dev *edev; 114 struct event_dev *edev;
114 struct resource *res; 115 struct resource *res;
115 unsigned keymapnamelen; 116 unsigned int keymapnamelen;
116 void __iomem *addr; 117 void __iomem *addr;
117 int irq; 118 int irq;
118 int i; 119 int i;
@@ -150,7 +151,7 @@ static int events_probe(struct platform_device *pdev)
150 for (i = 0; i < keymapnamelen; i++) 151 for (i = 0; i < keymapnamelen; i++)
151 edev->name[i] = __raw_readb(edev->addr + REG_DATA + i); 152 edev->name[i] = __raw_readb(edev->addr + REG_DATA + i);
152 153
153 pr_debug("events_probe() keymap=%s\n", edev->name); 154 pr_debug("%s: keymap=%s\n", __func__, edev->name);
154 155
155 input_dev->name = edev->name; 156 input_dev->name = edev->name;
156 input_dev->id.bustype = BUS_HOST; 157 input_dev->id.bustype = BUS_HOST;
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index c25606e00693..ca59a2be9bc5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -841,4 +841,14 @@ config INPUT_RAVE_SP_PWRBUTTON
841 To compile this driver as a module, choose M here: the 841 To compile this driver as a module, choose M here: the
842 module will be called rave-sp-pwrbutton. 842 module will be called rave-sp-pwrbutton.
843 843
844config INPUT_SC27XX_VIBRA
845 tristate "Spreadtrum sc27xx vibrator support"
846 depends on MFD_SC27XX_PMIC || COMPILE_TEST
847 select INPUT_FF_MEMLESS
848 help
849 This option enables support for Spreadtrum sc27xx vibrator driver.
850
851 To compile this driver as a module, choose M here. The module will
852 be called sc27xx_vibra.
853
844endif 854endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 72cde28649e2..9d0f9d1ff68f 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o
66obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o 66obj-$(CONFIG_INPUT_AXP20X_PEK) += axp20x-pek.o
67obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o 67obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
68obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o 68obj-$(CONFIG_INPUT_RK805_PWRKEY) += rk805-pwrkey.o
69obj-$(CONFIG_INPUT_SC27XX_VIBRA) += sc27xx-vibra.o
69obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 70obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
70obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o 71obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o
71obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o 72obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o
diff --git a/drivers/input/misc/sc27xx-vibra.c b/drivers/input/misc/sc27xx-vibra.c
new file mode 100644
index 000000000000..295251abbdac
--- /dev/null
+++ b/drivers/input/misc/sc27xx-vibra.c
@@ -0,0 +1,154 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2018 Spreadtrum Communications Inc.
4 */
5
6#include <linux/module.h>
7#include <linux/of_address.h>
8#include <linux/platform_device.h>
9#include <linux/regmap.h>
10#include <linux/input.h>
11#include <linux/workqueue.h>
12
13#define CUR_DRV_CAL_SEL GENMASK(13, 12)
14#define SLP_LDOVIBR_PD_EN BIT(9)
15#define LDO_VIBR_PD BIT(8)
16
17struct vibra_info {
18 struct input_dev *input_dev;
19 struct work_struct play_work;
20 struct regmap *regmap;
21 u32 base;
22 u32 strength;
23 bool enabled;
24};
25
26static void sc27xx_vibra_set(struct vibra_info *info, bool on)
27{
28 if (on) {
29 regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD, 0);
30 regmap_update_bits(info->regmap, info->base,
31 SLP_LDOVIBR_PD_EN, 0);
32 info->enabled = true;
33 } else {
34 regmap_update_bits(info->regmap, info->base, LDO_VIBR_PD,
35 LDO_VIBR_PD);
36 regmap_update_bits(info->regmap, info->base,
37 SLP_LDOVIBR_PD_EN, SLP_LDOVIBR_PD_EN);
38 info->enabled = false;
39 }
40}
41
42static int sc27xx_vibra_hw_init(struct vibra_info *info)
43{
44 return regmap_update_bits(info->regmap, info->base, CUR_DRV_CAL_SEL, 0);
45}
46
47static void sc27xx_vibra_play_work(struct work_struct *work)
48{
49 struct vibra_info *info = container_of(work, struct vibra_info,
50 play_work);
51
52 if (info->strength && !info->enabled)
53 sc27xx_vibra_set(info, true);
54 else if (info->strength == 0 && info->enabled)
55 sc27xx_vibra_set(info, false);
56}
57
58static int sc27xx_vibra_play(struct input_dev *input, void *data,
59 struct ff_effect *effect)
60{
61 struct vibra_info *info = input_get_drvdata(input);
62
63 info->strength = effect->u.rumble.weak_magnitude;
64 schedule_work(&info->play_work);
65
66 return 0;
67}
68
69static void sc27xx_vibra_close(struct input_dev *input)
70{
71 struct vibra_info *info = input_get_drvdata(input);
72
73 cancel_work_sync(&info->play_work);
74 if (info->enabled)
75 sc27xx_vibra_set(info, false);
76}
77
78static int sc27xx_vibra_probe(struct platform_device *pdev)
79{
80 struct vibra_info *info;
81 int error;
82
83 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
84 if (!info)
85 return -ENOMEM;
86
87 info->regmap = dev_get_regmap(pdev->dev.parent, NULL);
88 if (!info->regmap) {
89 dev_err(&pdev->dev, "failed to get vibrator regmap.\n");
90 return -ENODEV;
91 }
92
93 error = device_property_read_u32(&pdev->dev, "reg", &info->base);
94 if (error) {
95 dev_err(&pdev->dev, "failed to get vibrator base address.\n");
96 return error;
97 }
98
99 info->input_dev = devm_input_allocate_device(&pdev->dev);
100 if (!info->input_dev) {
101 dev_err(&pdev->dev, "failed to allocate input device.\n");
102 return -ENOMEM;
103 }
104
105 info->input_dev->name = "sc27xx:vibrator";
106 info->input_dev->id.version = 0;
107 info->input_dev->close = sc27xx_vibra_close;
108
109 input_set_drvdata(info->input_dev, info);
110 input_set_capability(info->input_dev, EV_FF, FF_RUMBLE);
111 INIT_WORK(&info->play_work, sc27xx_vibra_play_work);
112 info->enabled = false;
113
114 error = sc27xx_vibra_hw_init(info);
115 if (error) {
116 dev_err(&pdev->dev, "failed to initialize the vibrator.\n");
117 return error;
118 }
119
120 error = input_ff_create_memless(info->input_dev, NULL,
121 sc27xx_vibra_play);
122 if (error) {
123 dev_err(&pdev->dev, "failed to register vibrator to FF.\n");
124 return error;
125 }
126
127 error = input_register_device(info->input_dev);
128 if (error) {
129 dev_err(&pdev->dev, "failed to register input device.\n");
130 return error;
131 }
132
133 return 0;
134}
135
136static const struct of_device_id sc27xx_vibra_of_match[] = {
137 { .compatible = "sprd,sc2731-vibrator", },
138 {}
139};
140MODULE_DEVICE_TABLE(of, sc27xx_vibra_of_match);
141
142static struct platform_driver sc27xx_vibra_driver = {
143 .driver = {
144 .name = "sc27xx-vibrator",
145 .of_match_table = sc27xx_vibra_of_match,
146 },
147 .probe = sc27xx_vibra_probe,
148};
149
150module_platform_driver(sc27xx_vibra_driver);
151
152MODULE_DESCRIPTION("Spreadtrum SC27xx Vibrator Driver");
153MODULE_LICENSE("GPL v2");
154MODULE_AUTHOR("Xiaotong Lu <xiaotong.lu@spreadtrum.com>");
diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 599544c1a91c..243e0fa6e3e3 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -27,6 +27,8 @@
27#define ETP_DISABLE_POWER 0x0001 27#define ETP_DISABLE_POWER 0x0001
28#define ETP_PRESSURE_OFFSET 25 28#define ETP_PRESSURE_OFFSET 25
29 29
30#define ETP_CALIBRATE_MAX_LEN 3
31
30/* IAP Firmware handling */ 32/* IAP Firmware handling */
31#define ETP_PRODUCT_ID_FORMAT_STRING "%d.0" 33#define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
32#define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin" 34#define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 8ff75114e762..1f9cd7d8b7ad 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -613,7 +613,7 @@ static ssize_t calibrate_store(struct device *dev,
613 int tries = 20; 613 int tries = 20;
614 int retval; 614 int retval;
615 int error; 615 int error;
616 u8 val[3]; 616 u8 val[ETP_CALIBRATE_MAX_LEN];
617 617
618 retval = mutex_lock_interruptible(&data->sysfs_mutex); 618 retval = mutex_lock_interruptible(&data->sysfs_mutex);
619 if (retval) 619 if (retval)
@@ -1345,6 +1345,7 @@ static const struct acpi_device_id elan_acpi_id[] = {
1345 { "ELAN060C", 0 }, 1345 { "ELAN060C", 0 },
1346 { "ELAN0611", 0 }, 1346 { "ELAN0611", 0 },
1347 { "ELAN0612", 0 }, 1347 { "ELAN0612", 0 },
1348 { "ELAN0618", 0 },
1348 { "ELAN1000", 0 }, 1349 { "ELAN1000", 0 },
1349 { } 1350 { }
1350}; 1351};
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index cfcb32559925..c060d270bc4d 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -56,7 +56,7 @@
56static int elan_smbus_initialize(struct i2c_client *client) 56static int elan_smbus_initialize(struct i2c_client *client)
57{ 57{
58 u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 }; 58 u8 check[ETP_SMBUS_HELLOPACKET_LEN] = { 0x55, 0x55, 0x55, 0x55, 0x55 };
59 u8 values[ETP_SMBUS_HELLOPACKET_LEN] = { 0, 0, 0, 0, 0 }; 59 u8 values[I2C_SMBUS_BLOCK_MAX] = {0};
60 int len, error; 60 int len, error;
61 61
62 /* Get hello packet */ 62 /* Get hello packet */
@@ -117,12 +117,16 @@ static int elan_smbus_calibrate(struct i2c_client *client)
117static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val) 117static int elan_smbus_calibrate_result(struct i2c_client *client, u8 *val)
118{ 118{
119 int error; 119 int error;
120 u8 buf[I2C_SMBUS_BLOCK_MAX] = {0};
121
122 BUILD_BUG_ON(ETP_CALIBRATE_MAX_LEN > sizeof(buf));
120 123
121 error = i2c_smbus_read_block_data(client, 124 error = i2c_smbus_read_block_data(client,
122 ETP_SMBUS_CALIBRATE_QUERY, val); 125 ETP_SMBUS_CALIBRATE_QUERY, buf);
123 if (error < 0) 126 if (error < 0)
124 return error; 127 return error;
125 128
129 memcpy(val, buf, ETP_CALIBRATE_MAX_LEN);
126 return 0; 130 return 0;
127} 131}
128 132
@@ -472,6 +476,8 @@ static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
472{ 476{
473 int len; 477 int len;
474 478
479 BUILD_BUG_ON(I2C_SMBUS_BLOCK_MAX > ETP_SMBUS_REPORT_LEN);
480
475 len = i2c_smbus_read_block_data(client, 481 len = i2c_smbus_read_block_data(client,
476 ETP_SMBUS_PACKET_QUERY, 482 ETP_SMBUS_PACKET_QUERY,
477 &report[ETP_SMBUS_REPORT_OFFSET]); 483 &report[ETP_SMBUS_REPORT_OFFSET]);
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index fb4d902c4403..dd85b16dc6f8 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -799,7 +799,7 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
799 else if (ic_version == 7 && etd->info.samples[1] == 0x2A) 799 else if (ic_version == 7 && etd->info.samples[1] == 0x2A)
800 sanity_check = ((packet[3] & 0x1c) == 0x10); 800 sanity_check = ((packet[3] & 0x1c) == 0x10);
801 else 801 else
802 sanity_check = ((packet[0] & 0x0c) == 0x04 && 802 sanity_check = ((packet[0] & 0x08) == 0x00 &&
803 (packet[3] & 0x1c) == 0x10); 803 (packet[3] & 0x1c) == 0x10);
804 804
805 if (!sanity_check) 805 if (!sanity_check)
@@ -1175,6 +1175,12 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
1175 { } 1175 { }
1176}; 1176};
1177 1177
1178static const char * const middle_button_pnp_ids[] = {
1179 "LEN2131", /* ThinkPad P52 w/ NFC */
1180 "LEN2132", /* ThinkPad P52 */
1181 NULL
1182};
1183
1178/* 1184/*
1179 * Set the appropriate event bits for the input subsystem 1185 * Set the appropriate event bits for the input subsystem
1180 */ 1186 */
@@ -1194,7 +1200,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1194 __clear_bit(EV_REL, dev->evbit); 1200 __clear_bit(EV_REL, dev->evbit);
1195 1201
1196 __set_bit(BTN_LEFT, dev->keybit); 1202 __set_bit(BTN_LEFT, dev->keybit);
1197 if (dmi_check_system(elantech_dmi_has_middle_button)) 1203 if (dmi_check_system(elantech_dmi_has_middle_button) ||
1204 psmouse_matches_pnp_id(psmouse, middle_button_pnp_ids))
1198 __set_bit(BTN_MIDDLE, dev->keybit); 1205 __set_bit(BTN_MIDDLE, dev->keybit);
1199 __set_bit(BTN_RIGHT, dev->keybit); 1206 __set_bit(BTN_RIGHT, dev->keybit);
1200 1207
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 5ff5b1952be0..d3ff1fc09af7 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -192,8 +192,8 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
192 else 192 else
193 input_report_rel(dev, REL_WHEEL, -wheel); 193 input_report_rel(dev, REL_WHEEL, -wheel);
194 194
195 input_report_key(dev, BTN_SIDE, BIT(4)); 195 input_report_key(dev, BTN_SIDE, packet[3] & BIT(4));
196 input_report_key(dev, BTN_EXTRA, BIT(5)); 196 input_report_key(dev, BTN_EXTRA, packet[3] & BIT(5));
197 break; 197 break;
198 } 198 }
199 break; 199 break;
@@ -203,13 +203,13 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
203 input_report_rel(dev, REL_WHEEL, -(s8) packet[3]); 203 input_report_rel(dev, REL_WHEEL, -(s8) packet[3]);
204 204
205 /* Extra buttons on Genius NewNet 3D */ 205 /* Extra buttons on Genius NewNet 3D */
206 input_report_key(dev, BTN_SIDE, BIT(6)); 206 input_report_key(dev, BTN_SIDE, packet[0] & BIT(6));
207 input_report_key(dev, BTN_EXTRA, BIT(7)); 207 input_report_key(dev, BTN_EXTRA, packet[0] & BIT(7));
208 break; 208 break;
209 209
210 case PSMOUSE_THINKPS: 210 case PSMOUSE_THINKPS:
211 /* Extra button on ThinkingMouse */ 211 /* Extra button on ThinkingMouse */
212 input_report_key(dev, BTN_EXTRA, BIT(3)); 212 input_report_key(dev, BTN_EXTRA, packet[0] & BIT(3));
213 213
214 /* 214 /*
215 * Without this bit of weirdness moving up gives wildly 215 * Without this bit of weirdness moving up gives wildly
@@ -223,7 +223,7 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
223 * Cortron PS2 Trackball reports SIDE button in the 223 * Cortron PS2 Trackball reports SIDE button in the
224 * 4th bit of the first byte. 224 * 4th bit of the first byte.
225 */ 225 */
226 input_report_key(dev, BTN_SIDE, BIT(3)); 226 input_report_key(dev, BTN_SIDE, packet[0] & BIT(3));
227 packet[0] |= BIT(3); 227 packet[0] |= BIT(3);
228 break; 228 break;
229 229
diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig
index 7172b88cd064..fad2eae4a118 100644
--- a/drivers/input/rmi4/Kconfig
+++ b/drivers/input/rmi4/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4config RMI4_CORE 4config RMI4_CORE
5 tristate "Synaptics RMI4 bus support" 5 tristate "Synaptics RMI4 bus support"
6 select IRQ_DOMAIN
6 help 7 help
7 Say Y here if you want to support the Synaptics RMI4 bus. This is 8 Say Y here if you want to support the Synaptics RMI4 bus. This is
8 required for all RMI4 device support. 9 required for all RMI4 device support.
diff --git a/drivers/input/rmi4/rmi_2d_sensor.c b/drivers/input/rmi4/rmi_2d_sensor.c
index 8bb866c7b985..8eeffa066022 100644
--- a/drivers/input/rmi4/rmi_2d_sensor.c
+++ b/drivers/input/rmi4/rmi_2d_sensor.c
@@ -32,15 +32,15 @@ void rmi_2d_sensor_abs_process(struct rmi_2d_sensor *sensor,
32 if (obj->type == RMI_2D_OBJECT_NONE) 32 if (obj->type == RMI_2D_OBJECT_NONE)
33 return; 33 return;
34 34
35 if (axis_align->swap_axes)
36 swap(obj->x, obj->y);
37
38 if (axis_align->flip_x) 35 if (axis_align->flip_x)
39 obj->x = sensor->max_x - obj->x; 36 obj->x = sensor->max_x - obj->x;
40 37
41 if (axis_align->flip_y) 38 if (axis_align->flip_y)
42 obj->y = sensor->max_y - obj->y; 39 obj->y = sensor->max_y - obj->y;
43 40
41 if (axis_align->swap_axes)
42 swap(obj->x, obj->y);
43
44 /* 44 /*
45 * Here checking if X offset or y offset are specified is 45 * Here checking if X offset or y offset are specified is
46 * redundant. We just add the offsets or clip the values. 46 * redundant. We just add the offsets or clip the values.
@@ -120,15 +120,15 @@ void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y)
120 x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x)); 120 x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x));
121 y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y)); 121 y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y));
122 122
123 if (axis_align->swap_axes)
124 swap(x, y);
125
126 if (axis_align->flip_x) 123 if (axis_align->flip_x)
127 x = min(RMI_2D_REL_POS_MAX, -x); 124 x = min(RMI_2D_REL_POS_MAX, -x);
128 125
129 if (axis_align->flip_y) 126 if (axis_align->flip_y)
130 y = min(RMI_2D_REL_POS_MAX, -y); 127 y = min(RMI_2D_REL_POS_MAX, -y);
131 128
129 if (axis_align->swap_axes)
130 swap(x, y);
131
132 if (x || y) { 132 if (x || y) {
133 input_report_rel(sensor->input, REL_X, x); 133 input_report_rel(sensor->input, REL_X, x);
134 input_report_rel(sensor->input, REL_Y, y); 134 input_report_rel(sensor->input, REL_Y, y);
@@ -141,17 +141,10 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
141 struct input_dev *input = sensor->input; 141 struct input_dev *input = sensor->input;
142 int res_x; 142 int res_x;
143 int res_y; 143 int res_y;
144 int max_x, max_y;
144 int input_flags = 0; 145 int input_flags = 0;
145 146
146 if (sensor->report_abs) { 147 if (sensor->report_abs) {
147 if (sensor->axis_align.swap_axes) {
148 swap(sensor->max_x, sensor->max_y);
149 swap(sensor->axis_align.clip_x_low,
150 sensor->axis_align.clip_y_low);
151 swap(sensor->axis_align.clip_x_high,
152 sensor->axis_align.clip_y_high);
153 }
154
155 sensor->min_x = sensor->axis_align.clip_x_low; 148 sensor->min_x = sensor->axis_align.clip_x_low;
156 if (sensor->axis_align.clip_x_high) 149 if (sensor->axis_align.clip_x_high)
157 sensor->max_x = min(sensor->max_x, 150 sensor->max_x = min(sensor->max_x,
@@ -163,14 +156,19 @@ static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
163 sensor->axis_align.clip_y_high); 156 sensor->axis_align.clip_y_high);
164 157
165 set_bit(EV_ABS, input->evbit); 158 set_bit(EV_ABS, input->evbit);
166 input_set_abs_params(input, ABS_MT_POSITION_X, 0, sensor->max_x, 159
167 0, 0); 160 max_x = sensor->max_x;
168 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, sensor->max_y, 161 max_y = sensor->max_y;
169 0, 0); 162 if (sensor->axis_align.swap_axes)
163 swap(max_x, max_y);
164 input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
165 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
170 166
171 if (sensor->x_mm && sensor->y_mm) { 167 if (sensor->x_mm && sensor->y_mm) {
172 res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm; 168 res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm;
173 res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm; 169 res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm;
170 if (sensor->axis_align.swap_axes)
171 swap(res_x, res_y);
174 172
175 input_abs_set_res(input, ABS_X, res_x); 173 input_abs_set_res(input, ABS_X, res_x);
176 input_abs_set_res(input, ABS_Y, res_y); 174 input_abs_set_res(input, ABS_Y, res_y);
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index c5fa53adba8d..bd0d5ff01b08 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -9,6 +9,8 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/irq.h>
13#include <linux/irqdomain.h>
12#include <linux/list.h> 14#include <linux/list.h>
13#include <linux/pm.h> 15#include <linux/pm.h>
14#include <linux/rmi.h> 16#include <linux/rmi.h>
@@ -167,6 +169,39 @@ static inline void rmi_function_of_probe(struct rmi_function *fn)
167{} 169{}
168#endif 170#endif
169 171
172static struct irq_chip rmi_irq_chip = {
173 .name = "rmi4",
174};
175
176static int rmi_create_function_irq(struct rmi_function *fn,
177 struct rmi_function_handler *handler)
178{
179 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev);
180 int i, error;
181
182 for (i = 0; i < fn->num_of_irqs; i++) {
183 set_bit(fn->irq_pos + i, fn->irq_mask);
184
185 fn->irq[i] = irq_create_mapping(drvdata->irqdomain,
186 fn->irq_pos + i);
187
188 irq_set_chip_data(fn->irq[i], fn);
189 irq_set_chip_and_handler(fn->irq[i], &rmi_irq_chip,
190 handle_simple_irq);
191 irq_set_nested_thread(fn->irq[i], 1);
192
193 error = devm_request_threaded_irq(&fn->dev, fn->irq[i], NULL,
194 handler->attention, IRQF_ONESHOT,
195 dev_name(&fn->dev), fn);
196 if (error) {
197 dev_err(&fn->dev, "Error %d registering IRQ\n", error);
198 return error;
199 }
200 }
201
202 return 0;
203}
204
170static int rmi_function_probe(struct device *dev) 205static int rmi_function_probe(struct device *dev)
171{ 206{
172 struct rmi_function *fn = to_rmi_function(dev); 207 struct rmi_function *fn = to_rmi_function(dev);
@@ -178,7 +213,14 @@ static int rmi_function_probe(struct device *dev)
178 213
179 if (handler->probe) { 214 if (handler->probe) {
180 error = handler->probe(fn); 215 error = handler->probe(fn);
181 return error; 216 if (error)
217 return error;
218 }
219
220 if (fn->num_of_irqs && handler->attention) {
221 error = rmi_create_function_irq(fn, handler);
222 if (error)
223 return error;
182 } 224 }
183 225
184 return 0; 226 return 0;
@@ -230,12 +272,18 @@ err_put_device:
230 272
231void rmi_unregister_function(struct rmi_function *fn) 273void rmi_unregister_function(struct rmi_function *fn)
232{ 274{
275 int i;
276
233 rmi_dbg(RMI_DEBUG_CORE, &fn->dev, "Unregistering F%02X.\n", 277 rmi_dbg(RMI_DEBUG_CORE, &fn->dev, "Unregistering F%02X.\n",
234 fn->fd.function_number); 278 fn->fd.function_number);
235 279
236 device_del(&fn->dev); 280 device_del(&fn->dev);
237 of_node_put(fn->dev.of_node); 281 of_node_put(fn->dev.of_node);
238 put_device(&fn->dev); 282 put_device(&fn->dev);
283
284 for (i = 0; i < fn->num_of_irqs; i++)
285 irq_dispose_mapping(fn->irq[i]);
286
239} 287}
240 288
241/** 289/**
diff --git a/drivers/input/rmi4/rmi_bus.h b/drivers/input/rmi4/rmi_bus.h
index b7625a9ac66a..96383eab41ba 100644
--- a/drivers/input/rmi4/rmi_bus.h
+++ b/drivers/input/rmi4/rmi_bus.h
@@ -14,6 +14,12 @@
14 14
15struct rmi_device; 15struct rmi_device;
16 16
17/*
18 * The interrupt source count in the function descriptor can represent up to
19 * 6 interrupt sources in the normal manner.
20 */
21#define RMI_FN_MAX_IRQS 6
22
17/** 23/**
18 * struct rmi_function - represents the implementation of an RMI4 24 * struct rmi_function - represents the implementation of an RMI4
19 * function for a particular device (basically, a driver for that RMI4 function) 25 * function for a particular device (basically, a driver for that RMI4 function)
@@ -26,6 +32,7 @@ struct rmi_device;
26 * @irq_pos: The position in the irq bitfield this function holds 32 * @irq_pos: The position in the irq bitfield this function holds
27 * @irq_mask: For convenience, can be used to mask IRQ bits off during ATTN 33 * @irq_mask: For convenience, can be used to mask IRQ bits off during ATTN
28 * interrupt handling. 34 * interrupt handling.
35 * @irqs: assigned virq numbers (up to num_of_irqs)
29 * 36 *
30 * @node: entry in device's list of functions 37 * @node: entry in device's list of functions
31 */ 38 */
@@ -36,6 +43,7 @@ struct rmi_function {
36 struct list_head node; 43 struct list_head node;
37 44
38 unsigned int num_of_irqs; 45 unsigned int num_of_irqs;
46 int irq[RMI_FN_MAX_IRQS];
39 unsigned int irq_pos; 47 unsigned int irq_pos;
40 unsigned long irq_mask[]; 48 unsigned long irq_mask[];
41}; 49};
@@ -76,7 +84,7 @@ struct rmi_function_handler {
76 void (*remove)(struct rmi_function *fn); 84 void (*remove)(struct rmi_function *fn);
77 int (*config)(struct rmi_function *fn); 85 int (*config)(struct rmi_function *fn);
78 int (*reset)(struct rmi_function *fn); 86 int (*reset)(struct rmi_function *fn);
79 int (*attention)(struct rmi_function *fn, unsigned long *irq_bits); 87 irqreturn_t (*attention)(int irq, void *ctx);
80 int (*suspend)(struct rmi_function *fn); 88 int (*suspend)(struct rmi_function *fn);
81 int (*resume)(struct rmi_function *fn); 89 int (*resume)(struct rmi_function *fn);
82}; 90};
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 7d29053dfb0f..fc3ab93b7aea 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -21,6 +21,7 @@
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/irqdomain.h>
24#include <uapi/linux/input.h> 25#include <uapi/linux/input.h>
25#include <linux/rmi.h> 26#include <linux/rmi.h>
26#include "rmi_bus.h" 27#include "rmi_bus.h"
@@ -127,28 +128,11 @@ static int rmi_driver_process_config_requests(struct rmi_device *rmi_dev)
127 return 0; 128 return 0;
128} 129}
129 130
130static void process_one_interrupt(struct rmi_driver_data *data,
131 struct rmi_function *fn)
132{
133 struct rmi_function_handler *fh;
134
135 if (!fn || !fn->dev.driver)
136 return;
137
138 fh = to_rmi_function_handler(fn->dev.driver);
139 if (fh->attention) {
140 bitmap_and(data->fn_irq_bits, data->irq_status, fn->irq_mask,
141 data->irq_count);
142 if (!bitmap_empty(data->fn_irq_bits, data->irq_count))
143 fh->attention(fn, data->fn_irq_bits);
144 }
145}
146
147static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev) 131static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
148{ 132{
149 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev); 133 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
150 struct device *dev = &rmi_dev->dev; 134 struct device *dev = &rmi_dev->dev;
151 struct rmi_function *entry; 135 int i;
152 int error; 136 int error;
153 137
154 if (!data) 138 if (!data)
@@ -173,16 +157,8 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
173 */ 157 */
174 mutex_unlock(&data->irq_mutex); 158 mutex_unlock(&data->irq_mutex);
175 159
176 /* 160 for_each_set_bit(i, data->irq_status, data->irq_count)
177 * It would be nice to be able to use irq_chip to handle these 161 handle_nested_irq(irq_find_mapping(data->irqdomain, i));
178 * nested IRQs. Unfortunately, most of the current customers for
179 * this driver are using older kernels (3.0.x) that don't support
180 * the features required for that. Once they've shifted to more
181 * recent kernels (say, 3.3 and higher), this should be switched to
182 * use irq_chip.
183 */
184 list_for_each_entry(entry, &data->function_list, node)
185 process_one_interrupt(data, entry);
186 162
187 if (data->input) 163 if (data->input)
188 input_sync(data->input); 164 input_sync(data->input);
@@ -1001,9 +977,13 @@ EXPORT_SYMBOL_GPL(rmi_driver_resume);
1001static int rmi_driver_remove(struct device *dev) 977static int rmi_driver_remove(struct device *dev)
1002{ 978{
1003 struct rmi_device *rmi_dev = to_rmi_device(dev); 979 struct rmi_device *rmi_dev = to_rmi_device(dev);
980 struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
1004 981
1005 rmi_disable_irq(rmi_dev, false); 982 rmi_disable_irq(rmi_dev, false);
1006 983
984 irq_domain_remove(data->irqdomain);
985 data->irqdomain = NULL;
986
1007 rmi_f34_remove_sysfs(rmi_dev); 987 rmi_f34_remove_sysfs(rmi_dev);
1008 rmi_free_function_list(rmi_dev); 988 rmi_free_function_list(rmi_dev);
1009 989
@@ -1035,7 +1015,8 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1035{ 1015{
1036 struct rmi_device *rmi_dev = data->rmi_dev; 1016 struct rmi_device *rmi_dev = data->rmi_dev;
1037 struct device *dev = &rmi_dev->dev; 1017 struct device *dev = &rmi_dev->dev;
1038 int irq_count; 1018 struct fwnode_handle *fwnode = rmi_dev->xport->dev->fwnode;
1019 int irq_count = 0;
1039 size_t size; 1020 size_t size;
1040 int retval; 1021 int retval;
1041 1022
@@ -1046,7 +1027,6 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1046 * being accessed. 1027 * being accessed.
1047 */ 1028 */
1048 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Counting IRQs.\n", __func__); 1029 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Counting IRQs.\n", __func__);
1049 irq_count = 0;
1050 data->bootloader_mode = false; 1030 data->bootloader_mode = false;
1051 1031
1052 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_count_irqs); 1032 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_count_irqs);
@@ -1058,6 +1038,15 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1058 if (data->bootloader_mode) 1038 if (data->bootloader_mode)
1059 dev_warn(dev, "Device in bootloader mode.\n"); 1039 dev_warn(dev, "Device in bootloader mode.\n");
1060 1040
1041 /* Allocate and register a linear revmap irq_domain */
1042 data->irqdomain = irq_domain_create_linear(fwnode, irq_count,
1043 &irq_domain_simple_ops,
1044 data);
1045 if (!data->irqdomain) {
1046 dev_err(&rmi_dev->dev, "Failed to create IRQ domain\n");
1047 return -ENOMEM;
1048 }
1049
1061 data->irq_count = irq_count; 1050 data->irq_count = irq_count;
1062 data->num_of_irq_regs = (data->irq_count + 7) / 8; 1051 data->num_of_irq_regs = (data->irq_count + 7) / 8;
1063 1052
@@ -1080,10 +1069,9 @@ int rmi_init_functions(struct rmi_driver_data *data)
1080{ 1069{
1081 struct rmi_device *rmi_dev = data->rmi_dev; 1070 struct rmi_device *rmi_dev = data->rmi_dev;
1082 struct device *dev = &rmi_dev->dev; 1071 struct device *dev = &rmi_dev->dev;
1083 int irq_count; 1072 int irq_count = 0;
1084 int retval; 1073 int retval;
1085 1074
1086 irq_count = 0;
1087 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Creating functions.\n", __func__); 1075 rmi_dbg(RMI_DEBUG_CORE, dev, "%s: Creating functions.\n", __func__);
1088 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function); 1076 retval = rmi_scan_pdt(rmi_dev, &irq_count, rmi_create_function);
1089 if (retval < 0) { 1077 if (retval < 0) {
diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index 8a07ae147df6..4edaa14fe878 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -681,9 +681,9 @@ static int rmi_f01_resume(struct rmi_function *fn)
681 return 0; 681 return 0;
682} 682}
683 683
684static int rmi_f01_attention(struct rmi_function *fn, 684static irqreturn_t rmi_f01_attention(int irq, void *ctx)
685 unsigned long *irq_bits)
686{ 685{
686 struct rmi_function *fn = ctx;
687 struct rmi_device *rmi_dev = fn->rmi_dev; 687 struct rmi_device *rmi_dev = fn->rmi_dev;
688 int error; 688 int error;
689 u8 device_status; 689 u8 device_status;
@@ -692,7 +692,7 @@ static int rmi_f01_attention(struct rmi_function *fn,
692 if (error) { 692 if (error) {
693 dev_err(&fn->dev, 693 dev_err(&fn->dev,
694 "Failed to read device status: %d.\n", error); 694 "Failed to read device status: %d.\n", error);
695 return error; 695 return IRQ_RETVAL(error);
696 } 696 }
697 697
698 if (RMI_F01_STATUS_BOOTLOADER(device_status)) 698 if (RMI_F01_STATUS_BOOTLOADER(device_status))
@@ -704,11 +704,11 @@ static int rmi_f01_attention(struct rmi_function *fn,
704 error = rmi_dev->driver->reset_handler(rmi_dev); 704 error = rmi_dev->driver->reset_handler(rmi_dev);
705 if (error) { 705 if (error) {
706 dev_err(&fn->dev, "Device reset failed: %d\n", error); 706 dev_err(&fn->dev, "Device reset failed: %d\n", error);
707 return error; 707 return IRQ_RETVAL(error);
708 } 708 }
709 } 709 }
710 710
711 return 0; 711 return IRQ_HANDLED;
712} 712}
713 713
714struct rmi_function_handler rmi_f01_handler = { 714struct rmi_function_handler rmi_f01_handler = {
diff --git a/drivers/input/rmi4/rmi_f03.c b/drivers/input/rmi4/rmi_f03.c
index 88822196d6b7..aaa1edc95522 100644
--- a/drivers/input/rmi4/rmi_f03.c
+++ b/drivers/input/rmi4/rmi_f03.c
@@ -244,8 +244,9 @@ static int rmi_f03_config(struct rmi_function *fn)
244 return 0; 244 return 0;
245} 245}
246 246
247static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits) 247static irqreturn_t rmi_f03_attention(int irq, void *ctx)
248{ 248{
249 struct rmi_function *fn = ctx;
249 struct rmi_device *rmi_dev = fn->rmi_dev; 250 struct rmi_device *rmi_dev = fn->rmi_dev;
250 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 251 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
251 struct f03_data *f03 = dev_get_drvdata(&fn->dev); 252 struct f03_data *f03 = dev_get_drvdata(&fn->dev);
@@ -262,7 +263,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
262 /* First grab the data passed by the transport device */ 263 /* First grab the data passed by the transport device */
263 if (drvdata->attn_data.size < ob_len) { 264 if (drvdata->attn_data.size < ob_len) {
264 dev_warn(&fn->dev, "F03 interrupted, but data is missing!\n"); 265 dev_warn(&fn->dev, "F03 interrupted, but data is missing!\n");
265 return 0; 266 return IRQ_HANDLED;
266 } 267 }
267 268
268 memcpy(obs, drvdata->attn_data.data, ob_len); 269 memcpy(obs, drvdata->attn_data.data, ob_len);
@@ -277,7 +278,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
277 "%s: Failed to read F03 output buffers: %d\n", 278 "%s: Failed to read F03 output buffers: %d\n",
278 __func__, error); 279 __func__, error);
279 serio_interrupt(f03->serio, 0, SERIO_TIMEOUT); 280 serio_interrupt(f03->serio, 0, SERIO_TIMEOUT);
280 return error; 281 return IRQ_RETVAL(error);
281 } 282 }
282 } 283 }
283 284
@@ -303,7 +304,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits)
303 serio_interrupt(f03->serio, ob_data, serio_flags); 304 serio_interrupt(f03->serio, ob_data, serio_flags);
304 } 305 }
305 306
306 return 0; 307 return IRQ_HANDLED;
307} 308}
308 309
309static void rmi_f03_remove(struct rmi_function *fn) 310static void rmi_f03_remove(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 12a233251793..df64d6aed4f7 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -570,9 +570,7 @@ static inline u8 rmi_f11_parse_finger_state(const u8 *f_state, u8 n_finger)
570} 570}
571 571
572static void rmi_f11_finger_handler(struct f11_data *f11, 572static void rmi_f11_finger_handler(struct f11_data *f11,
573 struct rmi_2d_sensor *sensor, 573 struct rmi_2d_sensor *sensor, int size)
574 unsigned long *irq_bits, int num_irq_regs,
575 int size)
576{ 574{
577 const u8 *f_state = f11->data.f_state; 575 const u8 *f_state = f11->data.f_state;
578 u8 finger_state; 576 u8 finger_state;
@@ -581,12 +579,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
581 int rel_fingers; 579 int rel_fingers;
582 int abs_size = sensor->nbr_fingers * RMI_F11_ABS_BYTES; 580 int abs_size = sensor->nbr_fingers * RMI_F11_ABS_BYTES;
583 581
584 int abs_bits = bitmap_and(f11->result_bits, irq_bits, f11->abs_mask, 582 if (sensor->report_abs) {
585 num_irq_regs * 8);
586 int rel_bits = bitmap_and(f11->result_bits, irq_bits, f11->rel_mask,
587 num_irq_regs * 8);
588
589 if (abs_bits) {
590 if (abs_size > size) 583 if (abs_size > size)
591 abs_fingers = size / RMI_F11_ABS_BYTES; 584 abs_fingers = size / RMI_F11_ABS_BYTES;
592 else 585 else
@@ -604,19 +597,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
604 rmi_f11_abs_pos_process(f11, sensor, &sensor->objs[i], 597 rmi_f11_abs_pos_process(f11, sensor, &sensor->objs[i],
605 finger_state, i); 598 finger_state, i);
606 } 599 }
607 }
608 600
609 if (rel_bits) {
610 if ((abs_size + sensor->nbr_fingers * RMI_F11_REL_BYTES) > size)
611 rel_fingers = (size - abs_size) / RMI_F11_REL_BYTES;
612 else
613 rel_fingers = sensor->nbr_fingers;
614
615 for (i = 0; i < rel_fingers; i++)
616 rmi_f11_rel_pos_report(f11, i);
617 }
618
619 if (abs_bits) {
620 /* 601 /*
621 * the absolute part is made in 2 parts to allow the kernel 602 * the absolute part is made in 2 parts to allow the kernel
622 * tracking to take place. 603 * tracking to take place.
@@ -638,7 +619,16 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
638 } 619 }
639 620
640 input_mt_sync_frame(sensor->input); 621 input_mt_sync_frame(sensor->input);
622 } else if (sensor->report_rel) {
623 if ((abs_size + sensor->nbr_fingers * RMI_F11_REL_BYTES) > size)
624 rel_fingers = (size - abs_size) / RMI_F11_REL_BYTES;
625 else
626 rel_fingers = sensor->nbr_fingers;
627
628 for (i = 0; i < rel_fingers; i++)
629 rmi_f11_rel_pos_report(f11, i);
641 } 630 }
631
642} 632}
643 633
644static int f11_2d_construct_data(struct f11_data *f11) 634static int f11_2d_construct_data(struct f11_data *f11)
@@ -1276,8 +1266,9 @@ static int rmi_f11_config(struct rmi_function *fn)
1276 return 0; 1266 return 0;
1277} 1267}
1278 1268
1279static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits) 1269static irqreturn_t rmi_f11_attention(int irq, void *ctx)
1280{ 1270{
1271 struct rmi_function *fn = ctx;
1281 struct rmi_device *rmi_dev = fn->rmi_dev; 1272 struct rmi_device *rmi_dev = fn->rmi_dev;
1282 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 1273 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
1283 struct f11_data *f11 = dev_get_drvdata(&fn->dev); 1274 struct f11_data *f11 = dev_get_drvdata(&fn->dev);
@@ -1303,13 +1294,12 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
1303 data_base_addr, f11->sensor.data_pkt, 1294 data_base_addr, f11->sensor.data_pkt,
1304 f11->sensor.pkt_size); 1295 f11->sensor.pkt_size);
1305 if (error < 0) 1296 if (error < 0)
1306 return error; 1297 return IRQ_RETVAL(error);
1307 } 1298 }
1308 1299
1309 rmi_f11_finger_handler(f11, &f11->sensor, irq_bits, 1300 rmi_f11_finger_handler(f11, &f11->sensor, valid_bytes);
1310 drvdata->num_of_irq_regs, valid_bytes);
1311 1301
1312 return 0; 1302 return IRQ_HANDLED;
1313} 1303}
1314 1304
1315static int rmi_f11_resume(struct rmi_function *fn) 1305static int rmi_f11_resume(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c
index a3d1aa88f2a9..5c7f48915779 100644
--- a/drivers/input/rmi4/rmi_f12.c
+++ b/drivers/input/rmi4/rmi_f12.c
@@ -197,10 +197,10 @@ static void rmi_f12_process_objects(struct f12_data *f12, u8 *data1, int size)
197 rmi_2d_sensor_abs_report(sensor, &sensor->objs[i], i); 197 rmi_2d_sensor_abs_report(sensor, &sensor->objs[i], i);
198} 198}
199 199
200static int rmi_f12_attention(struct rmi_function *fn, 200static irqreturn_t rmi_f12_attention(int irq, void *ctx)
201 unsigned long *irq_nr_regs)
202{ 201{
203 int retval; 202 int retval;
203 struct rmi_function *fn = ctx;
204 struct rmi_device *rmi_dev = fn->rmi_dev; 204 struct rmi_device *rmi_dev = fn->rmi_dev;
205 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); 205 struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
206 struct f12_data *f12 = dev_get_drvdata(&fn->dev); 206 struct f12_data *f12 = dev_get_drvdata(&fn->dev);
@@ -222,7 +222,7 @@ static int rmi_f12_attention(struct rmi_function *fn,
222 if (retval < 0) { 222 if (retval < 0) {
223 dev_err(&fn->dev, "Failed to read object data. Code: %d.\n", 223 dev_err(&fn->dev, "Failed to read object data. Code: %d.\n",
224 retval); 224 retval);
225 return retval; 225 return IRQ_RETVAL(retval);
226 } 226 }
227 } 227 }
228 228
@@ -232,7 +232,7 @@ static int rmi_f12_attention(struct rmi_function *fn,
232 232
233 input_mt_sync_frame(sensor->input); 233 input_mt_sync_frame(sensor->input);
234 234
235 return 0; 235 return IRQ_HANDLED;
236} 236}
237 237
238static int rmi_f12_write_control_regs(struct rmi_function *fn) 238static int rmi_f12_write_control_regs(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f30.c b/drivers/input/rmi4/rmi_f30.c
index 82e0f0d43d55..5e3ed5ac0c3e 100644
--- a/drivers/input/rmi4/rmi_f30.c
+++ b/drivers/input/rmi4/rmi_f30.c
@@ -122,8 +122,9 @@ static void rmi_f30_report_button(struct rmi_function *fn,
122 } 122 }
123} 123}
124 124
125static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits) 125static irqreturn_t rmi_f30_attention(int irq, void *ctx)
126{ 126{
127 struct rmi_function *fn = ctx;
127 struct f30_data *f30 = dev_get_drvdata(&fn->dev); 128 struct f30_data *f30 = dev_get_drvdata(&fn->dev);
128 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); 129 struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev);
129 int error; 130 int error;
@@ -134,7 +135,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
134 if (drvdata->attn_data.size < f30->register_count) { 135 if (drvdata->attn_data.size < f30->register_count) {
135 dev_warn(&fn->dev, 136 dev_warn(&fn->dev,
136 "F30 interrupted, but data is missing\n"); 137 "F30 interrupted, but data is missing\n");
137 return 0; 138 return IRQ_HANDLED;
138 } 139 }
139 memcpy(f30->data_regs, drvdata->attn_data.data, 140 memcpy(f30->data_regs, drvdata->attn_data.data,
140 f30->register_count); 141 f30->register_count);
@@ -147,7 +148,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
147 dev_err(&fn->dev, 148 dev_err(&fn->dev,
148 "%s: Failed to read F30 data registers: %d\n", 149 "%s: Failed to read F30 data registers: %d\n",
149 __func__, error); 150 __func__, error);
150 return error; 151 return IRQ_RETVAL(error);
151 } 152 }
152 } 153 }
153 154
@@ -159,7 +160,7 @@ static int rmi_f30_attention(struct rmi_function *fn, unsigned long *irq_bits)
159 rmi_f03_commit_buttons(f30->f03); 160 rmi_f03_commit_buttons(f30->f03);
160 } 161 }
161 162
162 return 0; 163 return IRQ_HANDLED;
163} 164}
164 165
165static int rmi_f30_config(struct rmi_function *fn) 166static int rmi_f30_config(struct rmi_function *fn)
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index f1f5ac539d5d..87a7d4ba382d 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -100,8 +100,9 @@ static int rmi_f34_command(struct f34_data *f34, u8 command,
100 return 0; 100 return 0;
101} 101}
102 102
103static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits) 103static irqreturn_t rmi_f34_attention(int irq, void *ctx)
104{ 104{
105 struct rmi_function *fn = ctx;
105 struct f34_data *f34 = dev_get_drvdata(&fn->dev); 106 struct f34_data *f34 = dev_get_drvdata(&fn->dev);
106 int ret; 107 int ret;
107 u8 status; 108 u8 status;
@@ -126,7 +127,7 @@ static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits)
126 complete(&f34->v7.cmd_done); 127 complete(&f34->v7.cmd_done);
127 } 128 }
128 129
129 return 0; 130 return IRQ_HANDLED;
130} 131}
131 132
132static int rmi_f34_write_blocks(struct f34_data *f34, const void *data, 133static int rmi_f34_write_blocks(struct f34_data *f34, const void *data,
diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c
index e8a59d164019..a6f515bcab22 100644
--- a/drivers/input/rmi4/rmi_f54.c
+++ b/drivers/input/rmi4/rmi_f54.c
@@ -610,11 +610,6 @@ error:
610 mutex_unlock(&f54->data_mutex); 610 mutex_unlock(&f54->data_mutex);
611} 611}
612 612
613static int rmi_f54_attention(struct rmi_function *fn, unsigned long *irqbits)
614{
615 return 0;
616}
617
618static int rmi_f54_config(struct rmi_function *fn) 613static int rmi_f54_config(struct rmi_function *fn)
619{ 614{
620 struct rmi_driver *drv = fn->rmi_dev->driver; 615 struct rmi_driver *drv = fn->rmi_dev->driver;
@@ -756,6 +751,5 @@ struct rmi_function_handler rmi_f54_handler = {
756 .func = 0x54, 751 .func = 0x54,
757 .probe = rmi_f54_probe, 752 .probe = rmi_f54_probe,
758 .config = rmi_f54_config, 753 .config = rmi_f54_config,
759 .attention = rmi_f54_attention,
760 .remove = rmi_f54_remove, 754 .remove = rmi_f54_remove,
761}; 755};
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index ff7043f74a3d..d196ac3d8b8c 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -603,6 +603,7 @@ static const struct acpi_device_id silead_ts_acpi_match[] = {
603 { "GSL3692", 0 }, 603 { "GSL3692", 0 },
604 { "MSSL1680", 0 }, 604 { "MSSL1680", 0 },
605 { "MSSL0001", 0 }, 605 { "MSSL0001", 0 },
606 { "MSSL0002", 0 },
606 { } 607 { }
607}; 608};
608MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match); 609MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match);
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 0f52d44b3f69..f5fe0100f9ff 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -199,7 +199,7 @@ static int gicv2m_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
199 199
200fail: 200fail:
201 irq_domain_free_irqs_parent(domain, virq, nr_irqs); 201 irq_domain_free_irqs_parent(domain, virq, nr_irqs);
202 gicv2m_unalloc_msi(v2m, hwirq, get_count_order(nr_irqs)); 202 gicv2m_unalloc_msi(v2m, hwirq, nr_irqs);
203 return err; 203 return err;
204} 204}
205 205
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 5377d7e2afba..d7842d312d3e 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -182,6 +182,22 @@ static struct its_collection *dev_event_to_col(struct its_device *its_dev,
182 return its->collections + its_dev->event_map.col_map[event]; 182 return its->collections + its_dev->event_map.col_map[event];
183} 183}
184 184
185static struct its_collection *valid_col(struct its_collection *col)
186{
187 if (WARN_ON_ONCE(col->target_address & GENMASK_ULL(0, 15)))
188 return NULL;
189
190 return col;
191}
192
193static struct its_vpe *valid_vpe(struct its_node *its, struct its_vpe *vpe)
194{
195 if (valid_col(its->collections + vpe->col_idx))
196 return vpe;
197
198 return NULL;
199}
200
185/* 201/*
186 * ITS command descriptors - parameters to be encoded in a command 202 * ITS command descriptors - parameters to be encoded in a command
187 * block. 203 * block.
@@ -439,7 +455,7 @@ static struct its_collection *its_build_mapti_cmd(struct its_node *its,
439 455
440 its_fixup_cmd(cmd); 456 its_fixup_cmd(cmd);
441 457
442 return col; 458 return valid_col(col);
443} 459}
444 460
445static struct its_collection *its_build_movi_cmd(struct its_node *its, 461static struct its_collection *its_build_movi_cmd(struct its_node *its,
@@ -458,7 +474,7 @@ static struct its_collection *its_build_movi_cmd(struct its_node *its,
458 474
459 its_fixup_cmd(cmd); 475 its_fixup_cmd(cmd);
460 476
461 return col; 477 return valid_col(col);
462} 478}
463 479
464static struct its_collection *its_build_discard_cmd(struct its_node *its, 480static struct its_collection *its_build_discard_cmd(struct its_node *its,
@@ -476,7 +492,7 @@ static struct its_collection *its_build_discard_cmd(struct its_node *its,
476 492
477 its_fixup_cmd(cmd); 493 its_fixup_cmd(cmd);
478 494
479 return col; 495 return valid_col(col);
480} 496}
481 497
482static struct its_collection *its_build_inv_cmd(struct its_node *its, 498static struct its_collection *its_build_inv_cmd(struct its_node *its,
@@ -494,7 +510,7 @@ static struct its_collection *its_build_inv_cmd(struct its_node *its,
494 510
495 its_fixup_cmd(cmd); 511 its_fixup_cmd(cmd);
496 512
497 return col; 513 return valid_col(col);
498} 514}
499 515
500static struct its_collection *its_build_int_cmd(struct its_node *its, 516static struct its_collection *its_build_int_cmd(struct its_node *its,
@@ -512,7 +528,7 @@ static struct its_collection *its_build_int_cmd(struct its_node *its,
512 528
513 its_fixup_cmd(cmd); 529 its_fixup_cmd(cmd);
514 530
515 return col; 531 return valid_col(col);
516} 532}
517 533
518static struct its_collection *its_build_clear_cmd(struct its_node *its, 534static struct its_collection *its_build_clear_cmd(struct its_node *its,
@@ -530,7 +546,7 @@ static struct its_collection *its_build_clear_cmd(struct its_node *its,
530 546
531 its_fixup_cmd(cmd); 547 its_fixup_cmd(cmd);
532 548
533 return col; 549 return valid_col(col);
534} 550}
535 551
536static struct its_collection *its_build_invall_cmd(struct its_node *its, 552static struct its_collection *its_build_invall_cmd(struct its_node *its,
@@ -554,7 +570,7 @@ static struct its_vpe *its_build_vinvall_cmd(struct its_node *its,
554 570
555 its_fixup_cmd(cmd); 571 its_fixup_cmd(cmd);
556 572
557 return desc->its_vinvall_cmd.vpe; 573 return valid_vpe(its, desc->its_vinvall_cmd.vpe);
558} 574}
559 575
560static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, 576static struct its_vpe *its_build_vmapp_cmd(struct its_node *its,
@@ -576,7 +592,7 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its,
576 592
577 its_fixup_cmd(cmd); 593 its_fixup_cmd(cmd);
578 594
579 return desc->its_vmapp_cmd.vpe; 595 return valid_vpe(its, desc->its_vmapp_cmd.vpe);
580} 596}
581 597
582static struct its_vpe *its_build_vmapti_cmd(struct its_node *its, 598static struct its_vpe *its_build_vmapti_cmd(struct its_node *its,
@@ -599,7 +615,7 @@ static struct its_vpe *its_build_vmapti_cmd(struct its_node *its,
599 615
600 its_fixup_cmd(cmd); 616 its_fixup_cmd(cmd);
601 617
602 return desc->its_vmapti_cmd.vpe; 618 return valid_vpe(its, desc->its_vmapti_cmd.vpe);
603} 619}
604 620
605static struct its_vpe *its_build_vmovi_cmd(struct its_node *its, 621static struct its_vpe *its_build_vmovi_cmd(struct its_node *its,
@@ -622,7 +638,7 @@ static struct its_vpe *its_build_vmovi_cmd(struct its_node *its,
622 638
623 its_fixup_cmd(cmd); 639 its_fixup_cmd(cmd);
624 640
625 return desc->its_vmovi_cmd.vpe; 641 return valid_vpe(its, desc->its_vmovi_cmd.vpe);
626} 642}
627 643
628static struct its_vpe *its_build_vmovp_cmd(struct its_node *its, 644static struct its_vpe *its_build_vmovp_cmd(struct its_node *its,
@@ -640,7 +656,7 @@ static struct its_vpe *its_build_vmovp_cmd(struct its_node *its,
640 656
641 its_fixup_cmd(cmd); 657 its_fixup_cmd(cmd);
642 658
643 return desc->its_vmovp_cmd.vpe; 659 return valid_vpe(its, desc->its_vmovp_cmd.vpe);
644} 660}
645 661
646static u64 its_cmd_ptr_to_offset(struct its_node *its, 662static u64 its_cmd_ptr_to_offset(struct its_node *its,
@@ -1824,11 +1840,16 @@ static int its_alloc_tables(struct its_node *its)
1824 1840
1825static int its_alloc_collections(struct its_node *its) 1841static int its_alloc_collections(struct its_node *its)
1826{ 1842{
1843 int i;
1844
1827 its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections), 1845 its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections),
1828 GFP_KERNEL); 1846 GFP_KERNEL);
1829 if (!its->collections) 1847 if (!its->collections)
1830 return -ENOMEM; 1848 return -ENOMEM;
1831 1849
1850 for (i = 0; i < nr_cpu_ids; i++)
1851 its->collections[i].target_address = ~0ULL;
1852
1832 return 0; 1853 return 0;
1833} 1854}
1834 1855
@@ -2310,7 +2331,14 @@ static int its_irq_domain_activate(struct irq_domain *domain,
2310 cpu_mask = cpumask_of_node(its_dev->its->numa_node); 2331 cpu_mask = cpumask_of_node(its_dev->its->numa_node);
2311 2332
2312 /* Bind the LPI to the first possible CPU */ 2333 /* Bind the LPI to the first possible CPU */
2313 cpu = cpumask_first(cpu_mask); 2334 cpu = cpumask_first_and(cpu_mask, cpu_online_mask);
2335 if (cpu >= nr_cpu_ids) {
2336 if (its_dev->its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144)
2337 return -EINVAL;
2338
2339 cpu = cpumask_first(cpu_online_mask);
2340 }
2341
2314 its_dev->event_map.col_map[event] = cpu; 2342 its_dev->event_map.col_map[event] = cpu;
2315 irq_data_update_effective_affinity(d, cpumask_of(cpu)); 2343 irq_data_update_effective_affinity(d, cpumask_of(cpu));
2316 2344
@@ -3399,6 +3427,16 @@ static int redist_disable_lpis(void)
3399 u64 timeout = USEC_PER_SEC; 3427 u64 timeout = USEC_PER_SEC;
3400 u64 val; 3428 u64 val;
3401 3429
3430 /*
3431 * If coming via a CPU hotplug event, we don't need to disable
3432 * LPIs before trying to re-enable them. They are already
3433 * configured and all is well in the world. Detect this case
3434 * by checking the allocation of the pending table for the
3435 * current CPU.
3436 */
3437 if (gic_data_rdist()->pend_page)
3438 return 0;
3439
3402 if (!gic_rdists_supports_plpis()) { 3440 if (!gic_rdists_supports_plpis()) {
3403 pr_info("CPU%d: LPIs not supported\n", smp_processor_id()); 3441 pr_info("CPU%d: LPIs not supported\n", smp_processor_id());
3404 return -ENXIO; 3442 return -ENXIO;
diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c
index 1ec3bfe56693..c671b3212010 100644
--- a/drivers/irqchip/irq-ls-scfg-msi.c
+++ b/drivers/irqchip/irq-ls-scfg-msi.c
@@ -93,8 +93,12 @@ static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
93 msg->address_lo = lower_32_bits(msi_data->msiir_addr); 93 msg->address_lo = lower_32_bits(msi_data->msiir_addr);
94 msg->data = data->hwirq; 94 msg->data = data->hwirq;
95 95
96 if (msi_affinity_flag) 96 if (msi_affinity_flag) {
97 msg->data |= cpumask_first(data->common->affinity); 97 const struct cpumask *mask;
98
99 mask = irq_data_get_effective_affinity_mask(data);
100 msg->data |= cpumask_first(mask);
101 }
98 102
99 iommu_dma_map_msi_msg(data->irq, msg); 103 iommu_dma_map_msi_msg(data->irq, msg);
100} 104}
@@ -121,7 +125,7 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,
121 return -EINVAL; 125 return -EINVAL;
122 } 126 }
123 127
124 cpumask_copy(irq_data->common->affinity, mask); 128 irq_data_update_effective_affinity(irq_data, cpumask_of(cpu));
125 129
126 return IRQ_SET_MASK_OK; 130 return IRQ_SET_MASK_OK;
127} 131}
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 98f90aadd141..18c0a1281914 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -588,7 +588,7 @@ static const struct proto_ops data_sock_ops = {
588 .getname = data_sock_getname, 588 .getname = data_sock_getname,
589 .sendmsg = mISDN_sock_sendmsg, 589 .sendmsg = mISDN_sock_sendmsg,
590 .recvmsg = mISDN_sock_recvmsg, 590 .recvmsg = mISDN_sock_recvmsg,
591 .poll_mask = datagram_poll_mask, 591 .poll = datagram_poll,
592 .listen = sock_no_listen, 592 .listen = sock_no_listen,
593 .shutdown = sock_no_shutdown, 593 .shutdown = sock_no_shutdown,
594 .setsockopt = data_sock_setsockopt, 594 .setsockopt = data_sock_setsockopt,
diff --git a/drivers/lightnvm/Kconfig b/drivers/lightnvm/Kconfig
index 10c08982185a..9c03f35d9df1 100644
--- a/drivers/lightnvm/Kconfig
+++ b/drivers/lightnvm/Kconfig
@@ -4,7 +4,7 @@
4 4
5menuconfig NVM 5menuconfig NVM
6 bool "Open-Channel SSD target support" 6 bool "Open-Channel SSD target support"
7 depends on BLOCK && HAS_DMA && PCI 7 depends on BLOCK && PCI
8 select BLK_DEV_NVME 8 select BLK_DEV_NVME
9 help 9 help
10 Say Y here to get to enable Open-channel SSDs. 10 Say Y here to get to enable Open-channel SSDs.
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index ab13fcec3fca..75df4c9d8b54 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -588,7 +588,7 @@ static const char *raid10_md_layout_to_format(int layout)
588} 588}
589 589
590/* Return md raid10 algorithm for @name */ 590/* Return md raid10 algorithm for @name */
591static const int raid10_name_to_format(const char *name) 591static int raid10_name_to_format(const char *name)
592{ 592{
593 if (!strcasecmp(name, "near")) 593 if (!strcasecmp(name, "near"))
594 return ALGORITHM_RAID10_NEAR; 594 return ALGORITHM_RAID10_NEAR;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 938766794c2e..3d0e2c198f06 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -885,9 +885,7 @@ EXPORT_SYMBOL_GPL(dm_table_set_type);
885static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, 885static int device_supports_dax(struct dm_target *ti, struct dm_dev *dev,
886 sector_t start, sector_t len, void *data) 886 sector_t start, sector_t len, void *data)
887{ 887{
888 struct request_queue *q = bdev_get_queue(dev->bdev); 888 return bdev_dax_supported(dev->bdev, PAGE_SIZE);
889
890 return q && blk_queue_dax(q);
891} 889}
892 890
893static bool dm_table_supports_dax(struct dm_table *t) 891static bool dm_table_supports_dax(struct dm_table *t)
@@ -1907,6 +1905,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
1907 1905
1908 if (dm_table_supports_dax(t)) 1906 if (dm_table_supports_dax(t))
1909 blk_queue_flag_set(QUEUE_FLAG_DAX, q); 1907 blk_queue_flag_set(QUEUE_FLAG_DAX, q);
1908 else
1909 blk_queue_flag_clear(QUEUE_FLAG_DAX, q);
1910
1910 if (dm_table_supports_dax_write_cache(t)) 1911 if (dm_table_supports_dax_write_cache(t))
1911 dax_write_cache(t->md->dax_dev, true); 1912 dax_write_cache(t->md->dax_dev, true);
1912 1913
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 36ef284ad086..72142021b5c9 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -776,7 +776,6 @@ static int __write_changed_details(struct dm_pool_metadata *pmd)
776static int __commit_transaction(struct dm_pool_metadata *pmd) 776static int __commit_transaction(struct dm_pool_metadata *pmd)
777{ 777{
778 int r; 778 int r;
779 size_t metadata_len, data_len;
780 struct thin_disk_superblock *disk_super; 779 struct thin_disk_superblock *disk_super;
781 struct dm_block *sblock; 780 struct dm_block *sblock;
782 781
@@ -797,14 +796,6 @@ static int __commit_transaction(struct dm_pool_metadata *pmd)
797 if (r < 0) 796 if (r < 0)
798 return r; 797 return r;
799 798
800 r = dm_sm_root_size(pmd->metadata_sm, &metadata_len);
801 if (r < 0)
802 return r;
803
804 r = dm_sm_root_size(pmd->data_sm, &data_len);
805 if (r < 0)
806 return r;
807
808 r = save_sm_roots(pmd); 799 r = save_sm_roots(pmd);
809 if (r < 0) 800 if (r < 0)
810 return r; 801 return r;
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 7945238df1c0..b900723bbd0f 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1386,6 +1386,8 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block,
1386 1386
1387static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); 1387static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
1388 1388
1389static void requeue_bios(struct pool *pool);
1390
1389static void check_for_space(struct pool *pool) 1391static void check_for_space(struct pool *pool)
1390{ 1392{
1391 int r; 1393 int r;
@@ -1398,8 +1400,10 @@ static void check_for_space(struct pool *pool)
1398 if (r) 1400 if (r)
1399 return; 1401 return;
1400 1402
1401 if (nr_free) 1403 if (nr_free) {
1402 set_pool_mode(pool, PM_WRITE); 1404 set_pool_mode(pool, PM_WRITE);
1405 requeue_bios(pool);
1406 }
1403} 1407}
1404 1408
1405/* 1409/*
@@ -1476,7 +1480,10 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
1476 1480
1477 r = dm_pool_alloc_data_block(pool->pmd, result); 1481 r = dm_pool_alloc_data_block(pool->pmd, result);
1478 if (r) { 1482 if (r) {
1479 metadata_operation_failed(pool, "dm_pool_alloc_data_block", r); 1483 if (r == -ENOSPC)
1484 set_pool_mode(pool, PM_OUT_OF_DATA_SPACE);
1485 else
1486 metadata_operation_failed(pool, "dm_pool_alloc_data_block", r);
1480 return r; 1487 return r;
1481 } 1488 }
1482 1489
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index 5961c7794ef3..07ea6a48aac6 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -259,7 +259,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
259 if (da != p) { 259 if (da != p) {
260 long i; 260 long i;
261 wc->memory_map = NULL; 261 wc->memory_map = NULL;
262 pages = kvmalloc(p * sizeof(struct page *), GFP_KERNEL); 262 pages = kvmalloc_array(p, sizeof(struct page *), GFP_KERNEL);
263 if (!pages) { 263 if (!pages) {
264 r = -ENOMEM; 264 r = -ENOMEM;
265 goto err2; 265 goto err2;
@@ -859,7 +859,7 @@ static int writecache_alloc_entries(struct dm_writecache *wc)
859 859
860 if (wc->entries) 860 if (wc->entries)
861 return 0; 861 return 0;
862 wc->entries = vmalloc(sizeof(struct wc_entry) * wc->n_blocks); 862 wc->entries = vmalloc(array_size(sizeof(struct wc_entry), wc->n_blocks));
863 if (!wc->entries) 863 if (!wc->entries)
864 return -ENOMEM; 864 return -ENOMEM;
865 for (b = 0; b < wc->n_blocks; b++) { 865 for (b = 0; b < wc->n_blocks; b++) {
@@ -1481,9 +1481,9 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba
1481 wb->bio.bi_iter.bi_sector = read_original_sector(wc, e); 1481 wb->bio.bi_iter.bi_sector = read_original_sector(wc, e);
1482 wb->page_offset = PAGE_SIZE; 1482 wb->page_offset = PAGE_SIZE;
1483 if (max_pages <= WB_LIST_INLINE || 1483 if (max_pages <= WB_LIST_INLINE ||
1484 unlikely(!(wb->wc_list = kmalloc(max_pages * sizeof(struct wc_entry *), 1484 unlikely(!(wb->wc_list = kmalloc_array(max_pages, sizeof(struct wc_entry *),
1485 GFP_NOIO | __GFP_NORETRY | 1485 GFP_NOIO | __GFP_NORETRY |
1486 __GFP_NOMEMALLOC | __GFP_NOWARN)))) { 1486 __GFP_NOMEMALLOC | __GFP_NOWARN)))) {
1487 wb->wc_list = wb->wc_list_inline; 1487 wb->wc_list = wb->wc_list_inline;
1488 max_pages = WB_LIST_INLINE; 1488 max_pages = WB_LIST_INLINE;
1489 } 1489 }
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 3c0e45f4dcf5..a44183ff4be0 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -787,7 +787,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
787 787
788 /* Chunk BIO work */ 788 /* Chunk BIO work */
789 mutex_init(&dmz->chunk_lock); 789 mutex_init(&dmz->chunk_lock);
790 INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_KERNEL); 790 INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_NOIO);
791 dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s", WQ_MEM_RECLAIM | WQ_UNBOUND, 791 dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s", WQ_MEM_RECLAIM | WQ_UNBOUND,
792 0, dev->name); 792 0, dev->name);
793 if (!dmz->chunk_wq) { 793 if (!dmz->chunk_wq) {
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index e65429a29c06..b0dd7027848b 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1056,8 +1056,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
1056 if (len < 1) 1056 if (len < 1)
1057 goto out; 1057 goto out;
1058 nr_pages = min(len, nr_pages); 1058 nr_pages = min(len, nr_pages);
1059 if (ti->type->direct_access) 1059 ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
1060 ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn);
1061 1060
1062 out: 1061 out:
1063 dm_put_live_table(md, srcu_idx); 1062 dm_put_live_table(md, srcu_idx);
@@ -1606,10 +1605,9 @@ static blk_qc_t __split_and_process_bio(struct mapped_device *md,
1606 * the usage of io->orig_bio in dm_remap_zone_report() 1605 * the usage of io->orig_bio in dm_remap_zone_report()
1607 * won't be affected by this reassignment. 1606 * won't be affected by this reassignment.
1608 */ 1607 */
1609 struct bio *b = bio_clone_bioset(bio, GFP_NOIO, 1608 struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count,
1610 &md->queue->bio_split); 1609 GFP_NOIO, &md->queue->bio_split);
1611 ci.io->orig_bio = b; 1610 ci.io->orig_bio = b;
1612 bio_advance(bio, (bio_sectors(bio) - ci.sector_count) << 9);
1613 bio_chain(b, bio); 1611 bio_chain(b, bio);
1614 ret = generic_make_request(bio); 1612 ret = generic_make_request(bio);
1615 break; 1613 break;
diff --git a/drivers/memory/ti-emif-pm.c b/drivers/memory/ti-emif-pm.c
index 632651f4b6e8..2250d03ea17f 100644
--- a/drivers/memory/ti-emif-pm.c
+++ b/drivers/memory/ti-emif-pm.c
@@ -249,6 +249,34 @@ static const struct of_device_id ti_emif_of_match[] = {
249}; 249};
250MODULE_DEVICE_TABLE(of, ti_emif_of_match); 250MODULE_DEVICE_TABLE(of, ti_emif_of_match);
251 251
252#ifdef CONFIG_PM_SLEEP
253static int ti_emif_resume(struct device *dev)
254{
255 unsigned long tmp =
256 __raw_readl((void *)emif_instance->ti_emif_sram_virt);
257
258 /*
259 * Check to see if what we are copying is already present in the
260 * first byte at the destination, only copy if it is not which
261 * indicates we have lost context and sram no longer contains
262 * the PM code
263 */
264 if (tmp != ti_emif_sram)
265 ti_emif_push_sram(dev, emif_instance);
266
267 return 0;
268}
269
270static int ti_emif_suspend(struct device *dev)
271{
272 /*
273 * The contents will be present in DDR hence no need to
274 * explicitly save
275 */
276 return 0;
277}
278#endif /* CONFIG_PM_SLEEP */
279
252static int ti_emif_probe(struct platform_device *pdev) 280static int ti_emif_probe(struct platform_device *pdev)
253{ 281{
254 int ret; 282 int ret;
@@ -308,12 +336,17 @@ static int ti_emif_remove(struct platform_device *pdev)
308 return 0; 336 return 0;
309} 337}
310 338
339static const struct dev_pm_ops ti_emif_pm_ops = {
340 SET_SYSTEM_SLEEP_PM_OPS(ti_emif_suspend, ti_emif_resume)
341};
342
311static struct platform_driver ti_emif_driver = { 343static struct platform_driver ti_emif_driver = {
312 .probe = ti_emif_probe, 344 .probe = ti_emif_probe,
313 .remove = ti_emif_remove, 345 .remove = ti_emif_remove,
314 .driver = { 346 .driver = {
315 .name = KBUILD_MODNAME, 347 .name = KBUILD_MODNAME,
316 .of_match_table = of_match_ptr(ti_emif_of_match), 348 .of_match_table = of_match_ptr(ti_emif_of_match),
349 .pm = &ti_emif_pm_ops,
317 }, 350 },
318}; 351};
319module_platform_driver(ti_emif_driver); 352module_platform_driver(ti_emif_driver);
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index a0c655628d6d..1b64ac8c5bc8 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -2526,7 +2526,7 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
2526 2526
2527struct ppb_lock { 2527struct ppb_lock {
2528 struct flchip *chip; 2528 struct flchip *chip;
2529 loff_t offset; 2529 unsigned long adr;
2530 int locked; 2530 int locked;
2531}; 2531};
2532 2532
@@ -2544,8 +2544,9 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
2544 unsigned long timeo; 2544 unsigned long timeo;
2545 int ret; 2545 int ret;
2546 2546
2547 adr += chip->start;
2547 mutex_lock(&chip->mutex); 2548 mutex_lock(&chip->mutex);
2548 ret = get_chip(map, chip, adr + chip->start, FL_LOCKING); 2549 ret = get_chip(map, chip, adr, FL_LOCKING);
2549 if (ret) { 2550 if (ret) {
2550 mutex_unlock(&chip->mutex); 2551 mutex_unlock(&chip->mutex);
2551 return ret; 2552 return ret;
@@ -2563,8 +2564,8 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
2563 2564
2564 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) { 2565 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
2565 chip->state = FL_LOCKING; 2566 chip->state = FL_LOCKING;
2566 map_write(map, CMD(0xA0), chip->start + adr); 2567 map_write(map, CMD(0xA0), adr);
2567 map_write(map, CMD(0x00), chip->start + adr); 2568 map_write(map, CMD(0x00), adr);
2568 } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) { 2569 } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) {
2569 /* 2570 /*
2570 * Unlocking of one specific sector is not supported, so we 2571 * Unlocking of one specific sector is not supported, so we
@@ -2602,7 +2603,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
2602 map_write(map, CMD(0x00), chip->start); 2603 map_write(map, CMD(0x00), chip->start);
2603 2604
2604 chip->state = FL_READY; 2605 chip->state = FL_READY;
2605 put_chip(map, chip, adr + chip->start); 2606 put_chip(map, chip, adr);
2606 mutex_unlock(&chip->mutex); 2607 mutex_unlock(&chip->mutex);
2607 2608
2608 return ret; 2609 return ret;
@@ -2659,9 +2660,9 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
2659 * sectors shall be unlocked, so lets keep their locking 2660 * sectors shall be unlocked, so lets keep their locking
2660 * status at "unlocked" (locked=0) for the final re-locking. 2661 * status at "unlocked" (locked=0) for the final re-locking.
2661 */ 2662 */
2662 if ((adr < ofs) || (adr >= (ofs + len))) { 2663 if ((offset < ofs) || (offset >= (ofs + len))) {
2663 sect[sectors].chip = &cfi->chips[chipnum]; 2664 sect[sectors].chip = &cfi->chips[chipnum];
2664 sect[sectors].offset = offset; 2665 sect[sectors].adr = adr;
2665 sect[sectors].locked = do_ppb_xxlock( 2666 sect[sectors].locked = do_ppb_xxlock(
2666 map, &cfi->chips[chipnum], adr, 0, 2667 map, &cfi->chips[chipnum], adr, 0,
2667 DO_XXLOCK_ONEBLOCK_GETLOCK); 2668 DO_XXLOCK_ONEBLOCK_GETLOCK);
@@ -2675,6 +2676,8 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
2675 i++; 2676 i++;
2676 2677
2677 if (adr >> cfi->chipshift) { 2678 if (adr >> cfi->chipshift) {
2679 if (offset >= (ofs + len))
2680 break;
2678 adr = 0; 2681 adr = 0;
2679 chipnum++; 2682 chipnum++;
2680 2683
@@ -2705,7 +2708,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
2705 */ 2708 */
2706 for (i = 0; i < sectors; i++) { 2709 for (i = 0; i < sectors; i++) {
2707 if (sect[i].locked) 2710 if (sect[i].locked)
2708 do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0, 2711 do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0,
2709 DO_XXLOCK_ONEBLOCK_LOCK); 2712 DO_XXLOCK_ONEBLOCK_LOCK);
2710 } 2713 }
2711 2714
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 3a6f450d1093..53febe8a68c3 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -733,8 +733,8 @@ static struct flash_info dataflash_data[] = {
733 { "AT45DB642x", 0x1f2800, 8192, 1056, 11, SUP_POW2PS}, 733 { "AT45DB642x", 0x1f2800, 8192, 1056, 11, SUP_POW2PS},
734 { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS}, 734 { "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
735 735
736 { "AT45DB641E", 0x1f28000100, 32768, 264, 9, SUP_EXTID | SUP_POW2PS}, 736 { "AT45DB641E", 0x1f28000100ULL, 32768, 264, 9, SUP_EXTID | SUP_POW2PS},
737 { "at45db641e", 0x1f28000100, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS}, 737 { "at45db641e", 0x1f28000100ULL, 32768, 256, 8, SUP_EXTID | SUP_POW2PS | IS_POW2PS},
738}; 738};
739 739
740static struct flash_info *jedec_lookup(struct spi_device *spi, 740static struct flash_info *jedec_lookup(struct spi_device *spi,
diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
index cfd33e6ca77f..5869e90cc14b 100644
--- a/drivers/mtd/nand/raw/denali_dt.c
+++ b/drivers/mtd/nand/raw/denali_dt.c
@@ -123,7 +123,11 @@ static int denali_dt_probe(struct platform_device *pdev)
123 if (ret) 123 if (ret)
124 return ret; 124 return ret;
125 125
126 denali->clk_x_rate = clk_get_rate(dt->clk); 126 /*
127 * Hardcode the clock rate for the backward compatibility.
128 * This works for both SOCFPGA and UniPhier.
129 */
130 denali->clk_x_rate = 200000000;
127 131
128 ret = denali_init(denali); 132 ret = denali_init(denali);
129 if (ret) 133 if (ret)
diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
index 45786e707b7b..26cef218bb43 100644
--- a/drivers/mtd/nand/raw/mxc_nand.c
+++ b/drivers/mtd/nand/raw/mxc_nand.c
@@ -48,7 +48,7 @@
48#define NFC_V1_V2_CONFIG (host->regs + 0x0a) 48#define NFC_V1_V2_CONFIG (host->regs + 0x0a)
49#define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c) 49#define NFC_V1_V2_ECC_STATUS_RESULT (host->regs + 0x0c)
50#define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e) 50#define NFC_V1_V2_RSLTMAIN_AREA (host->regs + 0x0e)
51#define NFC_V1_V2_RSLTSPARE_AREA (host->regs + 0x10) 51#define NFC_V21_RSLTSPARE_AREA (host->regs + 0x10)
52#define NFC_V1_V2_WRPROT (host->regs + 0x12) 52#define NFC_V1_V2_WRPROT (host->regs + 0x12)
53#define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14) 53#define NFC_V1_UNLOCKSTART_BLKADDR (host->regs + 0x14)
54#define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16) 54#define NFC_V1_UNLOCKEND_BLKADDR (host->regs + 0x16)
@@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
1274 writew(config1, NFC_V1_V2_CONFIG1); 1274 writew(config1, NFC_V1_V2_CONFIG1);
1275 /* preset operation */ 1275 /* preset operation */
1276 1276
1277 /* spare area size in 16-bit half-words */
1278 writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
1279
1277 /* Unlock the internal RAM Buffer */ 1280 /* Unlock the internal RAM Buffer */
1278 writew(0x2, NFC_V1_V2_CONFIG); 1281 writew(0x2, NFC_V1_V2_CONFIG);
1279 1282
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 10c4f9919850..b01d15ec4c56 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)
440 440
441 for (; page < page_end; page++) { 441 for (; page < page_end; page++) {
442 res = chip->ecc.read_oob(mtd, chip, page); 442 res = chip->ecc.read_oob(mtd, chip, page);
443 if (res) 443 if (res < 0)
444 return res; 444 return res;
445 445
446 bad = chip->oob_poi[chip->badblockpos]; 446 bad = chip->oob_poi[chip->badblockpos];
diff --git a/drivers/mtd/nand/raw/nand_macronix.c b/drivers/mtd/nand/raw/nand_macronix.c
index 7ed1f87e742a..49c546c97c6f 100644
--- a/drivers/mtd/nand/raw/nand_macronix.c
+++ b/drivers/mtd/nand/raw/nand_macronix.c
@@ -17,23 +17,47 @@
17 17
18#include <linux/mtd/rawnand.h> 18#include <linux/mtd/rawnand.h>
19 19
20/*
21 * Macronix AC series does not support using SET/GET_FEATURES to change
22 * the timings unlike what is declared in the parameter page. Unflag
23 * this feature to avoid unnecessary downturns.
24 */
25static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
26{
27 unsigned int i;
28 static const char * const broken_get_timings[] = {
29 "MX30LF1G18AC",
30 "MX30LF1G28AC",
31 "MX30LF2G18AC",
32 "MX30LF2G28AC",
33 "MX30LF4G18AC",
34 "MX30LF4G28AC",
35 "MX60LF8G18AC",
36 };
37
38 if (!chip->parameters.supports_set_get_features)
39 return;
40
41 for (i = 0; i < ARRAY_SIZE(broken_get_timings); i++) {
42 if (!strcmp(broken_get_timings[i], chip->parameters.model))
43 break;
44 }
45
46 if (i == ARRAY_SIZE(broken_get_timings))
47 return;
48
49 bitmap_clear(chip->parameters.get_feature_list,
50 ONFI_FEATURE_ADDR_TIMING_MODE, 1);
51 bitmap_clear(chip->parameters.set_feature_list,
52 ONFI_FEATURE_ADDR_TIMING_MODE, 1);
53}
54
20static int macronix_nand_init(struct nand_chip *chip) 55static int macronix_nand_init(struct nand_chip *chip)
21{ 56{
22 if (nand_is_slc(chip)) 57 if (nand_is_slc(chip))
23 chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; 58 chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
24 59
25 /* 60 macronix_nand_fix_broken_get_timings(chip);
26 * MX30LF2G18AC chip does not support using SET/GET_FEATURES to change
27 * the timings unlike what is declared in the parameter page. Unflag
28 * this feature to avoid unnecessary downturns.
29 */
30 if (chip->parameters.supports_set_get_features &&
31 !strcmp("MX30LF2G18AC", chip->parameters.model)) {
32 bitmap_clear(chip->parameters.get_feature_list,
33 ONFI_FEATURE_ADDR_TIMING_MODE, 1);
34 bitmap_clear(chip->parameters.set_feature_list,
35 ONFI_FEATURE_ADDR_TIMING_MODE, 1);
36 }
37 61
38 return 0; 62 return 0;
39} 63}
diff --git a/drivers/mtd/nand/raw/nand_micron.c b/drivers/mtd/nand/raw/nand_micron.c
index 0af45b134c0c..5ec4c90a637d 100644
--- a/drivers/mtd/nand/raw/nand_micron.c
+++ b/drivers/mtd/nand/raw/nand_micron.c
@@ -66,7 +66,9 @@ static int micron_nand_onfi_init(struct nand_chip *chip)
66 66
67 if (p->supports_set_get_features) { 67 if (p->supports_set_get_features) {
68 set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->set_feature_list); 68 set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->set_feature_list);
69 set_bit(ONFI_FEATURE_ON_DIE_ECC, p->set_feature_list);
69 set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->get_feature_list); 70 set_bit(ONFI_FEATURE_ADDR_READ_RETRY, p->get_feature_list);
71 set_bit(ONFI_FEATURE_ON_DIE_ECC, p->get_feature_list);
70 } 72 }
71 73
72 return 0; 74 return 0;
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index d5c15e8bb3de..f273af136fc7 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -173,7 +173,7 @@ config SUNLANCE
173 173
174config AMD_XGBE 174config AMD_XGBE
175 tristate "AMD 10GbE Ethernet driver" 175 tristate "AMD 10GbE Ethernet driver"
176 depends on ((OF_NET && OF_ADDRESS) || ACPI || PCI) && HAS_IOMEM && HAS_DMA 176 depends on ((OF_NET && OF_ADDRESS) || ACPI || PCI) && HAS_IOMEM
177 depends on X86 || ARM64 || COMPILE_TEST 177 depends on X86 || ARM64 || COMPILE_TEST
178 select BITREVERSE 178 select BITREVERSE
179 select CRC32 179 select CRC32
diff --git a/drivers/net/ethernet/apm/xgene-v2/Kconfig b/drivers/net/ethernet/apm/xgene-v2/Kconfig
index 1205861b6318..eedd3f3dd22e 100644
--- a/drivers/net/ethernet/apm/xgene-v2/Kconfig
+++ b/drivers/net/ethernet/apm/xgene-v2/Kconfig
@@ -1,6 +1,5 @@
1config NET_XGENE_V2 1config NET_XGENE_V2
2 tristate "APM X-Gene SoC Ethernet-v2 Driver" 2 tristate "APM X-Gene SoC Ethernet-v2 Driver"
3 depends on HAS_DMA
4 depends on ARCH_XGENE || COMPILE_TEST 3 depends on ARCH_XGENE || COMPILE_TEST
5 help 4 help
6 This is the Ethernet driver for the on-chip ethernet interface 5 This is the Ethernet driver for the on-chip ethernet interface
diff --git a/drivers/net/ethernet/apm/xgene/Kconfig b/drivers/net/ethernet/apm/xgene/Kconfig
index afccb033177b..e4e33c900b57 100644
--- a/drivers/net/ethernet/apm/xgene/Kconfig
+++ b/drivers/net/ethernet/apm/xgene/Kconfig
@@ -1,6 +1,5 @@
1config NET_XGENE 1config NET_XGENE
2 tristate "APM X-Gene SoC Ethernet Driver" 2 tristate "APM X-Gene SoC Ethernet Driver"
3 depends on HAS_DMA
4 depends on ARCH_XGENE || COMPILE_TEST 3 depends on ARCH_XGENE || COMPILE_TEST
5 select PHYLIB 4 select PHYLIB
6 select MDIO_XGENE 5 select MDIO_XGENE
diff --git a/drivers/net/ethernet/arc/Kconfig b/drivers/net/ethernet/arc/Kconfig
index e743ddf46343..5d0ab8e74b68 100644
--- a/drivers/net/ethernet/arc/Kconfig
+++ b/drivers/net/ethernet/arc/Kconfig
@@ -24,7 +24,8 @@ config ARC_EMAC_CORE
24config ARC_EMAC 24config ARC_EMAC
25 tristate "ARC EMAC support" 25 tristate "ARC EMAC support"
26 select ARC_EMAC_CORE 26 select ARC_EMAC_CORE
27 depends on OF_IRQ && OF_NET && HAS_DMA && (ARC || COMPILE_TEST) 27 depends on OF_IRQ && OF_NET
28 depends on ARC || COMPILE_TEST
28 ---help--- 29 ---help---
29 On some legacy ARC (Synopsys) FPGA boards such as ARCAngel4/ML50x 30 On some legacy ARC (Synopsys) FPGA boards such as ARCAngel4/ML50x
30 non-standard on-chip ethernet device ARC EMAC 10/100 is used. 31 non-standard on-chip ethernet device ARC EMAC 10/100 is used.
@@ -33,7 +34,8 @@ config ARC_EMAC
33config EMAC_ROCKCHIP 34config EMAC_ROCKCHIP
34 tristate "Rockchip EMAC support" 35 tristate "Rockchip EMAC support"
35 select ARC_EMAC_CORE 36 select ARC_EMAC_CORE
36 depends on OF_IRQ && OF_NET && REGULATOR && HAS_DMA && (ARCH_ROCKCHIP || COMPILE_TEST) 37 depends on OF_IRQ && OF_NET && REGULATOR
38 depends on ARCH_ROCKCHIP || COMPILE_TEST
37 ---help--- 39 ---help---
38 Support for Rockchip RK3036/RK3066/RK3188 EMAC ethernet controllers. 40 Support for Rockchip RK3036/RK3066/RK3188 EMAC ethernet controllers.
39 This selects Rockchip SoC glue layer support for the 41 This selects Rockchip SoC glue layer support for the
diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig
index af75156919ed..4c3bfde6e8de 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -157,7 +157,6 @@ config BGMAC
157config BGMAC_BCMA 157config BGMAC_BCMA
158 tristate "Broadcom iProc GBit BCMA support" 158 tristate "Broadcom iProc GBit BCMA support"
159 depends on BCMA && BCMA_HOST_SOC 159 depends on BCMA && BCMA_HOST_SOC
160 depends on HAS_DMA
161 depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST 160 depends on BCM47XX || ARCH_BCM_5301X || COMPILE_TEST
162 select BGMAC 161 select BGMAC
163 select PHYLIB 162 select PHYLIB
@@ -170,7 +169,6 @@ config BGMAC_BCMA
170 169
171config BGMAC_PLATFORM 170config BGMAC_PLATFORM
172 tristate "Broadcom iProc GBit platform support" 171 tristate "Broadcom iProc GBit platform support"
173 depends on HAS_DMA
174 depends on ARCH_BCM_IPROC || COMPILE_TEST 172 depends on ARCH_BCM_IPROC || COMPILE_TEST
175 depends on OF 173 depends on OF
176 select BGMAC 174 select BGMAC
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 2220c771092b..678835136bf8 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -170,10 +170,7 @@ static int gem_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
170 170
171 if (delta > TSU_NSEC_MAX_VAL) { 171 if (delta > TSU_NSEC_MAX_VAL) {
172 gem_tsu_get_time(&bp->ptp_clock_info, &now); 172 gem_tsu_get_time(&bp->ptp_clock_info, &now);
173 if (sign) 173 now = timespec64_add(now, then);
174 now = timespec64_sub(now, then);
175 else
176 now = timespec64_add(now, then);
177 174
178 gem_tsu_set_time(&bp->ptp_clock_info, 175 gem_tsu_set_time(&bp->ptp_clock_info,
179 (const struct timespec64 *)&now); 176 (const struct timespec64 *)&now);
diff --git a/drivers/net/ethernet/calxeda/Kconfig b/drivers/net/ethernet/calxeda/Kconfig
index 07d2201530d2..9fdd496b90ff 100644
--- a/drivers/net/ethernet/calxeda/Kconfig
+++ b/drivers/net/ethernet/calxeda/Kconfig
@@ -1,6 +1,6 @@
1config NET_CALXEDA_XGMAC 1config NET_CALXEDA_XGMAC
2 tristate "Calxeda 1G/10G XGMAC Ethernet driver" 2 tristate "Calxeda 1G/10G XGMAC Ethernet driver"
3 depends on HAS_IOMEM && HAS_DMA 3 depends on HAS_IOMEM
4 depends on ARCH_HIGHBANK || COMPILE_TEST 4 depends on ARCH_HIGHBANK || COMPILE_TEST
5 select CRC32 5 select CRC32
6 help 6 help
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index dd04a2f89ce6..bc03c175a3cd 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -263,7 +263,7 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
263 "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n", 263 "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
264 enable ? "set" : "unset", pi->port_id, i, -err); 264 enable ? "set" : "unset", pi->port_id, i, -err);
265 else 265 else
266 txq->dcb_prio = value; 266 txq->dcb_prio = enable ? value : 0;
267 } 267 }
268} 268}
269 269
diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c
index 973c1fb70d09..99038dfc7fbe 100644
--- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
+++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
@@ -79,7 +79,6 @@ void enic_rfs_flw_tbl_init(struct enic *enic)
79 enic->rfs_h.max = enic->config.num_arfs; 79 enic->rfs_h.max = enic->config.num_arfs;
80 enic->rfs_h.free = enic->rfs_h.max; 80 enic->rfs_h.free = enic->rfs_h.max;
81 enic->rfs_h.toclean = 0; 81 enic->rfs_h.toclean = 0;
82 enic_rfs_timer_start(enic);
83} 82}
84 83
85void enic_rfs_flw_tbl_free(struct enic *enic) 84void enic_rfs_flw_tbl_free(struct enic *enic)
@@ -88,7 +87,6 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
88 87
89 enic_rfs_timer_stop(enic); 88 enic_rfs_timer_stop(enic);
90 spin_lock_bh(&enic->rfs_h.lock); 89 spin_lock_bh(&enic->rfs_h.lock);
91 enic->rfs_h.free = 0;
92 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) { 90 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) {
93 struct hlist_head *hhead; 91 struct hlist_head *hhead;
94 struct hlist_node *tmp; 92 struct hlist_node *tmp;
@@ -99,6 +97,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
99 enic_delfltr(enic, n->fltr_id); 97 enic_delfltr(enic, n->fltr_id);
100 hlist_del(&n->node); 98 hlist_del(&n->node);
101 kfree(n); 99 kfree(n);
100 enic->rfs_h.free++;
102 } 101 }
103 } 102 }
104 spin_unlock_bh(&enic->rfs_h.lock); 103 spin_unlock_bh(&enic->rfs_h.lock);
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 30d2eaa18c04..90c645b8538e 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1920,7 +1920,7 @@ static int enic_open(struct net_device *netdev)
1920{ 1920{
1921 struct enic *enic = netdev_priv(netdev); 1921 struct enic *enic = netdev_priv(netdev);
1922 unsigned int i; 1922 unsigned int i;
1923 int err; 1923 int err, ret;
1924 1924
1925 err = enic_request_intr(enic); 1925 err = enic_request_intr(enic);
1926 if (err) { 1926 if (err) {
@@ -1971,16 +1971,15 @@ static int enic_open(struct net_device *netdev)
1971 vnic_intr_unmask(&enic->intr[i]); 1971 vnic_intr_unmask(&enic->intr[i]);
1972 1972
1973 enic_notify_timer_start(enic); 1973 enic_notify_timer_start(enic);
1974 enic_rfs_flw_tbl_init(enic); 1974 enic_rfs_timer_start(enic);
1975 1975
1976 return 0; 1976 return 0;
1977 1977
1978err_out_free_rq: 1978err_out_free_rq:
1979 for (i = 0; i < enic->rq_count; i++) { 1979 for (i = 0; i < enic->rq_count; i++) {
1980 err = vnic_rq_disable(&enic->rq[i]); 1980 ret = vnic_rq_disable(&enic->rq[i]);
1981 if (err) 1981 if (!ret)
1982 return err; 1982 vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
1983 vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
1984 } 1983 }
1985 enic_dev_notify_unset(enic); 1984 enic_dev_notify_unset(enic);
1986err_out_free_intr: 1985err_out_free_intr:
@@ -2904,6 +2903,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2904 2903
2905 timer_setup(&enic->notify_timer, enic_notify_timer, 0); 2904 timer_setup(&enic->notify_timer, enic_notify_timer, 0);
2906 2905
2906 enic_rfs_flw_tbl_init(enic);
2907 enic_set_rx_coal_setting(enic); 2907 enic_set_rx_coal_setting(enic);
2908 INIT_WORK(&enic->reset, enic_reset); 2908 INIT_WORK(&enic->reset, enic_reset);
2909 INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset); 2909 INIT_WORK(&enic->tx_hang_reset, enic_tx_hang_reset);
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 78db8e62a83f..ed6c76d20b45 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1735,8 +1735,8 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
1735 if (unlikely(nd->state != ncsi_dev_state_functional)) 1735 if (unlikely(nd->state != ncsi_dev_state_functional))
1736 return; 1736 return;
1737 1737
1738 netdev_info(nd->dev, "NCSI interface %s\n", 1738 netdev_dbg(nd->dev, "NCSI interface %s\n",
1739 nd->link_up ? "up" : "down"); 1739 nd->link_up ? "up" : "down");
1740} 1740}
1741 1741
1742static void ftgmac100_setup_clk(struct ftgmac100 *priv) 1742static void ftgmac100_setup_clk(struct ftgmac100 *priv)
diff --git a/drivers/net/ethernet/hisilicon/Kconfig b/drivers/net/ethernet/hisilicon/Kconfig
index 8bcf470ff5f3..fb1a7251f45d 100644
--- a/drivers/net/ethernet/hisilicon/Kconfig
+++ b/drivers/net/ethernet/hisilicon/Kconfig
@@ -5,7 +5,7 @@
5config NET_VENDOR_HISILICON 5config NET_VENDOR_HISILICON
6 bool "Hisilicon devices" 6 bool "Hisilicon devices"
7 default y 7 default y
8 depends on (OF || ACPI) && HAS_DMA 8 depends on OF || ACPI
9 depends on ARM || ARM64 || COMPILE_TEST 9 depends on ARM || ARM64 || COMPILE_TEST
10 ---help--- 10 ---help---
11 If you have a network (Ethernet) card belonging to this class, say Y. 11 If you have a network (Ethernet) card belonging to this class, say Y.
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 8ffb7454e67c..ed6dbcfd4e96 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -2103,9 +2103,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
2103 unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2; 2103 unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
2104#else 2104#else
2105 unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + 2105 unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
2106 SKB_DATA_ALIGN(I40E_SKB_PAD + 2106 SKB_DATA_ALIGN(xdp->data_end -
2107 (xdp->data_end - 2107 xdp->data_hard_start);
2108 xdp->data_hard_start));
2109#endif 2108#endif
2110 struct sk_buff *skb; 2109 struct sk_buff *skb;
2111 2110
@@ -2124,7 +2123,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
2124 return NULL; 2123 return NULL;
2125 2124
2126 /* update pointers within the skb to store the data */ 2125 /* update pointers within the skb to store the data */
2127 skb_reserve(skb, I40E_SKB_PAD + (xdp->data - xdp->data_hard_start)); 2126 skb_reserve(skb, xdp->data - xdp->data_hard_start);
2128 __skb_put(skb, xdp->data_end - xdp->data); 2127 __skb_put(skb, xdp->data_end - xdp->data);
2129 if (metasize) 2128 if (metasize)
2130 skb_metadata_set(skb, metasize); 2129 skb_metadata_set(skb, metasize);
diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig
index cc2f7701e71e..f33fd22b351c 100644
--- a/drivers/net/ethernet/marvell/Kconfig
+++ b/drivers/net/ethernet/marvell/Kconfig
@@ -18,8 +18,8 @@ if NET_VENDOR_MARVELL
18 18
19config MV643XX_ETH 19config MV643XX_ETH
20 tristate "Marvell Discovery (643XX) and Orion ethernet support" 20 tristate "Marvell Discovery (643XX) and Orion ethernet support"
21 depends on (MV64X60 || PPC32 || PLAT_ORION || COMPILE_TEST) && INET 21 depends on MV64X60 || PPC32 || PLAT_ORION || COMPILE_TEST
22 depends on HAS_DMA 22 depends on INET
23 select PHYLIB 23 select PHYLIB
24 select MVMDIO 24 select MVMDIO
25 ---help--- 25 ---help---
@@ -58,7 +58,6 @@ config MVNETA_BM_ENABLE
58config MVNETA 58config MVNETA
59 tristate "Marvell Armada 370/38x/XP/37xx network interface support" 59 tristate "Marvell Armada 370/38x/XP/37xx network interface support"
60 depends on ARCH_MVEBU || COMPILE_TEST 60 depends on ARCH_MVEBU || COMPILE_TEST
61 depends on HAS_DMA
62 select MVMDIO 61 select MVMDIO
63 select PHYLINK 62 select PHYLINK
64 ---help--- 63 ---help---
@@ -84,7 +83,6 @@ config MVNETA_BM
84config MVPP2 83config MVPP2
85 tristate "Marvell Armada 375/7K/8K network interface support" 84 tristate "Marvell Armada 375/7K/8K network interface support"
86 depends on ARCH_MVEBU || COMPILE_TEST 85 depends on ARCH_MVEBU || COMPILE_TEST
87 depends on HAS_DMA
88 select MVMDIO 86 select MVMDIO
89 select PHYLINK 87 select PHYLINK
90 ---help--- 88 ---help---
@@ -93,7 +91,7 @@ config MVPP2
93 91
94config PXA168_ETH 92config PXA168_ETH
95 tristate "Marvell pxa168 ethernet support" 93 tristate "Marvell pxa168 ethernet support"
96 depends on HAS_IOMEM && HAS_DMA 94 depends on HAS_IOMEM
97 depends on CPU_PXA168 || ARCH_BERLIN || COMPILE_TEST 95 depends on CPU_PXA168 || ARCH_BERLIN || COMPILE_TEST
98 select PHYLIB 96 select PHYLIB
99 ---help--- 97 ---help---
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 17a904cc6a5e..0ad2f3f7da85 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1932,7 +1932,7 @@ static int mvneta_rx_swbm(struct mvneta_port *pp, int rx_todo,
1932 rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE); 1932 rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
1933 index = rx_desc - rxq->descs; 1933 index = rx_desc - rxq->descs;
1934 data = rxq->buf_virt_addr[index]; 1934 data = rxq->buf_virt_addr[index];
1935 phys_addr = rx_desc->buf_phys_addr; 1935 phys_addr = rx_desc->buf_phys_addr - pp->rx_offset_correction;
1936 1936
1937 if (!mvneta_rxq_desc_is_first_last(rx_status) || 1937 if (!mvneta_rxq_desc_is_first_last(rx_status) ||
1938 (rx_status & MVNETA_RXD_ERR_SUMMARY)) { 1938 (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
diff --git a/drivers/net/ethernet/mellanox/mlxsw/Kconfig b/drivers/net/ethernet/mellanox/mlxsw/Kconfig
index f4d9c9975ac3..82827a8d3d67 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlxsw/Kconfig
@@ -30,7 +30,7 @@ config MLXSW_CORE_THERMAL
30 30
31config MLXSW_PCI 31config MLXSW_PCI
32 tristate "PCI bus implementation for Mellanox Technologies Switch ASICs" 32 tristate "PCI bus implementation for Mellanox Technologies Switch ASICs"
33 depends on PCI && HAS_DMA && HAS_IOMEM && MLXSW_CORE 33 depends on PCI && HAS_IOMEM && MLXSW_CORE
34 default m 34 default m
35 ---help--- 35 ---help---
36 This is PCI bus implementation for Mellanox Technologies Switch ASICs. 36 This is PCI bus implementation for Mellanox Technologies Switch ASICs.
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index fb2c8f8071e6..776a8a9be8e3 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -344,10 +344,9 @@ static int ocelot_port_stop(struct net_device *dev)
344static int ocelot_gen_ifh(u32 *ifh, struct frame_info *info) 344static int ocelot_gen_ifh(u32 *ifh, struct frame_info *info)
345{ 345{
346 ifh[0] = IFH_INJ_BYPASS; 346 ifh[0] = IFH_INJ_BYPASS;
347 ifh[1] = (0xff00 & info->port) >> 8; 347 ifh[1] = (0xf00 & info->port) >> 8;
348 ifh[2] = (0xff & info->port) << 24; 348 ifh[2] = (0xff & info->port) << 24;
349 ifh[3] = IFH_INJ_POP_CNT_DISABLE | (info->cpuq << 20) | 349 ifh[3] = (info->tag_type << 16) | info->vid;
350 (info->tag_type << 16) | info->vid;
351 350
352 return 0; 351 return 0;
353} 352}
@@ -370,11 +369,13 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
370 QS_INJ_CTRL_SOF, QS_INJ_CTRL, grp); 369 QS_INJ_CTRL_SOF, QS_INJ_CTRL, grp);
371 370
372 info.port = BIT(port->chip_port); 371 info.port = BIT(port->chip_port);
373 info.cpuq = 0xff; 372 info.tag_type = IFH_TAG_TYPE_C;
373 info.vid = skb_vlan_tag_get(skb);
374 ocelot_gen_ifh(ifh, &info); 374 ocelot_gen_ifh(ifh, &info);
375 375
376 for (i = 0; i < IFH_LEN; i++) 376 for (i = 0; i < IFH_LEN; i++)
377 ocelot_write_rix(ocelot, ifh[i], QS_INJ_WR, grp); 377 ocelot_write_rix(ocelot, (__force u32)cpu_to_be32(ifh[i]),
378 QS_INJ_WR, grp);
378 379
379 count = (skb->len + 3) / 4; 380 count = (skb->len + 3) / 4;
380 last = skb->len % 4; 381 last = skb->len % 4;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 8f31406ec894..f0b01385d5cb 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -255,9 +255,8 @@ qed_dcbx_get_app_protocol_type(struct qed_hwfn *p_hwfn,
255 *type = DCBX_PROTOCOL_ROCE_V2; 255 *type = DCBX_PROTOCOL_ROCE_V2;
256 } else { 256 } else {
257 *type = DCBX_MAX_PROTOCOL_TYPE; 257 *type = DCBX_MAX_PROTOCOL_TYPE;
258 DP_ERR(p_hwfn, 258 DP_ERR(p_hwfn, "No action required, App TLV entry = 0x%x\n",
259 "No action required, App TLV id = 0x%x app_prio_bitmap = 0x%x\n", 259 app_prio_bitmap);
260 id, app_prio_bitmap);
261 return false; 260 return false;
262 } 261 }
263 262
@@ -1479,8 +1478,8 @@ static u8 qed_dcbnl_getcap(struct qed_dev *cdev, int capid, u8 *cap)
1479 *cap = 0x80; 1478 *cap = 0x80;
1480 break; 1479 break;
1481 case DCB_CAP_ATTR_DCBX: 1480 case DCB_CAP_ATTR_DCBX:
1482 *cap = (DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE | 1481 *cap = (DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_VER_IEEE |
1483 DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_STATIC); 1482 DCB_CAP_DCBX_STATIC);
1484 break; 1483 break;
1485 default: 1484 default:
1486 *cap = false; 1485 *cap = false;
@@ -1548,8 +1547,6 @@ static u8 qed_dcbnl_getdcbx(struct qed_dev *cdev)
1548 if (!dcbx_info) 1547 if (!dcbx_info)
1549 return 0; 1548 return 0;
1550 1549
1551 if (dcbx_info->operational.enabled)
1552 mode |= DCB_CAP_DCBX_LLD_MANAGED;
1553 if (dcbx_info->operational.ieee) 1550 if (dcbx_info->operational.ieee)
1554 mode |= DCB_CAP_DCBX_VER_IEEE; 1551 mode |= DCB_CAP_DCBX_VER_IEEE;
1555 if (dcbx_info->operational.cee) 1552 if (dcbx_info->operational.cee)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index c97ebd681c47..012973d75ad0 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -201,8 +201,9 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
201 201
202 skb = build_skb(buffer->data, 0); 202 skb = build_skb(buffer->data, 0);
203 if (!skb) { 203 if (!skb) {
204 rc = -ENOMEM; 204 DP_INFO(cdev, "Failed to build SKB\n");
205 goto out_post; 205 kfree(buffer->data);
206 goto out_post1;
206 } 207 }
207 208
208 data->u.placement_offset += NET_SKB_PAD; 209 data->u.placement_offset += NET_SKB_PAD;
@@ -224,8 +225,14 @@ void qed_ll2b_complete_rx_packet(void *cxt, struct qed_ll2_comp_rx_data *data)
224 cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb, 225 cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb,
225 data->opaque_data_0, 226 data->opaque_data_0,
226 data->opaque_data_1); 227 data->opaque_data_1);
228 } else {
229 DP_VERBOSE(p_hwfn, (NETIF_MSG_RX_STATUS | NETIF_MSG_PKTDATA |
230 QED_MSG_LL2 | QED_MSG_STORAGE),
231 "Dropping the packet\n");
232 kfree(buffer->data);
227 } 233 }
228 234
235out_post1:
229 /* Update Buffer information and update FW producer */ 236 /* Update Buffer information and update FW producer */
230 buffer->data = new_data; 237 buffer->data = new_data;
231 buffer->phys_addr = new_phys_addr; 238 buffer->phys_addr = new_phys_addr;
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index b04d57ca5176..5c10fd7210c3 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -567,8 +567,16 @@ static irqreturn_t qed_single_int(int irq, void *dev_instance)
567 /* Fastpath interrupts */ 567 /* Fastpath interrupts */
568 for (j = 0; j < 64; j++) { 568 for (j = 0; j < 64; j++) {
569 if ((0x2ULL << j) & status) { 569 if ((0x2ULL << j) & status) {
570 hwfn->simd_proto_handler[j].func( 570 struct qed_simd_fp_handler *p_handler =
571 hwfn->simd_proto_handler[j].token); 571 &hwfn->simd_proto_handler[j];
572
573 if (p_handler->func)
574 p_handler->func(p_handler->token);
575 else
576 DP_NOTICE(hwfn,
577 "Not calling fastpath handler as it is NULL [handler #%d, status 0x%llx]\n",
578 j, status);
579
572 status &= ~(0x2ULL << j); 580 status &= ~(0x2ULL << j);
573 rc = IRQ_HANDLED; 581 rc = IRQ_HANDLED;
574 } 582 }
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 75dfac0248f4..f4cae2be0fda 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7148,7 +7148,7 @@ static void rtl8169_netpoll(struct net_device *dev)
7148{ 7148{
7149 struct rtl8169_private *tp = netdev_priv(dev); 7149 struct rtl8169_private *tp = netdev_priv(dev);
7150 7150
7151 rtl8169_interrupt(pci_irq_vector(tp->pci_dev, 0), dev); 7151 rtl8169_interrupt(pci_irq_vector(tp->pci_dev, 0), tp);
7152} 7152}
7153#endif 7153#endif
7154 7154
diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig
index 27be51f0a421..f3f7477043ce 100644
--- a/drivers/net/ethernet/renesas/Kconfig
+++ b/drivers/net/ethernet/renesas/Kconfig
@@ -17,7 +17,6 @@ if NET_VENDOR_RENESAS
17 17
18config SH_ETH 18config SH_ETH
19 tristate "Renesas SuperH Ethernet support" 19 tristate "Renesas SuperH Ethernet support"
20 depends on HAS_DMA
21 depends on ARCH_RENESAS || SUPERH || COMPILE_TEST 20 depends on ARCH_RENESAS || SUPERH || COMPILE_TEST
22 select CRC32 21 select CRC32
23 select MII 22 select MII
@@ -31,7 +30,6 @@ config SH_ETH
31 30
32config RAVB 31config RAVB
33 tristate "Renesas Ethernet AVB support" 32 tristate "Renesas Ethernet AVB support"
34 depends on HAS_DMA
35 depends on ARCH_RENESAS || COMPILE_TEST 33 depends on ARCH_RENESAS || COMPILE_TEST
36 select CRC32 34 select CRC32
37 select MII 35 select MII
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index ad4a354ce570..570ec72266f3 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -3180,6 +3180,7 @@ bool efx_rps_check_rule(struct efx_arfs_rule *rule, unsigned int filter_idx,
3180 return true; 3180 return true;
3181} 3181}
3182 3182
3183static
3183struct hlist_head *efx_rps_hash_bucket(struct efx_nic *efx, 3184struct hlist_head *efx_rps_hash_bucket(struct efx_nic *efx,
3184 const struct efx_filter_spec *spec) 3185 const struct efx_filter_spec *spec)
3185{ 3186{
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index cb5b0f58c395..edf20361ea5f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -111,7 +111,7 @@ config DWMAC_ROCKCHIP
111config DWMAC_SOCFPGA 111config DWMAC_SOCFPGA
112 tristate "SOCFPGA dwmac support" 112 tristate "SOCFPGA dwmac support"
113 default ARCH_SOCFPGA 113 default ARCH_SOCFPGA
114 depends on OF && (ARCH_SOCFPGA || COMPILE_TEST) 114 depends on OF && (ARCH_SOCFPGA || ARCH_STRATIX10 || COMPILE_TEST)
115 select MFD_SYSCON 115 select MFD_SYSCON
116 help 116 help
117 Support for ethernet controller on Altera SOCFPGA 117 Support for ethernet controller on Altera SOCFPGA
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 6e359572b9f0..5b3b06a0a3bf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -55,6 +55,7 @@ struct socfpga_dwmac {
55 struct device *dev; 55 struct device *dev;
56 struct regmap *sys_mgr_base_addr; 56 struct regmap *sys_mgr_base_addr;
57 struct reset_control *stmmac_rst; 57 struct reset_control *stmmac_rst;
58 struct reset_control *stmmac_ocp_rst;
58 void __iomem *splitter_base; 59 void __iomem *splitter_base;
59 bool f2h_ptp_ref_clk; 60 bool f2h_ptp_ref_clk;
60 struct tse_pcs pcs; 61 struct tse_pcs pcs;
@@ -262,8 +263,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
262 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII; 263 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
263 264
264 /* Assert reset to the enet controller before changing the phy mode */ 265 /* Assert reset to the enet controller before changing the phy mode */
265 if (dwmac->stmmac_rst) 266 reset_control_assert(dwmac->stmmac_ocp_rst);
266 reset_control_assert(dwmac->stmmac_rst); 267 reset_control_assert(dwmac->stmmac_rst);
267 268
268 regmap_read(sys_mgr_base_addr, reg_offset, &ctrl); 269 regmap_read(sys_mgr_base_addr, reg_offset, &ctrl);
269 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift); 270 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
@@ -288,8 +289,8 @@ static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
288 /* Deassert reset for the phy configuration to be sampled by 289 /* Deassert reset for the phy configuration to be sampled by
289 * the enet controller, and operation to start in requested mode 290 * the enet controller, and operation to start in requested mode
290 */ 291 */
291 if (dwmac->stmmac_rst) 292 reset_control_deassert(dwmac->stmmac_ocp_rst);
292 reset_control_deassert(dwmac->stmmac_rst); 293 reset_control_deassert(dwmac->stmmac_rst);
293 if (phymode == PHY_INTERFACE_MODE_SGMII) { 294 if (phymode == PHY_INTERFACE_MODE_SGMII) {
294 if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) { 295 if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) {
295 dev_err(dwmac->dev, "Unable to initialize TSE PCS"); 296 dev_err(dwmac->dev, "Unable to initialize TSE PCS");
@@ -324,6 +325,15 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
324 goto err_remove_config_dt; 325 goto err_remove_config_dt;
325 } 326 }
326 327
328 dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
329 if (IS_ERR(dwmac->stmmac_ocp_rst)) {
330 ret = PTR_ERR(dwmac->stmmac_ocp_rst);
331 dev_err(dev, "error getting reset control of ocp %d\n", ret);
332 goto err_remove_config_dt;
333 }
334
335 reset_control_deassert(dwmac->stmmac_ocp_rst);
336
327 ret = socfpga_dwmac_parse_data(dwmac, dev); 337 ret = socfpga_dwmac_parse_data(dwmac, dev);
328 if (ret) { 338 if (ret) {
329 dev_err(dev, "Unable to parse OF data\n"); 339 dev_err(dev, "Unable to parse OF data\n");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index e79b0d7b388a..cba46b62a1cd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -928,6 +928,7 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
928static int stmmac_init_phy(struct net_device *dev) 928static int stmmac_init_phy(struct net_device *dev)
929{ 929{
930 struct stmmac_priv *priv = netdev_priv(dev); 930 struct stmmac_priv *priv = netdev_priv(dev);
931 u32 tx_cnt = priv->plat->tx_queues_to_use;
931 struct phy_device *phydev; 932 struct phy_device *phydev;
932 char phy_id_fmt[MII_BUS_ID_SIZE + 3]; 933 char phy_id_fmt[MII_BUS_ID_SIZE + 3];
933 char bus_id[MII_BUS_ID_SIZE]; 934 char bus_id[MII_BUS_ID_SIZE];
@@ -969,6 +970,15 @@ static int stmmac_init_phy(struct net_device *dev)
969 SUPPORTED_1000baseT_Full); 970 SUPPORTED_1000baseT_Full);
970 971
971 /* 972 /*
973 * Half-duplex mode not supported with multiqueue
974 * half-duplex can only works with single queue
975 */
976 if (tx_cnt > 1)
977 phydev->supported &= ~(SUPPORTED_1000baseT_Half |
978 SUPPORTED_100baseT_Half |
979 SUPPORTED_10baseT_Half);
980
981 /*
972 * Broken HW is sometimes missing the pull-up resistor on the 982 * Broken HW is sometimes missing the pull-up resistor on the
973 * MDIO line, which results in reads to non-existent devices returning 983 * MDIO line, which results in reads to non-existent devices returning
974 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent 984 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 7a16d40a72d1..b9221fc1674d 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -60,8 +60,7 @@
60#include <linux/sungem_phy.h> 60#include <linux/sungem_phy.h>
61#include "sungem.h" 61#include "sungem.h"
62 62
63/* Stripping FCS is causing problems, disabled for now */ 63#define STRIP_FCS
64#undef STRIP_FCS
65 64
66#define DEFAULT_MSG (NETIF_MSG_DRV | \ 65#define DEFAULT_MSG (NETIF_MSG_DRV | \
67 NETIF_MSG_PROBE | \ 66 NETIF_MSG_PROBE | \
@@ -435,7 +434,7 @@ static int gem_rxmac_reset(struct gem *gp)
435 writel(desc_dma & 0xffffffff, gp->regs + RXDMA_DBLOW); 434 writel(desc_dma & 0xffffffff, gp->regs + RXDMA_DBLOW);
436 writel(RX_RING_SIZE - 4, gp->regs + RXDMA_KICK); 435 writel(RX_RING_SIZE - 4, gp->regs + RXDMA_KICK);
437 val = (RXDMA_CFG_BASE | (RX_OFFSET << 10) | 436 val = (RXDMA_CFG_BASE | (RX_OFFSET << 10) |
438 ((14 / 2) << 13) | RXDMA_CFG_FTHRESH_128); 437 (ETH_HLEN << 13) | RXDMA_CFG_FTHRESH_128);
439 writel(val, gp->regs + RXDMA_CFG); 438 writel(val, gp->regs + RXDMA_CFG);
440 if (readl(gp->regs + GREG_BIFCFG) & GREG_BIFCFG_M66EN) 439 if (readl(gp->regs + GREG_BIFCFG) & GREG_BIFCFG_M66EN)
441 writel(((5 & RXDMA_BLANK_IPKTS) | 440 writel(((5 & RXDMA_BLANK_IPKTS) |
@@ -760,7 +759,6 @@ static int gem_rx(struct gem *gp, int work_to_do)
760 struct net_device *dev = gp->dev; 759 struct net_device *dev = gp->dev;
761 int entry, drops, work_done = 0; 760 int entry, drops, work_done = 0;
762 u32 done; 761 u32 done;
763 __sum16 csum;
764 762
765 if (netif_msg_rx_status(gp)) 763 if (netif_msg_rx_status(gp))
766 printk(KERN_DEBUG "%s: rx interrupt, done: %d, rx_new: %d\n", 764 printk(KERN_DEBUG "%s: rx interrupt, done: %d, rx_new: %d\n",
@@ -855,9 +853,13 @@ static int gem_rx(struct gem *gp, int work_to_do)
855 skb = copy_skb; 853 skb = copy_skb;
856 } 854 }
857 855
858 csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 0xffff); 856 if (likely(dev->features & NETIF_F_RXCSUM)) {
859 skb->csum = csum_unfold(csum); 857 __sum16 csum;
860 skb->ip_summed = CHECKSUM_COMPLETE; 858
859 csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 0xffff);
860 skb->csum = csum_unfold(csum);
861 skb->ip_summed = CHECKSUM_COMPLETE;
862 }
861 skb->protocol = eth_type_trans(skb, gp->dev); 863 skb->protocol = eth_type_trans(skb, gp->dev);
862 864
863 napi_gro_receive(&gp->napi, skb); 865 napi_gro_receive(&gp->napi, skb);
@@ -1761,7 +1763,7 @@ static void gem_init_dma(struct gem *gp)
1761 writel(0, gp->regs + TXDMA_KICK); 1763 writel(0, gp->regs + TXDMA_KICK);
1762 1764
1763 val = (RXDMA_CFG_BASE | (RX_OFFSET << 10) | 1765 val = (RXDMA_CFG_BASE | (RX_OFFSET << 10) |
1764 ((14 / 2) << 13) | RXDMA_CFG_FTHRESH_128); 1766 (ETH_HLEN << 13) | RXDMA_CFG_FTHRESH_128);
1765 writel(val, gp->regs + RXDMA_CFG); 1767 writel(val, gp->regs + RXDMA_CFG);
1766 1768
1767 writel(desc_dma >> 32, gp->regs + RXDMA_DBHI); 1769 writel(desc_dma >> 32, gp->regs + RXDMA_DBHI);
@@ -2985,8 +2987,8 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2985 pci_set_drvdata(pdev, dev); 2987 pci_set_drvdata(pdev, dev);
2986 2988
2987 /* We can do scatter/gather and HW checksum */ 2989 /* We can do scatter/gather and HW checksum */
2988 dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; 2990 dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
2989 dev->features |= dev->hw_features | NETIF_F_RXCSUM; 2991 dev->features = dev->hw_features;
2990 if (pci_using_dac) 2992 if (pci_using_dac)
2991 dev->features |= NETIF_F_HIGHDMA; 2993 dev->features |= NETIF_F_HIGHDMA;
2992 2994
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index cdbddf16dd29..4f1267477aa4 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -205,7 +205,7 @@ static void cpdma_desc_pool_destroy(struct cpdma_ctlr *ctlr)
205 * devices (e.g. cpsw switches) use plain old memory. Descriptor pools 205 * devices (e.g. cpsw switches) use plain old memory. Descriptor pools
206 * abstract out these details 206 * abstract out these details
207 */ 207 */
208int cpdma_desc_pool_create(struct cpdma_ctlr *ctlr) 208static int cpdma_desc_pool_create(struct cpdma_ctlr *ctlr)
209{ 209{
210 struct cpdma_params *cpdma_params = &ctlr->params; 210 struct cpdma_params *cpdma_params = &ctlr->params;
211 struct cpdma_desc_pool *pool; 211 struct cpdma_desc_pool *pool;
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 06d7c9e4dcda..f270beebb428 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1385,6 +1385,15 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
1385 return -EOPNOTSUPP; 1385 return -EOPNOTSUPP;
1386} 1386}
1387 1387
1388static int match_first_device(struct device *dev, void *data)
1389{
1390 if (dev->parent && dev->parent->of_node)
1391 return of_device_is_compatible(dev->parent->of_node,
1392 "ti,davinci_mdio");
1393
1394 return !strncmp(dev_name(dev), "davinci_mdio", 12);
1395}
1396
1388/** 1397/**
1389 * emac_dev_open - EMAC device open 1398 * emac_dev_open - EMAC device open
1390 * @ndev: The DaVinci EMAC network adapter 1399 * @ndev: The DaVinci EMAC network adapter
@@ -1484,8 +1493,14 @@ static int emac_dev_open(struct net_device *ndev)
1484 1493
1485 /* use the first phy on the bus if pdata did not give us a phy id */ 1494 /* use the first phy on the bus if pdata did not give us a phy id */
1486 if (!phydev && !priv->phy_id) { 1495 if (!phydev && !priv->phy_id) {
1487 phy = bus_find_device_by_name(&mdio_bus_type, NULL, 1496 /* NOTE: we can't use bus_find_device_by_name() here because
1488 "davinci_mdio"); 1497 * the device name is not guaranteed to be 'davinci_mdio'. On
1498 * some systems it can be 'davinci_mdio.0' so we need to use
1499 * strncmp() against the first part of the string to correctly
1500 * match it.
1501 */
1502 phy = bus_find_device(&mdio_bus_type, NULL, NULL,
1503 match_first_device);
1489 if (phy) { 1504 if (phy) {
1490 priv->phy_id = dev_name(phy); 1505 priv->phy_id = dev_name(phy);
1491 if (!priv->phy_id || !*priv->phy_id) 1506 if (!priv->phy_id || !*priv->phy_id)
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index f347fd9c5b28..777fa59f5e0c 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -89,10 +89,6 @@
89static const char banner[] __initconst = KERN_INFO \ 89static const char banner[] __initconst = KERN_INFO \
90 "AX.25: bpqether driver version 004\n"; 90 "AX.25: bpqether driver version 004\n";
91 91
92static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
93
94static char bpq_eth_addr[6];
95
96static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); 92static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
97static int bpq_device_event(struct notifier_block *, unsigned long, void *); 93static int bpq_device_event(struct notifier_block *, unsigned long, void *);
98 94
@@ -501,8 +497,8 @@ static int bpq_new_device(struct net_device *edev)
501 bpq->ethdev = edev; 497 bpq->ethdev = edev;
502 bpq->axdev = ndev; 498 bpq->axdev = ndev;
503 499
504 memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr)); 500 eth_broadcast_addr(bpq->dest_addr);
505 memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr)); 501 eth_broadcast_addr(bpq->acpt_addr);
506 502
507 err = register_netdevice(ndev); 503 err = register_netdevice(ndev);
508 if (err) 504 if (err)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4377c26f714d..23c1d6600241 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -594,7 +594,8 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
594 ipvlan->phy_dev = phy_dev; 594 ipvlan->phy_dev = phy_dev;
595 ipvlan->dev = dev; 595 ipvlan->dev = dev;
596 ipvlan->sfeatures = IPVLAN_FEATURES; 596 ipvlan->sfeatures = IPVLAN_FEATURES;
597 ipvlan_adjust_mtu(ipvlan, phy_dev); 597 if (!tb[IFLA_MTU])
598 ipvlan_adjust_mtu(ipvlan, phy_dev);
598 INIT_LIST_HEAD(&ipvlan->addrs); 599 INIT_LIST_HEAD(&ipvlan->addrs);
599 spin_lock_init(&ipvlan->addrs_lock); 600 spin_lock_init(&ipvlan->addrs_lock);
600 601
@@ -693,6 +694,7 @@ void ipvlan_link_setup(struct net_device *dev)
693{ 694{
694 ether_setup(dev); 695 ether_setup(dev);
695 696
697 dev->max_mtu = ETH_MAX_MTU;
696 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); 698 dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
697 dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE; 699 dev->priv_flags |= IFF_UNICAST_FLT | IFF_NO_QUEUE;
698 dev->netdev_ops = &ipvlan_netdev_ops; 700 dev->netdev_ops = &ipvlan_netdev_ops;
diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 83f7420ddea5..4f390fa557e4 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -527,7 +527,7 @@ static int net_failover_slave_register(struct net_device *slave_dev,
527 527
528 netif_addr_lock_bh(failover_dev); 528 netif_addr_lock_bh(failover_dev);
529 dev_uc_sync_multiple(slave_dev, failover_dev); 529 dev_uc_sync_multiple(slave_dev, failover_dev);
530 dev_uc_sync_multiple(slave_dev, failover_dev); 530 dev_mc_sync_multiple(slave_dev, failover_dev);
531 netif_addr_unlock_bh(failover_dev); 531 netif_addr_unlock_bh(failover_dev);
532 532
533 err = vlan_vids_add_by_dev(slave_dev, failover_dev); 533 err = vlan_vids_add_by_dev(slave_dev, failover_dev);
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index de51e8f70f44..ce61231e96ea 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -1107,7 +1107,7 @@ static const struct proto_ops pppoe_ops = {
1107 .socketpair = sock_no_socketpair, 1107 .socketpair = sock_no_socketpair,
1108 .accept = sock_no_accept, 1108 .accept = sock_no_accept,
1109 .getname = pppoe_getname, 1109 .getname = pppoe_getname,
1110 .poll_mask = datagram_poll_mask, 1110 .poll = datagram_poll,
1111 .listen = sock_no_listen, 1111 .listen = sock_no_listen,
1112 .shutdown = sock_no_shutdown, 1112 .shutdown = sock_no_shutdown,
1113 .setsockopt = sock_no_setsockopt, 1113 .setsockopt = sock_no_setsockopt,
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index b0e8b9613054..1eaec648bd1f 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -967,8 +967,7 @@ void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
967 967
968 atomic_set(&ctx->stop, 1); 968 atomic_set(&ctx->stop, 1);
969 969
970 if (hrtimer_active(&ctx->tx_timer)) 970 hrtimer_cancel(&ctx->tx_timer);
971 hrtimer_cancel(&ctx->tx_timer);
972 971
973 tasklet_kill(&ctx->bh); 972 tasklet_kill(&ctx->bh);
974 973
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 8e8b51f171f4..8fac8e132c5b 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -1246,6 +1246,7 @@ static const struct usb_device_id products[] = {
1246 {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ 1246 {QMI_FIXED_INTF(0x413c, 0x81b3, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
1247 {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ 1247 {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */
1248 {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ 1248 {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */
1249 {QMI_FIXED_INTF(0x413c, 0x81d7, 1)}, /* Dell Wireless 5821e */
1249 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ 1250 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
1250 {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ 1251 {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */
1251 {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ 1252 {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */
diff --git a/drivers/net/wireless/broadcom/brcm80211/Kconfig b/drivers/net/wireless/broadcom/brcm80211/Kconfig
index 9d99eb42d917..6acba67bca07 100644
--- a/drivers/net/wireless/broadcom/brcm80211/Kconfig
+++ b/drivers/net/wireless/broadcom/brcm80211/Kconfig
@@ -60,7 +60,6 @@ config BRCMFMAC_PCIE
60 bool "PCIE bus interface support for FullMAC driver" 60 bool "PCIE bus interface support for FullMAC driver"
61 depends on BRCMFMAC 61 depends on BRCMFMAC
62 depends on PCI 62 depends on PCI
63 depends on HAS_DMA
64 select BRCMFMAC_PROTO_MSGBUF 63 select BRCMFMAC_PROTO_MSGBUF
65 select FW_LOADER 64 select FW_LOADER
66 ---help--- 65 ---help---
diff --git a/drivers/net/wireless/quantenna/qtnfmac/Kconfig b/drivers/net/wireless/quantenna/qtnfmac/Kconfig
index 025fa6018550..8d1492a90bd1 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/Kconfig
+++ b/drivers/net/wireless/quantenna/qtnfmac/Kconfig
@@ -7,7 +7,7 @@ config QTNFMAC
7config QTNFMAC_PEARL_PCIE 7config QTNFMAC_PEARL_PCIE
8 tristate "Quantenna QSR10g PCIe support" 8 tristate "Quantenna QSR10g PCIe support"
9 default n 9 default n
10 depends on HAS_DMA && PCI && CFG80211 10 depends on PCI && CFG80211
11 select QTNFMAC 11 select QTNFMAC
12 select FW_LOADER 12 select FW_LOADER
13 select CRC32 13 select CRC32
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 922ce0abf5cf..a57daecf1d57 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1810,7 +1810,7 @@ static int talk_to_netback(struct xenbus_device *dev,
1810 err = xen_net_read_mac(dev, info->netdev->dev_addr); 1810 err = xen_net_read_mac(dev, info->netdev->dev_addr);
1811 if (err) { 1811 if (err) {
1812 xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); 1812 xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
1813 goto out; 1813 goto out_unlocked;
1814 } 1814 }
1815 1815
1816 rtnl_lock(); 1816 rtnl_lock();
@@ -1925,6 +1925,7 @@ abort_transaction_no_dev_fatal:
1925 xennet_destroy_queues(info); 1925 xennet_destroy_queues(info);
1926 out: 1926 out:
1927 rtnl_unlock(); 1927 rtnl_unlock();
1928out_unlocked:
1928 device_unregister(&dev->dev); 1929 device_unregister(&dev->dev);
1929 return err; 1930 return err;
1930} 1931}
@@ -1950,10 +1951,6 @@ static int xennet_connect(struct net_device *dev)
1950 /* talk_to_netback() sets the correct number of queues */ 1951 /* talk_to_netback() sets the correct number of queues */
1951 num_queues = dev->real_num_tx_queues; 1952 num_queues = dev->real_num_tx_queues;
1952 1953
1953 rtnl_lock();
1954 netdev_update_features(dev);
1955 rtnl_unlock();
1956
1957 if (dev->reg_state == NETREG_UNINITIALIZED) { 1954 if (dev->reg_state == NETREG_UNINITIALIZED) {
1958 err = register_netdev(dev); 1955 err = register_netdev(dev);
1959 if (err) { 1956 if (err) {
@@ -1963,6 +1960,10 @@ static int xennet_connect(struct net_device *dev)
1963 } 1960 }
1964 } 1961 }
1965 1962
1963 rtnl_lock();
1964 netdev_update_features(dev);
1965 rtnl_unlock();
1966
1966 /* 1967 /*
1967 * All public and private state should now be sane. Get 1968 * All public and private state should now be sane. Get
1968 * ready to start sending and receiving packets and give the driver 1969 * ready to start sending and receiving packets and give the driver
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index d5553c47014f..5d823e965883 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -74,7 +74,7 @@ static void pn533_recv_response(struct urb *urb)
74 struct sk_buff *skb = NULL; 74 struct sk_buff *skb = NULL;
75 75
76 if (!urb->status) { 76 if (!urb->status) {
77 skb = alloc_skb(urb->actual_length, GFP_KERNEL); 77 skb = alloc_skb(urb->actual_length, GFP_ATOMIC);
78 if (!skb) { 78 if (!skb) {
79 nfc_err(&phy->udev->dev, "failed to alloc memory\n"); 79 nfc_err(&phy->udev->dev, "failed to alloc memory\n");
80 } else { 80 } else {
@@ -186,7 +186,7 @@ static int pn533_usb_send_frame(struct pn533 *dev,
186 186
187 if (dev->protocol_type == PN533_PROTO_REQ_RESP) { 187 if (dev->protocol_type == PN533_PROTO_REQ_RESP) {
188 /* request for response for sent packet directly */ 188 /* request for response for sent packet directly */
189 rc = pn533_submit_urb_for_response(phy, GFP_ATOMIC); 189 rc = pn533_submit_urb_for_response(phy, GFP_KERNEL);
190 if (rc) 190 if (rc)
191 goto error; 191 goto error;
192 } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) { 192 } else if (dev->protocol_type == PN533_PROTO_REQ_ACK_RESP) {
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 68940356cad3..8b1fd7f1a224 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -414,7 +414,8 @@ static int pmem_attach_disk(struct device *dev,
414 blk_queue_logical_block_size(q, pmem_sector_size(ndns)); 414 blk_queue_logical_block_size(q, pmem_sector_size(ndns));
415 blk_queue_max_hw_sectors(q, UINT_MAX); 415 blk_queue_max_hw_sectors(q, UINT_MAX);
416 blk_queue_flag_set(QUEUE_FLAG_NONROT, q); 416 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
417 blk_queue_flag_set(QUEUE_FLAG_DAX, q); 417 if (pmem->pfn_flags & PFN_MAP)
418 blk_queue_flag_set(QUEUE_FLAG_DAX, q);
418 q->queuedata = pmem; 419 q->queuedata = pmem;
419 420
420 disk = alloc_disk_node(0, nid); 421 disk = alloc_disk_node(0, nid);
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 21710a7460c8..46df030b2c3f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1808,6 +1808,7 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
1808 u32 max_segments = 1808 u32 max_segments =
1809 (ctrl->max_hw_sectors / (ctrl->page_size >> 9)) + 1; 1809 (ctrl->max_hw_sectors / (ctrl->page_size >> 9)) + 1;
1810 1810
1811 max_segments = min_not_zero(max_segments, ctrl->max_segments);
1811 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); 1812 blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
1812 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX)); 1813 blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
1813 } 1814 }
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index b528a2f5826c..41d45a1b5c62 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -2790,6 +2790,9 @@ nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl)
2790 /* re-enable the admin_q so anything new can fast fail */ 2790 /* re-enable the admin_q so anything new can fast fail */
2791 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); 2791 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
2792 2792
2793 /* resume the io queues so that things will fast fail */
2794 nvme_start_queues(&ctrl->ctrl);
2795
2793 nvme_fc_ctlr_inactive_on_rport(ctrl); 2796 nvme_fc_ctlr_inactive_on_rport(ctrl);
2794} 2797}
2795 2798
@@ -2804,9 +2807,6 @@ nvme_fc_delete_ctrl(struct nvme_ctrl *nctrl)
2804 * waiting for io to terminate 2807 * waiting for io to terminate
2805 */ 2808 */
2806 nvme_fc_delete_association(ctrl); 2809 nvme_fc_delete_association(ctrl);
2807
2808 /* resume the io queues so that things will fast fail */
2809 nvme_start_queues(nctrl);
2810} 2810}
2811 2811
2812static void 2812static void
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 231807cbc849..0c4a33df3b2f 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -170,6 +170,7 @@ struct nvme_ctrl {
170 u64 cap; 170 u64 cap;
171 u32 page_size; 171 u32 page_size;
172 u32 max_hw_sectors; 172 u32 max_hw_sectors;
173 u32 max_segments;
173 u16 oncs; 174 u16 oncs;
174 u16 oacs; 175 u16 oacs;
175 u16 nssa; 176 u16 nssa;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index fc33804662e7..ba943f211687 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -38,6 +38,13 @@
38 38
39#define SGES_PER_PAGE (PAGE_SIZE / sizeof(struct nvme_sgl_desc)) 39#define SGES_PER_PAGE (PAGE_SIZE / sizeof(struct nvme_sgl_desc))
40 40
41/*
42 * These can be higher, but we need to ensure that any command doesn't
43 * require an sg allocation that needs more than a page of data.
44 */
45#define NVME_MAX_KB_SZ 4096
46#define NVME_MAX_SEGS 127
47
41static int use_threaded_interrupts; 48static int use_threaded_interrupts;
42module_param(use_threaded_interrupts, int, 0); 49module_param(use_threaded_interrupts, int, 0);
43 50
@@ -100,6 +107,8 @@ struct nvme_dev {
100 struct nvme_ctrl ctrl; 107 struct nvme_ctrl ctrl;
101 struct completion ioq_wait; 108 struct completion ioq_wait;
102 109
110 mempool_t *iod_mempool;
111
103 /* shadow doorbell buffer support: */ 112 /* shadow doorbell buffer support: */
104 u32 *dbbuf_dbs; 113 u32 *dbbuf_dbs;
105 dma_addr_t dbbuf_dbs_dma_addr; 114 dma_addr_t dbbuf_dbs_dma_addr;
@@ -477,10 +486,7 @@ static blk_status_t nvme_init_iod(struct request *rq, struct nvme_dev *dev)
477 iod->use_sgl = nvme_pci_use_sgls(dev, rq); 486 iod->use_sgl = nvme_pci_use_sgls(dev, rq);
478 487
479 if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) { 488 if (nseg > NVME_INT_PAGES || size > NVME_INT_BYTES(dev)) {
480 size_t alloc_size = nvme_pci_iod_alloc_size(dev, size, nseg, 489 iod->sg = mempool_alloc(dev->iod_mempool, GFP_ATOMIC);
481 iod->use_sgl);
482
483 iod->sg = kmalloc(alloc_size, GFP_ATOMIC);
484 if (!iod->sg) 490 if (!iod->sg)
485 return BLK_STS_RESOURCE; 491 return BLK_STS_RESOURCE;
486 } else { 492 } else {
@@ -526,7 +532,7 @@ static void nvme_free_iod(struct nvme_dev *dev, struct request *req)
526 } 532 }
527 533
528 if (iod->sg != iod->inline_sg) 534 if (iod->sg != iod->inline_sg)
529 kfree(iod->sg); 535 mempool_free(iod->sg, dev->iod_mempool);
530} 536}
531 537
532#ifdef CONFIG_BLK_DEV_INTEGRITY 538#ifdef CONFIG_BLK_DEV_INTEGRITY
@@ -2280,6 +2286,7 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
2280 blk_put_queue(dev->ctrl.admin_q); 2286 blk_put_queue(dev->ctrl.admin_q);
2281 kfree(dev->queues); 2287 kfree(dev->queues);
2282 free_opal_dev(dev->ctrl.opal_dev); 2288 free_opal_dev(dev->ctrl.opal_dev);
2289 mempool_destroy(dev->iod_mempool);
2283 kfree(dev); 2290 kfree(dev);
2284} 2291}
2285 2292
@@ -2289,6 +2296,7 @@ static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status)
2289 2296
2290 nvme_get_ctrl(&dev->ctrl); 2297 nvme_get_ctrl(&dev->ctrl);
2291 nvme_dev_disable(dev, false); 2298 nvme_dev_disable(dev, false);
2299 nvme_kill_queues(&dev->ctrl);
2292 if (!queue_work(nvme_wq, &dev->remove_work)) 2300 if (!queue_work(nvme_wq, &dev->remove_work))
2293 nvme_put_ctrl(&dev->ctrl); 2301 nvme_put_ctrl(&dev->ctrl);
2294} 2302}
@@ -2333,6 +2341,13 @@ static void nvme_reset_work(struct work_struct *work)
2333 if (result) 2341 if (result)
2334 goto out; 2342 goto out;
2335 2343
2344 /*
2345 * Limit the max command size to prevent iod->sg allocations going
2346 * over a single page.
2347 */
2348 dev->ctrl.max_hw_sectors = NVME_MAX_KB_SZ << 1;
2349 dev->ctrl.max_segments = NVME_MAX_SEGS;
2350
2336 result = nvme_init_identify(&dev->ctrl); 2351 result = nvme_init_identify(&dev->ctrl);
2337 if (result) 2352 if (result)
2338 goto out; 2353 goto out;
@@ -2405,7 +2420,6 @@ static void nvme_remove_dead_ctrl_work(struct work_struct *work)
2405 struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work); 2420 struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work);
2406 struct pci_dev *pdev = to_pci_dev(dev->dev); 2421 struct pci_dev *pdev = to_pci_dev(dev->dev);
2407 2422
2408 nvme_kill_queues(&dev->ctrl);
2409 if (pci_get_drvdata(pdev)) 2423 if (pci_get_drvdata(pdev))
2410 device_release_driver(&pdev->dev); 2424 device_release_driver(&pdev->dev);
2411 nvme_put_ctrl(&dev->ctrl); 2425 nvme_put_ctrl(&dev->ctrl);
@@ -2509,6 +2523,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2509 int node, result = -ENOMEM; 2523 int node, result = -ENOMEM;
2510 struct nvme_dev *dev; 2524 struct nvme_dev *dev;
2511 unsigned long quirks = id->driver_data; 2525 unsigned long quirks = id->driver_data;
2526 size_t alloc_size;
2512 2527
2513 node = dev_to_node(&pdev->dev); 2528 node = dev_to_node(&pdev->dev);
2514 if (node == NUMA_NO_NODE) 2529 if (node == NUMA_NO_NODE)
@@ -2546,6 +2561,23 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2546 if (result) 2561 if (result)
2547 goto release_pools; 2562 goto release_pools;
2548 2563
2564 /*
2565 * Double check that our mempool alloc size will cover the biggest
2566 * command we support.
2567 */
2568 alloc_size = nvme_pci_iod_alloc_size(dev, NVME_MAX_KB_SZ,
2569 NVME_MAX_SEGS, true);
2570 WARN_ON_ONCE(alloc_size > PAGE_SIZE);
2571
2572 dev->iod_mempool = mempool_create_node(1, mempool_kmalloc,
2573 mempool_kfree,
2574 (void *) alloc_size,
2575 GFP_KERNEL, node);
2576 if (!dev->iod_mempool) {
2577 result = -ENOMEM;
2578 goto release_pools;
2579 }
2580
2549 dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev)); 2581 dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
2550 2582
2551 nvme_get_ctrl(&dev->ctrl); 2583 nvme_get_ctrl(&dev->ctrl);
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index c9424da0d23e..518c5b09038c 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -560,12 +560,6 @@ static void nvme_rdma_free_queue(struct nvme_rdma_queue *queue)
560 if (!test_and_clear_bit(NVME_RDMA_Q_ALLOCATED, &queue->flags)) 560 if (!test_and_clear_bit(NVME_RDMA_Q_ALLOCATED, &queue->flags))
561 return; 561 return;
562 562
563 if (nvme_rdma_queue_idx(queue) == 0) {
564 nvme_rdma_free_qe(queue->device->dev,
565 &queue->ctrl->async_event_sqe,
566 sizeof(struct nvme_command), DMA_TO_DEVICE);
567 }
568
569 nvme_rdma_destroy_queue_ib(queue); 563 nvme_rdma_destroy_queue_ib(queue);
570 rdma_destroy_id(queue->cm_id); 564 rdma_destroy_id(queue->cm_id);
571} 565}
@@ -698,7 +692,7 @@ static struct blk_mq_tag_set *nvme_rdma_alloc_tagset(struct nvme_ctrl *nctrl,
698 set = &ctrl->tag_set; 692 set = &ctrl->tag_set;
699 memset(set, 0, sizeof(*set)); 693 memset(set, 0, sizeof(*set));
700 set->ops = &nvme_rdma_mq_ops; 694 set->ops = &nvme_rdma_mq_ops;
701 set->queue_depth = nctrl->opts->queue_size; 695 set->queue_depth = nctrl->sqsize + 1;
702 set->reserved_tags = 1; /* fabric connect */ 696 set->reserved_tags = 1; /* fabric connect */
703 set->numa_node = NUMA_NO_NODE; 697 set->numa_node = NUMA_NO_NODE;
704 set->flags = BLK_MQ_F_SHOULD_MERGE; 698 set->flags = BLK_MQ_F_SHOULD_MERGE;
@@ -734,11 +728,15 @@ out:
734static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl, 728static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
735 bool remove) 729 bool remove)
736{ 730{
737 nvme_rdma_stop_queue(&ctrl->queues[0]);
738 if (remove) { 731 if (remove) {
739 blk_cleanup_queue(ctrl->ctrl.admin_q); 732 blk_cleanup_queue(ctrl->ctrl.admin_q);
740 nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.admin_tagset); 733 nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.admin_tagset);
741 } 734 }
735 if (ctrl->async_event_sqe.data) {
736 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
737 sizeof(struct nvme_command), DMA_TO_DEVICE);
738 ctrl->async_event_sqe.data = NULL;
739 }
742 nvme_rdma_free_queue(&ctrl->queues[0]); 740 nvme_rdma_free_queue(&ctrl->queues[0]);
743} 741}
744 742
@@ -755,11 +753,16 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,
755 753
756 ctrl->max_fr_pages = nvme_rdma_get_max_fr_pages(ctrl->device->dev); 754 ctrl->max_fr_pages = nvme_rdma_get_max_fr_pages(ctrl->device->dev);
757 755
756 error = nvme_rdma_alloc_qe(ctrl->device->dev, &ctrl->async_event_sqe,
757 sizeof(struct nvme_command), DMA_TO_DEVICE);
758 if (error)
759 goto out_free_queue;
760
758 if (new) { 761 if (new) {
759 ctrl->ctrl.admin_tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, true); 762 ctrl->ctrl.admin_tagset = nvme_rdma_alloc_tagset(&ctrl->ctrl, true);
760 if (IS_ERR(ctrl->ctrl.admin_tagset)) { 763 if (IS_ERR(ctrl->ctrl.admin_tagset)) {
761 error = PTR_ERR(ctrl->ctrl.admin_tagset); 764 error = PTR_ERR(ctrl->ctrl.admin_tagset);
762 goto out_free_queue; 765 goto out_free_async_qe;
763 } 766 }
764 767
765 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set); 768 ctrl->ctrl.admin_q = blk_mq_init_queue(&ctrl->admin_tag_set);
@@ -795,12 +798,6 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,
795 if (error) 798 if (error)
796 goto out_stop_queue; 799 goto out_stop_queue;
797 800
798 error = nvme_rdma_alloc_qe(ctrl->queues[0].device->dev,
799 &ctrl->async_event_sqe, sizeof(struct nvme_command),
800 DMA_TO_DEVICE);
801 if (error)
802 goto out_stop_queue;
803
804 return 0; 801 return 0;
805 802
806out_stop_queue: 803out_stop_queue:
@@ -811,6 +808,9 @@ out_cleanup_queue:
811out_free_tagset: 808out_free_tagset:
812 if (new) 809 if (new)
813 nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.admin_tagset); 810 nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.admin_tagset);
811out_free_async_qe:
812 nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
813 sizeof(struct nvme_command), DMA_TO_DEVICE);
814out_free_queue: 814out_free_queue:
815 nvme_rdma_free_queue(&ctrl->queues[0]); 815 nvme_rdma_free_queue(&ctrl->queues[0]);
816 return error; 816 return error;
@@ -819,7 +819,6 @@ out_free_queue:
819static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl, 819static void nvme_rdma_destroy_io_queues(struct nvme_rdma_ctrl *ctrl,
820 bool remove) 820 bool remove)
821{ 821{
822 nvme_rdma_stop_io_queues(ctrl);
823 if (remove) { 822 if (remove) {
824 blk_cleanup_queue(ctrl->ctrl.connect_q); 823 blk_cleanup_queue(ctrl->ctrl.connect_q);
825 nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.tagset); 824 nvme_rdma_free_tagset(&ctrl->ctrl, ctrl->ctrl.tagset);
@@ -888,9 +887,9 @@ static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl)
888 list_del(&ctrl->list); 887 list_del(&ctrl->list);
889 mutex_unlock(&nvme_rdma_ctrl_mutex); 888 mutex_unlock(&nvme_rdma_ctrl_mutex);
890 889
891 kfree(ctrl->queues);
892 nvmf_free_options(nctrl->opts); 890 nvmf_free_options(nctrl->opts);
893free_ctrl: 891free_ctrl:
892 kfree(ctrl->queues);
894 kfree(ctrl); 893 kfree(ctrl);
895} 894}
896 895
@@ -949,6 +948,7 @@ static void nvme_rdma_reconnect_ctrl_work(struct work_struct *work)
949 return; 948 return;
950 949
951destroy_admin: 950destroy_admin:
951 nvme_rdma_stop_queue(&ctrl->queues[0]);
952 nvme_rdma_destroy_admin_queue(ctrl, false); 952 nvme_rdma_destroy_admin_queue(ctrl, false);
953requeue: 953requeue:
954 dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", 954 dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n",
@@ -965,12 +965,14 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work)
965 965
966 if (ctrl->ctrl.queue_count > 1) { 966 if (ctrl->ctrl.queue_count > 1) {
967 nvme_stop_queues(&ctrl->ctrl); 967 nvme_stop_queues(&ctrl->ctrl);
968 nvme_rdma_stop_io_queues(ctrl);
968 blk_mq_tagset_busy_iter(&ctrl->tag_set, 969 blk_mq_tagset_busy_iter(&ctrl->tag_set,
969 nvme_cancel_request, &ctrl->ctrl); 970 nvme_cancel_request, &ctrl->ctrl);
970 nvme_rdma_destroy_io_queues(ctrl, false); 971 nvme_rdma_destroy_io_queues(ctrl, false);
971 } 972 }
972 973
973 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); 974 blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
975 nvme_rdma_stop_queue(&ctrl->queues[0]);
974 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, 976 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
975 nvme_cancel_request, &ctrl->ctrl); 977 nvme_cancel_request, &ctrl->ctrl);
976 nvme_rdma_destroy_admin_queue(ctrl, false); 978 nvme_rdma_destroy_admin_queue(ctrl, false);
@@ -1736,6 +1738,7 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
1736{ 1738{
1737 if (ctrl->ctrl.queue_count > 1) { 1739 if (ctrl->ctrl.queue_count > 1) {
1738 nvme_stop_queues(&ctrl->ctrl); 1740 nvme_stop_queues(&ctrl->ctrl);
1741 nvme_rdma_stop_io_queues(ctrl);
1739 blk_mq_tagset_busy_iter(&ctrl->tag_set, 1742 blk_mq_tagset_busy_iter(&ctrl->tag_set,
1740 nvme_cancel_request, &ctrl->ctrl); 1743 nvme_cancel_request, &ctrl->ctrl);
1741 nvme_rdma_destroy_io_queues(ctrl, shutdown); 1744 nvme_rdma_destroy_io_queues(ctrl, shutdown);
@@ -1747,6 +1750,7 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
1747 nvme_disable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap); 1750 nvme_disable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap);
1748 1751
1749 blk_mq_quiesce_queue(ctrl->ctrl.admin_q); 1752 blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
1753 nvme_rdma_stop_queue(&ctrl->queues[0]);
1750 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set, 1754 blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
1751 nvme_cancel_request, &ctrl->ctrl); 1755 nvme_cancel_request, &ctrl->ctrl);
1752 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q); 1756 blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
@@ -1932,11 +1936,6 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
1932 goto out_free_ctrl; 1936 goto out_free_ctrl;
1933 } 1937 }
1934 1938
1935 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops,
1936 0 /* no quirks, we're perfect! */);
1937 if (ret)
1938 goto out_free_ctrl;
1939
1940 INIT_DELAYED_WORK(&ctrl->reconnect_work, 1939 INIT_DELAYED_WORK(&ctrl->reconnect_work,
1941 nvme_rdma_reconnect_ctrl_work); 1940 nvme_rdma_reconnect_ctrl_work);
1942 INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work); 1941 INIT_WORK(&ctrl->err_work, nvme_rdma_error_recovery_work);
@@ -1950,14 +1949,19 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
1950 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), 1949 ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues),
1951 GFP_KERNEL); 1950 GFP_KERNEL);
1952 if (!ctrl->queues) 1951 if (!ctrl->queues)
1953 goto out_uninit_ctrl; 1952 goto out_free_ctrl;
1953
1954 ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops,
1955 0 /* no quirks, we're perfect! */);
1956 if (ret)
1957 goto out_kfree_queues;
1954 1958
1955 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING); 1959 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING);
1956 WARN_ON_ONCE(!changed); 1960 WARN_ON_ONCE(!changed);
1957 1961
1958 ret = nvme_rdma_configure_admin_queue(ctrl, true); 1962 ret = nvme_rdma_configure_admin_queue(ctrl, true);
1959 if (ret) 1963 if (ret)
1960 goto out_kfree_queues; 1964 goto out_uninit_ctrl;
1961 1965
1962 /* sanity check icdoff */ 1966 /* sanity check icdoff */
1963 if (ctrl->ctrl.icdoff) { 1967 if (ctrl->ctrl.icdoff) {
@@ -1974,20 +1978,19 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
1974 goto out_remove_admin_queue; 1978 goto out_remove_admin_queue;
1975 } 1979 }
1976 1980
1977 if (opts->queue_size > ctrl->ctrl.maxcmd) { 1981 /* only warn if argument is too large here, will clamp later */
1978 /* warn if maxcmd is lower than queue_size */
1979 dev_warn(ctrl->ctrl.device,
1980 "queue_size %zu > ctrl maxcmd %u, clamping down\n",
1981 opts->queue_size, ctrl->ctrl.maxcmd);
1982 opts->queue_size = ctrl->ctrl.maxcmd;
1983 }
1984
1985 if (opts->queue_size > ctrl->ctrl.sqsize + 1) { 1982 if (opts->queue_size > ctrl->ctrl.sqsize + 1) {
1986 /* warn if sqsize is lower than queue_size */
1987 dev_warn(ctrl->ctrl.device, 1983 dev_warn(ctrl->ctrl.device,
1988 "queue_size %zu > ctrl sqsize %u, clamping down\n", 1984 "queue_size %zu > ctrl sqsize %u, clamping down\n",
1989 opts->queue_size, ctrl->ctrl.sqsize + 1); 1985 opts->queue_size, ctrl->ctrl.sqsize + 1);
1990 opts->queue_size = ctrl->ctrl.sqsize + 1; 1986 }
1987
1988 /* warn if maxcmd is lower than sqsize+1 */
1989 if (ctrl->ctrl.sqsize + 1 > ctrl->ctrl.maxcmd) {
1990 dev_warn(ctrl->ctrl.device,
1991 "sqsize %u > ctrl maxcmd %u, clamping down\n",
1992 ctrl->ctrl.sqsize + 1, ctrl->ctrl.maxcmd);
1993 ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1;
1991 } 1994 }
1992 1995
1993 if (opts->nr_io_queues) { 1996 if (opts->nr_io_queues) {
@@ -2013,15 +2016,16 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
2013 return &ctrl->ctrl; 2016 return &ctrl->ctrl;
2014 2017
2015out_remove_admin_queue: 2018out_remove_admin_queue:
2019 nvme_rdma_stop_queue(&ctrl->queues[0]);
2016 nvme_rdma_destroy_admin_queue(ctrl, true); 2020 nvme_rdma_destroy_admin_queue(ctrl, true);
2017out_kfree_queues:
2018 kfree(ctrl->queues);
2019out_uninit_ctrl: 2021out_uninit_ctrl:
2020 nvme_uninit_ctrl(&ctrl->ctrl); 2022 nvme_uninit_ctrl(&ctrl->ctrl);
2021 nvme_put_ctrl(&ctrl->ctrl); 2023 nvme_put_ctrl(&ctrl->ctrl);
2022 if (ret > 0) 2024 if (ret > 0)
2023 ret = -EIO; 2025 ret = -EIO;
2024 return ERR_PTR(ret); 2026 return ERR_PTR(ret);
2027out_kfree_queues:
2028 kfree(ctrl->queues);
2025out_free_ctrl: 2029out_free_ctrl:
2026 kfree(ctrl); 2030 kfree(ctrl);
2027 return ERR_PTR(ret); 2031 return ERR_PTR(ret);
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index a03da764ecae..74d4b785d2da 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -686,6 +686,14 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
686 } 686 }
687 687
688 ctrl->csts = NVME_CSTS_RDY; 688 ctrl->csts = NVME_CSTS_RDY;
689
690 /*
691 * Controllers that are not yet enabled should not really enforce the
692 * keep alive timeout, but we still want to track a timeout and cleanup
693 * in case a host died before it enabled the controller. Hence, simply
694 * reset the keep alive timer when the controller is enabled.
695 */
696 mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ);
689} 697}
690 698
691static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl) 699static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index ab2f3fead6b1..31ff03dbeb83 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -598,7 +598,7 @@ static int _generic_set_opp_regulator(const struct opp_table *opp_table,
598 } 598 }
599 599
600 /* Scaling up? Scale voltage before frequency */ 600 /* Scaling up? Scale voltage before frequency */
601 if (freq > old_freq) { 601 if (freq >= old_freq) {
602 ret = _set_opp_voltage(dev, reg, new_supply); 602 ret = _set_opp_voltage(dev, reg, new_supply);
603 if (ret) 603 if (ret)
604 goto restore_voltage; 604 goto restore_voltage;
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 535201984b8b..1b2cfe51e8d7 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -28,10 +28,10 @@ obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o
28obj-$(CONFIG_PCI_ECAM) += ecam.o 28obj-$(CONFIG_PCI_ECAM) += ecam.o
29obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o 29obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
30 30
31obj-y += controller/
32obj-y += switch/
33
34# Endpoint library must be initialized before its users 31# Endpoint library must be initialized before its users
35obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ 32obj-$(CONFIG_PCI_ENDPOINT) += endpoint/
36 33
34obj-y += controller/
35obj-y += switch/
36
37ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG 37ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 18fa09b3ac8f..cc9fa02d32a0 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -96,7 +96,6 @@ config PCI_HOST_GENERIC
96 depends on OF 96 depends on OF
97 select PCI_HOST_COMMON 97 select PCI_HOST_COMMON
98 select IRQ_DOMAIN 98 select IRQ_DOMAIN
99 select PCI_DOMAINS
100 help 99 help
101 Say Y here if you want to support a simple generic PCI host 100 Say Y here if you want to support a simple generic PCI host
102 controller, such as the one emulated by kvmtool. 101 controller, such as the one emulated by kvmtool.
@@ -138,7 +137,6 @@ config PCI_VERSATILE
138 137
139config PCIE_IPROC 138config PCIE_IPROC
140 tristate 139 tristate
141 select PCI_DOMAINS
142 help 140 help
143 This enables the iProc PCIe core controller support for Broadcom's 141 This enables the iProc PCIe core controller support for Broadcom's
144 iProc family of SoCs. An appropriate bus interface driver needs 142 iProc family of SoCs. An appropriate bus interface driver needs
@@ -176,7 +174,6 @@ config PCIE_IPROC_MSI
176config PCIE_ALTERA 174config PCIE_ALTERA
177 bool "Altera PCIe controller" 175 bool "Altera PCIe controller"
178 depends on ARM || NIOS2 || COMPILE_TEST 176 depends on ARM || NIOS2 || COMPILE_TEST
179 select PCI_DOMAINS
180 help 177 help
181 Say Y here if you want to enable PCIe controller support on Altera 178 Say Y here if you want to enable PCIe controller support on Altera
182 FPGA. 179 FPGA.
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 3979f89b250a..5bd6c1573295 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -7,7 +7,6 @@
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Send feedback to <kristen.c.accardi@intel.com> 9 * Send feedback to <kristen.c.accardi@intel.com>
10 *
11 */ 10 */
12 11
13#include <linux/module.h> 12#include <linux/module.h>
@@ -87,8 +86,17 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev)
87 return 0; 86 return 0;
88 87
89 /* If _OSC exists, we should not evaluate OSHP */ 88 /* If _OSC exists, we should not evaluate OSHP */
89
90 /*
91 * If there's no ACPI host bridge (i.e., ACPI support is compiled
92 * into the kernel but the hardware platform doesn't support ACPI),
93 * there's nothing to do here.
94 */
90 host = pci_find_host_bridge(pdev->bus); 95 host = pci_find_host_bridge(pdev->bus);
91 root = acpi_pci_find_root(ACPI_HANDLE(&host->dev)); 96 root = acpi_pci_find_root(ACPI_HANDLE(&host->dev));
97 if (!root)
98 return 0;
99
92 if (root->osc_support_set) 100 if (root->osc_support_set)
93 goto no_control; 101 goto no_control;
94 102
diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
index 6bdb1dad805f..0e31f1392a53 100644
--- a/drivers/perf/xgene_pmu.c
+++ b/drivers/perf/xgene_pmu.c
@@ -1463,7 +1463,7 @@ static char *xgene_pmu_dev_name(struct device *dev, u32 type, int id)
1463 case PMU_TYPE_IOB: 1463 case PMU_TYPE_IOB:
1464 return devm_kasprintf(dev, GFP_KERNEL, "iob%d", id); 1464 return devm_kasprintf(dev, GFP_KERNEL, "iob%d", id);
1465 case PMU_TYPE_IOB_SLOW: 1465 case PMU_TYPE_IOB_SLOW:
1466 return devm_kasprintf(dev, GFP_KERNEL, "iob-slow%d", id); 1466 return devm_kasprintf(dev, GFP_KERNEL, "iob_slow%d", id);
1467 case PMU_TYPE_MCB: 1467 case PMU_TYPE_MCB:
1468 return devm_kasprintf(dev, GFP_KERNEL, "mcb%d", id); 1468 return devm_kasprintf(dev, GFP_KERNEL, "mcb%d", id);
1469 case PMU_TYPE_MC: 1469 case PMU_TYPE_MC:
diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c
index 76243caa08c6..b5c880b50bb3 100644
--- a/drivers/pinctrl/actions/pinctrl-owl.c
+++ b/drivers/pinctrl/actions/pinctrl-owl.c
@@ -333,7 +333,7 @@ static int owl_pin_config_set(struct pinctrl_dev *pctrldev,
333 unsigned long flags; 333 unsigned long flags;
334 unsigned int param; 334 unsigned int param;
335 u32 reg, bit, width, arg; 335 u32 reg, bit, width, arg;
336 int ret, i; 336 int ret = 0, i;
337 337
338 info = &pctrl->soc->padinfo[pin]; 338 info = &pctrl->soc->padinfo[pin];
339 339
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index b601039d6c69..c4aa411f5935 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -101,10 +101,11 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
101} 101}
102 102
103static int dt_to_map_one_config(struct pinctrl *p, 103static int dt_to_map_one_config(struct pinctrl *p,
104 struct pinctrl_dev *pctldev, 104 struct pinctrl_dev *hog_pctldev,
105 const char *statename, 105 const char *statename,
106 struct device_node *np_config) 106 struct device_node *np_config)
107{ 107{
108 struct pinctrl_dev *pctldev = NULL;
108 struct device_node *np_pctldev; 109 struct device_node *np_pctldev;
109 const struct pinctrl_ops *ops; 110 const struct pinctrl_ops *ops;
110 int ret; 111 int ret;
@@ -123,8 +124,10 @@ static int dt_to_map_one_config(struct pinctrl *p,
123 return -EPROBE_DEFER; 124 return -EPROBE_DEFER;
124 } 125 }
125 /* If we're creating a hog we can use the passed pctldev */ 126 /* If we're creating a hog we can use the passed pctldev */
126 if (pctldev && (np_pctldev == p->dev->of_node)) 127 if (hog_pctldev && (np_pctldev == p->dev->of_node)) {
128 pctldev = hog_pctldev;
127 break; 129 break;
130 }
128 pctldev = get_pinctrl_dev_from_of_node(np_pctldev); 131 pctldev = get_pinctrl_dev_from_of_node(np_pctldev);
129 if (pctldev) 132 if (pctldev)
130 break; 133 break;
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
index ad6da1184c9f..e3f1ab2290fc 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
@@ -1459,6 +1459,9 @@ static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
1459 struct mtk_pinctrl *hw = gpiochip_get_data(chip); 1459 struct mtk_pinctrl *hw = gpiochip_get_data(chip);
1460 unsigned long eint_n; 1460 unsigned long eint_n;
1461 1461
1462 if (!hw->eint)
1463 return -ENOTSUPP;
1464
1462 eint_n = offset; 1465 eint_n = offset;
1463 1466
1464 return mtk_eint_find_irq(hw->eint, eint_n); 1467 return mtk_eint_find_irq(hw->eint, eint_n);
@@ -1471,7 +1474,8 @@ static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
1471 unsigned long eint_n; 1474 unsigned long eint_n;
1472 u32 debounce; 1475 u32 debounce;
1473 1476
1474 if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE) 1477 if (!hw->eint ||
1478 pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
1475 return -ENOTSUPP; 1479 return -ENOTSUPP;
1476 1480
1477 debounce = pinconf_to_config_argument(config); 1481 debounce = pinconf_to_config_argument(config);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index b3799695d8db..16ff56f93501 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -1000,11 +1000,6 @@ static int mtk_eint_init(struct mtk_pinctrl *pctl, struct platform_device *pdev)
1000 return -ENOMEM; 1000 return -ENOMEM;
1001 1001
1002 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1002 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1003 if (!res) {
1004 dev_err(&pdev->dev, "Unable to get eint resource\n");
1005 return -ENODEV;
1006 }
1007
1008 pctl->eint->base = devm_ioremap_resource(&pdev->dev, res); 1003 pctl->eint->base = devm_ioremap_resource(&pdev->dev, res);
1009 if (IS_ERR(pctl->eint->base)) 1004 if (IS_ERR(pctl->eint->base))
1010 return PTR_ERR(pctl->eint->base); 1005 return PTR_ERR(pctl->eint->base);
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index b3153c095199..e5647dac0818 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1590,8 +1590,11 @@ static int pcs_save_context(struct pcs_device *pcs)
1590 1590
1591 mux_bytes = pcs->width / BITS_PER_BYTE; 1591 mux_bytes = pcs->width / BITS_PER_BYTE;
1592 1592
1593 if (!pcs->saved_vals) 1593 if (!pcs->saved_vals) {
1594 pcs->saved_vals = devm_kzalloc(pcs->dev, pcs->size, GFP_ATOMIC); 1594 pcs->saved_vals = devm_kzalloc(pcs->dev, pcs->size, GFP_ATOMIC);
1595 if (!pcs->saved_vals)
1596 return -ENOMEM;
1597 }
1595 1598
1596 switch (pcs->width) { 1599 switch (pcs->width) {
1597 case 64: 1600 case 64:
@@ -1651,8 +1654,13 @@ static int pinctrl_single_suspend(struct platform_device *pdev,
1651 if (!pcs) 1654 if (!pcs)
1652 return -EINVAL; 1655 return -EINVAL;
1653 1656
1654 if (pcs->flags & PCS_CONTEXT_LOSS_OFF) 1657 if (pcs->flags & PCS_CONTEXT_LOSS_OFF) {
1655 pcs_save_context(pcs); 1658 int ret;
1659
1660 ret = pcs_save_context(pcs);
1661 if (ret < 0)
1662 return ret;
1663 }
1656 1664
1657 return pinctrl_force_sleep(pcs->pctl); 1665 return pinctrl_force_sleep(pcs->pctl);
1658} 1666}
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 767c485af59b..547dbdac9d54 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -221,7 +221,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
221 } 221 }
222 pct = &sysoff->ts[0]; 222 pct = &sysoff->ts[0];
223 for (i = 0; i < sysoff->n_samples; i++) { 223 for (i = 0; i < sysoff->n_samples; i++) {
224 getnstimeofday64(&ts); 224 ktime_get_real_ts64(&ts);
225 pct->sec = ts.tv_sec; 225 pct->sec = ts.tv_sec;
226 pct->nsec = ts.tv_nsec; 226 pct->nsec = ts.tv_nsec;
227 pct++; 227 pct++;
@@ -230,7 +230,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
230 pct->nsec = ts.tv_nsec; 230 pct->nsec = ts.tv_nsec;
231 pct++; 231 pct++;
232 } 232 }
233 getnstimeofday64(&ts); 233 ktime_get_real_ts64(&ts);
234 pct->sec = ts.tv_sec; 234 pct->sec = ts.tv_sec;
235 pct->nsec = ts.tv_nsec; 235 pct->nsec = ts.tv_nsec;
236 if (copy_to_user((void __user *)arg, sysoff, sizeof(*sysoff))) 236 if (copy_to_user((void __user *)arg, sysoff, sizeof(*sysoff)))
diff --git a/drivers/ptp/ptp_qoriq.c b/drivers/ptp/ptp_qoriq.c
index 1468a1642b49..e8652c148c52 100644
--- a/drivers/ptp/ptp_qoriq.c
+++ b/drivers/ptp/ptp_qoriq.c
@@ -374,7 +374,7 @@ static int qoriq_ptp_probe(struct platform_device *dev)
374 pr_err("ioremap ptp registers failed\n"); 374 pr_err("ioremap ptp registers failed\n");
375 goto no_ioremap; 375 goto no_ioremap;
376 } 376 }
377 getnstimeofday64(&now); 377 ktime_get_real_ts64(&now);
378 ptp_qoriq_settime(&qoriq_ptp->caps, &now); 378 ptp_qoriq_settime(&qoriq_ptp->caps, &now);
379 379
380 tmr_ctrl = 380 tmr_ctrl =
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 73cce3ecb97f..d3a38c421503 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1222,80 +1222,37 @@ static void dasd_hosts_init(struct dentry *base_dentry,
1222 device->hosts_dentry = pde; 1222 device->hosts_dentry = pde;
1223} 1223}
1224 1224
1225/* 1225struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize,
1226 * Allocate memory for a channel program with 'cplength' channel 1226 struct dasd_device *device,
1227 * command words and 'datasize' additional space. There are two 1227 struct dasd_ccw_req *cqr)
1228 * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed
1229 * memory and 2) dasd_smalloc_request uses the static ccw memory
1230 * that gets allocated for each device.
1231 */
1232struct dasd_ccw_req *dasd_kmalloc_request(int magic, int cplength,
1233 int datasize,
1234 struct dasd_device *device)
1235{
1236 struct dasd_ccw_req *cqr;
1237
1238 /* Sanity checks */
1239 BUG_ON(datasize > PAGE_SIZE ||
1240 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
1241
1242 cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
1243 if (cqr == NULL)
1244 return ERR_PTR(-ENOMEM);
1245 cqr->cpaddr = NULL;
1246 if (cplength > 0) {
1247 cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
1248 GFP_ATOMIC | GFP_DMA);
1249 if (cqr->cpaddr == NULL) {
1250 kfree(cqr);
1251 return ERR_PTR(-ENOMEM);
1252 }
1253 }
1254 cqr->data = NULL;
1255 if (datasize > 0) {
1256 cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
1257 if (cqr->data == NULL) {
1258 kfree(cqr->cpaddr);
1259 kfree(cqr);
1260 return ERR_PTR(-ENOMEM);
1261 }
1262 }
1263 cqr->magic = magic;
1264 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1265 dasd_get_device(device);
1266 return cqr;
1267}
1268EXPORT_SYMBOL(dasd_kmalloc_request);
1269
1270struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength,
1271 int datasize,
1272 struct dasd_device *device)
1273{ 1228{
1274 unsigned long flags; 1229 unsigned long flags;
1275 struct dasd_ccw_req *cqr; 1230 char *data, *chunk;
1276 char *data; 1231 int size = 0;
1277 int size;
1278 1232
1279 size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
1280 if (cplength > 0) 1233 if (cplength > 0)
1281 size += cplength * sizeof(struct ccw1); 1234 size += cplength * sizeof(struct ccw1);
1282 if (datasize > 0) 1235 if (datasize > 0)
1283 size += datasize; 1236 size += datasize;
1237 if (!cqr)
1238 size += (sizeof(*cqr) + 7L) & -8L;
1239
1284 spin_lock_irqsave(&device->mem_lock, flags); 1240 spin_lock_irqsave(&device->mem_lock, flags);
1285 cqr = (struct dasd_ccw_req *) 1241 data = chunk = dasd_alloc_chunk(&device->ccw_chunks, size);
1286 dasd_alloc_chunk(&device->ccw_chunks, size);
1287 spin_unlock_irqrestore(&device->mem_lock, flags); 1242 spin_unlock_irqrestore(&device->mem_lock, flags);
1288 if (cqr == NULL) 1243 if (!chunk)
1289 return ERR_PTR(-ENOMEM); 1244 return ERR_PTR(-ENOMEM);
1290 memset(cqr, 0, sizeof(struct dasd_ccw_req)); 1245 if (!cqr) {
1291 data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L); 1246 cqr = (void *) data;
1292 cqr->cpaddr = NULL; 1247 data += (sizeof(*cqr) + 7L) & -8L;
1248 }
1249 memset(cqr, 0, sizeof(*cqr));
1250 cqr->mem_chunk = chunk;
1293 if (cplength > 0) { 1251 if (cplength > 0) {
1294 cqr->cpaddr = (struct ccw1 *) data; 1252 cqr->cpaddr = data;
1295 data += cplength*sizeof(struct ccw1); 1253 data += cplength * sizeof(struct ccw1);
1296 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1)); 1254 memset(cqr->cpaddr, 0, cplength * sizeof(struct ccw1));
1297 } 1255 }
1298 cqr->data = NULL;
1299 if (datasize > 0) { 1256 if (datasize > 0) {
1300 cqr->data = data; 1257 cqr->data = data;
1301 memset(cqr->data, 0, datasize); 1258 memset(cqr->data, 0, datasize);
@@ -1307,33 +1264,12 @@ struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength,
1307} 1264}
1308EXPORT_SYMBOL(dasd_smalloc_request); 1265EXPORT_SYMBOL(dasd_smalloc_request);
1309 1266
1310/*
1311 * Free memory of a channel program. This function needs to free all the
1312 * idal lists that might have been created by dasd_set_cda and the
1313 * struct dasd_ccw_req itself.
1314 */
1315void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
1316{
1317 struct ccw1 *ccw;
1318
1319 /* Clear any idals used for the request. */
1320 ccw = cqr->cpaddr;
1321 do {
1322 clear_normalized_cda(ccw);
1323 } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
1324 kfree(cqr->cpaddr);
1325 kfree(cqr->data);
1326 kfree(cqr);
1327 dasd_put_device(device);
1328}
1329EXPORT_SYMBOL(dasd_kfree_request);
1330
1331void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) 1267void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
1332{ 1268{
1333 unsigned long flags; 1269 unsigned long flags;
1334 1270
1335 spin_lock_irqsave(&device->mem_lock, flags); 1271 spin_lock_irqsave(&device->mem_lock, flags);
1336 dasd_free_chunk(&device->ccw_chunks, cqr); 1272 dasd_free_chunk(&device->ccw_chunks, cqr->mem_chunk);
1337 spin_unlock_irqrestore(&device->mem_lock, flags); 1273 spin_unlock_irqrestore(&device->mem_lock, flags);
1338 dasd_put_device(device); 1274 dasd_put_device(device);
1339} 1275}
@@ -1885,6 +1821,33 @@ static void __dasd_device_process_ccw_queue(struct dasd_device *device,
1885 } 1821 }
1886} 1822}
1887 1823
1824static void __dasd_process_cqr(struct dasd_device *device,
1825 struct dasd_ccw_req *cqr)
1826{
1827 char errorstring[ERRORLENGTH];
1828
1829 switch (cqr->status) {
1830 case DASD_CQR_SUCCESS:
1831 cqr->status = DASD_CQR_DONE;
1832 break;
1833 case DASD_CQR_ERROR:
1834 cqr->status = DASD_CQR_NEED_ERP;
1835 break;
1836 case DASD_CQR_CLEARED:
1837 cqr->status = DASD_CQR_TERMINATED;
1838 break;
1839 default:
1840 /* internal error 12 - wrong cqr status*/
1841 snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status);
1842 dev_err(&device->cdev->dev,
1843 "An error occurred in the DASD device driver, "
1844 "reason=%s\n", errorstring);
1845 BUG();
1846 }
1847 if (cqr->callback)
1848 cqr->callback(cqr, cqr->callback_data);
1849}
1850
1888/* 1851/*
1889 * the cqrs from the final queue are returned to the upper layer 1852 * the cqrs from the final queue are returned to the upper layer
1890 * by setting a dasd_block state and calling the callback function 1853 * by setting a dasd_block state and calling the callback function
@@ -1895,40 +1858,18 @@ static void __dasd_device_process_final_queue(struct dasd_device *device,
1895 struct list_head *l, *n; 1858 struct list_head *l, *n;
1896 struct dasd_ccw_req *cqr; 1859 struct dasd_ccw_req *cqr;
1897 struct dasd_block *block; 1860 struct dasd_block *block;
1898 void (*callback)(struct dasd_ccw_req *, void *data);
1899 void *callback_data;
1900 char errorstring[ERRORLENGTH];
1901 1861
1902 list_for_each_safe(l, n, final_queue) { 1862 list_for_each_safe(l, n, final_queue) {
1903 cqr = list_entry(l, struct dasd_ccw_req, devlist); 1863 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1904 list_del_init(&cqr->devlist); 1864 list_del_init(&cqr->devlist);
1905 block = cqr->block; 1865 block = cqr->block;
1906 callback = cqr->callback; 1866 if (!block) {
1907 callback_data = cqr->callback_data; 1867 __dasd_process_cqr(device, cqr);
1908 if (block) 1868 } else {
1909 spin_lock_bh(&block->queue_lock); 1869 spin_lock_bh(&block->queue_lock);
1910 switch (cqr->status) { 1870 __dasd_process_cqr(device, cqr);
1911 case DASD_CQR_SUCCESS:
1912 cqr->status = DASD_CQR_DONE;
1913 break;
1914 case DASD_CQR_ERROR:
1915 cqr->status = DASD_CQR_NEED_ERP;
1916 break;
1917 case DASD_CQR_CLEARED:
1918 cqr->status = DASD_CQR_TERMINATED;
1919 break;
1920 default:
1921 /* internal error 12 - wrong cqr status*/
1922 snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status);
1923 dev_err(&device->cdev->dev,
1924 "An error occurred in the DASD device driver, "
1925 "reason=%s\n", errorstring);
1926 BUG();
1927 }
1928 if (cqr->callback != NULL)
1929 (callback)(cqr, callback_data);
1930 if (block)
1931 spin_unlock_bh(&block->queue_lock); 1871 spin_unlock_bh(&block->queue_lock);
1872 }
1932 } 1873 }
1933} 1874}
1934 1875
@@ -3041,7 +2982,6 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx,
3041 cqr->callback_data = req; 2982 cqr->callback_data = req;
3042 cqr->status = DASD_CQR_FILLED; 2983 cqr->status = DASD_CQR_FILLED;
3043 cqr->dq = dq; 2984 cqr->dq = dq;
3044 *((struct dasd_ccw_req **) blk_mq_rq_to_pdu(req)) = cqr;
3045 2985
3046 blk_mq_start_request(req); 2986 blk_mq_start_request(req);
3047 spin_lock(&block->queue_lock); 2987 spin_lock(&block->queue_lock);
@@ -3072,7 +3012,7 @@ enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved)
3072 unsigned long flags; 3012 unsigned long flags;
3073 int rc = 0; 3013 int rc = 0;
3074 3014
3075 cqr = *((struct dasd_ccw_req **) blk_mq_rq_to_pdu(req)); 3015 cqr = blk_mq_rq_to_pdu(req);
3076 if (!cqr) 3016 if (!cqr)
3077 return BLK_EH_DONE; 3017 return BLK_EH_DONE;
3078 3018
@@ -3174,7 +3114,7 @@ static int dasd_alloc_queue(struct dasd_block *block)
3174 int rc; 3114 int rc;
3175 3115
3176 block->tag_set.ops = &dasd_mq_ops; 3116 block->tag_set.ops = &dasd_mq_ops;
3177 block->tag_set.cmd_size = sizeof(struct dasd_ccw_req *); 3117 block->tag_set.cmd_size = sizeof(struct dasd_ccw_req);
3178 block->tag_set.nr_hw_queues = DASD_NR_HW_QUEUES; 3118 block->tag_set.nr_hw_queues = DASD_NR_HW_QUEUES;
3179 block->tag_set.queue_depth = DASD_MAX_LCU_DEV * DASD_REQ_PER_DEV; 3119 block->tag_set.queue_depth = DASD_MAX_LCU_DEV * DASD_REQ_PER_DEV;
3180 block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; 3120 block->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
@@ -4038,7 +3978,8 @@ static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device,
4038 struct ccw1 *ccw; 3978 struct ccw1 *ccw;
4039 unsigned long *idaw; 3979 unsigned long *idaw;
4040 3980
4041 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device); 3981 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device,
3982 NULL);
4042 3983
4043 if (IS_ERR(cqr)) { 3984 if (IS_ERR(cqr)) {
4044 /* internal error 13 - Allocating the RDC request failed*/ 3985 /* internal error 13 - Allocating the RDC request failed*/
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 5e963fe0e38d..e36a114354fc 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -407,9 +407,9 @@ static int read_unit_address_configuration(struct dasd_device *device,
407 int rc; 407 int rc;
408 unsigned long flags; 408 unsigned long flags;
409 409
410 cqr = dasd_kmalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 410 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
411 (sizeof(struct dasd_psf_prssd_data)), 411 (sizeof(struct dasd_psf_prssd_data)),
412 device); 412 device, NULL);
413 if (IS_ERR(cqr)) 413 if (IS_ERR(cqr))
414 return PTR_ERR(cqr); 414 return PTR_ERR(cqr);
415 cqr->startdev = device; 415 cqr->startdev = device;
@@ -457,7 +457,7 @@ static int read_unit_address_configuration(struct dasd_device *device,
457 lcu->flags |= NEED_UAC_UPDATE; 457 lcu->flags |= NEED_UAC_UPDATE;
458 spin_unlock_irqrestore(&lcu->lock, flags); 458 spin_unlock_irqrestore(&lcu->lock, flags);
459 } 459 }
460 dasd_kfree_request(cqr, cqr->memdev); 460 dasd_sfree_request(cqr, cqr->memdev);
461 return rc; 461 return rc;
462} 462}
463 463
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index 131f1989f6f3..e1fe02477ea8 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -536,7 +536,8 @@ static struct dasd_ccw_req *dasd_diag_build_cp(struct dasd_device *memdev,
536 /* Build the request */ 536 /* Build the request */
537 datasize = sizeof(struct dasd_diag_req) + 537 datasize = sizeof(struct dasd_diag_req) +
538 count*sizeof(struct dasd_diag_bio); 538 count*sizeof(struct dasd_diag_bio);
539 cqr = dasd_smalloc_request(DASD_DIAG_MAGIC, 0, datasize, memdev); 539 cqr = dasd_smalloc_request(DASD_DIAG_MAGIC, 0, datasize, memdev,
540 blk_mq_rq_to_pdu(req));
540 if (IS_ERR(cqr)) 541 if (IS_ERR(cqr))
541 return cqr; 542 return cqr;
542 543
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index be208e7adcb4..bbf95b78ef5d 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -886,7 +886,7 @@ static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
886 } 886 }
887 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* RCD */, 887 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* RCD */,
888 0, /* use rcd_buf as data ara */ 888 0, /* use rcd_buf as data ara */
889 device); 889 device, NULL);
890 if (IS_ERR(cqr)) { 890 if (IS_ERR(cqr)) {
891 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 891 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
892 "Could not allocate RCD request"); 892 "Could not allocate RCD request");
@@ -1442,7 +1442,7 @@ static int dasd_eckd_read_features(struct dasd_device *device)
1442 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 1442 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
1443 (sizeof(struct dasd_psf_prssd_data) + 1443 (sizeof(struct dasd_psf_prssd_data) +
1444 sizeof(struct dasd_rssd_features)), 1444 sizeof(struct dasd_rssd_features)),
1445 device); 1445 device, NULL);
1446 if (IS_ERR(cqr)) { 1446 if (IS_ERR(cqr)) {
1447 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", "Could not " 1447 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", "Could not "
1448 "allocate initialization request"); 1448 "allocate initialization request");
@@ -1504,7 +1504,7 @@ static struct dasd_ccw_req *dasd_eckd_build_psf_ssc(struct dasd_device *device,
1504 1504
1505 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ , 1505 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ ,
1506 sizeof(struct dasd_psf_ssc_data), 1506 sizeof(struct dasd_psf_ssc_data),
1507 device); 1507 device, NULL);
1508 1508
1509 if (IS_ERR(cqr)) { 1509 if (IS_ERR(cqr)) {
1510 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1510 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
@@ -1815,7 +1815,8 @@ dasd_eckd_analysis_ccw(struct dasd_device *device)
1815 1815
1816 cplength = 8; 1816 cplength = 8;
1817 datasize = sizeof(struct DE_eckd_data) + 2*sizeof(struct LO_eckd_data); 1817 datasize = sizeof(struct DE_eckd_data) + 2*sizeof(struct LO_eckd_data);
1818 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize, device); 1818 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize, device,
1819 NULL);
1819 if (IS_ERR(cqr)) 1820 if (IS_ERR(cqr))
1820 return cqr; 1821 return cqr;
1821 ccw = cqr->cpaddr; 1822 ccw = cqr->cpaddr;
@@ -2092,7 +2093,8 @@ dasd_eckd_build_check_tcw(struct dasd_device *base, struct format_data_t *fdata,
2092 */ 2093 */
2093 itcw_size = itcw_calc_size(0, count, 0); 2094 itcw_size = itcw_calc_size(0, count, 0);
2094 2095
2095 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 0, itcw_size, startdev); 2096 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 0, itcw_size, startdev,
2097 NULL);
2096 if (IS_ERR(cqr)) 2098 if (IS_ERR(cqr))
2097 return cqr; 2099 return cqr;
2098 2100
@@ -2186,7 +2188,7 @@ dasd_eckd_build_check(struct dasd_device *base, struct format_data_t *fdata,
2186 cplength += count; 2188 cplength += count;
2187 2189
2188 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize, 2190 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize,
2189 startdev); 2191 startdev, NULL);
2190 if (IS_ERR(cqr)) 2192 if (IS_ERR(cqr))
2191 return cqr; 2193 return cqr;
2192 2194
@@ -2332,7 +2334,7 @@ dasd_eckd_build_format(struct dasd_device *base,
2332 } 2334 }
2333 /* Allocate the format ccw request. */ 2335 /* Allocate the format ccw request. */
2334 fcp = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, 2336 fcp = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength,
2335 datasize, startdev); 2337 datasize, startdev, NULL);
2336 if (IS_ERR(fcp)) 2338 if (IS_ERR(fcp))
2337 return fcp; 2339 return fcp;
2338 2340
@@ -3103,7 +3105,7 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_cmd_single(
3103 } 3105 }
3104 /* Allocate the ccw request. */ 3106 /* Allocate the ccw request. */
3105 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize, 3107 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize,
3106 startdev); 3108 startdev, blk_mq_rq_to_pdu(req));
3107 if (IS_ERR(cqr)) 3109 if (IS_ERR(cqr))
3108 return cqr; 3110 return cqr;
3109 ccw = cqr->cpaddr; 3111 ccw = cqr->cpaddr;
@@ -3262,7 +3264,7 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_cmd_track(
3262 3264
3263 /* Allocate the ccw request. */ 3265 /* Allocate the ccw request. */
3264 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize, 3266 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize,
3265 startdev); 3267 startdev, blk_mq_rq_to_pdu(req));
3266 if (IS_ERR(cqr)) 3268 if (IS_ERR(cqr))
3267 return cqr; 3269 return cqr;
3268 ccw = cqr->cpaddr; 3270 ccw = cqr->cpaddr;
@@ -3595,7 +3597,8 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
3595 3597
3596 /* Allocate the ccw request. */ 3598 /* Allocate the ccw request. */
3597 itcw_size = itcw_calc_size(0, ctidaw, 0); 3599 itcw_size = itcw_calc_size(0, ctidaw, 0);
3598 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 0, itcw_size, startdev); 3600 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 0, itcw_size, startdev,
3601 blk_mq_rq_to_pdu(req));
3599 if (IS_ERR(cqr)) 3602 if (IS_ERR(cqr))
3600 return cqr; 3603 return cqr;
3601 3604
@@ -3862,7 +3865,7 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_raw(struct dasd_device *startdev,
3862 3865
3863 /* Allocate the ccw request. */ 3866 /* Allocate the ccw request. */
3864 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, 3867 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength,
3865 datasize, startdev); 3868 datasize, startdev, blk_mq_rq_to_pdu(req));
3866 if (IS_ERR(cqr)) 3869 if (IS_ERR(cqr))
3867 return cqr; 3870 return cqr;
3868 3871
@@ -4102,7 +4105,7 @@ dasd_eckd_release(struct dasd_device *device)
4102 return -EACCES; 4105 return -EACCES;
4103 4106
4104 useglobal = 0; 4107 useglobal = 0;
4105 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device); 4108 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device, NULL);
4106 if (IS_ERR(cqr)) { 4109 if (IS_ERR(cqr)) {
4107 mutex_lock(&dasd_reserve_mutex); 4110 mutex_lock(&dasd_reserve_mutex);
4108 useglobal = 1; 4111 useglobal = 1;
@@ -4157,7 +4160,7 @@ dasd_eckd_reserve(struct dasd_device *device)
4157 return -EACCES; 4160 return -EACCES;
4158 4161
4159 useglobal = 0; 4162 useglobal = 0;
4160 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device); 4163 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device, NULL);
4161 if (IS_ERR(cqr)) { 4164 if (IS_ERR(cqr)) {
4162 mutex_lock(&dasd_reserve_mutex); 4165 mutex_lock(&dasd_reserve_mutex);
4163 useglobal = 1; 4166 useglobal = 1;
@@ -4211,7 +4214,7 @@ dasd_eckd_steal_lock(struct dasd_device *device)
4211 return -EACCES; 4214 return -EACCES;
4212 4215
4213 useglobal = 0; 4216 useglobal = 0;
4214 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device); 4217 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device, NULL);
4215 if (IS_ERR(cqr)) { 4218 if (IS_ERR(cqr)) {
4216 mutex_lock(&dasd_reserve_mutex); 4219 mutex_lock(&dasd_reserve_mutex);
4217 useglobal = 1; 4220 useglobal = 1;
@@ -4271,7 +4274,8 @@ static int dasd_eckd_snid(struct dasd_device *device,
4271 4274
4272 useglobal = 0; 4275 useglobal = 0;
4273 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 4276 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1,
4274 sizeof(struct dasd_snid_data), device); 4277 sizeof(struct dasd_snid_data), device,
4278 NULL);
4275 if (IS_ERR(cqr)) { 4279 if (IS_ERR(cqr)) {
4276 mutex_lock(&dasd_reserve_mutex); 4280 mutex_lock(&dasd_reserve_mutex);
4277 useglobal = 1; 4281 useglobal = 1;
@@ -4331,7 +4335,7 @@ dasd_eckd_performance(struct dasd_device *device, void __user *argp)
4331 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 4335 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
4332 (sizeof(struct dasd_psf_prssd_data) + 4336 (sizeof(struct dasd_psf_prssd_data) +
4333 sizeof(struct dasd_rssd_perf_stats_t)), 4337 sizeof(struct dasd_rssd_perf_stats_t)),
4334 device); 4338 device, NULL);
4335 if (IS_ERR(cqr)) { 4339 if (IS_ERR(cqr)) {
4336 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 4340 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
4337 "Could not allocate initialization request"); 4341 "Could not allocate initialization request");
@@ -4477,7 +4481,7 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp)
4477 psf1 = psf_data[1]; 4481 psf1 = psf_data[1];
4478 4482
4479 /* setup CCWs for PSF + RSSD */ 4483 /* setup CCWs for PSF + RSSD */
4480 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 2 , 0, device); 4484 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 2, 0, device, NULL);
4481 if (IS_ERR(cqr)) { 4485 if (IS_ERR(cqr)) {
4482 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 4486 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
4483 "Could not allocate initialization request"); 4487 "Could not allocate initialization request");
@@ -5037,7 +5041,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
5037 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 5041 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
5038 (sizeof(struct dasd_psf_prssd_data) + 5042 (sizeof(struct dasd_psf_prssd_data) +
5039 sizeof(struct dasd_rssd_messages)), 5043 sizeof(struct dasd_rssd_messages)),
5040 device); 5044 device, NULL);
5041 if (IS_ERR(cqr)) { 5045 if (IS_ERR(cqr)) {
5042 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", 5046 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s",
5043 "Could not allocate read message buffer request"); 5047 "Could not allocate read message buffer request");
@@ -5126,7 +5130,7 @@ static int dasd_eckd_query_host_access(struct dasd_device *device,
5126 5130
5127 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 5131 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
5128 sizeof(struct dasd_psf_prssd_data) + 1, 5132 sizeof(struct dasd_psf_prssd_data) + 1,
5129 device); 5133 device, NULL);
5130 if (IS_ERR(cqr)) { 5134 if (IS_ERR(cqr)) {
5131 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", 5135 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s",
5132 "Could not allocate read message buffer request"); 5136 "Could not allocate read message buffer request");
@@ -5284,8 +5288,8 @@ dasd_eckd_psf_cuir_response(struct dasd_device *device, int response,
5284 int rc; 5288 int rc;
5285 5289
5286 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ , 5290 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ ,
5287 sizeof(struct dasd_psf_cuir_response), 5291 sizeof(struct dasd_psf_cuir_response),
5288 device); 5292 device, NULL);
5289 5293
5290 if (IS_ERR(cqr)) { 5294 if (IS_ERR(cqr)) {
5291 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 5295 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 0af8c5295b65..6ef8714dc693 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -447,7 +447,7 @@ static void dasd_eer_snss_cb(struct dasd_ccw_req *cqr, void *data)
447 * is a new ccw in device->eer_cqr. Free the "old" 447 * is a new ccw in device->eer_cqr. Free the "old"
448 * snss request now. 448 * snss request now.
449 */ 449 */
450 dasd_kfree_request(cqr, device); 450 dasd_sfree_request(cqr, device);
451} 451}
452 452
453/* 453/*
@@ -472,8 +472,8 @@ int dasd_eer_enable(struct dasd_device *device)
472 if (rc) 472 if (rc)
473 goto out; 473 goto out;
474 474
475 cqr = dasd_kmalloc_request(DASD_ECKD_MAGIC, 1 /* SNSS */, 475 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* SNSS */,
476 SNSS_DATA_SIZE, device); 476 SNSS_DATA_SIZE, device, NULL);
477 if (IS_ERR(cqr)) { 477 if (IS_ERR(cqr)) {
478 rc = -ENOMEM; 478 rc = -ENOMEM;
479 cqr = NULL; 479 cqr = NULL;
@@ -505,7 +505,7 @@ out:
505 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 505 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
506 506
507 if (cqr) 507 if (cqr)
508 dasd_kfree_request(cqr, device); 508 dasd_sfree_request(cqr, device);
509 509
510 return rc; 510 return rc;
511} 511}
@@ -528,7 +528,7 @@ void dasd_eer_disable(struct dasd_device *device)
528 in_use = test_and_clear_bit(DASD_FLAG_EER_IN_USE, &device->flags); 528 in_use = test_and_clear_bit(DASD_FLAG_EER_IN_USE, &device->flags);
529 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 529 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
530 if (cqr && !in_use) 530 if (cqr && !in_use)
531 dasd_kfree_request(cqr, device); 531 dasd_sfree_request(cqr, device);
532} 532}
533 533
534/* 534/*
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index a6b132f7e869..56007a3e7f11 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -356,7 +356,8 @@ static struct dasd_ccw_req *dasd_fba_build_cp_discard(
356 datasize = sizeof(struct DE_fba_data) + 356 datasize = sizeof(struct DE_fba_data) +
357 nr_ccws * (sizeof(struct LO_fba_data) + sizeof(struct ccw1)); 357 nr_ccws * (sizeof(struct LO_fba_data) + sizeof(struct ccw1));
358 358
359 cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev); 359 cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev,
360 blk_mq_rq_to_pdu(req));
360 if (IS_ERR(cqr)) 361 if (IS_ERR(cqr))
361 return cqr; 362 return cqr;
362 363
@@ -490,7 +491,8 @@ static struct dasd_ccw_req *dasd_fba_build_cp_regular(
490 datasize += (count - 1)*sizeof(struct LO_fba_data); 491 datasize += (count - 1)*sizeof(struct LO_fba_data);
491 } 492 }
492 /* Allocate the ccw request. */ 493 /* Allocate the ccw request. */
493 cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev); 494 cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev,
495 blk_mq_rq_to_pdu(req));
494 if (IS_ERR(cqr)) 496 if (IS_ERR(cqr))
495 return cqr; 497 return cqr;
496 ccw = cqr->cpaddr; 498 ccw = cqr->cpaddr;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 96709b1a7bf8..976b6bd4fb05 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -158,40 +158,33 @@ do { \
158 158
159struct dasd_ccw_req { 159struct dasd_ccw_req {
160 unsigned int magic; /* Eye catcher */ 160 unsigned int magic; /* Eye catcher */
161 int intrc; /* internal error, e.g. from start_IO */
161 struct list_head devlist; /* for dasd_device request queue */ 162 struct list_head devlist; /* for dasd_device request queue */
162 struct list_head blocklist; /* for dasd_block request queue */ 163 struct list_head blocklist; /* for dasd_block request queue */
163
164 /* Where to execute what... */
165 struct dasd_block *block; /* the originating block device */ 164 struct dasd_block *block; /* the originating block device */
166 struct dasd_device *memdev; /* the device used to allocate this */ 165 struct dasd_device *memdev; /* the device used to allocate this */
167 struct dasd_device *startdev; /* device the request is started on */ 166 struct dasd_device *startdev; /* device the request is started on */
168 struct dasd_device *basedev; /* base device if no block->base */ 167 struct dasd_device *basedev; /* base device if no block->base */
169 void *cpaddr; /* address of ccw or tcw */ 168 void *cpaddr; /* address of ccw or tcw */
169 short retries; /* A retry counter */
170 unsigned char cpmode; /* 0 = cmd mode, 1 = itcw */ 170 unsigned char cpmode; /* 0 = cmd mode, 1 = itcw */
171 char status; /* status of this request */ 171 char status; /* status of this request */
172 short retries; /* A retry counter */ 172 char lpm; /* logical path mask */
173 unsigned long flags; /* flags of this request */ 173 unsigned long flags; /* flags of this request */
174 struct dasd_queue *dq; 174 struct dasd_queue *dq;
175
176 /* ... and how */
177 unsigned long starttime; /* jiffies time of request start */ 175 unsigned long starttime; /* jiffies time of request start */
178 unsigned long expires; /* expiration period in jiffies */ 176 unsigned long expires; /* expiration period in jiffies */
179 char lpm; /* logical path mask */
180 void *data; /* pointer to data area */ 177 void *data; /* pointer to data area */
181
182 /* these are important for recovering erroneous requests */
183 int intrc; /* internal error, e.g. from start_IO */
184 struct irb irb; /* device status in case of an error */ 178 struct irb irb; /* device status in case of an error */
185 struct dasd_ccw_req *refers; /* ERP-chain queueing. */ 179 struct dasd_ccw_req *refers; /* ERP-chain queueing. */
186 void *function; /* originating ERP action */ 180 void *function; /* originating ERP action */
181 void *mem_chunk;
187 182
188 /* these are for statistics only */
189 unsigned long buildclk; /* TOD-clock of request generation */ 183 unsigned long buildclk; /* TOD-clock of request generation */
190 unsigned long startclk; /* TOD-clock of request start */ 184 unsigned long startclk; /* TOD-clock of request start */
191 unsigned long stopclk; /* TOD-clock of request interrupt */ 185 unsigned long stopclk; /* TOD-clock of request interrupt */
192 unsigned long endclk; /* TOD-clock of request termination */ 186 unsigned long endclk; /* TOD-clock of request termination */
193 187
194 /* Callback that is called after reaching final status. */
195 void (*callback)(struct dasd_ccw_req *, void *data); 188 void (*callback)(struct dasd_ccw_req *, void *data);
196 void *callback_data; 189 void *callback_data;
197}; 190};
@@ -714,19 +707,10 @@ extern const struct block_device_operations dasd_device_operations;
714extern struct kmem_cache *dasd_page_cache; 707extern struct kmem_cache *dasd_page_cache;
715 708
716struct dasd_ccw_req * 709struct dasd_ccw_req *
717dasd_kmalloc_request(int , int, int, struct dasd_device *); 710dasd_smalloc_request(int, int, int, struct dasd_device *, struct dasd_ccw_req *);
718struct dasd_ccw_req *
719dasd_smalloc_request(int , int, int, struct dasd_device *);
720void dasd_kfree_request(struct dasd_ccw_req *, struct dasd_device *);
721void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *); 711void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *);
722void dasd_wakeup_cb(struct dasd_ccw_req *, void *); 712void dasd_wakeup_cb(struct dasd_ccw_req *, void *);
723 713
724static inline int
725dasd_kmalloc_set_cda(struct ccw1 *ccw, void *cda, struct dasd_device *device)
726{
727 return set_normalized_cda(ccw, cda);
728}
729
730struct dasd_device *dasd_alloc_device(void); 714struct dasd_device *dasd_alloc_device(void);
731void dasd_free_device(struct dasd_device *); 715void dasd_free_device(struct dasd_device *);
732 716
diff --git a/drivers/s390/cio/Makefile b/drivers/s390/cio/Makefile
index a070ef0efe65..f230516abb96 100644
--- a/drivers/s390/cio/Makefile
+++ b/drivers/s390/cio/Makefile
@@ -5,6 +5,7 @@
5 5
6# The following is required for define_trace.h to find ./trace.h 6# The following is required for define_trace.h to find ./trace.h
7CFLAGS_trace.o := -I$(src) 7CFLAGS_trace.o := -I$(src)
8CFLAGS_vfio_ccw_fsm.o := -I$(src)
8 9
9obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o \ 10obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o \
10 fcx.o itcw.o crw.o ccwreq.o trace.o ioasm.o 11 fcx.o itcw.o crw.o ccwreq.o trace.o ioasm.o
diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
index dce92b2a895d..dbe7c7ac9ac8 100644
--- a/drivers/s390/cio/vfio_ccw_cp.c
+++ b/drivers/s390/cio/vfio_ccw_cp.c
@@ -23,9 +23,13 @@
23#define CCWCHAIN_LEN_MAX 256 23#define CCWCHAIN_LEN_MAX 256
24 24
25struct pfn_array { 25struct pfn_array {
26 /* Starting guest physical I/O address. */
26 unsigned long pa_iova; 27 unsigned long pa_iova;
28 /* Array that stores PFNs of the pages need to pin. */
27 unsigned long *pa_iova_pfn; 29 unsigned long *pa_iova_pfn;
30 /* Array that receives PFNs of the pages pinned. */
28 unsigned long *pa_pfn; 31 unsigned long *pa_pfn;
32 /* Number of pages pinned from @pa_iova. */
29 int pa_nr; 33 int pa_nr;
30}; 34};
31 35
@@ -46,70 +50,33 @@ struct ccwchain {
46}; 50};
47 51
48/* 52/*
49 * pfn_array_pin() - pin user pages in memory 53 * pfn_array_alloc_pin() - alloc memory for PFNs, then pin user pages in memory
50 * @pa: pfn_array on which to perform the operation 54 * @pa: pfn_array on which to perform the operation
51 * @mdev: the mediated device to perform pin/unpin operations 55 * @mdev: the mediated device to perform pin/unpin operations
56 * @iova: target guest physical address
57 * @len: number of bytes that should be pinned from @iova
52 * 58 *
53 * Attempt to pin user pages in memory. 59 * Attempt to allocate memory for PFNs, and pin user pages in memory.
54 * 60 *
55 * Usage of pfn_array: 61 * Usage of pfn_array:
56 * @pa->pa_iova starting guest physical I/O address. Assigned by caller. 62 * We expect (pa_nr == 0) and (pa_iova_pfn == NULL), any field in
57 * @pa->pa_iova_pfn array that stores PFNs of the pages need to pin. Allocated 63 * this structure will be filled in by this function.
58 * by caller.
59 * @pa->pa_pfn array that receives PFNs of the pages pinned. Allocated by
60 * caller.
61 * @pa->pa_nr number of pages from @pa->pa_iova to pin. Assigned by
62 * caller.
63 * number of pages pinned. Assigned by callee.
64 * 64 *
65 * Returns: 65 * Returns:
66 * Number of pages pinned on success. 66 * Number of pages pinned on success.
67 * If @pa->pa_nr is 0 or negative, returns 0. 67 * If @pa->pa_nr is not 0, or @pa->pa_iova_pfn is not NULL initially,
68 * returns -EINVAL.
68 * If no pages were pinned, returns -errno. 69 * If no pages were pinned, returns -errno.
69 */ 70 */
70static int pfn_array_pin(struct pfn_array *pa, struct device *mdev)
71{
72 int i, ret;
73
74 if (pa->pa_nr <= 0) {
75 pa->pa_nr = 0;
76 return 0;
77 }
78
79 pa->pa_iova_pfn[0] = pa->pa_iova >> PAGE_SHIFT;
80 for (i = 1; i < pa->pa_nr; i++)
81 pa->pa_iova_pfn[i] = pa->pa_iova_pfn[i - 1] + 1;
82
83 ret = vfio_pin_pages(mdev, pa->pa_iova_pfn, pa->pa_nr,
84 IOMMU_READ | IOMMU_WRITE, pa->pa_pfn);
85
86 if (ret > 0 && ret != pa->pa_nr) {
87 vfio_unpin_pages(mdev, pa->pa_iova_pfn, ret);
88 pa->pa_nr = 0;
89 return 0;
90 }
91
92 return ret;
93}
94
95/* Unpin the pages before releasing the memory. */
96static void pfn_array_unpin_free(struct pfn_array *pa, struct device *mdev)
97{
98 vfio_unpin_pages(mdev, pa->pa_iova_pfn, pa->pa_nr);
99 pa->pa_nr = 0;
100 kfree(pa->pa_iova_pfn);
101}
102
103/* Alloc memory for PFNs, then pin pages with them. */
104static int pfn_array_alloc_pin(struct pfn_array *pa, struct device *mdev, 71static int pfn_array_alloc_pin(struct pfn_array *pa, struct device *mdev,
105 u64 iova, unsigned int len) 72 u64 iova, unsigned int len)
106{ 73{
107 int ret = 0; 74 int i, ret = 0;
108 75
109 if (!len) 76 if (!len)
110 return 0; 77 return 0;
111 78
112 if (pa->pa_nr) 79 if (pa->pa_nr || pa->pa_iova_pfn)
113 return -EINVAL; 80 return -EINVAL;
114 81
115 pa->pa_iova = iova; 82 pa->pa_iova = iova;
@@ -126,18 +93,39 @@ static int pfn_array_alloc_pin(struct pfn_array *pa, struct device *mdev,
126 return -ENOMEM; 93 return -ENOMEM;
127 pa->pa_pfn = pa->pa_iova_pfn + pa->pa_nr; 94 pa->pa_pfn = pa->pa_iova_pfn + pa->pa_nr;
128 95
129 ret = pfn_array_pin(pa, mdev); 96 pa->pa_iova_pfn[0] = pa->pa_iova >> PAGE_SHIFT;
97 for (i = 1; i < pa->pa_nr; i++)
98 pa->pa_iova_pfn[i] = pa->pa_iova_pfn[i - 1] + 1;
130 99
131 if (ret > 0) 100 ret = vfio_pin_pages(mdev, pa->pa_iova_pfn, pa->pa_nr,
132 return ret; 101 IOMMU_READ | IOMMU_WRITE, pa->pa_pfn);
133 else if (!ret) 102
103 if (ret < 0) {
104 goto err_out;
105 } else if (ret > 0 && ret != pa->pa_nr) {
106 vfio_unpin_pages(mdev, pa->pa_iova_pfn, ret);
134 ret = -EINVAL; 107 ret = -EINVAL;
108 goto err_out;
109 }
135 110
111 return ret;
112
113err_out:
114 pa->pa_nr = 0;
136 kfree(pa->pa_iova_pfn); 115 kfree(pa->pa_iova_pfn);
116 pa->pa_iova_pfn = NULL;
137 117
138 return ret; 118 return ret;
139} 119}
140 120
121/* Unpin the pages before releasing the memory. */
122static void pfn_array_unpin_free(struct pfn_array *pa, struct device *mdev)
123{
124 vfio_unpin_pages(mdev, pa->pa_iova_pfn, pa->pa_nr);
125 pa->pa_nr = 0;
126 kfree(pa->pa_iova_pfn);
127}
128
141static int pfn_array_table_init(struct pfn_array_table *pat, int nr) 129static int pfn_array_table_init(struct pfn_array_table *pat, int nr)
142{ 130{
143 pat->pat_pa = kcalloc(nr, sizeof(*pat->pat_pa), GFP_KERNEL); 131 pat->pat_pa = kcalloc(nr, sizeof(*pat->pat_pa), GFP_KERNEL);
@@ -365,6 +353,9 @@ static void cp_unpin_free(struct channel_program *cp)
365 * This is the chain length not considering any TICs. 353 * This is the chain length not considering any TICs.
366 * You need to do a new round for each TIC target. 354 * You need to do a new round for each TIC target.
367 * 355 *
356 * The program is also validated for absence of not yet supported
357 * indirect data addressing scenarios.
358 *
368 * Returns: the length of the ccw chain or -errno. 359 * Returns: the length of the ccw chain or -errno.
369 */ 360 */
370static int ccwchain_calc_length(u64 iova, struct channel_program *cp) 361static int ccwchain_calc_length(u64 iova, struct channel_program *cp)
@@ -391,6 +382,14 @@ static int ccwchain_calc_length(u64 iova, struct channel_program *cp)
391 do { 382 do {
392 cnt++; 383 cnt++;
393 384
385 /*
386 * As we don't want to fail direct addressing even if the
387 * orb specified one of the unsupported formats, we defer
388 * checking for IDAWs in unsupported formats to here.
389 */
390 if ((!cp->orb.cmd.c64 || cp->orb.cmd.i2k) && ccw_is_idal(ccw))
391 return -EOPNOTSUPP;
392
394 if ((!ccw_is_chain(ccw)) && (!ccw_is_tic(ccw))) 393 if ((!ccw_is_chain(ccw)) && (!ccw_is_tic(ccw)))
395 break; 394 break;
396 395
@@ -503,7 +502,7 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
503 struct ccw1 *ccw; 502 struct ccw1 *ccw;
504 struct pfn_array_table *pat; 503 struct pfn_array_table *pat;
505 unsigned long *idaws; 504 unsigned long *idaws;
506 int idaw_nr; 505 int ret;
507 506
508 ccw = chain->ch_ccw + idx; 507 ccw = chain->ch_ccw + idx;
509 508
@@ -523,18 +522,19 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
523 * needed when translating a direct ccw to a idal ccw. 522 * needed when translating a direct ccw to a idal ccw.
524 */ 523 */
525 pat = chain->ch_pat + idx; 524 pat = chain->ch_pat + idx;
526 if (pfn_array_table_init(pat, 1)) 525 ret = pfn_array_table_init(pat, 1);
527 return -ENOMEM; 526 if (ret)
528 idaw_nr = pfn_array_alloc_pin(pat->pat_pa, cp->mdev, 527 goto out_init;
529 ccw->cda, ccw->count); 528
530 if (idaw_nr < 0) 529 ret = pfn_array_alloc_pin(pat->pat_pa, cp->mdev, ccw->cda, ccw->count);
531 return idaw_nr; 530 if (ret < 0)
531 goto out_init;
532 532
533 /* Translate this direct ccw to a idal ccw. */ 533 /* Translate this direct ccw to a idal ccw. */
534 idaws = kcalloc(idaw_nr, sizeof(*idaws), GFP_DMA | GFP_KERNEL); 534 idaws = kcalloc(ret, sizeof(*idaws), GFP_DMA | GFP_KERNEL);
535 if (!idaws) { 535 if (!idaws) {
536 pfn_array_table_unpin_free(pat, cp->mdev); 536 ret = -ENOMEM;
537 return -ENOMEM; 537 goto out_unpin;
538 } 538 }
539 ccw->cda = (__u32) virt_to_phys(idaws); 539 ccw->cda = (__u32) virt_to_phys(idaws);
540 ccw->flags |= CCW_FLAG_IDA; 540 ccw->flags |= CCW_FLAG_IDA;
@@ -542,6 +542,12 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
542 pfn_array_table_idal_create_words(pat, idaws); 542 pfn_array_table_idal_create_words(pat, idaws);
543 543
544 return 0; 544 return 0;
545
546out_unpin:
547 pfn_array_table_unpin_free(pat, cp->mdev);
548out_init:
549 ccw->cda = 0;
550 return ret;
545} 551}
546 552
547static int ccwchain_fetch_idal(struct ccwchain *chain, 553static int ccwchain_fetch_idal(struct ccwchain *chain,
@@ -571,7 +577,7 @@ static int ccwchain_fetch_idal(struct ccwchain *chain,
571 pat = chain->ch_pat + idx; 577 pat = chain->ch_pat + idx;
572 ret = pfn_array_table_init(pat, idaw_nr); 578 ret = pfn_array_table_init(pat, idaw_nr);
573 if (ret) 579 if (ret)
574 return ret; 580 goto out_init;
575 581
576 /* Translate idal ccw to use new allocated idaws. */ 582 /* Translate idal ccw to use new allocated idaws. */
577 idaws = kzalloc(idaw_len, GFP_DMA | GFP_KERNEL); 583 idaws = kzalloc(idaw_len, GFP_DMA | GFP_KERNEL);
@@ -603,6 +609,8 @@ out_free_idaws:
603 kfree(idaws); 609 kfree(idaws);
604out_unpin: 610out_unpin:
605 pfn_array_table_unpin_free(pat, cp->mdev); 611 pfn_array_table_unpin_free(pat, cp->mdev);
612out_init:
613 ccw->cda = 0;
606 return ret; 614 return ret;
607} 615}
608 616
@@ -656,10 +664,8 @@ int cp_init(struct channel_program *cp, struct device *mdev, union orb *orb)
656 /* 664 /*
657 * XXX: 665 * XXX:
658 * Only support prefetch enable mode now. 666 * Only support prefetch enable mode now.
659 * Only support 64bit addressing idal.
660 * Only support 4k IDAW.
661 */ 667 */
662 if (!orb->cmd.pfch || !orb->cmd.c64 || orb->cmd.i2k) 668 if (!orb->cmd.pfch)
663 return -EOPNOTSUPP; 669 return -EOPNOTSUPP;
664 670
665 INIT_LIST_HEAD(&cp->ccwchain_list); 671 INIT_LIST_HEAD(&cp->ccwchain_list);
@@ -688,6 +694,10 @@ int cp_init(struct channel_program *cp, struct device *mdev, union orb *orb)
688 ret = ccwchain_loop_tic(chain, cp); 694 ret = ccwchain_loop_tic(chain, cp);
689 if (ret) 695 if (ret)
690 cp_unpin_free(cp); 696 cp_unpin_free(cp);
697 /* It is safe to force: if not set but idals used
698 * ccwchain_calc_length returns an error.
699 */
700 cp->orb.cmd.c64 = 1;
691 701
692 return ret; 702 return ret;
693} 703}
diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
index ea6a2d0b2894..770fa9cfc310 100644
--- a/drivers/s390/cio/vfio_ccw_drv.c
+++ b/drivers/s390/cio/vfio_ccw_drv.c
@@ -177,6 +177,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
177{ 177{
178 struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev); 178 struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev);
179 unsigned long flags; 179 unsigned long flags;
180 int rc = -EAGAIN;
180 181
181 spin_lock_irqsave(sch->lock, flags); 182 spin_lock_irqsave(sch->lock, flags);
182 if (!device_is_registered(&sch->dev)) 183 if (!device_is_registered(&sch->dev))
@@ -187,6 +188,7 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
187 188
188 if (cio_update_schib(sch)) { 189 if (cio_update_schib(sch)) {
189 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER); 190 vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER);
191 rc = 0;
190 goto out_unlock; 192 goto out_unlock;
191 } 193 }
192 194
@@ -195,11 +197,12 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
195 private->state = private->mdev ? VFIO_CCW_STATE_IDLE : 197 private->state = private->mdev ? VFIO_CCW_STATE_IDLE :
196 VFIO_CCW_STATE_STANDBY; 198 VFIO_CCW_STATE_STANDBY;
197 } 199 }
200 rc = 0;
198 201
199out_unlock: 202out_unlock:
200 spin_unlock_irqrestore(sch->lock, flags); 203 spin_unlock_irqrestore(sch->lock, flags);
201 204
202 return 0; 205 return rc;
203} 206}
204 207
205static struct css_device_id vfio_ccw_sch_ids[] = { 208static struct css_device_id vfio_ccw_sch_ids[] = {
diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c
index 3c800642134e..797a82731159 100644
--- a/drivers/s390/cio/vfio_ccw_fsm.c
+++ b/drivers/s390/cio/vfio_ccw_fsm.c
@@ -13,6 +13,9 @@
13#include "ioasm.h" 13#include "ioasm.h"
14#include "vfio_ccw_private.h" 14#include "vfio_ccw_private.h"
15 15
16#define CREATE_TRACE_POINTS
17#include "vfio_ccw_trace.h"
18
16static int fsm_io_helper(struct vfio_ccw_private *private) 19static int fsm_io_helper(struct vfio_ccw_private *private)
17{ 20{
18 struct subchannel *sch; 21 struct subchannel *sch;
@@ -110,6 +113,10 @@ static void fsm_disabled_irq(struct vfio_ccw_private *private,
110 */ 113 */
111 cio_disable_subchannel(sch); 114 cio_disable_subchannel(sch);
112} 115}
116inline struct subchannel_id get_schid(struct vfio_ccw_private *p)
117{
118 return p->sch->schid;
119}
113 120
114/* 121/*
115 * Deal with the ccw command request from the userspace. 122 * Deal with the ccw command request from the userspace.
@@ -121,6 +128,7 @@ static void fsm_io_request(struct vfio_ccw_private *private,
121 union scsw *scsw = &private->scsw; 128 union scsw *scsw = &private->scsw;
122 struct ccw_io_region *io_region = &private->io_region; 129 struct ccw_io_region *io_region = &private->io_region;
123 struct mdev_device *mdev = private->mdev; 130 struct mdev_device *mdev = private->mdev;
131 char *errstr = "request";
124 132
125 private->state = VFIO_CCW_STATE_BOXED; 133 private->state = VFIO_CCW_STATE_BOXED;
126 134
@@ -132,15 +140,19 @@ static void fsm_io_request(struct vfio_ccw_private *private,
132 /* Don't try to build a cp if transport mode is specified. */ 140 /* Don't try to build a cp if transport mode is specified. */
133 if (orb->tm.b) { 141 if (orb->tm.b) {
134 io_region->ret_code = -EOPNOTSUPP; 142 io_region->ret_code = -EOPNOTSUPP;
143 errstr = "transport mode";
135 goto err_out; 144 goto err_out;
136 } 145 }
137 io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev), 146 io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev),
138 orb); 147 orb);
139 if (io_region->ret_code) 148 if (io_region->ret_code) {
149 errstr = "cp init";
140 goto err_out; 150 goto err_out;
151 }
141 152
142 io_region->ret_code = cp_prefetch(&private->cp); 153 io_region->ret_code = cp_prefetch(&private->cp);
143 if (io_region->ret_code) { 154 if (io_region->ret_code) {
155 errstr = "cp prefetch";
144 cp_free(&private->cp); 156 cp_free(&private->cp);
145 goto err_out; 157 goto err_out;
146 } 158 }
@@ -148,6 +160,7 @@ static void fsm_io_request(struct vfio_ccw_private *private,
148 /* Start channel program and wait for I/O interrupt. */ 160 /* Start channel program and wait for I/O interrupt. */
149 io_region->ret_code = fsm_io_helper(private); 161 io_region->ret_code = fsm_io_helper(private);
150 if (io_region->ret_code) { 162 if (io_region->ret_code) {
163 errstr = "cp fsm_io_helper";
151 cp_free(&private->cp); 164 cp_free(&private->cp);
152 goto err_out; 165 goto err_out;
153 } 166 }
@@ -164,6 +177,8 @@ static void fsm_io_request(struct vfio_ccw_private *private,
164 177
165err_out: 178err_out:
166 private->state = VFIO_CCW_STATE_IDLE; 179 private->state = VFIO_CCW_STATE_IDLE;
180 trace_vfio_ccw_io_fctl(scsw->cmd.fctl, get_schid(private),
181 io_region->ret_code, errstr);
167} 182}
168 183
169/* 184/*
diff --git a/drivers/s390/cio/vfio_ccw_trace.h b/drivers/s390/cio/vfio_ccw_trace.h
new file mode 100644
index 000000000000..b1da53ddec1f
--- /dev/null
+++ b/drivers/s390/cio/vfio_ccw_trace.h
@@ -0,0 +1,54 @@
1/* SPDX-License-Identifier: GPL-2.0
2 * Tracepoints for vfio_ccw driver
3 *
4 * Copyright IBM Corp. 2018
5 *
6 * Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
7 * Halil Pasic <pasic@linux.vnet.ibm.com>
8 */
9
10#undef TRACE_SYSTEM
11#define TRACE_SYSTEM vfio_ccw
12
13#if !defined(_VFIO_CCW_TRACE_) || defined(TRACE_HEADER_MULTI_READ)
14#define _VFIO_CCW_TRACE_
15
16#include <linux/tracepoint.h>
17
18TRACE_EVENT(vfio_ccw_io_fctl,
19 TP_PROTO(int fctl, struct subchannel_id schid, int errno, char *errstr),
20 TP_ARGS(fctl, schid, errno, errstr),
21
22 TP_STRUCT__entry(
23 __field(int, fctl)
24 __field_struct(struct subchannel_id, schid)
25 __field(int, errno)
26 __field(char*, errstr)
27 ),
28
29 TP_fast_assign(
30 __entry->fctl = fctl;
31 __entry->schid = schid;
32 __entry->errno = errno;
33 __entry->errstr = errstr;
34 ),
35
36 TP_printk("schid=%x.%x.%04x fctl=%x errno=%d info=%s",
37 __entry->schid.cssid,
38 __entry->schid.ssid,
39 __entry->schid.sch_no,
40 __entry->fctl,
41 __entry->errno,
42 __entry->errstr)
43);
44
45#endif /* _VFIO_CCW_TRACE_ */
46
47/* This part must be outside protection */
48
49#undef TRACE_INCLUDE_PATH
50#define TRACE_INCLUDE_PATH .
51#undef TRACE_INCLUDE_FILE
52#define TRACE_INCLUDE_FILE vfio_ccw_trace
53
54#include <trace/define_trace.h>
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 0a9b8b387bd2..02d65dce74e5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -760,7 +760,6 @@ static void ipr_mask_and_clear_interrupts(struct ipr_ioa_cfg *ioa_cfg,
760 ioa_cfg->hrrq[i].allow_interrupts = 0; 760 ioa_cfg->hrrq[i].allow_interrupts = 0;
761 spin_unlock(&ioa_cfg->hrrq[i]._lock); 761 spin_unlock(&ioa_cfg->hrrq[i]._lock);
762 } 762 }
763 wmb();
764 763
765 /* Set interrupt mask to stop all new interrupts */ 764 /* Set interrupt mask to stop all new interrupts */
766 if (ioa_cfg->sis64) 765 if (ioa_cfg->sis64)
@@ -8403,7 +8402,6 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd)
8403 ioa_cfg->hrrq[i].allow_interrupts = 1; 8402 ioa_cfg->hrrq[i].allow_interrupts = 1;
8404 spin_unlock(&ioa_cfg->hrrq[i]._lock); 8403 spin_unlock(&ioa_cfg->hrrq[i]._lock);
8405 } 8404 }
8406 wmb();
8407 if (ioa_cfg->sis64) { 8405 if (ioa_cfg->sis64) {
8408 /* Set the adapter to the correct endian mode. */ 8406 /* Set the adapter to the correct endian mode. */
8409 writel(IPR_ENDIAN_SWAP_KEY, ioa_cfg->regs.endian_swap_reg); 8407 writel(IPR_ENDIAN_SWAP_KEY, ioa_cfg->regs.endian_swap_reg);
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 0fea2e2326be..1027b0cb7fa3 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -1224,7 +1224,6 @@ static void qla24xx_chk_fcp_state(struct fc_port *sess)
1224void qlt_schedule_sess_for_deletion(struct fc_port *sess) 1224void qlt_schedule_sess_for_deletion(struct fc_port *sess)
1225{ 1225{
1226 struct qla_tgt *tgt = sess->tgt; 1226 struct qla_tgt *tgt = sess->tgt;
1227 struct qla_hw_data *ha = sess->vha->hw;
1228 unsigned long flags; 1227 unsigned long flags;
1229 1228
1230 if (sess->disc_state == DSC_DELETE_PEND) 1229 if (sess->disc_state == DSC_DELETE_PEND)
@@ -1241,16 +1240,16 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess)
1241 return; 1240 return;
1242 } 1241 }
1243 1242
1244 spin_lock_irqsave(&ha->tgt.sess_lock, flags);
1245 if (sess->deleted == QLA_SESS_DELETED) 1243 if (sess->deleted == QLA_SESS_DELETED)
1246 sess->logout_on_delete = 0; 1244 sess->logout_on_delete = 0;
1247 1245
1246 spin_lock_irqsave(&sess->vha->work_lock, flags);
1248 if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) { 1247 if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
1249 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); 1248 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1250 return; 1249 return;
1251 } 1250 }
1252 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; 1251 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
1253 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); 1252 spin_unlock_irqrestore(&sess->vha->work_lock, flags);
1254 1253
1255 sess->disc_state = DSC_DELETE_PEND; 1254 sess->disc_state = DSC_DELETE_PEND;
1256 1255
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 24d7496cd9e2..364e71861bfd 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5507,9 +5507,9 @@ static void __exit scsi_debug_exit(void)
5507 int k = sdebug_add_host; 5507 int k = sdebug_add_host;
5508 5508
5509 stop_all_queued(); 5509 stop_all_queued();
5510 free_all_queued();
5511 for (; k; k--) 5510 for (; k; k--)
5512 sdebug_remove_adapter(); 5511 sdebug_remove_adapter();
5512 free_all_queued();
5513 driver_unregister(&sdebug_driverfs_driver); 5513 driver_unregister(&sdebug_driverfs_driver);
5514 bus_unregister(&pseudo_lld_bus); 5514 bus_unregister(&pseudo_lld_bus);
5515 root_device_unregister(pseudo_primary); 5515 root_device_unregister(pseudo_primary);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 1da3d71e9f61..13948102ca29 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -3592,7 +3592,7 @@ fc_bsg_job_timeout(struct request *req)
3592 3592
3593 /* the blk_end_sync_io() doesn't check the error */ 3593 /* the blk_end_sync_io() doesn't check the error */
3594 if (inflight) 3594 if (inflight)
3595 blk_mq_complete_request(req); 3595 __blk_complete_request(req);
3596 return BLK_EH_DONE; 3596 return BLK_EH_DONE;
3597} 3597}
3598 3598
diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 36f59a1be7e9..61389bdc7926 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -654,10 +654,17 @@ static int scsifront_dev_reset_handler(struct scsi_cmnd *sc)
654static int scsifront_sdev_configure(struct scsi_device *sdev) 654static int scsifront_sdev_configure(struct scsi_device *sdev)
655{ 655{
656 struct vscsifrnt_info *info = shost_priv(sdev->host); 656 struct vscsifrnt_info *info = shost_priv(sdev->host);
657 int err;
657 658
658 if (info && current == info->curr) 659 if (info && current == info->curr) {
659 xenbus_printf(XBT_NIL, info->dev->nodename, 660 err = xenbus_printf(XBT_NIL, info->dev->nodename,
660 info->dev_state_path, "%d", XenbusStateConnected); 661 info->dev_state_path, "%d", XenbusStateConnected);
662 if (err) {
663 xenbus_dev_error(info->dev, err,
664 "%s: writing dev_state_path", __func__);
665 return err;
666 }
667 }
661 668
662 return 0; 669 return 0;
663} 670}
@@ -665,10 +672,15 @@ static int scsifront_sdev_configure(struct scsi_device *sdev)
665static void scsifront_sdev_destroy(struct scsi_device *sdev) 672static void scsifront_sdev_destroy(struct scsi_device *sdev)
666{ 673{
667 struct vscsifrnt_info *info = shost_priv(sdev->host); 674 struct vscsifrnt_info *info = shost_priv(sdev->host);
675 int err;
668 676
669 if (info && current == info->curr) 677 if (info && current == info->curr) {
670 xenbus_printf(XBT_NIL, info->dev->nodename, 678 err = xenbus_printf(XBT_NIL, info->dev->nodename,
671 info->dev_state_path, "%d", XenbusStateClosed); 679 info->dev_state_path, "%d", XenbusStateClosed);
680 if (err)
681 xenbus_dev_error(info->dev, err,
682 "%s: writing dev_state_path", __func__);
683 }
672} 684}
673 685
674static struct scsi_host_template scsifront_sht = { 686static struct scsi_host_template scsifront_sht = {
@@ -1003,9 +1015,12 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
1003 1015
1004 if (scsi_add_device(info->host, chn, tgt, lun)) { 1016 if (scsi_add_device(info->host, chn, tgt, lun)) {
1005 dev_err(&dev->dev, "scsi_add_device\n"); 1017 dev_err(&dev->dev, "scsi_add_device\n");
1006 xenbus_printf(XBT_NIL, dev->nodename, 1018 err = xenbus_printf(XBT_NIL, dev->nodename,
1007 info->dev_state_path, 1019 info->dev_state_path,
1008 "%d", XenbusStateClosed); 1020 "%d", XenbusStateClosed);
1021 if (err)
1022 xenbus_dev_error(dev, err,
1023 "%s: writing dev_state_path", __func__);
1009 } 1024 }
1010 break; 1025 break;
1011 case VSCSIFRONT_OP_DEL_LUN: 1026 case VSCSIFRONT_OP_DEL_LUN:
@@ -1019,10 +1034,14 @@ static void scsifront_do_lun_hotplug(struct vscsifrnt_info *info, int op)
1019 } 1034 }
1020 break; 1035 break;
1021 case VSCSIFRONT_OP_READD_LUN: 1036 case VSCSIFRONT_OP_READD_LUN:
1022 if (device_state == XenbusStateConnected) 1037 if (device_state == XenbusStateConnected) {
1023 xenbus_printf(XBT_NIL, dev->nodename, 1038 err = xenbus_printf(XBT_NIL, dev->nodename,
1024 info->dev_state_path, 1039 info->dev_state_path,
1025 "%d", XenbusStateConnected); 1040 "%d", XenbusStateConnected);
1041 if (err)
1042 xenbus_dev_error(dev, err,
1043 "%s: writing dev_state_path", __func__);
1044 }
1026 break; 1045 break;
1027 default: 1046 default:
1028 break; 1047 break;
diff --git a/drivers/soc/bcm/brcmstb/pm/pm-arm.c b/drivers/soc/bcm/brcmstb/pm/pm-arm.c
index dcf8c8065508..a5577dd5eb08 100644
--- a/drivers/soc/bcm/brcmstb/pm/pm-arm.c
+++ b/drivers/soc/bcm/brcmstb/pm/pm-arm.c
@@ -628,10 +628,26 @@ static const struct of_device_id ddr_shimphy_dt_ids[] = {
628 628
629static const struct of_device_id brcmstb_memc_of_match[] = { 629static const struct of_device_id brcmstb_memc_of_match[] = {
630 { 630 {
631 .compatible = "brcm,brcmstb-memc-ddr-rev-b.2.1",
632 .data = &ddr_seq,
633 },
634 {
631 .compatible = "brcm,brcmstb-memc-ddr-rev-b.2.2", 635 .compatible = "brcm,brcmstb-memc-ddr-rev-b.2.2",
632 .data = &ddr_seq_b22, 636 .data = &ddr_seq_b22,
633 }, 637 },
634 { 638 {
639 .compatible = "brcm,brcmstb-memc-ddr-rev-b.2.3",
640 .data = &ddr_seq_b22,
641 },
642 {
643 .compatible = "brcm,brcmstb-memc-ddr-rev-b.3.0",
644 .data = &ddr_seq_b22,
645 },
646 {
647 .compatible = "brcm,brcmstb-memc-ddr-rev-b.3.1",
648 .data = &ddr_seq_b22,
649 },
650 {
635 .compatible = "brcm,brcmstb-memc-ddr", 651 .compatible = "brcm,brcmstb-memc-ddr",
636 .data = &ddr_seq, 652 .data = &ddr_seq,
637 }, 653 },
diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index f4e3bd40c72e..6ef18cf8f243 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -39,10 +39,15 @@
39 39
40#define GPC_M4_PU_PDN_FLG 0x1bc 40#define GPC_M4_PU_PDN_FLG 0x1bc
41 41
42 42/*
43#define PGC_MIPI 4 43 * The PGC offset values in Reference Manual
44#define PGC_PCIE 5 44 * (Rev. 1, 01/2018 and the older ones) GPC chapter's
45#define PGC_USB_HSIC 8 45 * GPC_PGC memory map are incorrect, below offset
46 * values are from design RTL.
47 */
48#define PGC_MIPI 16
49#define PGC_PCIE 17
50#define PGC_USB_HSIC 20
46#define GPC_PGC_CTRL(n) (0x800 + (n) * 0x40) 51#define GPC_PGC_CTRL(n) (0x800 + (n) * 0x40)
47#define GPC_PGC_SR(n) (GPC_PGC_CTRL(n) + 0xc) 52#define GPC_PGC_SR(n) (GPC_PGC_CTRL(n) + 0xc)
48 53
diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 9dc02f390ba3..5856e792d09c 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -5,7 +5,8 @@ menu "Qualcomm SoC drivers"
5 5
6config QCOM_COMMAND_DB 6config QCOM_COMMAND_DB
7 bool "Qualcomm Command DB" 7 bool "Qualcomm Command DB"
8 depends on (ARCH_QCOM && OF) || COMPILE_TEST 8 depends on ARCH_QCOM || COMPILE_TEST
9 depends on OF_RESERVED_MEM
9 help 10 help
10 Command DB queries shared memory by key string for shared system 11 Command DB queries shared memory by key string for shared system
11 resources. Platform drivers that require to set state of a shared 12 resources. Platform drivers that require to set state of a shared
diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
index 95120acc4d80..50d03d8b4f9a 100644
--- a/drivers/soc/renesas/rcar-sysc.c
+++ b/drivers/soc/renesas/rcar-sysc.c
@@ -194,11 +194,12 @@ static int rcar_sysc_pd_power_on(struct generic_pm_domain *genpd)
194 194
195static bool has_cpg_mstp; 195static bool has_cpg_mstp;
196 196
197static void __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd) 197static int __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
198{ 198{
199 struct generic_pm_domain *genpd = &pd->genpd; 199 struct generic_pm_domain *genpd = &pd->genpd;
200 const char *name = pd->genpd.name; 200 const char *name = pd->genpd.name;
201 struct dev_power_governor *gov = &simple_qos_governor; 201 struct dev_power_governor *gov = &simple_qos_governor;
202 int error;
202 203
203 if (pd->flags & PD_CPU) { 204 if (pd->flags & PD_CPU) {
204 /* 205 /*
@@ -251,7 +252,11 @@ static void __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd)
251 rcar_sysc_power_up(&pd->ch); 252 rcar_sysc_power_up(&pd->ch);
252 253
253finalize: 254finalize:
254 pm_genpd_init(genpd, gov, false); 255 error = pm_genpd_init(genpd, gov, false);
256 if (error)
257 pr_err("Failed to init PM domain %s: %d\n", name, error);
258
259 return error;
255} 260}
256 261
257static const struct of_device_id rcar_sysc_matches[] __initconst = { 262static const struct of_device_id rcar_sysc_matches[] __initconst = {
@@ -375,6 +380,9 @@ static int __init rcar_sysc_pd_init(void)
375 pr_debug("%pOF: syscier = 0x%08x\n", np, syscier); 380 pr_debug("%pOF: syscier = 0x%08x\n", np, syscier);
376 iowrite32(syscier, base + SYSCIER); 381 iowrite32(syscier, base + SYSCIER);
377 382
383 /*
384 * First, create all PM domains
385 */
378 for (i = 0; i < info->num_areas; i++) { 386 for (i = 0; i < info->num_areas; i++) {
379 const struct rcar_sysc_area *area = &info->areas[i]; 387 const struct rcar_sysc_area *area = &info->areas[i];
380 struct rcar_sysc_pd *pd; 388 struct rcar_sysc_pd *pd;
@@ -397,14 +405,29 @@ static int __init rcar_sysc_pd_init(void)
397 pd->ch.isr_bit = area->isr_bit; 405 pd->ch.isr_bit = area->isr_bit;
398 pd->flags = area->flags; 406 pd->flags = area->flags;
399 407
400 rcar_sysc_pd_setup(pd); 408 error = rcar_sysc_pd_setup(pd);
401 if (area->parent >= 0) 409 if (error)
402 pm_genpd_add_subdomain(domains->domains[area->parent], 410 goto out_put;
403 &pd->genpd);
404 411
405 domains->domains[area->isr_bit] = &pd->genpd; 412 domains->domains[area->isr_bit] = &pd->genpd;
406 } 413 }
407 414
415 /*
416 * Second, link all PM domains to their parents
417 */
418 for (i = 0; i < info->num_areas; i++) {
419 const struct rcar_sysc_area *area = &info->areas[i];
420
421 if (!area->name || area->parent < 0)
422 continue;
423
424 error = pm_genpd_add_subdomain(domains->domains[area->parent],
425 domains->domains[area->isr_bit]);
426 if (error)
427 pr_warn("Failed to add PM subdomain %s to parent %u\n",
428 area->name, area->parent);
429 }
430
408 error = of_genpd_add_provider_onecell(np, &domains->onecell_data); 431 error = of_genpd_add_provider_onecell(np, &domains->onecell_data);
409 432
410out_put: 433out_put:
diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
index 369aef5e7228..f5cb8c0af09f 100644
--- a/drivers/soc/ti/wkup_m3_ipc.c
+++ b/drivers/soc/ti/wkup_m3_ipc.c
@@ -46,6 +46,7 @@
46#define M3_BASELINE_VERSION 0x191 46#define M3_BASELINE_VERSION 0x191
47#define M3_STATUS_RESP_MASK (0xffff << 16) 47#define M3_STATUS_RESP_MASK (0xffff << 16)
48#define M3_FW_VERSION_MASK 0xffff 48#define M3_FW_VERSION_MASK 0xffff
49#define M3_WAKE_SRC_MASK 0xff
49 50
50#define M3_STATE_UNKNOWN 0 51#define M3_STATE_UNKNOWN 0
51#define M3_STATE_RESET 1 52#define M3_STATE_RESET 1
@@ -55,6 +56,23 @@
55 56
56static struct wkup_m3_ipc *m3_ipc_state; 57static struct wkup_m3_ipc *m3_ipc_state;
57 58
59static const struct wkup_m3_wakeup_src wakeups[] = {
60 {.irq_nr = 35, .src = "USB0_PHY"},
61 {.irq_nr = 36, .src = "USB1_PHY"},
62 {.irq_nr = 40, .src = "I2C0"},
63 {.irq_nr = 41, .src = "RTC Timer"},
64 {.irq_nr = 42, .src = "RTC Alarm"},
65 {.irq_nr = 43, .src = "Timer0"},
66 {.irq_nr = 44, .src = "Timer1"},
67 {.irq_nr = 45, .src = "UART"},
68 {.irq_nr = 46, .src = "GPIO0"},
69 {.irq_nr = 48, .src = "MPU_WAKE"},
70 {.irq_nr = 49, .src = "WDT0"},
71 {.irq_nr = 50, .src = "WDT1"},
72 {.irq_nr = 51, .src = "ADC_TSC"},
73 {.irq_nr = 0, .src = "Unknown"},
74};
75
58static void am33xx_txev_eoi(struct wkup_m3_ipc *m3_ipc) 76static void am33xx_txev_eoi(struct wkup_m3_ipc *m3_ipc)
59{ 77{
60 writel(AM33XX_M3_TXEV_ACK, 78 writel(AM33XX_M3_TXEV_ACK,
@@ -329,12 +347,45 @@ static int wkup_m3_finish_low_power(struct wkup_m3_ipc *m3_ipc)
329 return 0; 347 return 0;
330} 348}
331 349
350/**
351 * wkup_m3_request_wake_src - Get the wakeup source info passed from wkup_m3
352 * @m3_ipc: Pointer to wkup_m3_ipc context
353 */
354static const char *wkup_m3_request_wake_src(struct wkup_m3_ipc *m3_ipc)
355{
356 unsigned int wakeup_src_idx;
357 int j, val;
358
359 val = wkup_m3_ctrl_ipc_read(m3_ipc, 6);
360
361 wakeup_src_idx = val & M3_WAKE_SRC_MASK;
362
363 for (j = 0; j < ARRAY_SIZE(wakeups) - 1; j++) {
364 if (wakeups[j].irq_nr == wakeup_src_idx)
365 return wakeups[j].src;
366 }
367 return wakeups[j].src;
368}
369
370/**
371 * wkup_m3_set_rtc_only - Set the rtc_only flag
372 * @wkup_m3_wakeup: struct wkup_m3_wakeup_src * gets assigned the
373 * wakeup src value
374 */
375static void wkup_m3_set_rtc_only(struct wkup_m3_ipc *m3_ipc)
376{
377 if (m3_ipc_state)
378 m3_ipc_state->is_rtc_only = true;
379}
380
332static struct wkup_m3_ipc_ops ipc_ops = { 381static struct wkup_m3_ipc_ops ipc_ops = {
333 .set_mem_type = wkup_m3_set_mem_type, 382 .set_mem_type = wkup_m3_set_mem_type,
334 .set_resume_address = wkup_m3_set_resume_address, 383 .set_resume_address = wkup_m3_set_resume_address,
335 .prepare_low_power = wkup_m3_prepare_low_power, 384 .prepare_low_power = wkup_m3_prepare_low_power,
336 .finish_low_power = wkup_m3_finish_low_power, 385 .finish_low_power = wkup_m3_finish_low_power,
337 .request_pm_status = wkup_m3_request_pm_status, 386 .request_pm_status = wkup_m3_request_pm_status,
387 .request_wake_src = wkup_m3_request_wake_src,
388 .set_rtc_only = wkup_m3_set_rtc_only,
338}; 389};
339 390
340/** 391/**
@@ -484,6 +535,30 @@ static int wkup_m3_ipc_remove(struct platform_device *pdev)
484 return 0; 535 return 0;
485} 536}
486 537
538static int __maybe_unused wkup_m3_ipc_suspend(struct device *dev)
539{
540 /*
541 * Nothing needs to be done on suspend even with rtc_only flag set
542 */
543 return 0;
544}
545
546static int __maybe_unused wkup_m3_ipc_resume(struct device *dev)
547{
548 if (m3_ipc_state->is_rtc_only) {
549 rproc_shutdown(m3_ipc_state->rproc);
550 rproc_boot(m3_ipc_state->rproc);
551 }
552
553 m3_ipc_state->is_rtc_only = false;
554
555 return 0;
556}
557
558static const struct dev_pm_ops wkup_m3_ipc_pm_ops = {
559 SET_SYSTEM_SLEEP_PM_OPS(wkup_m3_ipc_suspend, wkup_m3_ipc_resume)
560};
561
487static const struct of_device_id wkup_m3_ipc_of_match[] = { 562static const struct of_device_id wkup_m3_ipc_of_match[] = {
488 { .compatible = "ti,am3352-wkup-m3-ipc", }, 563 { .compatible = "ti,am3352-wkup-m3-ipc", },
489 { .compatible = "ti,am4372-wkup-m3-ipc", }, 564 { .compatible = "ti,am4372-wkup-m3-ipc", },
@@ -497,6 +572,7 @@ static struct platform_driver wkup_m3_ipc_driver = {
497 .driver = { 572 .driver = {
498 .name = "wkup_m3_ipc", 573 .name = "wkup_m3_ipc",
499 .of_match_table = wkup_m3_ipc_of_match, 574 .of_match_table = wkup_m3_ipc_of_match,
575 .pm = &wkup_m3_ipc_pm_ops,
500 }, 576 },
501}; 577};
502 578
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
index e8c440329708..31db510018a9 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -30,7 +30,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap,
30 struct page **tmp = pages; 30 struct page **tmp = pages;
31 31
32 if (!pages) 32 if (!pages)
33 return NULL; 33 return ERR_PTR(-ENOMEM);
34 34
35 if (buffer->flags & ION_FLAG_CACHED) 35 if (buffer->flags & ION_FLAG_CACHED)
36 pgprot = PAGE_KERNEL; 36 pgprot = PAGE_KERNEL;
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index ea194aa01a64..257b0daff01f 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -642,7 +642,7 @@ static int daqp_ao_insn_write(struct comedi_device *dev,
642 /* Make sure D/A update mode is direct update */ 642 /* Make sure D/A update mode is direct update */
643 outb(0, dev->iobase + DAQP_AUX_REG); 643 outb(0, dev->iobase + DAQP_AUX_REG);
644 644
645 for (i = 0; i > insn->n; i++) { 645 for (i = 0; i < insn->n; i++) {
646 unsigned int val = data[i]; 646 unsigned int val = data[i];
647 int ret; 647 int ret;
648 648
diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig
index 3aa981fbc8f5..e45ed08a5166 100644
--- a/drivers/staging/typec/Kconfig
+++ b/drivers/staging/typec/Kconfig
@@ -11,6 +11,7 @@ config TYPEC_TCPCI
11 11
12config TYPEC_RT1711H 12config TYPEC_RT1711H
13 tristate "Richtek RT1711H Type-C chip driver" 13 tristate "Richtek RT1711H Type-C chip driver"
14 depends on I2C
14 select TYPEC_TCPCI 15 select TYPEC_TCPCI
15 help 16 help
16 Richtek RT1711H Type-C chip driver that works with 17 Richtek RT1711H Type-C chip driver that works with
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 7f96dfa32b9c..d8dc3d22051f 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -656,7 +656,7 @@ static void scatter_data_area(struct tcmu_dev *udev,
656} 656}
657 657
658static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd, 658static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
659 bool bidi) 659 bool bidi, uint32_t read_len)
660{ 660{
661 struct se_cmd *se_cmd = cmd->se_cmd; 661 struct se_cmd *se_cmd = cmd->se_cmd;
662 int i, dbi; 662 int i, dbi;
@@ -689,7 +689,7 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
689 for_each_sg(data_sg, sg, data_nents, i) { 689 for_each_sg(data_sg, sg, data_nents, i) {
690 int sg_remaining = sg->length; 690 int sg_remaining = sg->length;
691 to = kmap_atomic(sg_page(sg)) + sg->offset; 691 to = kmap_atomic(sg_page(sg)) + sg->offset;
692 while (sg_remaining > 0) { 692 while (sg_remaining > 0 && read_len > 0) {
693 if (block_remaining == 0) { 693 if (block_remaining == 0) {
694 if (from) 694 if (from)
695 kunmap_atomic(from); 695 kunmap_atomic(from);
@@ -701,6 +701,8 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
701 } 701 }
702 copy_bytes = min_t(size_t, sg_remaining, 702 copy_bytes = min_t(size_t, sg_remaining,
703 block_remaining); 703 block_remaining);
704 if (read_len < copy_bytes)
705 copy_bytes = read_len;
704 offset = DATA_BLOCK_SIZE - block_remaining; 706 offset = DATA_BLOCK_SIZE - block_remaining;
705 tcmu_flush_dcache_range(from, copy_bytes); 707 tcmu_flush_dcache_range(from, copy_bytes);
706 memcpy(to + sg->length - sg_remaining, from + offset, 708 memcpy(to + sg->length - sg_remaining, from + offset,
@@ -708,8 +710,11 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
708 710
709 sg_remaining -= copy_bytes; 711 sg_remaining -= copy_bytes;
710 block_remaining -= copy_bytes; 712 block_remaining -= copy_bytes;
713 read_len -= copy_bytes;
711 } 714 }
712 kunmap_atomic(to - sg->offset); 715 kunmap_atomic(to - sg->offset);
716 if (read_len == 0)
717 break;
713 } 718 }
714 if (from) 719 if (from)
715 kunmap_atomic(from); 720 kunmap_atomic(from);
@@ -1042,6 +1047,8 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
1042{ 1047{
1043 struct se_cmd *se_cmd = cmd->se_cmd; 1048 struct se_cmd *se_cmd = cmd->se_cmd;
1044 struct tcmu_dev *udev = cmd->tcmu_dev; 1049 struct tcmu_dev *udev = cmd->tcmu_dev;
1050 bool read_len_valid = false;
1051 uint32_t read_len = se_cmd->data_length;
1045 1052
1046 /* 1053 /*
1047 * cmd has been completed already from timeout, just reclaim 1054 * cmd has been completed already from timeout, just reclaim
@@ -1056,13 +1063,28 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
1056 pr_warn("TCMU: Userspace set UNKNOWN_OP flag on se_cmd %p\n", 1063 pr_warn("TCMU: Userspace set UNKNOWN_OP flag on se_cmd %p\n",
1057 cmd->se_cmd); 1064 cmd->se_cmd);
1058 entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION; 1065 entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION;
1059 } else if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) { 1066 goto done;
1067 }
1068
1069 if (se_cmd->data_direction == DMA_FROM_DEVICE &&
1070 (entry->hdr.uflags & TCMU_UFLAG_READ_LEN) && entry->rsp.read_len) {
1071 read_len_valid = true;
1072 if (entry->rsp.read_len < read_len)
1073 read_len = entry->rsp.read_len;
1074 }
1075
1076 if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) {
1060 transport_copy_sense_to_cmd(se_cmd, entry->rsp.sense_buffer); 1077 transport_copy_sense_to_cmd(se_cmd, entry->rsp.sense_buffer);
1061 } else if (se_cmd->se_cmd_flags & SCF_BIDI) { 1078 if (!read_len_valid )
1079 goto done;
1080 else
1081 se_cmd->se_cmd_flags |= SCF_TREAT_READ_AS_NORMAL;
1082 }
1083 if (se_cmd->se_cmd_flags & SCF_BIDI) {
1062 /* Get Data-In buffer before clean up */ 1084 /* Get Data-In buffer before clean up */
1063 gather_data_area(udev, cmd, true); 1085 gather_data_area(udev, cmd, true, read_len);
1064 } else if (se_cmd->data_direction == DMA_FROM_DEVICE) { 1086 } else if (se_cmd->data_direction == DMA_FROM_DEVICE) {
1065 gather_data_area(udev, cmd, false); 1087 gather_data_area(udev, cmd, false, read_len);
1066 } else if (se_cmd->data_direction == DMA_TO_DEVICE) { 1088 } else if (se_cmd->data_direction == DMA_TO_DEVICE) {
1067 /* TODO: */ 1089 /* TODO: */
1068 } else if (se_cmd->data_direction != DMA_NONE) { 1090 } else if (se_cmd->data_direction != DMA_NONE) {
@@ -1070,7 +1092,13 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
1070 se_cmd->data_direction); 1092 se_cmd->data_direction);
1071 } 1093 }
1072 1094
1073 target_complete_cmd(cmd->se_cmd, entry->rsp.scsi_status); 1095done:
1096 if (read_len_valid) {
1097 pr_debug("read_len = %d\n", read_len);
1098 target_complete_cmd_with_length(cmd->se_cmd,
1099 entry->rsp.scsi_status, read_len);
1100 } else
1101 target_complete_cmd(cmd->se_cmd, entry->rsp.scsi_status);
1074 1102
1075out: 1103out:
1076 cmd->se_cmd = NULL; 1104 cmd->se_cmd = NULL;
@@ -1740,7 +1768,7 @@ static int tcmu_configure_device(struct se_device *dev)
1740 /* Initialise the mailbox of the ring buffer */ 1768 /* Initialise the mailbox of the ring buffer */
1741 mb = udev->mb_addr; 1769 mb = udev->mb_addr;
1742 mb->version = TCMU_MAILBOX_VERSION; 1770 mb->version = TCMU_MAILBOX_VERSION;
1743 mb->flags = TCMU_MAILBOX_FLAG_CAP_OOOC; 1771 mb->flags = TCMU_MAILBOX_FLAG_CAP_OOOC | TCMU_MAILBOX_FLAG_CAP_READ_LEN;
1744 mb->cmdr_off = CMDR_OFF; 1772 mb->cmdr_off = CMDR_OFF;
1745 mb->cmdr_size = udev->cmdr_size; 1773 mb->cmdr_size = udev->cmdr_size;
1746 1774
diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig
index 0126de898036..3c59e19029be 100644
--- a/drivers/tee/optee/Kconfig
+++ b/drivers/tee/optee/Kconfig
@@ -5,3 +5,11 @@ config OPTEE
5 help 5 help
6 This implements the OP-TEE Trusted Execution Environment (TEE) 6 This implements the OP-TEE Trusted Execution Environment (TEE)
7 driver. 7 driver.
8
9config OPTEE_SHM_NUM_PRIV_PAGES
10 int "Private Shared Memory Pages"
11 default 1
12 depends on OPTEE
13 help
14 This sets the number of private shared memory pages to be
15 used by OP-TEE TEE driver.
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index e5fd5ed217da..e1aafe842d66 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -32,7 +32,7 @@
32 32
33#define DRIVER_NAME "optee" 33#define DRIVER_NAME "optee"
34 34
35#define OPTEE_SHM_NUM_PRIV_PAGES 1 35#define OPTEE_SHM_NUM_PRIV_PAGES CONFIG_OPTEE_SHM_NUM_PRIV_PAGES
36 36
37/** 37/**
38 * optee_from_msg_param() - convert from OPTEE_MSG parameters to 38 * optee_from_msg_param() - convert from OPTEE_MSG parameters to
diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
index 41aea12e2bcc..b45c73dd37a5 100644
--- a/drivers/tee/optee/rpc.c
+++ b/drivers/tee/optee/rpc.c
@@ -48,7 +48,7 @@ static void handle_rpc_func_cmd_get_time(struct optee_msg_arg *arg)
48 OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT) 48 OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT)
49 goto bad; 49 goto bad;
50 50
51 getnstimeofday64(&ts); 51 ktime_get_real_ts64(&ts);
52 arg->params[0].u.value.a = ts.tv_sec; 52 arg->params[0].u.value.a = ts.tv_sec;
53 arg->params[0].u.value.b = ts.tv_nsec; 53 arg->params[0].u.value.b = ts.tv_nsec;
54 54
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index cbe98bc2b998..431742201709 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -124,6 +124,8 @@ struct n_tty_data {
124 struct mutex output_lock; 124 struct mutex output_lock;
125}; 125};
126 126
127#define MASK(x) ((x) & (N_TTY_BUF_SIZE - 1))
128
127static inline size_t read_cnt(struct n_tty_data *ldata) 129static inline size_t read_cnt(struct n_tty_data *ldata)
128{ 130{
129 return ldata->read_head - ldata->read_tail; 131 return ldata->read_head - ldata->read_tail;
@@ -141,6 +143,7 @@ static inline unsigned char *read_buf_addr(struct n_tty_data *ldata, size_t i)
141 143
142static inline unsigned char echo_buf(struct n_tty_data *ldata, size_t i) 144static inline unsigned char echo_buf(struct n_tty_data *ldata, size_t i)
143{ 145{
146 smp_rmb(); /* Matches smp_wmb() in add_echo_byte(). */
144 return ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)]; 147 return ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)];
145} 148}
146 149
@@ -316,9 +319,7 @@ static inline void put_tty_queue(unsigned char c, struct n_tty_data *ldata)
316static void reset_buffer_flags(struct n_tty_data *ldata) 319static void reset_buffer_flags(struct n_tty_data *ldata)
317{ 320{
318 ldata->read_head = ldata->canon_head = ldata->read_tail = 0; 321 ldata->read_head = ldata->canon_head = ldata->read_tail = 0;
319 ldata->echo_head = ldata->echo_tail = ldata->echo_commit = 0;
320 ldata->commit_head = 0; 322 ldata->commit_head = 0;
321 ldata->echo_mark = 0;
322 ldata->line_start = 0; 323 ldata->line_start = 0;
323 324
324 ldata->erasing = 0; 325 ldata->erasing = 0;
@@ -617,13 +618,20 @@ static size_t __process_echoes(struct tty_struct *tty)
617 old_space = space = tty_write_room(tty); 618 old_space = space = tty_write_room(tty);
618 619
619 tail = ldata->echo_tail; 620 tail = ldata->echo_tail;
620 while (ldata->echo_commit != tail) { 621 while (MASK(ldata->echo_commit) != MASK(tail)) {
621 c = echo_buf(ldata, tail); 622 c = echo_buf(ldata, tail);
622 if (c == ECHO_OP_START) { 623 if (c == ECHO_OP_START) {
623 unsigned char op; 624 unsigned char op;
624 int no_space_left = 0; 625 int no_space_left = 0;
625 626
626 /* 627 /*
628 * Since add_echo_byte() is called without holding
629 * output_lock, we might see only portion of multi-byte
630 * operation.
631 */
632 if (MASK(ldata->echo_commit) == MASK(tail + 1))
633 goto not_yet_stored;
634 /*
627 * If the buffer byte is the start of a multi-byte 635 * If the buffer byte is the start of a multi-byte
628 * operation, get the next byte, which is either the 636 * operation, get the next byte, which is either the
629 * op code or a control character value. 637 * op code or a control character value.
@@ -634,6 +642,8 @@ static size_t __process_echoes(struct tty_struct *tty)
634 unsigned int num_chars, num_bs; 642 unsigned int num_chars, num_bs;
635 643
636 case ECHO_OP_ERASE_TAB: 644 case ECHO_OP_ERASE_TAB:
645 if (MASK(ldata->echo_commit) == MASK(tail + 2))
646 goto not_yet_stored;
637 num_chars = echo_buf(ldata, tail + 2); 647 num_chars = echo_buf(ldata, tail + 2);
638 648
639 /* 649 /*
@@ -728,7 +738,8 @@ static size_t __process_echoes(struct tty_struct *tty)
728 /* If the echo buffer is nearly full (so that the possibility exists 738 /* If the echo buffer is nearly full (so that the possibility exists
729 * of echo overrun before the next commit), then discard enough 739 * of echo overrun before the next commit), then discard enough
730 * data at the tail to prevent a subsequent overrun */ 740 * data at the tail to prevent a subsequent overrun */
731 while (ldata->echo_commit - tail >= ECHO_DISCARD_WATERMARK) { 741 while (ldata->echo_commit > tail &&
742 ldata->echo_commit - tail >= ECHO_DISCARD_WATERMARK) {
732 if (echo_buf(ldata, tail) == ECHO_OP_START) { 743 if (echo_buf(ldata, tail) == ECHO_OP_START) {
733 if (echo_buf(ldata, tail + 1) == ECHO_OP_ERASE_TAB) 744 if (echo_buf(ldata, tail + 1) == ECHO_OP_ERASE_TAB)
734 tail += 3; 745 tail += 3;
@@ -738,6 +749,7 @@ static size_t __process_echoes(struct tty_struct *tty)
738 tail++; 749 tail++;
739 } 750 }
740 751
752 not_yet_stored:
741 ldata->echo_tail = tail; 753 ldata->echo_tail = tail;
742 return old_space - space; 754 return old_space - space;
743} 755}
@@ -748,6 +760,7 @@ static void commit_echoes(struct tty_struct *tty)
748 size_t nr, old, echoed; 760 size_t nr, old, echoed;
749 size_t head; 761 size_t head;
750 762
763 mutex_lock(&ldata->output_lock);
751 head = ldata->echo_head; 764 head = ldata->echo_head;
752 ldata->echo_mark = head; 765 ldata->echo_mark = head;
753 old = ldata->echo_commit - ldata->echo_tail; 766 old = ldata->echo_commit - ldata->echo_tail;
@@ -756,10 +769,12 @@ static void commit_echoes(struct tty_struct *tty)
756 * is over the threshold (and try again each time another 769 * is over the threshold (and try again each time another
757 * block is accumulated) */ 770 * block is accumulated) */
758 nr = head - ldata->echo_tail; 771 nr = head - ldata->echo_tail;
759 if (nr < ECHO_COMMIT_WATERMARK || (nr % ECHO_BLOCK > old % ECHO_BLOCK)) 772 if (nr < ECHO_COMMIT_WATERMARK ||
773 (nr % ECHO_BLOCK > old % ECHO_BLOCK)) {
774 mutex_unlock(&ldata->output_lock);
760 return; 775 return;
776 }
761 777
762 mutex_lock(&ldata->output_lock);
763 ldata->echo_commit = head; 778 ldata->echo_commit = head;
764 echoed = __process_echoes(tty); 779 echoed = __process_echoes(tty);
765 mutex_unlock(&ldata->output_lock); 780 mutex_unlock(&ldata->output_lock);
@@ -810,7 +825,9 @@ static void flush_echoes(struct tty_struct *tty)
810 825
811static inline void add_echo_byte(unsigned char c, struct n_tty_data *ldata) 826static inline void add_echo_byte(unsigned char c, struct n_tty_data *ldata)
812{ 827{
813 *echo_buf_addr(ldata, ldata->echo_head++) = c; 828 *echo_buf_addr(ldata, ldata->echo_head) = c;
829 smp_wmb(); /* Matches smp_rmb() in echo_buf(). */
830 ldata->echo_head++;
814} 831}
815 832
816/** 833/**
@@ -978,14 +995,15 @@ static void eraser(unsigned char c, struct tty_struct *tty)
978 } 995 }
979 996
980 seen_alnums = 0; 997 seen_alnums = 0;
981 while (ldata->read_head != ldata->canon_head) { 998 while (MASK(ldata->read_head) != MASK(ldata->canon_head)) {
982 head = ldata->read_head; 999 head = ldata->read_head;
983 1000
984 /* erase a single possibly multibyte character */ 1001 /* erase a single possibly multibyte character */
985 do { 1002 do {
986 head--; 1003 head--;
987 c = read_buf(ldata, head); 1004 c = read_buf(ldata, head);
988 } while (is_continuation(c, tty) && head != ldata->canon_head); 1005 } while (is_continuation(c, tty) &&
1006 MASK(head) != MASK(ldata->canon_head));
989 1007
990 /* do not partially erase */ 1008 /* do not partially erase */
991 if (is_continuation(c, tty)) 1009 if (is_continuation(c, tty))
@@ -1027,7 +1045,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
1027 * This info is used to go back the correct 1045 * This info is used to go back the correct
1028 * number of columns. 1046 * number of columns.
1029 */ 1047 */
1030 while (tail != ldata->canon_head) { 1048 while (MASK(tail) != MASK(ldata->canon_head)) {
1031 tail--; 1049 tail--;
1032 c = read_buf(ldata, tail); 1050 c = read_buf(ldata, tail);
1033 if (c == '\t') { 1051 if (c == '\t') {
@@ -1302,7 +1320,7 @@ n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
1302 finish_erasing(ldata); 1320 finish_erasing(ldata);
1303 echo_char(c, tty); 1321 echo_char(c, tty);
1304 echo_char_raw('\n', ldata); 1322 echo_char_raw('\n', ldata);
1305 while (tail != ldata->read_head) { 1323 while (MASK(tail) != MASK(ldata->read_head)) {
1306 echo_char(read_buf(ldata, tail), tty); 1324 echo_char(read_buf(ldata, tail), tty);
1307 tail++; 1325 tail++;
1308 } 1326 }
@@ -1878,30 +1896,21 @@ static int n_tty_open(struct tty_struct *tty)
1878 struct n_tty_data *ldata; 1896 struct n_tty_data *ldata;
1879 1897
1880 /* Currently a malloc failure here can panic */ 1898 /* Currently a malloc failure here can panic */
1881 ldata = vmalloc(sizeof(*ldata)); 1899 ldata = vzalloc(sizeof(*ldata));
1882 if (!ldata) 1900 if (!ldata)
1883 goto err; 1901 return -ENOMEM;
1884 1902
1885 ldata->overrun_time = jiffies; 1903 ldata->overrun_time = jiffies;
1886 mutex_init(&ldata->atomic_read_lock); 1904 mutex_init(&ldata->atomic_read_lock);
1887 mutex_init(&ldata->output_lock); 1905 mutex_init(&ldata->output_lock);
1888 1906
1889 tty->disc_data = ldata; 1907 tty->disc_data = ldata;
1890 reset_buffer_flags(tty->disc_data);
1891 ldata->column = 0;
1892 ldata->canon_column = 0;
1893 ldata->num_overrun = 0;
1894 ldata->no_room = 0;
1895 ldata->lnext = 0;
1896 tty->closing = 0; 1908 tty->closing = 0;
1897 /* indicate buffer work may resume */ 1909 /* indicate buffer work may resume */
1898 clear_bit(TTY_LDISC_HALTED, &tty->flags); 1910 clear_bit(TTY_LDISC_HALTED, &tty->flags);
1899 n_tty_set_termios(tty, NULL); 1911 n_tty_set_termios(tty, NULL);
1900 tty_unthrottle(tty); 1912 tty_unthrottle(tty);
1901
1902 return 0; 1913 return 0;
1903err:
1904 return -ENOMEM;
1905} 1914}
1906 1915
1907static inline int input_available_p(struct tty_struct *tty, int poll) 1916static inline int input_available_p(struct tty_struct *tty, int poll)
@@ -2411,7 +2420,7 @@ static unsigned long inq_canon(struct n_tty_data *ldata)
2411 tail = ldata->read_tail; 2420 tail = ldata->read_tail;
2412 nr = head - tail; 2421 nr = head - tail;
2413 /* Skip EOF-chars.. */ 2422 /* Skip EOF-chars.. */
2414 while (head != tail) { 2423 while (MASK(head) != MASK(tail)) {
2415 if (test_bit(tail & (N_TTY_BUF_SIZE - 1), ldata->read_flags) && 2424 if (test_bit(tail & (N_TTY_BUF_SIZE - 1), ldata->read_flags) &&
2416 read_buf(ldata, tail) == __DISABLED_CHAR) 2425 read_buf(ldata, tail) == __DISABLED_CHAR)
2417 nr--; 2426 nr--;
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index df93b727e984..9e59f4788589 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -617,6 +617,7 @@ EXPORT_SYMBOL_GPL(__serdev_device_driver_register);
617static void __exit serdev_exit(void) 617static void __exit serdev_exit(void)
618{ 618{
619 bus_unregister(&serdev_bus_type); 619 bus_unregister(&serdev_bus_type);
620 ida_destroy(&ctrl_ida);
620} 621}
621module_exit(serdev_exit); 622module_exit(serdev_exit);
622 623
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 3296a05cda2d..f80a300b5d68 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -3339,9 +3339,7 @@ static const struct pci_device_id blacklist[] = {
3339 /* multi-io cards handled by parport_serial */ 3339 /* multi-io cards handled by parport_serial */
3340 { PCI_DEVICE(0x4348, 0x7053), }, /* WCH CH353 2S1P */ 3340 { PCI_DEVICE(0x4348, 0x7053), }, /* WCH CH353 2S1P */
3341 { PCI_DEVICE(0x4348, 0x5053), }, /* WCH CH353 1S1P */ 3341 { PCI_DEVICE(0x4348, 0x5053), }, /* WCH CH353 1S1P */
3342 { PCI_DEVICE(0x4348, 0x7173), }, /* WCH CH355 4S */
3343 { PCI_DEVICE(0x1c00, 0x3250), }, /* WCH CH382 2S1P */ 3342 { PCI_DEVICE(0x1c00, 0x3250), }, /* WCH CH382 2S1P */
3344 { PCI_DEVICE(0x1c00, 0x3470), }, /* WCH CH384 4S */
3345 3343
3346 /* Moxa Smartio MUE boards handled by 8250_moxa */ 3344 /* Moxa Smartio MUE boards handled by 8250_moxa */
3347 { PCI_VDEVICE(MOXA, 0x1024), }, 3345 { PCI_VDEVICE(MOXA, 0x1024), },
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 1eb1a376a041..15eb6c829d39 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -784,7 +784,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
784 if (!*vc->vc_uni_pagedir_loc) 784 if (!*vc->vc_uni_pagedir_loc)
785 con_set_default_unimap(vc); 785 con_set_default_unimap(vc);
786 786
787 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); 787 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL);
788 if (!vc->vc_screenbuf) 788 if (!vc->vc_screenbuf)
789 goto err_free; 789 goto err_free;
790 790
@@ -871,7 +871,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
871 871
872 if (new_screen_size > (4 << 20)) 872 if (new_screen_size > (4 << 20))
873 return -EINVAL; 873 return -EINVAL;
874 newscreen = kmalloc(new_screen_size, GFP_USER); 874 newscreen = kzalloc(new_screen_size, GFP_USER);
875 if (!newscreen) 875 if (!newscreen)
876 return -ENOMEM; 876 return -ENOMEM;
877 877
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index af45aa3222b5..4638d9b066be 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -124,8 +124,11 @@ static int host_start(struct ci_hdrc *ci)
124 124
125 hcd->power_budget = ci->platdata->power_budget; 125 hcd->power_budget = ci->platdata->power_budget;
126 hcd->tpl_support = ci->platdata->tpl_support; 126 hcd->tpl_support = ci->platdata->tpl_support;
127 if (ci->phy || ci->usb_phy) 127 if (ci->phy || ci->usb_phy) {
128 hcd->skip_phy_initialization = 1; 128 hcd->skip_phy_initialization = 1;
129 if (ci->usb_phy)
130 hcd->usb_phy = ci->usb_phy;
131 }
129 132
130 ehci = hcd_to_ehci(hcd); 133 ehci = hcd_to_ehci(hcd);
131 ehci->caps = ci->hw_bank.cap; 134 ehci->caps = ci->hw_bank.cap;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 7b366a6c0b49..998b32d0167e 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1758,6 +1758,9 @@ static const struct usb_device_id acm_ids[] = {
1758 { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */ 1758 { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */
1759 .driver_info = SINGLE_RX_URB, 1759 .driver_info = SINGLE_RX_URB,
1760 }, 1760 },
1761 { USB_DEVICE(0x1965, 0x0018), /* Uniden UBC125XLT */
1762 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1763 },
1761 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ 1764 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
1762 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1765 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1763 }, 1766 },
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 4a56ac772a3c..71b3b08ad516 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1004,6 +1004,7 @@ struct dwc2_hregs_backup {
1004 * @frame_list_sz: Frame list size 1004 * @frame_list_sz: Frame list size
1005 * @desc_gen_cache: Kmem cache for generic descriptors 1005 * @desc_gen_cache: Kmem cache for generic descriptors
1006 * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors 1006 * @desc_hsisoc_cache: Kmem cache for hs isochronous descriptors
1007 * @unaligned_cache: Kmem cache for DMA mode to handle non-aligned buf
1007 * 1008 *
1008 * These are for peripheral mode: 1009 * These are for peripheral mode:
1009 * 1010 *
@@ -1177,6 +1178,8 @@ struct dwc2_hsotg {
1177 u32 frame_list_sz; 1178 u32 frame_list_sz;
1178 struct kmem_cache *desc_gen_cache; 1179 struct kmem_cache *desc_gen_cache;
1179 struct kmem_cache *desc_hsisoc_cache; 1180 struct kmem_cache *desc_hsisoc_cache;
1181 struct kmem_cache *unaligned_cache;
1182#define DWC2_KMEM_UNALIGNED_BUF_SIZE 1024
1180 1183
1181#endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */ 1184#endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */
1182 1185
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index f0d9ccf1d665..a0f82cca2d9a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -812,6 +812,7 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
812 u32 index; 812 u32 index;
813 u32 maxsize = 0; 813 u32 maxsize = 0;
814 u32 mask = 0; 814 u32 mask = 0;
815 u8 pid = 0;
815 816
816 maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask); 817 maxsize = dwc2_gadget_get_desc_params(hs_ep, &mask);
817 818
@@ -840,7 +841,11 @@ static int dwc2_gadget_fill_isoc_desc(struct dwc2_hsotg_ep *hs_ep,
840 ((len << DEV_DMA_NBYTES_SHIFT) & mask)); 841 ((len << DEV_DMA_NBYTES_SHIFT) & mask));
841 842
842 if (hs_ep->dir_in) { 843 if (hs_ep->dir_in) {
843 desc->status |= ((hs_ep->mc << DEV_DMA_ISOC_PID_SHIFT) & 844 if (len)
845 pid = DIV_ROUND_UP(len, hs_ep->ep.maxpacket);
846 else
847 pid = 1;
848 desc->status |= ((pid << DEV_DMA_ISOC_PID_SHIFT) &
844 DEV_DMA_ISOC_PID_MASK) | 849 DEV_DMA_ISOC_PID_MASK) |
845 ((len % hs_ep->ep.maxpacket) ? 850 ((len % hs_ep->ep.maxpacket) ?
846 DEV_DMA_SHORT : 0) | 851 DEV_DMA_SHORT : 0) |
@@ -884,6 +889,7 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep)
884 struct dwc2_dma_desc *desc; 889 struct dwc2_dma_desc *desc;
885 890
886 if (list_empty(&hs_ep->queue)) { 891 if (list_empty(&hs_ep->queue)) {
892 hs_ep->target_frame = TARGET_FRAME_INITIAL;
887 dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__); 893 dev_dbg(hsotg->dev, "%s: No requests in queue\n", __func__);
888 return; 894 return;
889 } 895 }
@@ -2755,8 +2761,6 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
2755 */ 2761 */
2756 tmp = dwc2_hsotg_read_frameno(hsotg); 2762 tmp = dwc2_hsotg_read_frameno(hsotg);
2757 2763
2758 dwc2_hsotg_complete_request(hsotg, ep, get_ep_head(ep), 0);
2759
2760 if (using_desc_dma(hsotg)) { 2764 if (using_desc_dma(hsotg)) {
2761 if (ep->target_frame == TARGET_FRAME_INITIAL) { 2765 if (ep->target_frame == TARGET_FRAME_INITIAL) {
2762 /* Start first ISO Out */ 2766 /* Start first ISO Out */
@@ -2817,9 +2821,6 @@ static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep)
2817 2821
2818 tmp = dwc2_hsotg_read_frameno(hsotg); 2822 tmp = dwc2_hsotg_read_frameno(hsotg);
2819 if (using_desc_dma(hsotg)) { 2823 if (using_desc_dma(hsotg)) {
2820 dwc2_hsotg_complete_request(hsotg, hs_ep,
2821 get_ep_head(hs_ep), 0);
2822
2823 hs_ep->target_frame = tmp; 2824 hs_ep->target_frame = tmp;
2824 dwc2_gadget_incr_frame_num(hs_ep); 2825 dwc2_gadget_incr_frame_num(hs_ep);
2825 dwc2_gadget_start_isoc_ddma(hs_ep); 2826 dwc2_gadget_start_isoc_ddma(hs_ep);
@@ -4739,9 +4740,11 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
4739 } 4740 }
4740 4741
4741 ret = usb_add_gadget_udc(dev, &hsotg->gadget); 4742 ret = usb_add_gadget_udc(dev, &hsotg->gadget);
4742 if (ret) 4743 if (ret) {
4744 dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
4745 hsotg->ctrl_req);
4743 return ret; 4746 return ret;
4744 4747 }
4745 dwc2_hsotg_dump(hsotg); 4748 dwc2_hsotg_dump(hsotg);
4746 4749
4747 return 0; 4750 return 0;
@@ -4755,6 +4758,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
4755int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg) 4758int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
4756{ 4759{
4757 usb_del_gadget_udc(&hsotg->gadget); 4760 usb_del_gadget_udc(&hsotg->gadget);
4761 dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
4758 4762
4759 return 0; 4763 return 0;
4760} 4764}
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index edaf0b6af4f0..b1104be3429c 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1567,11 +1567,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg,
1567 } 1567 }
1568 1568
1569 if (hsotg->params.host_dma) { 1569 if (hsotg->params.host_dma) {
1570 dwc2_writel((u32)chan->xfer_dma, 1570 dma_addr_t dma_addr;
1571 hsotg->regs + HCDMA(chan->hc_num)); 1571
1572 if (chan->align_buf) {
1573 if (dbg_hc(chan))
1574 dev_vdbg(hsotg->dev, "align_buf\n");
1575 dma_addr = chan->align_buf;
1576 } else {
1577 dma_addr = chan->xfer_dma;
1578 }
1579 dwc2_writel((u32)dma_addr, hsotg->regs + HCDMA(chan->hc_num));
1580
1572 if (dbg_hc(chan)) 1581 if (dbg_hc(chan))
1573 dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n", 1582 dev_vdbg(hsotg->dev, "Wrote %08lx to HCDMA(%d)\n",
1574 (unsigned long)chan->xfer_dma, chan->hc_num); 1583 (unsigned long)dma_addr, chan->hc_num);
1575 } 1584 }
1576 1585
1577 /* Start the split */ 1586 /* Start the split */
@@ -2625,6 +2634,35 @@ static void dwc2_hc_init_xfer(struct dwc2_hsotg *hsotg,
2625 } 2634 }
2626} 2635}
2627 2636
2637static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
2638 struct dwc2_qh *qh,
2639 struct dwc2_host_chan *chan)
2640{
2641 if (!hsotg->unaligned_cache ||
2642 chan->max_packet > DWC2_KMEM_UNALIGNED_BUF_SIZE)
2643 return -ENOMEM;
2644
2645 if (!qh->dw_align_buf) {
2646 qh->dw_align_buf = kmem_cache_alloc(hsotg->unaligned_cache,
2647 GFP_ATOMIC | GFP_DMA);
2648 if (!qh->dw_align_buf)
2649 return -ENOMEM;
2650 }
2651
2652 qh->dw_align_buf_dma = dma_map_single(hsotg->dev, qh->dw_align_buf,
2653 DWC2_KMEM_UNALIGNED_BUF_SIZE,
2654 DMA_FROM_DEVICE);
2655
2656 if (dma_mapping_error(hsotg->dev, qh->dw_align_buf_dma)) {
2657 dev_err(hsotg->dev, "can't map align_buf\n");
2658 chan->align_buf = 0;
2659 return -EINVAL;
2660 }
2661
2662 chan->align_buf = qh->dw_align_buf_dma;
2663 return 0;
2664}
2665
2628#define DWC2_USB_DMA_ALIGN 4 2666#define DWC2_USB_DMA_ALIGN 4
2629 2667
2630struct dma_aligned_buffer { 2668struct dma_aligned_buffer {
@@ -2802,6 +2840,32 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
2802 /* Set the transfer attributes */ 2840 /* Set the transfer attributes */
2803 dwc2_hc_init_xfer(hsotg, chan, qtd); 2841 dwc2_hc_init_xfer(hsotg, chan, qtd);
2804 2842
2843 /* For non-dword aligned buffers */
2844 if (hsotg->params.host_dma && qh->do_split &&
2845 chan->ep_is_in && (chan->xfer_dma & 0x3)) {
2846 dev_vdbg(hsotg->dev, "Non-aligned buffer\n");
2847 if (dwc2_alloc_split_dma_aligned_buf(hsotg, qh, chan)) {
2848 dev_err(hsotg->dev,
2849 "Failed to allocate memory to handle non-aligned buffer\n");
2850 /* Add channel back to free list */
2851 chan->align_buf = 0;
2852 chan->multi_count = 0;
2853 list_add_tail(&chan->hc_list_entry,
2854 &hsotg->free_hc_list);
2855 qtd->in_process = 0;
2856 qh->channel = NULL;
2857 return -ENOMEM;
2858 }
2859 } else {
2860 /*
2861 * We assume that DMA is always aligned in non-split
2862 * case or split out case. Warn if not.
2863 */
2864 WARN_ON_ONCE(hsotg->params.host_dma &&
2865 (chan->xfer_dma & 0x3));
2866 chan->align_buf = 0;
2867 }
2868
2805 if (chan->ep_type == USB_ENDPOINT_XFER_INT || 2869 if (chan->ep_type == USB_ENDPOINT_XFER_INT ||
2806 chan->ep_type == USB_ENDPOINT_XFER_ISOC) 2870 chan->ep_type == USB_ENDPOINT_XFER_ISOC)
2807 /* 2871 /*
@@ -5246,6 +5310,19 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
5246 } 5310 }
5247 } 5311 }
5248 5312
5313 if (hsotg->params.host_dma) {
5314 /*
5315 * Create kmem caches to handle non-aligned buffer
5316 * in Buffer DMA mode.
5317 */
5318 hsotg->unaligned_cache = kmem_cache_create("dwc2-unaligned-dma",
5319 DWC2_KMEM_UNALIGNED_BUF_SIZE, 4,
5320 SLAB_CACHE_DMA, NULL);
5321 if (!hsotg->unaligned_cache)
5322 dev_err(hsotg->dev,
5323 "unable to create dwc2 unaligned cache\n");
5324 }
5325
5249 hsotg->otg_port = 1; 5326 hsotg->otg_port = 1;
5250 hsotg->frame_list = NULL; 5327 hsotg->frame_list = NULL;
5251 hsotg->frame_list_dma = 0; 5328 hsotg->frame_list_dma = 0;
@@ -5280,8 +5357,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
5280 return 0; 5357 return 0;
5281 5358
5282error4: 5359error4:
5283 kmem_cache_destroy(hsotg->desc_gen_cache); 5360 kmem_cache_destroy(hsotg->unaligned_cache);
5284 kmem_cache_destroy(hsotg->desc_hsisoc_cache); 5361 kmem_cache_destroy(hsotg->desc_hsisoc_cache);
5362 kmem_cache_destroy(hsotg->desc_gen_cache);
5285error3: 5363error3:
5286 dwc2_hcd_release(hsotg); 5364 dwc2_hcd_release(hsotg);
5287error2: 5365error2:
@@ -5322,8 +5400,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
5322 usb_remove_hcd(hcd); 5400 usb_remove_hcd(hcd);
5323 hsotg->priv = NULL; 5401 hsotg->priv = NULL;
5324 5402
5325 kmem_cache_destroy(hsotg->desc_gen_cache); 5403 kmem_cache_destroy(hsotg->unaligned_cache);
5326 kmem_cache_destroy(hsotg->desc_hsisoc_cache); 5404 kmem_cache_destroy(hsotg->desc_hsisoc_cache);
5405 kmem_cache_destroy(hsotg->desc_gen_cache);
5327 5406
5328 dwc2_hcd_release(hsotg); 5407 dwc2_hcd_release(hsotg);
5329 usb_put_hcd(hcd); 5408 usb_put_hcd(hcd);
@@ -5435,7 +5514,7 @@ int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg)
5435 dwc2_writel(hprt0, hsotg->regs + HPRT0); 5514 dwc2_writel(hprt0, hsotg->regs + HPRT0);
5436 5515
5437 /* Wait for the HPRT0.PrtSusp register field to be set */ 5516 /* Wait for the HPRT0.PrtSusp register field to be set */
5438 if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 300)) 5517 if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 3000))
5439 dev_warn(hsotg->dev, "Suspend wasn't generated\n"); 5518 dev_warn(hsotg->dev, "Suspend wasn't generated\n");
5440 5519
5441 /* 5520 /*
@@ -5616,6 +5695,8 @@ int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
5616 return ret; 5695 return ret;
5617 } 5696 }
5618 5697
5698 dwc2_hcd_rem_wakeup(hsotg);
5699
5619 hsotg->hibernated = 0; 5700 hsotg->hibernated = 0;
5620 hsotg->bus_suspended = 0; 5701 hsotg->bus_suspended = 0;
5621 hsotg->lx_state = DWC2_L0; 5702 hsotg->lx_state = DWC2_L0;
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index 7db1ee7e7a77..5502a501f516 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -76,6 +76,8 @@ struct dwc2_qh;
76 * (micro)frame 76 * (micro)frame
77 * @xfer_buf: Pointer to current transfer buffer position 77 * @xfer_buf: Pointer to current transfer buffer position
78 * @xfer_dma: DMA address of xfer_buf 78 * @xfer_dma: DMA address of xfer_buf
79 * @align_buf: In Buffer DMA mode this will be used if xfer_buf is not
80 * DWORD aligned
79 * @xfer_len: Total number of bytes to transfer 81 * @xfer_len: Total number of bytes to transfer
80 * @xfer_count: Number of bytes transferred so far 82 * @xfer_count: Number of bytes transferred so far
81 * @start_pkt_count: Packet count at start of transfer 83 * @start_pkt_count: Packet count at start of transfer
@@ -133,6 +135,7 @@ struct dwc2_host_chan {
133 135
134 u8 *xfer_buf; 136 u8 *xfer_buf;
135 dma_addr_t xfer_dma; 137 dma_addr_t xfer_dma;
138 dma_addr_t align_buf;
136 u32 xfer_len; 139 u32 xfer_len;
137 u32 xfer_count; 140 u32 xfer_count;
138 u16 start_pkt_count; 141 u16 start_pkt_count;
@@ -302,6 +305,9 @@ struct dwc2_hs_transfer_time {
302 * speed. Note that this is in "schedule slice" which 305 * speed. Note that this is in "schedule slice" which
303 * is tightly packed. 306 * is tightly packed.
304 * @ntd: Actual number of transfer descriptors in a list 307 * @ntd: Actual number of transfer descriptors in a list
308 * @dw_align_buf: Used instead of original buffer if its physical address
309 * is not dword-aligned
310 * @dw_align_buf_dma: DMA address for dw_align_buf
305 * @qtd_list: List of QTDs for this QH 311 * @qtd_list: List of QTDs for this QH
306 * @channel: Host channel currently processing transfers for this QH 312 * @channel: Host channel currently processing transfers for this QH
307 * @qh_list_entry: Entry for QH in either the periodic or non-periodic 313 * @qh_list_entry: Entry for QH in either the periodic or non-periodic
@@ -350,6 +356,8 @@ struct dwc2_qh {
350 struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES]; 356 struct dwc2_hs_transfer_time hs_transfers[DWC2_HS_SCHEDULE_UFRAMES];
351 u32 ls_start_schedule_slice; 357 u32 ls_start_schedule_slice;
352 u16 ntd; 358 u16 ntd;
359 u8 *dw_align_buf;
360 dma_addr_t dw_align_buf_dma;
353 struct list_head qtd_list; 361 struct list_head qtd_list;
354 struct dwc2_host_chan *channel; 362 struct dwc2_host_chan *channel;
355 struct list_head qh_list_entry; 363 struct list_head qh_list_entry;
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index fbea5e3fb947..ed7f05cf4906 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -942,14 +942,21 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
942 frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index]; 942 frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
943 len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd, 943 len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
944 DWC2_HC_XFER_COMPLETE, NULL); 944 DWC2_HC_XFER_COMPLETE, NULL);
945 if (!len) { 945 if (!len && !qtd->isoc_split_offset) {
946 qtd->complete_split = 0; 946 qtd->complete_split = 0;
947 qtd->isoc_split_offset = 0;
948 return 0; 947 return 0;
949 } 948 }
950 949
951 frame_desc->actual_length += len; 950 frame_desc->actual_length += len;
952 951
952 if (chan->align_buf) {
953 dev_vdbg(hsotg->dev, "non-aligned buffer\n");
954 dma_unmap_single(hsotg->dev, chan->qh->dw_align_buf_dma,
955 DWC2_KMEM_UNALIGNED_BUF_SIZE, DMA_FROM_DEVICE);
956 memcpy(qtd->urb->buf + (chan->xfer_dma - qtd->urb->dma),
957 chan->qh->dw_align_buf, len);
958 }
959
953 qtd->isoc_split_offset += len; 960 qtd->isoc_split_offset += len;
954 961
955 hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum)); 962 hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum));
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index d7c3d6c776d8..301ced1618f8 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -383,7 +383,7 @@ static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg,
383 /* Get the map and adjust if this is a multi_tt hub */ 383 /* Get the map and adjust if this is a multi_tt hub */
384 map = qh->dwc_tt->periodic_bitmaps; 384 map = qh->dwc_tt->periodic_bitmaps;
385 if (qh->dwc_tt->usb_tt->multi) 385 if (qh->dwc_tt->usb_tt->multi)
386 map += DWC2_ELEMENTS_PER_LS_BITMAP * qh->ttport; 386 map += DWC2_ELEMENTS_PER_LS_BITMAP * (qh->ttport - 1);
387 387
388 return map; 388 return map;
389} 389}
@@ -1696,6 +1696,9 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
1696 1696
1697 if (qh->desc_list) 1697 if (qh->desc_list)
1698 dwc2_hcd_qh_free_ddma(hsotg, qh); 1698 dwc2_hcd_qh_free_ddma(hsotg, qh);
1699 else if (hsotg->unaligned_cache && qh->dw_align_buf)
1700 kmem_cache_free(hsotg->unaligned_cache, qh->dw_align_buf);
1701
1699 kfree(qh); 1702 kfree(qh);
1700} 1703}
1701 1704
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index ea91310113b9..103807587dc6 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1272,7 +1272,6 @@ static int dwc3_probe(struct platform_device *pdev)
1272 if (!dwc->clks) 1272 if (!dwc->clks)
1273 return -ENOMEM; 1273 return -ENOMEM;
1274 1274
1275 dwc->num_clks = ARRAY_SIZE(dwc3_core_clks);
1276 dwc->dev = dev; 1275 dwc->dev = dev;
1277 1276
1278 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1277 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1307,15 +1306,19 @@ static int dwc3_probe(struct platform_device *pdev)
1307 if (IS_ERR(dwc->reset)) 1306 if (IS_ERR(dwc->reset))
1308 return PTR_ERR(dwc->reset); 1307 return PTR_ERR(dwc->reset);
1309 1308
1310 ret = clk_bulk_get(dev, dwc->num_clks, dwc->clks); 1309 if (dev->of_node) {
1311 if (ret == -EPROBE_DEFER) 1310 dwc->num_clks = ARRAY_SIZE(dwc3_core_clks);
1312 return ret; 1311
1313 /* 1312 ret = clk_bulk_get(dev, dwc->num_clks, dwc->clks);
1314 * Clocks are optional, but new DT platforms should support all clocks 1313 if (ret == -EPROBE_DEFER)
1315 * as required by the DT-binding. 1314 return ret;
1316 */ 1315 /*
1317 if (ret) 1316 * Clocks are optional, but new DT platforms should support all
1318 dwc->num_clks = 0; 1317 * clocks as required by the DT-binding.
1318 */
1319 if (ret)
1320 dwc->num_clks = 0;
1321 }
1319 1322
1320 ret = reset_control_deassert(dwc->reset); 1323 ret = reset_control_deassert(dwc->reset);
1321 if (ret) 1324 if (ret)
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index 6b3ccd542bd7..dbeff5e6ad14 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -165,8 +165,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev)
165 165
166 reset_control_put(simple->resets); 166 reset_control_put(simple->resets);
167 167
168 pm_runtime_put_sync(dev);
169 pm_runtime_disable(dev); 168 pm_runtime_disable(dev);
169 pm_runtime_put_noidle(dev);
170 pm_runtime_set_suspended(dev);
170 171
171 return 0; 172 return 0;
172} 173}
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index c961a94d136b..f57e7c94b8e5 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -34,6 +34,7 @@
34#define PCI_DEVICE_ID_INTEL_GLK 0x31aa 34#define PCI_DEVICE_ID_INTEL_GLK 0x31aa
35#define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee 35#define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
36#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e 36#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
37#define PCI_DEVICE_ID_INTEL_ICLLP 0x34ee
37 38
38#define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" 39#define PCI_INTEL_BXT_DSM_GUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
39#define PCI_INTEL_BXT_FUNC_PMU_PWR 4 40#define PCI_INTEL_BXT_FUNC_PMU_PWR 4
@@ -289,6 +290,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
289 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), }, 290 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
290 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), }, 291 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
291 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), }, 292 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
293 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICLLP), },
292 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 294 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
293 { } /* Terminating Entry */ 295 { } /* Terminating Entry */
294}; 296};
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index b0e67ab2f98c..a6d0203e40b6 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -490,6 +490,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
490 qcom->dwc3 = of_find_device_by_node(dwc3_np); 490 qcom->dwc3 = of_find_device_by_node(dwc3_np);
491 if (!qcom->dwc3) { 491 if (!qcom->dwc3) {
492 dev_err(&pdev->dev, "failed to get dwc3 platform device\n"); 492 dev_err(&pdev->dev, "failed to get dwc3 platform device\n");
493 ret = -ENODEV;
493 goto depopulate; 494 goto depopulate;
494 } 495 }
495 496
@@ -547,8 +548,7 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
547 return 0; 548 return 0;
548} 549}
549 550
550#ifdef CONFIG_PM_SLEEP 551static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev)
551static int dwc3_qcom_pm_suspend(struct device *dev)
552{ 552{
553 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 553 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
554 int ret = 0; 554 int ret = 0;
@@ -560,7 +560,7 @@ static int dwc3_qcom_pm_suspend(struct device *dev)
560 return ret; 560 return ret;
561} 561}
562 562
563static int dwc3_qcom_pm_resume(struct device *dev) 563static int __maybe_unused dwc3_qcom_pm_resume(struct device *dev)
564{ 564{
565 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 565 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
566 int ret; 566 int ret;
@@ -571,23 +571,20 @@ static int dwc3_qcom_pm_resume(struct device *dev)
571 571
572 return ret; 572 return ret;
573} 573}
574#endif
575 574
576#ifdef CONFIG_PM 575static int __maybe_unused dwc3_qcom_runtime_suspend(struct device *dev)
577static int dwc3_qcom_runtime_suspend(struct device *dev)
578{ 576{
579 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 577 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
580 578
581 return dwc3_qcom_suspend(qcom); 579 return dwc3_qcom_suspend(qcom);
582} 580}
583 581
584static int dwc3_qcom_runtime_resume(struct device *dev) 582static int __maybe_unused dwc3_qcom_runtime_resume(struct device *dev)
585{ 583{
586 struct dwc3_qcom *qcom = dev_get_drvdata(dev); 584 struct dwc3_qcom *qcom = dev_get_drvdata(dev);
587 585
588 return dwc3_qcom_resume(qcom); 586 return dwc3_qcom_resume(qcom);
589} 587}
590#endif
591 588
592static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = { 589static const struct dev_pm_ops dwc3_qcom_dev_pm_ops = {
593 SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume) 590 SET_SYSTEM_SLEEP_PM_OPS(dwc3_qcom_pm_suspend, dwc3_qcom_pm_resume)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f242c2bcea81..d2fa071c21b1 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1719,6 +1719,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1719 */ 1719 */
1720 if (w_value && !f->get_alt) 1720 if (w_value && !f->get_alt)
1721 break; 1721 break;
1722
1723 spin_lock(&cdev->lock);
1722 value = f->set_alt(f, w_index, w_value); 1724 value = f->set_alt(f, w_index, w_value);
1723 if (value == USB_GADGET_DELAYED_STATUS) { 1725 if (value == USB_GADGET_DELAYED_STATUS) {
1724 DBG(cdev, 1726 DBG(cdev,
@@ -1728,6 +1730,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1728 DBG(cdev, "delayed_status count %d\n", 1730 DBG(cdev, "delayed_status count %d\n",
1729 cdev->delayed_status); 1731 cdev->delayed_status);
1730 } 1732 }
1733 spin_unlock(&cdev->lock);
1731 break; 1734 break;
1732 case USB_REQ_GET_INTERFACE: 1735 case USB_REQ_GET_INTERFACE:
1733 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) 1736 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index dce9d12c7981..33e2030503fa 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -215,6 +215,7 @@ struct ffs_io_data {
215 215
216 struct mm_struct *mm; 216 struct mm_struct *mm;
217 struct work_struct work; 217 struct work_struct work;
218 struct work_struct cancellation_work;
218 219
219 struct usb_ep *ep; 220 struct usb_ep *ep;
220 struct usb_request *req; 221 struct usb_request *req;
@@ -1072,22 +1073,31 @@ ffs_epfile_open(struct inode *inode, struct file *file)
1072 return 0; 1073 return 0;
1073} 1074}
1074 1075
1076static void ffs_aio_cancel_worker(struct work_struct *work)
1077{
1078 struct ffs_io_data *io_data = container_of(work, struct ffs_io_data,
1079 cancellation_work);
1080
1081 ENTER();
1082
1083 usb_ep_dequeue(io_data->ep, io_data->req);
1084}
1085
1075static int ffs_aio_cancel(struct kiocb *kiocb) 1086static int ffs_aio_cancel(struct kiocb *kiocb)
1076{ 1087{
1077 struct ffs_io_data *io_data = kiocb->private; 1088 struct ffs_io_data *io_data = kiocb->private;
1078 struct ffs_epfile *epfile = kiocb->ki_filp->private_data; 1089 struct ffs_data *ffs = io_data->ffs;
1079 int value; 1090 int value;
1080 1091
1081 ENTER(); 1092 ENTER();
1082 1093
1083 spin_lock_irq(&epfile->ffs->eps_lock); 1094 if (likely(io_data && io_data->ep && io_data->req)) {
1084 1095 INIT_WORK(&io_data->cancellation_work, ffs_aio_cancel_worker);
1085 if (likely(io_data && io_data->ep && io_data->req)) 1096 queue_work(ffs->io_completion_wq, &io_data->cancellation_work);
1086 value = usb_ep_dequeue(io_data->ep, io_data->req); 1097 value = -EINPROGRESS;
1087 else 1098 } else {
1088 value = -EINVAL; 1099 value = -EINVAL;
1089 1100 }
1090 spin_unlock_irq(&epfile->ffs->eps_lock);
1091 1101
1092 return value; 1102 return value;
1093} 1103}
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index acbd3d7b8828..8a62eee9eee1 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -886,12 +886,12 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
886 886
887 dev = xhci->devs[slot_id]; 887 dev = xhci->devs[slot_id];
888 888
889 trace_xhci_free_virt_device(dev);
890
891 xhci->dcbaa->dev_context_ptrs[slot_id] = 0; 889 xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
892 if (!dev) 890 if (!dev)
893 return; 891 return;
894 892
893 trace_xhci_free_virt_device(dev);
894
895 if (dev->tt_info) 895 if (dev->tt_info)
896 old_active_eps = dev->tt_info->active_eps; 896 old_active_eps = dev->tt_info->active_eps;
897 897
diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index a8c1d073cba0..4b463e5202a4 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -481,7 +481,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
481 unsigned long mask; 481 unsigned long mask;
482 unsigned int port; 482 unsigned int port;
483 bool idle, enable; 483 bool idle, enable;
484 int err; 484 int err = 0;
485 485
486 memset(&rsp, 0, sizeof(rsp)); 486 memset(&rsp, 0, sizeof(rsp));
487 487
@@ -1223,10 +1223,10 @@ disable_rpm:
1223 pm_runtime_disable(&pdev->dev); 1223 pm_runtime_disable(&pdev->dev);
1224 usb_put_hcd(tegra->hcd); 1224 usb_put_hcd(tegra->hcd);
1225disable_xusbc: 1225disable_xusbc:
1226 if (!&pdev->dev.pm_domain) 1226 if (!pdev->dev.pm_domain)
1227 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBC); 1227 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBC);
1228disable_xusba: 1228disable_xusba:
1229 if (!&pdev->dev.pm_domain) 1229 if (!pdev->dev.pm_domain)
1230 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBA); 1230 tegra_powergate_power_off(TEGRA_POWERGATE_XUSBA);
1231put_padctl: 1231put_padctl:
1232 tegra_xusb_padctl_put(tegra->padctl); 1232 tegra_xusb_padctl_put(tegra->padctl);
diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index 410544ffe78f..88b427434bd8 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -171,6 +171,37 @@ DEFINE_EVENT(xhci_log_trb, xhci_dbc_gadget_ep_queue,
171 TP_ARGS(ring, trb) 171 TP_ARGS(ring, trb)
172); 172);
173 173
174DECLARE_EVENT_CLASS(xhci_log_free_virt_dev,
175 TP_PROTO(struct xhci_virt_device *vdev),
176 TP_ARGS(vdev),
177 TP_STRUCT__entry(
178 __field(void *, vdev)
179 __field(unsigned long long, out_ctx)
180 __field(unsigned long long, in_ctx)
181 __field(u8, fake_port)
182 __field(u8, real_port)
183 __field(u16, current_mel)
184
185 ),
186 TP_fast_assign(
187 __entry->vdev = vdev;
188 __entry->in_ctx = (unsigned long long) vdev->in_ctx->dma;
189 __entry->out_ctx = (unsigned long long) vdev->out_ctx->dma;
190 __entry->fake_port = (u8) vdev->fake_port;
191 __entry->real_port = (u8) vdev->real_port;
192 __entry->current_mel = (u16) vdev->current_mel;
193 ),
194 TP_printk("vdev %p ctx %llx | %llx fake_port %d real_port %d current_mel %d",
195 __entry->vdev, __entry->in_ctx, __entry->out_ctx,
196 __entry->fake_port, __entry->real_port, __entry->current_mel
197 )
198);
199
200DEFINE_EVENT(xhci_log_free_virt_dev, xhci_free_virt_device,
201 TP_PROTO(struct xhci_virt_device *vdev),
202 TP_ARGS(vdev)
203);
204
174DECLARE_EVENT_CLASS(xhci_log_virt_dev, 205DECLARE_EVENT_CLASS(xhci_log_virt_dev,
175 TP_PROTO(struct xhci_virt_device *vdev), 206 TP_PROTO(struct xhci_virt_device *vdev),
176 TP_ARGS(vdev), 207 TP_ARGS(vdev),
@@ -208,11 +239,6 @@ DEFINE_EVENT(xhci_log_virt_dev, xhci_alloc_virt_device,
208 TP_ARGS(vdev) 239 TP_ARGS(vdev)
209); 240);
210 241
211DEFINE_EVENT(xhci_log_virt_dev, xhci_free_virt_device,
212 TP_PROTO(struct xhci_virt_device *vdev),
213 TP_ARGS(vdev)
214);
215
216DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device, 242DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device,
217 TP_PROTO(struct xhci_virt_device *vdev), 243 TP_PROTO(struct xhci_virt_device *vdev),
218 TP_ARGS(vdev) 244 TP_ARGS(vdev)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8c8da2d657fa..2f4850f25e82 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -908,6 +908,41 @@ static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
908 spin_unlock_irqrestore(&xhci->lock, flags); 908 spin_unlock_irqrestore(&xhci->lock, flags);
909} 909}
910 910
911static bool xhci_pending_portevent(struct xhci_hcd *xhci)
912{
913 struct xhci_port **ports;
914 int port_index;
915 u32 status;
916 u32 portsc;
917
918 status = readl(&xhci->op_regs->status);
919 if (status & STS_EINT)
920 return true;
921 /*
922 * Checking STS_EINT is not enough as there is a lag between a change
923 * bit being set and the Port Status Change Event that it generated
924 * being written to the Event Ring. See note in xhci 1.1 section 4.19.2.
925 */
926
927 port_index = xhci->usb2_rhub.num_ports;
928 ports = xhci->usb2_rhub.ports;
929 while (port_index--) {
930 portsc = readl(ports[port_index]->addr);
931 if (portsc & PORT_CHANGE_MASK ||
932 (portsc & PORT_PLS_MASK) == XDEV_RESUME)
933 return true;
934 }
935 port_index = xhci->usb3_rhub.num_ports;
936 ports = xhci->usb3_rhub.ports;
937 while (port_index--) {
938 portsc = readl(ports[port_index]->addr);
939 if (portsc & PORT_CHANGE_MASK ||
940 (portsc & PORT_PLS_MASK) == XDEV_RESUME)
941 return true;
942 }
943 return false;
944}
945
911/* 946/*
912 * Stop HC (not bus-specific) 947 * Stop HC (not bus-specific)
913 * 948 *
@@ -1009,7 +1044,7 @@ EXPORT_SYMBOL_GPL(xhci_suspend);
1009 */ 1044 */
1010int xhci_resume(struct xhci_hcd *xhci, bool hibernated) 1045int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1011{ 1046{
1012 u32 command, temp = 0, status; 1047 u32 command, temp = 0;
1013 struct usb_hcd *hcd = xhci_to_hcd(xhci); 1048 struct usb_hcd *hcd = xhci_to_hcd(xhci);
1014 struct usb_hcd *secondary_hcd; 1049 struct usb_hcd *secondary_hcd;
1015 int retval = 0; 1050 int retval = 0;
@@ -1043,8 +1078,13 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1043 command = readl(&xhci->op_regs->command); 1078 command = readl(&xhci->op_regs->command);
1044 command |= CMD_CRS; 1079 command |= CMD_CRS;
1045 writel(command, &xhci->op_regs->command); 1080 writel(command, &xhci->op_regs->command);
1081 /*
1082 * Some controllers take up to 55+ ms to complete the controller
1083 * restore so setting the timeout to 100ms. Xhci specification
1084 * doesn't mention any timeout value.
1085 */
1046 if (xhci_handshake(&xhci->op_regs->status, 1086 if (xhci_handshake(&xhci->op_regs->status,
1047 STS_RESTORE, 0, 10 * 1000)) { 1087 STS_RESTORE, 0, 100 * 1000)) {
1048 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 1088 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
1049 spin_unlock_irq(&xhci->lock); 1089 spin_unlock_irq(&xhci->lock);
1050 return -ETIMEDOUT; 1090 return -ETIMEDOUT;
@@ -1134,8 +1174,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1134 done: 1174 done:
1135 if (retval == 0) { 1175 if (retval == 0) {
1136 /* Resume root hubs only when have pending events. */ 1176 /* Resume root hubs only when have pending events. */
1137 status = readl(&xhci->op_regs->status); 1177 if (xhci_pending_portevent(xhci)) {
1138 if (status & STS_EINT) {
1139 usb_hcd_resume_root_hub(xhci->shared_hcd); 1178 usb_hcd_resume_root_hub(xhci->shared_hcd);
1140 usb_hcd_resume_root_hub(hcd); 1179 usb_hcd_resume_root_hub(hcd);
1141 } 1180 }
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 939e2f86b595..841e89ffe2e9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -382,6 +382,10 @@ struct xhci_op_regs {
382#define PORT_PLC (1 << 22) 382#define PORT_PLC (1 << 22)
383/* port configure error change - port failed to configure its link partner */ 383/* port configure error change - port failed to configure its link partner */
384#define PORT_CEC (1 << 23) 384#define PORT_CEC (1 << 23)
385#define PORT_CHANGE_MASK (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \
386 PORT_RC | PORT_PLC | PORT_CEC)
387
388
385/* Cold Attach Status - xHC can set this bit to report device attached during 389/* Cold Attach Status - xHC can set this bit to report device attached during
386 * Sx state. Warm port reset should be perfomed to clear this bit and move port 390 * Sx state. Warm port reset should be perfomed to clear this bit and move port
387 * to connected state. 391 * to connected state.
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eb6c26cbe579..ee0cc1d90b51 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -95,6 +95,9 @@ static const struct usb_device_id id_table[] = {
95 { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */ 95 { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */
96 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 96 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
97 { USB_DEVICE(0x10C4, 0x815F) }, /* Timewave HamLinkUSB */ 97 { USB_DEVICE(0x10C4, 0x815F) }, /* Timewave HamLinkUSB */
98 { USB_DEVICE(0x10C4, 0x817C) }, /* CESINEL MEDCAL N Power Quality Monitor */
99 { USB_DEVICE(0x10C4, 0x817D) }, /* CESINEL MEDCAL NT Power Quality Monitor */
100 { USB_DEVICE(0x10C4, 0x817E) }, /* CESINEL MEDCAL S Power Quality Monitor */
98 { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */ 101 { USB_DEVICE(0x10C4, 0x818B) }, /* AVIT Research USB to TTL */
99 { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */ 102 { USB_DEVICE(0x10C4, 0x819F) }, /* MJS USB Toslink Switcher */
100 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */ 103 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */
@@ -112,6 +115,9 @@ static const struct usb_device_id id_table[] = {
112 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demonstration module */ 115 { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demonstration module */
113 { USB_DEVICE(0x10C4, 0x8281) }, /* Nanotec Plug & Drive */ 116 { USB_DEVICE(0x10C4, 0x8281) }, /* Nanotec Plug & Drive */
114 { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesis ETRX2USB */ 117 { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesis ETRX2USB */
118 { USB_DEVICE(0x10C4, 0x82EF) }, /* CESINEL FALCO 6105 AC Power Supply */
119 { USB_DEVICE(0x10C4, 0x82F1) }, /* CESINEL MEDCAL EFD Earth Fault Detector */
120 { USB_DEVICE(0x10C4, 0x82F2) }, /* CESINEL MEDCAL ST Network Analyzer */
115 { USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */ 121 { USB_DEVICE(0x10C4, 0x82F4) }, /* Starizona MicroTouch */
116 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */ 122 { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
117 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 123 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
@@ -124,7 +130,9 @@ static const struct usb_device_id id_table[] = {
124 { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */ 130 { USB_DEVICE(0x10C4, 0x8470) }, /* Juniper Networks BX Series System Console */
125 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ 131 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
126 { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */ 132 { USB_DEVICE(0x10C4, 0x84B6) }, /* Starizona Hyperion */
133 { USB_DEVICE(0x10C4, 0x851E) }, /* CESINEL MEDCAL PT Network Analyzer */
127 { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */ 134 { USB_DEVICE(0x10C4, 0x85A7) }, /* LifeScan OneTouch Verio IQ */
135 { USB_DEVICE(0x10C4, 0x85B8) }, /* CESINEL ReCon T Energy Logger */
128 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ 136 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */
129 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ 137 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */
130 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */ 138 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
@@ -134,17 +142,23 @@ static const struct usb_device_id id_table[] = {
134 { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */ 142 { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */
135 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ 143 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
136 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ 144 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
145 { USB_DEVICE(0x10C4, 0x88FB) }, /* CESINEL MEDCAL STII Network Analyzer */
146 { USB_DEVICE(0x10C4, 0x8938) }, /* CESINEL MEDCAL S II Network Analyzer */
137 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ 147 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
138 { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */ 148 { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */
139 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */ 149 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
140 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ 150 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
151 { USB_DEVICE(0x10C4, 0x89A4) }, /* CESINEL FTBC Flexible Thyristor Bridge Controller */
141 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */ 152 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
142 { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */ 153 { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
143 { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */ 154 { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
144 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 155 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
145 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 156 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
157 { USB_DEVICE(0x10C4, 0xEA63) }, /* Silicon Labs Windows Update (CP2101-4/CP2102N) */
146 { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ 158 { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
147 { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */ 159 { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */
160 { USB_DEVICE(0x10C4, 0xEA7A) }, /* Silicon Labs Windows Update (CP2105) */
161 { USB_DEVICE(0x10C4, 0xEA7B) }, /* Silicon Labs Windows Update (CP2108) */
148 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 162 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
149 { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */ 163 { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */
150 { USB_DEVICE(0x10C4, 0xF003) }, /* Elan Digital Systems USBpulse100 */ 164 { USB_DEVICE(0x10C4, 0xF003) }, /* Elan Digital Systems USBpulse100 */
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index 8a201dd53d36..d961f1ec0e08 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -418,17 +418,18 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
418 u64 ts_nsec = local_clock(); 418 u64 ts_nsec = local_clock();
419 unsigned long rem_nsec; 419 unsigned long rem_nsec;
420 420
421 mutex_lock(&port->logbuffer_lock);
421 if (!port->logbuffer[port->logbuffer_head]) { 422 if (!port->logbuffer[port->logbuffer_head]) {
422 port->logbuffer[port->logbuffer_head] = 423 port->logbuffer[port->logbuffer_head] =
423 kzalloc(LOG_BUFFER_ENTRY_SIZE, GFP_KERNEL); 424 kzalloc(LOG_BUFFER_ENTRY_SIZE, GFP_KERNEL);
424 if (!port->logbuffer[port->logbuffer_head]) 425 if (!port->logbuffer[port->logbuffer_head]) {
426 mutex_unlock(&port->logbuffer_lock);
425 return; 427 return;
428 }
426 } 429 }
427 430
428 vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args); 431 vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);
429 432
430 mutex_lock(&port->logbuffer_lock);
431
432 if (tcpm_log_full(port)) { 433 if (tcpm_log_full(port)) {
433 port->logbuffer_head = max(port->logbuffer_head - 1, 0); 434 port->logbuffer_head = max(port->logbuffer_head - 1, 0);
434 strcpy(tmpbuffer, "overflow"); 435 strcpy(tmpbuffer, "overflow");
@@ -3043,7 +3044,8 @@ static void run_state_machine(struct tcpm_port *port)
3043 tcpm_port_is_sink(port) && 3044 tcpm_port_is_sink(port) &&
3044 time_is_after_jiffies(port->delayed_runtime)) { 3045 time_is_after_jiffies(port->delayed_runtime)) {
3045 tcpm_set_state(port, SNK_DISCOVERY, 3046 tcpm_set_state(port, SNK_DISCOVERY,
3046 port->delayed_runtime - jiffies); 3047 jiffies_to_msecs(port->delayed_runtime -
3048 jiffies));
3047 break; 3049 break;
3048 } 3050 }
3049 tcpm_set_state(port, unattached_state(port), 0); 3051 tcpm_set_state(port, unattached_state(port), 0);
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index bd5cca5632b3..8d0a6fe748bd 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -350,6 +350,19 @@ static void ucsi_connector_change(struct work_struct *work)
350 } 350 }
351 351
352 if (con->status.change & UCSI_CONSTAT_CONNECT_CHANGE) { 352 if (con->status.change & UCSI_CONSTAT_CONNECT_CHANGE) {
353 typec_set_pwr_role(con->port, con->status.pwr_dir);
354
355 switch (con->status.partner_type) {
356 case UCSI_CONSTAT_PARTNER_TYPE_UFP:
357 typec_set_data_role(con->port, TYPEC_HOST);
358 break;
359 case UCSI_CONSTAT_PARTNER_TYPE_DFP:
360 typec_set_data_role(con->port, TYPEC_DEVICE);
361 break;
362 default:
363 break;
364 }
365
353 if (con->status.connected) 366 if (con->status.connected)
354 ucsi_register_partner(con); 367 ucsi_register_partner(con);
355 else 368 else
diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index 44eb4e1ea817..a18112a83fae 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -79,6 +79,11 @@ static int ucsi_acpi_probe(struct platform_device *pdev)
79 return -ENODEV; 79 return -ENODEV;
80 } 80 }
81 81
82 /* This will make sure we can use ioremap_nocache() */
83 status = acpi_release_memory(ACPI_HANDLE(&pdev->dev), res, 1);
84 if (ACPI_FAILURE(status))
85 return -ENOMEM;
86
82 /* 87 /*
83 * NOTE: The memory region for the data structures is used also in an 88 * NOTE: The memory region for the data structures is used also in an
84 * operation region, which means ACPI has already reserved it. Therefore 89 * operation region, which means ACPI has already reserved it. Therefore
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 686dc670fd29..29756d88799b 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1226,7 +1226,8 @@ err_used:
1226 if (ubufs) 1226 if (ubufs)
1227 vhost_net_ubuf_put_wait_and_free(ubufs); 1227 vhost_net_ubuf_put_wait_and_free(ubufs);
1228err_ubufs: 1228err_ubufs:
1229 sockfd_put(sock); 1229 if (sock)
1230 sockfd_put(sock);
1230err_vq: 1231err_vq:
1231 mutex_unlock(&vq->mutex); 1232 mutex_unlock(&vq->mutex);
1232err: 1233err:
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 451e833f5931..48b154276179 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -41,4 +41,4 @@ obj-$(CONFIG_XEN_PVCALLS_FRONTEND) += pvcalls-front.o
41xen-evtchn-y := evtchn.o 41xen-evtchn-y := evtchn.o
42xen-gntdev-y := gntdev.o 42xen-gntdev-y := gntdev.o
43xen-gntalloc-y := gntalloc.o 43xen-gntalloc-y := gntalloc.o
44xen-privcmd-y := privcmd.o 44xen-privcmd-y := privcmd.o privcmd-buf.o
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 762378f1811c..08e4af04d6f2 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -628,8 +628,6 @@ static void __unbind_from_irq(unsigned int irq)
628 xen_irq_info_cleanup(info); 628 xen_irq_info_cleanup(info);
629 } 629 }
630 630
631 BUG_ON(info_for_irq(irq)->type == IRQT_UNBOUND);
632
633 xen_free_irq(irq); 631 xen_free_irq(irq);
634} 632}
635 633
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 2473b0a9e6e4..ba9f3eec2bd0 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -799,7 +799,7 @@ int gnttab_alloc_pages(int nr_pages, struct page **pages)
799 799
800 return 0; 800 return 0;
801} 801}
802EXPORT_SYMBOL(gnttab_alloc_pages); 802EXPORT_SYMBOL_GPL(gnttab_alloc_pages);
803 803
804/** 804/**
805 * gnttab_free_pages - free pages allocated by gnttab_alloc_pages() 805 * gnttab_free_pages - free pages allocated by gnttab_alloc_pages()
@@ -820,7 +820,7 @@ void gnttab_free_pages(int nr_pages, struct page **pages)
820 } 820 }
821 free_xenballooned_pages(nr_pages, pages); 821 free_xenballooned_pages(nr_pages, pages);
822} 822}
823EXPORT_SYMBOL(gnttab_free_pages); 823EXPORT_SYMBOL_GPL(gnttab_free_pages);
824 824
825/* Handling of paged out grant targets (GNTST_eagain) */ 825/* Handling of paged out grant targets (GNTST_eagain) */
826#define MAX_DELAY 256 826#define MAX_DELAY 256
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 8835065029d3..c93d8ef8df34 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -289,8 +289,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path,
289 return; 289 return;
290 } 290 }
291 291
292 if (sysrq_key != '\0') 292 if (sysrq_key != '\0') {
293 xenbus_printf(xbt, "control", "sysrq", "%c", '\0'); 293 err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
294 if (err) {
295 pr_err("%s: Error %d writing sysrq in control/sysrq\n",
296 __func__, err);
297 xenbus_transaction_end(xbt, 1);
298 return;
299 }
300 }
294 301
295 err = xenbus_transaction_end(xbt, 0); 302 err = xenbus_transaction_end(xbt, 0);
296 if (err == -EAGAIN) 303 if (err == -EAGAIN)
@@ -342,7 +349,12 @@ static int setup_shutdown_watcher(void)
342 continue; 349 continue;
343 snprintf(node, FEATURE_PATH_SIZE, "feature-%s", 350 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
344 shutdown_handlers[idx].command); 351 shutdown_handlers[idx].command);
345 xenbus_printf(XBT_NIL, "control", node, "%u", 1); 352 err = xenbus_printf(XBT_NIL, "control", node, "%u", 1);
353 if (err) {
354 pr_err("%s: Error %d writing %s\n", __func__,
355 err, node);
356 return err;
357 }
346 } 358 }
347 359
348 return 0; 360 return 0;
diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c
new file mode 100644
index 000000000000..df1ed37c3269
--- /dev/null
+++ b/drivers/xen/privcmd-buf.c
@@ -0,0 +1,210 @@
1// SPDX-License-Identifier: GPL-2.0 OR MIT
2
3/******************************************************************************
4 * privcmd-buf.c
5 *
6 * Mmap of hypercall buffers.
7 *
8 * Copyright (c) 2018 Juergen Gross
9 */
10
11#define pr_fmt(fmt) "xen:" KBUILD_MODNAME ": " fmt
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/list.h>
16#include <linux/miscdevice.h>
17#include <linux/mm.h>
18#include <linux/slab.h>
19
20#include "privcmd.h"
21
22MODULE_LICENSE("GPL");
23
24static unsigned int limit = 64;
25module_param(limit, uint, 0644);
26MODULE_PARM_DESC(limit, "Maximum number of pages that may be allocated by "
27 "the privcmd-buf device per open file");
28
29struct privcmd_buf_private {
30 struct mutex lock;
31 struct list_head list;
32 unsigned int allocated;
33};
34
35struct privcmd_buf_vma_private {
36 struct privcmd_buf_private *file_priv;
37 struct list_head list;
38 unsigned int users;
39 unsigned int n_pages;
40 struct page *pages[];
41};
42
43static int privcmd_buf_open(struct inode *ino, struct file *file)
44{
45 struct privcmd_buf_private *file_priv;
46
47 file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
48 if (!file_priv)
49 return -ENOMEM;
50
51 mutex_init(&file_priv->lock);
52 INIT_LIST_HEAD(&file_priv->list);
53
54 file->private_data = file_priv;
55
56 return 0;
57}
58
59static void privcmd_buf_vmapriv_free(struct privcmd_buf_vma_private *vma_priv)
60{
61 unsigned int i;
62
63 vma_priv->file_priv->allocated -= vma_priv->n_pages;
64
65 list_del(&vma_priv->list);
66
67 for (i = 0; i < vma_priv->n_pages; i++)
68 if (vma_priv->pages[i])
69 __free_page(vma_priv->pages[i]);
70
71 kfree(vma_priv);
72}
73
74static int privcmd_buf_release(struct inode *ino, struct file *file)
75{
76 struct privcmd_buf_private *file_priv = file->private_data;
77 struct privcmd_buf_vma_private *vma_priv;
78
79 mutex_lock(&file_priv->lock);
80
81 while (!list_empty(&file_priv->list)) {
82 vma_priv = list_first_entry(&file_priv->list,
83 struct privcmd_buf_vma_private,
84 list);
85 privcmd_buf_vmapriv_free(vma_priv);
86 }
87
88 mutex_unlock(&file_priv->lock);
89
90 kfree(file_priv);
91
92 return 0;
93}
94
95static void privcmd_buf_vma_open(struct vm_area_struct *vma)
96{
97 struct privcmd_buf_vma_private *vma_priv = vma->vm_private_data;
98
99 if (!vma_priv)
100 return;
101
102 mutex_lock(&vma_priv->file_priv->lock);
103 vma_priv->users++;
104 mutex_unlock(&vma_priv->file_priv->lock);
105}
106
107static void privcmd_buf_vma_close(struct vm_area_struct *vma)
108{
109 struct privcmd_buf_vma_private *vma_priv = vma->vm_private_data;
110 struct privcmd_buf_private *file_priv;
111
112 if (!vma_priv)
113 return;
114
115 file_priv = vma_priv->file_priv;
116
117 mutex_lock(&file_priv->lock);
118
119 vma_priv->users--;
120 if (!vma_priv->users)
121 privcmd_buf_vmapriv_free(vma_priv);
122
123 mutex_unlock(&file_priv->lock);
124}
125
126static vm_fault_t privcmd_buf_vma_fault(struct vm_fault *vmf)
127{
128 pr_debug("fault: vma=%p %lx-%lx, pgoff=%lx, uv=%p\n",
129 vmf->vma, vmf->vma->vm_start, vmf->vma->vm_end,
130 vmf->pgoff, (void *)vmf->address);
131
132 return VM_FAULT_SIGBUS;
133}
134
135static const struct vm_operations_struct privcmd_buf_vm_ops = {
136 .open = privcmd_buf_vma_open,
137 .close = privcmd_buf_vma_close,
138 .fault = privcmd_buf_vma_fault,
139};
140
141static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
142{
143 struct privcmd_buf_private *file_priv = file->private_data;
144 struct privcmd_buf_vma_private *vma_priv;
145 unsigned long count = vma_pages(vma);
146 unsigned int i;
147 int ret = 0;
148
149 if (!(vma->vm_flags & VM_SHARED) || count > limit ||
150 file_priv->allocated + count > limit)
151 return -EINVAL;
152
153 vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
154 GFP_KERNEL);
155 if (!vma_priv)
156 return -ENOMEM;
157
158 vma_priv->n_pages = count;
159 count = 0;
160 for (i = 0; i < vma_priv->n_pages; i++) {
161 vma_priv->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO);
162 if (!vma_priv->pages[i])
163 break;
164 count++;
165 }
166
167 mutex_lock(&file_priv->lock);
168
169 file_priv->allocated += count;
170
171 vma_priv->file_priv = file_priv;
172 vma_priv->users = 1;
173
174 vma->vm_flags |= VM_IO | VM_DONTEXPAND;
175 vma->vm_ops = &privcmd_buf_vm_ops;
176 vma->vm_private_data = vma_priv;
177
178 list_add(&vma_priv->list, &file_priv->list);
179
180 if (vma_priv->n_pages != count)
181 ret = -ENOMEM;
182 else
183 for (i = 0; i < vma_priv->n_pages; i++) {
184 ret = vm_insert_page(vma, vma->vm_start + i * PAGE_SIZE,
185 vma_priv->pages[i]);
186 if (ret)
187 break;
188 }
189
190 if (ret)
191 privcmd_buf_vmapriv_free(vma_priv);
192
193 mutex_unlock(&file_priv->lock);
194
195 return ret;
196}
197
198const struct file_operations xen_privcmdbuf_fops = {
199 .owner = THIS_MODULE,
200 .open = privcmd_buf_open,
201 .release = privcmd_buf_release,
202 .mmap = privcmd_buf_mmap,
203};
204EXPORT_SYMBOL_GPL(xen_privcmdbuf_fops);
205
206struct miscdevice xen_privcmdbuf_dev = {
207 .minor = MISC_DYNAMIC_MINOR,
208 .name = "xen/hypercall",
209 .fops = &xen_privcmdbuf_fops,
210};
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 8ae0349d9f0a..7e6e682104dc 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -1007,12 +1007,21 @@ static int __init privcmd_init(void)
1007 pr_err("Could not register Xen privcmd device\n"); 1007 pr_err("Could not register Xen privcmd device\n");
1008 return err; 1008 return err;
1009 } 1009 }
1010
1011 err = misc_register(&xen_privcmdbuf_dev);
1012 if (err != 0) {
1013 pr_err("Could not register Xen hypercall-buf device\n");
1014 misc_deregister(&privcmd_dev);
1015 return err;
1016 }
1017
1010 return 0; 1018 return 0;
1011} 1019}
1012 1020
1013static void __exit privcmd_exit(void) 1021static void __exit privcmd_exit(void)
1014{ 1022{
1015 misc_deregister(&privcmd_dev); 1023 misc_deregister(&privcmd_dev);
1024 misc_deregister(&xen_privcmdbuf_dev);
1016} 1025}
1017 1026
1018module_init(privcmd_init); 1027module_init(privcmd_init);
diff --git a/drivers/xen/privcmd.h b/drivers/xen/privcmd.h
index 14facaeed36f..0dd9f8f67ee3 100644
--- a/drivers/xen/privcmd.h
+++ b/drivers/xen/privcmd.h
@@ -1,3 +1,6 @@
1#include <linux/fs.h> 1#include <linux/fs.h>
2 2
3extern const struct file_operations xen_privcmd_fops; 3extern const struct file_operations xen_privcmd_fops;
4extern const struct file_operations xen_privcmdbuf_fops;
5
6extern struct miscdevice xen_privcmdbuf_dev;
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 7bc88fd43cfc..e2f3e8b0fba9 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -1012,6 +1012,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
1012{ 1012{
1013 struct v2p_entry *entry; 1013 struct v2p_entry *entry;
1014 unsigned long flags; 1014 unsigned long flags;
1015 int err;
1015 1016
1016 if (try) { 1017 if (try) {
1017 spin_lock_irqsave(&info->v2p_lock, flags); 1018 spin_lock_irqsave(&info->v2p_lock, flags);
@@ -1027,8 +1028,11 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
1027 scsiback_del_translation_entry(info, vir); 1028 scsiback_del_translation_entry(info, vir);
1028 } 1029 }
1029 } else if (!try) { 1030 } else if (!try) {
1030 xenbus_printf(XBT_NIL, info->dev->nodename, state, 1031 err = xenbus_printf(XBT_NIL, info->dev->nodename, state,
1031 "%d", XenbusStateClosed); 1032 "%d", XenbusStateClosed);
1033 if (err)
1034 xenbus_dev_error(info->dev, err,
1035 "%s: writing %s", __func__, state);
1032 } 1036 }
1033} 1037}
1034 1038
@@ -1067,8 +1071,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
1067 snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent); 1071 snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent);
1068 val = xenbus_read(XBT_NIL, dev->nodename, str, NULL); 1072 val = xenbus_read(XBT_NIL, dev->nodename, str, NULL);
1069 if (IS_ERR(val)) { 1073 if (IS_ERR(val)) {
1070 xenbus_printf(XBT_NIL, dev->nodename, state, 1074 err = xenbus_printf(XBT_NIL, dev->nodename, state,
1071 "%d", XenbusStateClosed); 1075 "%d", XenbusStateClosed);
1076 if (err)
1077 xenbus_dev_error(info->dev, err,
1078 "%s: writing %s", __func__, state);
1072 return; 1079 return;
1073 } 1080 }
1074 strlcpy(phy, val, VSCSI_NAMELEN); 1081 strlcpy(phy, val, VSCSI_NAMELEN);
@@ -1079,8 +1086,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
1079 err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u", 1086 err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u",
1080 &vir.hst, &vir.chn, &vir.tgt, &vir.lun); 1087 &vir.hst, &vir.chn, &vir.tgt, &vir.lun);
1081 if (XENBUS_EXIST_ERR(err)) { 1088 if (XENBUS_EXIST_ERR(err)) {
1082 xenbus_printf(XBT_NIL, dev->nodename, state, 1089 err = xenbus_printf(XBT_NIL, dev->nodename, state,
1083 "%d", XenbusStateClosed); 1090 "%d", XenbusStateClosed);
1091 if (err)
1092 xenbus_dev_error(info->dev, err,
1093 "%s: writing %s", __func__, state);
1084 return; 1094 return;
1085 } 1095 }
1086 1096
diff --git a/fs/aio.c b/fs/aio.c
index e1d20124ec0e..210df9da1283 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -5,7 +5,6 @@
5 * Implements an efficient asynchronous io interface. 5 * Implements an efficient asynchronous io interface.
6 * 6 *
7 * Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved. 7 * Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.
8 * Copyright 2018 Christoph Hellwig.
9 * 8 *
10 * See ../COPYING for licensing terms. 9 * See ../COPYING for licensing terms.
11 */ 10 */
@@ -165,22 +164,10 @@ struct fsync_iocb {
165 bool datasync; 164 bool datasync;
166}; 165};
167 166
168struct poll_iocb {
169 struct file *file;
170 __poll_t events;
171 struct wait_queue_head *head;
172
173 union {
174 struct wait_queue_entry wait;
175 struct work_struct work;
176 };
177};
178
179struct aio_kiocb { 167struct aio_kiocb {
180 union { 168 union {
181 struct kiocb rw; 169 struct kiocb rw;
182 struct fsync_iocb fsync; 170 struct fsync_iocb fsync;
183 struct poll_iocb poll;
184 }; 171 };
185 172
186 struct kioctx *ki_ctx; 173 struct kioctx *ki_ctx;
@@ -1590,6 +1577,7 @@ static int aio_fsync(struct fsync_iocb *req, struct iocb *iocb, bool datasync)
1590 if (unlikely(iocb->aio_buf || iocb->aio_offset || iocb->aio_nbytes || 1577 if (unlikely(iocb->aio_buf || iocb->aio_offset || iocb->aio_nbytes ||
1591 iocb->aio_rw_flags)) 1578 iocb->aio_rw_flags))
1592 return -EINVAL; 1579 return -EINVAL;
1580
1593 req->file = fget(iocb->aio_fildes); 1581 req->file = fget(iocb->aio_fildes);
1594 if (unlikely(!req->file)) 1582 if (unlikely(!req->file))
1595 return -EBADF; 1583 return -EBADF;
@@ -1604,137 +1592,6 @@ static int aio_fsync(struct fsync_iocb *req, struct iocb *iocb, bool datasync)
1604 return 0; 1592 return 0;
1605} 1593}
1606 1594
1607/* need to use list_del_init so we can check if item was present */
1608static inline bool __aio_poll_remove(struct poll_iocb *req)
1609{
1610 if (list_empty(&req->wait.entry))
1611 return false;
1612 list_del_init(&req->wait.entry);
1613 return true;
1614}
1615
1616static inline void __aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask)
1617{
1618 fput(iocb->poll.file);
1619 aio_complete(iocb, mangle_poll(mask), 0);
1620}
1621
1622static void aio_poll_work(struct work_struct *work)
1623{
1624 struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, poll.work);
1625
1626 if (!list_empty_careful(&iocb->ki_list))
1627 aio_remove_iocb(iocb);
1628 __aio_poll_complete(iocb, iocb->poll.events);
1629}
1630
1631static int aio_poll_cancel(struct kiocb *iocb)
1632{
1633 struct aio_kiocb *aiocb = container_of(iocb, struct aio_kiocb, rw);
1634 struct poll_iocb *req = &aiocb->poll;
1635 struct wait_queue_head *head = req->head;
1636 bool found = false;
1637
1638 spin_lock(&head->lock);
1639 found = __aio_poll_remove(req);
1640 spin_unlock(&head->lock);
1641
1642 if (found) {
1643 req->events = 0;
1644 INIT_WORK(&req->work, aio_poll_work);
1645 schedule_work(&req->work);
1646 }
1647 return 0;
1648}
1649
1650static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
1651 void *key)
1652{
1653 struct poll_iocb *req = container_of(wait, struct poll_iocb, wait);
1654 struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll);
1655 struct file *file = req->file;
1656 __poll_t mask = key_to_poll(key);
1657
1658 assert_spin_locked(&req->head->lock);
1659
1660 /* for instances that support it check for an event match first: */
1661 if (mask && !(mask & req->events))
1662 return 0;
1663
1664 mask = file->f_op->poll_mask(file, req->events) & req->events;
1665 if (!mask)
1666 return 0;
1667
1668 __aio_poll_remove(req);
1669
1670 /*
1671 * Try completing without a context switch if we can acquire ctx_lock
1672 * without spinning. Otherwise we need to defer to a workqueue to
1673 * avoid a deadlock due to the lock order.
1674 */
1675 if (spin_trylock(&iocb->ki_ctx->ctx_lock)) {
1676 list_del_init(&iocb->ki_list);
1677 spin_unlock(&iocb->ki_ctx->ctx_lock);
1678
1679 __aio_poll_complete(iocb, mask);
1680 } else {
1681 req->events = mask;
1682 INIT_WORK(&req->work, aio_poll_work);
1683 schedule_work(&req->work);
1684 }
1685
1686 return 1;
1687}
1688
1689static ssize_t aio_poll(struct aio_kiocb *aiocb, struct iocb *iocb)
1690{
1691 struct kioctx *ctx = aiocb->ki_ctx;
1692 struct poll_iocb *req = &aiocb->poll;
1693 __poll_t mask;
1694
1695 /* reject any unknown events outside the normal event mask. */
1696 if ((u16)iocb->aio_buf != iocb->aio_buf)
1697 return -EINVAL;
1698 /* reject fields that are not defined for poll */
1699 if (iocb->aio_offset || iocb->aio_nbytes || iocb->aio_rw_flags)
1700 return -EINVAL;
1701
1702 req->events = demangle_poll(iocb->aio_buf) | EPOLLERR | EPOLLHUP;
1703 req->file = fget(iocb->aio_fildes);
1704 if (unlikely(!req->file))
1705 return -EBADF;
1706 if (!file_has_poll_mask(req->file))
1707 goto out_fail;
1708
1709 req->head = req->file->f_op->get_poll_head(req->file, req->events);
1710 if (!req->head)
1711 goto out_fail;
1712 if (IS_ERR(req->head)) {
1713 mask = EPOLLERR;
1714 goto done;
1715 }
1716
1717 init_waitqueue_func_entry(&req->wait, aio_poll_wake);
1718 aiocb->ki_cancel = aio_poll_cancel;
1719
1720 spin_lock_irq(&ctx->ctx_lock);
1721 spin_lock(&req->head->lock);
1722 mask = req->file->f_op->poll_mask(req->file, req->events) & req->events;
1723 if (!mask) {
1724 __add_wait_queue(req->head, &req->wait);
1725 list_add_tail(&aiocb->ki_list, &ctx->active_reqs);
1726 }
1727 spin_unlock(&req->head->lock);
1728 spin_unlock_irq(&ctx->ctx_lock);
1729done:
1730 if (mask)
1731 __aio_poll_complete(aiocb, mask);
1732 return 0;
1733out_fail:
1734 fput(req->file);
1735 return -EINVAL; /* same as no support for IOCB_CMD_POLL */
1736}
1737
1738static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, 1595static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1739 bool compat) 1596 bool compat)
1740{ 1597{
@@ -1808,9 +1665,6 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1808 case IOCB_CMD_FDSYNC: 1665 case IOCB_CMD_FDSYNC:
1809 ret = aio_fsync(&req->fsync, &iocb, true); 1666 ret = aio_fsync(&req->fsync, &iocb, true);
1810 break; 1667 break;
1811 case IOCB_CMD_POLL:
1812 ret = aio_poll(req, &iocb);
1813 break;
1814 default: 1668 default:
1815 pr_debug("invalid aio operation %d\n", iocb.aio_lio_opcode); 1669 pr_debug("invalid aio operation %d\n", iocb.aio_lio_opcode);
1816 ret = -EINVAL; 1670 ret = -EINVAL;
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index cce6087d6880..e55843f536bc 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4542,8 +4542,11 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4542 offset_in_extent = em_start - em->start; 4542 offset_in_extent = em_start - em->start;
4543 em_end = extent_map_end(em); 4543 em_end = extent_map_end(em);
4544 em_len = em_end - em_start; 4544 em_len = em_end - em_start;
4545 disko = em->block_start + offset_in_extent;
4546 flags = 0; 4545 flags = 0;
4546 if (em->block_start < EXTENT_MAP_LAST_BYTE)
4547 disko = em->block_start + offset_in_extent;
4548 else
4549 disko = 0;
4547 4550
4548 /* 4551 /*
4549 * bump off for our next call to get_extent 4552 * bump off for our next call to get_extent
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e9482f0db9d0..eba61bcb9bb3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9005,13 +9005,14 @@ again:
9005 9005
9006 unlock_extent_cached(io_tree, page_start, page_end, &cached_state); 9006 unlock_extent_cached(io_tree, page_start, page_end, &cached_state);
9007 9007
9008out_unlock:
9009 if (!ret2) { 9008 if (!ret2) {
9010 btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true); 9009 btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true);
9011 sb_end_pagefault(inode->i_sb); 9010 sb_end_pagefault(inode->i_sb);
9012 extent_changeset_free(data_reserved); 9011 extent_changeset_free(data_reserved);
9013 return VM_FAULT_LOCKED; 9012 return VM_FAULT_LOCKED;
9014 } 9013 }
9014
9015out_unlock:
9015 unlock_page(page); 9016 unlock_page(page);
9016out: 9017out:
9017 btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, (ret != 0)); 9018 btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, (ret != 0));
@@ -9443,6 +9444,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9443 u64 new_idx = 0; 9444 u64 new_idx = 0;
9444 u64 root_objectid; 9445 u64 root_objectid;
9445 int ret; 9446 int ret;
9447 int ret2;
9446 bool root_log_pinned = false; 9448 bool root_log_pinned = false;
9447 bool dest_log_pinned = false; 9449 bool dest_log_pinned = false;
9448 9450
@@ -9639,7 +9641,8 @@ out_fail:
9639 dest_log_pinned = false; 9641 dest_log_pinned = false;
9640 } 9642 }
9641 } 9643 }
9642 ret = btrfs_end_transaction(trans); 9644 ret2 = btrfs_end_transaction(trans);
9645 ret = ret ? ret : ret2;
9643out_notrans: 9646out_notrans:
9644 if (new_ino == BTRFS_FIRST_FREE_OBJECTID) 9647 if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
9645 up_read(&fs_info->subvol_sem); 9648 up_read(&fs_info->subvol_sem);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c2837a32d689..43ecbe620dea 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3577,7 +3577,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
3577 ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN, 3577 ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN,
3578 dst, dst_loff, &cmp); 3578 dst, dst_loff, &cmp);
3579 if (ret) 3579 if (ret)
3580 goto out_unlock; 3580 goto out_free;
3581 3581
3582 loff += BTRFS_MAX_DEDUPE_LEN; 3582 loff += BTRFS_MAX_DEDUPE_LEN;
3583 dst_loff += BTRFS_MAX_DEDUPE_LEN; 3583 dst_loff += BTRFS_MAX_DEDUPE_LEN;
@@ -3587,16 +3587,16 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
3587 ret = btrfs_extent_same_range(src, loff, tail_len, dst, 3587 ret = btrfs_extent_same_range(src, loff, tail_len, dst,
3588 dst_loff, &cmp); 3588 dst_loff, &cmp);
3589 3589
3590out_free:
3591 kvfree(cmp.src_pages);
3592 kvfree(cmp.dst_pages);
3593
3590out_unlock: 3594out_unlock:
3591 if (same_inode) 3595 if (same_inode)
3592 inode_unlock(src); 3596 inode_unlock(src);
3593 else 3597 else
3594 btrfs_double_inode_unlock(src, dst); 3598 btrfs_double_inode_unlock(src, dst);
3595 3599
3596out_free:
3597 kvfree(cmp.src_pages);
3598 kvfree(cmp.dst_pages);
3599
3600 return ret; 3600 return ret;
3601} 3601}
3602 3602
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 1874a6d2e6f5..c25dc47210a3 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2680,8 +2680,10 @@ out:
2680 free_extent_buffer(scratch_leaf); 2680 free_extent_buffer(scratch_leaf);
2681 } 2681 }
2682 2682
2683 if (done && !ret) 2683 if (done && !ret) {
2684 ret = 1; 2684 ret = 1;
2685 fs_info->qgroup_rescan_progress.objectid = (u64)-1;
2686 }
2685 return ret; 2687 return ret;
2686} 2688}
2687 2689
@@ -2784,13 +2786,20 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
2784 2786
2785 if (!init_flags) { 2787 if (!init_flags) {
2786 /* we're resuming qgroup rescan at mount time */ 2788 /* we're resuming qgroup rescan at mount time */
2787 if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN)) 2789 if (!(fs_info->qgroup_flags &
2790 BTRFS_QGROUP_STATUS_FLAG_RESCAN)) {
2788 btrfs_warn(fs_info, 2791 btrfs_warn(fs_info,
2789 "qgroup rescan init failed, qgroup is not enabled"); 2792 "qgroup rescan init failed, qgroup is not enabled");
2790 else if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON)) 2793 ret = -EINVAL;
2794 } else if (!(fs_info->qgroup_flags &
2795 BTRFS_QGROUP_STATUS_FLAG_ON)) {
2791 btrfs_warn(fs_info, 2796 btrfs_warn(fs_info,
2792 "qgroup rescan init failed, qgroup rescan is not queued"); 2797 "qgroup rescan init failed, qgroup rescan is not queued");
2793 return -EINVAL; 2798 ret = -EINVAL;
2799 }
2800
2801 if (ret)
2802 return ret;
2794 } 2803 }
2795 2804
2796 mutex_lock(&fs_info->qgroup_rescan_lock); 2805 mutex_lock(&fs_info->qgroup_rescan_lock);
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index ee764ac352ab..a866be999216 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1135,6 +1135,7 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in)
1135 if (IS_ERR(realdn)) { 1135 if (IS_ERR(realdn)) {
1136 pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n", 1136 pr_err("splice_dentry error %ld %p inode %p ino %llx.%llx\n",
1137 PTR_ERR(realdn), dn, in, ceph_vinop(in)); 1137 PTR_ERR(realdn), dn, in, ceph_vinop(in));
1138 dput(dn);
1138 dn = realdn; /* note realdn contains the error */ 1139 dn = realdn; /* note realdn contains the error */
1139 goto out; 1140 goto out;
1140 } else if (realdn) { 1141 } else if (realdn) {
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 116146022aa1..bfe999505815 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -126,6 +126,25 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
126 seq_putc(m, '\n'); 126 seq_putc(m, '\n');
127} 127}
128 128
129static void
130cifs_dump_iface(struct seq_file *m, struct cifs_server_iface *iface)
131{
132 struct sockaddr_in *ipv4 = (struct sockaddr_in *)&iface->sockaddr;
133 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&iface->sockaddr;
134
135 seq_printf(m, "\t\tSpeed: %zu bps\n", iface->speed);
136 seq_puts(m, "\t\tCapabilities: ");
137 if (iface->rdma_capable)
138 seq_puts(m, "rdma ");
139 if (iface->rss_capable)
140 seq_puts(m, "rss ");
141 seq_putc(m, '\n');
142 if (iface->sockaddr.ss_family == AF_INET)
143 seq_printf(m, "\t\tIPv4: %pI4\n", &ipv4->sin_addr);
144 else if (iface->sockaddr.ss_family == AF_INET6)
145 seq_printf(m, "\t\tIPv6: %pI6\n", &ipv6->sin6_addr);
146}
147
129static int cifs_debug_data_proc_show(struct seq_file *m, void *v) 148static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
130{ 149{
131 struct list_head *tmp1, *tmp2, *tmp3; 150 struct list_head *tmp1, *tmp2, *tmp3;
@@ -312,6 +331,16 @@ skip_rdma:
312 mid_entry->mid); 331 mid_entry->mid);
313 } 332 }
314 spin_unlock(&GlobalMid_Lock); 333 spin_unlock(&GlobalMid_Lock);
334
335 spin_lock(&ses->iface_lock);
336 if (ses->iface_count)
337 seq_printf(m, "\n\tServer interfaces: %zu\n",
338 ses->iface_count);
339 for (j = 0; j < ses->iface_count; j++) {
340 seq_printf(m, "\t%d)\n", j);
341 cifs_dump_iface(m, &ses->iface_list[j]);
342 }
343 spin_unlock(&ses->iface_lock);
315 } 344 }
316 } 345 }
317 spin_unlock(&cifs_tcp_ses_lock); 346 spin_unlock(&cifs_tcp_ses_lock);
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 937251cc61c0..ee2a8ec70056 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -37,7 +37,6 @@
37#include <crypto/aead.h> 37#include <crypto/aead.h>
38 38
39int __cifs_calc_signature(struct smb_rqst *rqst, 39int __cifs_calc_signature(struct smb_rqst *rqst,
40 int start,
41 struct TCP_Server_Info *server, char *signature, 40 struct TCP_Server_Info *server, char *signature,
42 struct shash_desc *shash) 41 struct shash_desc *shash)
43{ 42{
@@ -45,16 +44,27 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
45 int rc; 44 int rc;
46 struct kvec *iov = rqst->rq_iov; 45 struct kvec *iov = rqst->rq_iov;
47 int n_vec = rqst->rq_nvec; 46 int n_vec = rqst->rq_nvec;
47 int is_smb2 = server->vals->header_preamble_size == 0;
48 48
49 for (i = start; i < n_vec; i++) { 49 /* iov[0] is actual data and not the rfc1002 length for SMB2+ */
50 if (is_smb2) {
51 if (iov[0].iov_len <= 4)
52 return -EIO;
53 i = 0;
54 } else {
55 if (n_vec < 2 || iov[0].iov_len != 4)
56 return -EIO;
57 i = 1; /* skip rfc1002 length */
58 }
59
60 for (; i < n_vec; i++) {
50 if (iov[i].iov_len == 0) 61 if (iov[i].iov_len == 0)
51 continue; 62 continue;
52 if (iov[i].iov_base == NULL) { 63 if (iov[i].iov_base == NULL) {
53 cifs_dbg(VFS, "null iovec entry\n"); 64 cifs_dbg(VFS, "null iovec entry\n");
54 return -EIO; 65 return -EIO;
55 } 66 }
56 if (i == 1 && iov[1].iov_len <= 4) 67
57 break; /* nothing to sign or corrupt header */
58 rc = crypto_shash_update(shash, 68 rc = crypto_shash_update(shash,
59 iov[i].iov_base, iov[i].iov_len); 69 iov[i].iov_base, iov[i].iov_len);
60 if (rc) { 70 if (rc) {
@@ -118,7 +128,7 @@ static int cifs_calc_signature(struct smb_rqst *rqst,
118 return rc; 128 return rc;
119 } 129 }
120 130
121 return __cifs_calc_signature(rqst, 1, server, signature, 131 return __cifs_calc_signature(rqst, server, signature,
122 &server->secmech.sdescmd5->shash); 132 &server->secmech.sdescmd5->shash);
123} 133}
124 134
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 1efa2e65bc1a..bd78da59a4fd 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -33,6 +33,9 @@
33 33
34#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ 34#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
35 35
36#define CIFS_PORT 445
37#define RFC1001_PORT 139
38
36/* 39/*
37 * The sizes of various internal tables and strings 40 * The sizes of various internal tables and strings
38 */ 41 */
@@ -312,6 +315,10 @@ struct smb_version_operations {
312 /* send echo request */ 315 /* send echo request */
313 int (*echo)(struct TCP_Server_Info *); 316 int (*echo)(struct TCP_Server_Info *);
314 /* create directory */ 317 /* create directory */
318 int (*posix_mkdir)(const unsigned int xid, struct inode *inode,
319 umode_t mode, struct cifs_tcon *tcon,
320 const char *full_path,
321 struct cifs_sb_info *cifs_sb);
315 int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *, 322 int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *,
316 struct cifs_sb_info *); 323 struct cifs_sb_info *);
317 /* set info on created directory */ 324 /* set info on created directory */
@@ -838,6 +845,13 @@ static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
838 845
839#endif 846#endif
840 847
848struct cifs_server_iface {
849 size_t speed;
850 unsigned int rdma_capable : 1;
851 unsigned int rss_capable : 1;
852 struct sockaddr_storage sockaddr;
853};
854
841/* 855/*
842 * Session structure. One of these for each uid session with a particular host 856 * Session structure. One of these for each uid session with a particular host
843 */ 857 */
@@ -875,6 +889,20 @@ struct cifs_ses {
875#ifdef CONFIG_CIFS_SMB311 889#ifdef CONFIG_CIFS_SMB311
876 __u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE]; 890 __u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
877#endif /* 3.1.1 */ 891#endif /* 3.1.1 */
892
893 /*
894 * Network interfaces available on the server this session is
895 * connected to.
896 *
897 * Other channels can be opened by connecting and binding this
898 * session to interfaces from this list.
899 *
900 * iface_lock should be taken when accessing any of these fields
901 */
902 spinlock_t iface_lock;
903 struct cifs_server_iface *iface_list;
904 size_t iface_count;
905 unsigned long iface_last_update; /* jiffies */
878}; 906};
879 907
880static inline bool 908static inline bool
@@ -883,6 +911,14 @@ cap_unix(struct cifs_ses *ses)
883 return ses->server->vals->cap_unix & ses->capabilities; 911 return ses->server->vals->cap_unix & ses->capabilities;
884} 912}
885 913
914struct cached_fid {
915 bool is_valid:1; /* Do we have a useable root fid */
916 struct cifs_fid *fid;
917 struct mutex fid_mutex;
918 struct cifs_tcon *tcon;
919 struct work_struct lease_break;
920};
921
886/* 922/*
887 * there is one of these for each connection to a resource on a particular 923 * there is one of these for each connection to a resource on a particular
888 * session 924 * session
@@ -987,9 +1023,7 @@ struct cifs_tcon {
987 struct fscache_cookie *fscache; /* cookie for share */ 1023 struct fscache_cookie *fscache; /* cookie for share */
988#endif 1024#endif
989 struct list_head pending_opens; /* list of incomplete opens */ 1025 struct list_head pending_opens; /* list of incomplete opens */
990 bool valid_root_fid:1; /* Do we have a useable root fid */ 1026 struct cached_fid crfid; /* Cached root fid */
991 struct mutex prfid_mutex; /* prevents reopen race after dead ses*/
992 struct cifs_fid *prfid; /* handle to the directory at top of share */
993 /* BB add field for back pointer to sb struct(s)? */ 1027 /* BB add field for back pointer to sb struct(s)? */
994}; 1028};
995 1029
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 4e0d183c3d10..03018be17283 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -112,10 +112,6 @@ extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
112 struct kvec *, int /* nvec to send */, 112 struct kvec *, int /* nvec to send */,
113 int * /* type of buf returned */, const int flags, 113 int * /* type of buf returned */, const int flags,
114 struct kvec * /* resp vec */); 114 struct kvec * /* resp vec */);
115extern int smb2_send_recv(const unsigned int xid, struct cifs_ses *pses,
116 struct kvec *pkvec, int nvec_to_send,
117 int *pbuftype, const int flags,
118 struct kvec *presp);
119extern int SendReceiveBlockingLock(const unsigned int xid, 115extern int SendReceiveBlockingLock(const unsigned int xid,
120 struct cifs_tcon *ptcon, 116 struct cifs_tcon *ptcon,
121 struct smb_hdr *in_buf , 117 struct smb_hdr *in_buf ,
@@ -544,7 +540,7 @@ int cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
544 struct cifs_sb_info *cifs_sb, 540 struct cifs_sb_info *cifs_sb,
545 const unsigned char *path, char *pbuf, 541 const unsigned char *path, char *pbuf,
546 unsigned int *pbytes_written); 542 unsigned int *pbytes_written);
547int __cifs_calc_signature(struct smb_rqst *rqst, int start, 543int __cifs_calc_signature(struct smb_rqst *rqst,
548 struct TCP_Server_Info *server, char *signature, 544 struct TCP_Server_Info *server, char *signature,
549 struct shash_desc *shash); 545 struct shash_desc *shash);
550enum securityEnum cifs_select_sectype(struct TCP_Server_Info *, 546enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
@@ -552,6 +548,7 @@ enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
552struct cifs_aio_ctx *cifs_aio_ctx_alloc(void); 548struct cifs_aio_ctx *cifs_aio_ctx_alloc(void);
553void cifs_aio_ctx_release(struct kref *refcount); 549void cifs_aio_ctx_release(struct kref *refcount);
554int setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw); 550int setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw);
551void smb2_cached_lease_break(struct work_struct *work);
555 552
556int cifs_alloc_hash(const char *name, struct crypto_shash **shash, 553int cifs_alloc_hash(const char *name, struct crypto_shash **shash,
557 struct sdesc **sdesc); 554 struct sdesc **sdesc);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 42329b25877d..d352da325de3 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -107,10 +107,10 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon)
107 } 107 }
108 spin_unlock(&tcon->open_file_lock); 108 spin_unlock(&tcon->open_file_lock);
109 109
110 mutex_lock(&tcon->prfid_mutex); 110 mutex_lock(&tcon->crfid.fid_mutex);
111 tcon->valid_root_fid = false; 111 tcon->crfid.is_valid = false;
112 memset(tcon->prfid, 0, sizeof(struct cifs_fid)); 112 memset(tcon->crfid.fid, 0, sizeof(struct cifs_fid));
113 mutex_unlock(&tcon->prfid_mutex); 113 mutex_unlock(&tcon->crfid.fid_mutex);
114 114
115 /* 115 /*
116 * BB Add call to invalidate_inodes(sb) for all superblocks mounted 116 * BB Add call to invalidate_inodes(sb) for all superblocks mounted
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 96645a7d8f27..a57da1b88bdf 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -57,9 +57,6 @@
57#include "smb2proto.h" 57#include "smb2proto.h"
58#include "smbdirect.h" 58#include "smbdirect.h"
59 59
60#define CIFS_PORT 445
61#define RFC1001_PORT 139
62
63extern mempool_t *cifs_req_poolp; 60extern mempool_t *cifs_req_poolp;
64extern bool disable_legacy_dialects; 61extern bool disable_legacy_dialects;
65 62
@@ -3029,8 +3026,11 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
3029 3026
3030#ifdef CONFIG_CIFS_SMB311 3027#ifdef CONFIG_CIFS_SMB311
3031 if ((volume_info->linux_ext) && (ses->server->posix_ext_supported)) { 3028 if ((volume_info->linux_ext) && (ses->server->posix_ext_supported)) {
3032 if (ses->server->vals->protocol_id == SMB311_PROT_ID) 3029 if (ses->server->vals->protocol_id == SMB311_PROT_ID) {
3033 tcon->posix_extensions = true; 3030 tcon->posix_extensions = true;
3031 printk_once(KERN_WARNING
3032 "SMB3.11 POSIX Extensions are experimental\n");
3033 }
3034 } 3034 }
3035#endif /* 311 */ 3035#endif /* 311 */
3036 3036
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index f4697f548a39..a2cfb33e85c1 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1575,6 +1575,17 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
1575 goto mkdir_out; 1575 goto mkdir_out;
1576 } 1576 }
1577 1577
1578 server = tcon->ses->server;
1579
1580#ifdef CONFIG_CIFS_SMB311
1581 if ((server->ops->posix_mkdir) && (tcon->posix_extensions)) {
1582 rc = server->ops->posix_mkdir(xid, inode, mode, tcon, full_path,
1583 cifs_sb);
1584 d_drop(direntry); /* for time being always refresh inode info */
1585 goto mkdir_out;
1586 }
1587#endif /* SMB311 */
1588
1578 if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP & 1589 if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP &
1579 le64_to_cpu(tcon->fsUnixInfo.Capability))) { 1590 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
1580 rc = cifs_posix_mkdir(inode, direntry, mode, full_path, cifs_sb, 1591 rc = cifs_posix_mkdir(inode, direntry, mode, full_path, cifs_sb,
@@ -1583,8 +1594,6 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
1583 goto mkdir_out; 1594 goto mkdir_out;
1584 } 1595 }
1585 1596
1586 server = tcon->ses->server;
1587
1588 if (!server->ops->mkdir) { 1597 if (!server->ops->mkdir) {
1589 rc = -ENOSYS; 1598 rc = -ENOSYS;
1590 goto mkdir_out; 1599 goto mkdir_out;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index af29ade195c0..53e8362cbc4a 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -82,6 +82,7 @@ sesInfoAlloc(void)
82 INIT_LIST_HEAD(&ret_buf->smb_ses_list); 82 INIT_LIST_HEAD(&ret_buf->smb_ses_list);
83 INIT_LIST_HEAD(&ret_buf->tcon_list); 83 INIT_LIST_HEAD(&ret_buf->tcon_list);
84 mutex_init(&ret_buf->session_mutex); 84 mutex_init(&ret_buf->session_mutex);
85 spin_lock_init(&ret_buf->iface_lock);
85 } 86 }
86 return ret_buf; 87 return ret_buf;
87} 88}
@@ -102,6 +103,7 @@ sesInfoFree(struct cifs_ses *buf_to_free)
102 kfree(buf_to_free->user_name); 103 kfree(buf_to_free->user_name);
103 kfree(buf_to_free->domainName); 104 kfree(buf_to_free->domainName);
104 kzfree(buf_to_free->auth_key.response); 105 kzfree(buf_to_free->auth_key.response);
106 kfree(buf_to_free->iface_list);
105 kzfree(buf_to_free); 107 kzfree(buf_to_free);
106} 108}
107 109
@@ -117,8 +119,9 @@ tconInfoAlloc(void)
117 INIT_LIST_HEAD(&ret_buf->openFileList); 119 INIT_LIST_HEAD(&ret_buf->openFileList);
118 INIT_LIST_HEAD(&ret_buf->tcon_list); 120 INIT_LIST_HEAD(&ret_buf->tcon_list);
119 spin_lock_init(&ret_buf->open_file_lock); 121 spin_lock_init(&ret_buf->open_file_lock);
120 mutex_init(&ret_buf->prfid_mutex); 122 mutex_init(&ret_buf->crfid.fid_mutex);
121 ret_buf->prfid = kzalloc(sizeof(struct cifs_fid), GFP_KERNEL); 123 ret_buf->crfid.fid = kzalloc(sizeof(struct cifs_fid),
124 GFP_KERNEL);
122#ifdef CONFIG_CIFS_STATS 125#ifdef CONFIG_CIFS_STATS
123 spin_lock_init(&ret_buf->stat_lock); 126 spin_lock_init(&ret_buf->stat_lock);
124#endif 127#endif
@@ -136,7 +139,7 @@ tconInfoFree(struct cifs_tcon *buf_to_free)
136 atomic_dec(&tconInfoAllocCount); 139 atomic_dec(&tconInfoAllocCount);
137 kfree(buf_to_free->nativeFileSystem); 140 kfree(buf_to_free->nativeFileSystem);
138 kzfree(buf_to_free->password); 141 kzfree(buf_to_free->password);
139 kfree(buf_to_free->prfid); 142 kfree(buf_to_free->crfid.fid);
140 kfree(buf_to_free); 143 kfree(buf_to_free);
141} 144}
142 145
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index e2bec47c6845..3ff7cec2da81 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -454,7 +454,8 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb)
454#ifdef CONFIG_CIFS_SMB311 454#ifdef CONFIG_CIFS_SMB311
455 /* SMB311 POSIX extensions paths do not include leading slash */ 455 /* SMB311 POSIX extensions paths do not include leading slash */
456 else if (cifs_sb_master_tlink(cifs_sb) && 456 else if (cifs_sb_master_tlink(cifs_sb) &&
457 cifs_sb_master_tcon(cifs_sb)->posix_extensions) { 457 cifs_sb_master_tcon(cifs_sb)->posix_extensions &&
458 (from[0] == '/')) {
458 start_of_path = from + 1; 459 start_of_path = from + 1;
459 } 460 }
460#endif /* 311 */ 461#endif /* 311 */
@@ -492,10 +493,11 @@ cifs_ses_oplock_break(struct work_struct *work)
492{ 493{
493 struct smb2_lease_break_work *lw = container_of(work, 494 struct smb2_lease_break_work *lw = container_of(work,
494 struct smb2_lease_break_work, lease_break); 495 struct smb2_lease_break_work, lease_break);
495 int rc; 496 int rc = 0;
496 497
497 rc = SMB2_lease_break(0, tlink_tcon(lw->tlink), lw->lease_key, 498 rc = SMB2_lease_break(0, tlink_tcon(lw->tlink), lw->lease_key,
498 lw->lease_state); 499 lw->lease_state);
500
499 cifs_dbg(FYI, "Lease release rc %d\n", rc); 501 cifs_dbg(FYI, "Lease release rc %d\n", rc);
500 cifs_put_tlink(lw->tlink); 502 cifs_put_tlink(lw->tlink);
501 kfree(lw); 503 kfree(lw);
@@ -561,6 +563,7 @@ smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp,
561 563
562 open->oplock = lease_state; 564 open->oplock = lease_state;
563 } 565 }
566
564 return found; 567 return found;
565} 568}
566 569
@@ -603,6 +606,18 @@ smb2_is_valid_lease_break(char *buffer)
603 return true; 606 return true;
604 } 607 }
605 spin_unlock(&tcon->open_file_lock); 608 spin_unlock(&tcon->open_file_lock);
609
610 if (tcon->crfid.is_valid &&
611 !memcmp(rsp->LeaseKey,
612 tcon->crfid.fid->lease_key,
613 SMB2_LEASE_KEY_SIZE)) {
614 INIT_WORK(&tcon->crfid.lease_break,
615 smb2_cached_lease_break);
616 queue_work(cifsiod_wq,
617 &tcon->crfid.lease_break);
618 spin_unlock(&cifs_tcp_ses_lock);
619 return true;
620 }
606 } 621 }
607 } 622 }
608 } 623 }
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index b15f5957d645..0356b5559c71 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -294,34 +294,191 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
294 return rsize; 294 return rsize;
295} 295}
296 296
297#ifdef CONFIG_CIFS_STATS2 297
298static int
299parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
300 size_t buf_len,
301 struct cifs_server_iface **iface_list,
302 size_t *iface_count)
303{
304 struct network_interface_info_ioctl_rsp *p;
305 struct sockaddr_in *addr4;
306 struct sockaddr_in6 *addr6;
307 struct iface_info_ipv4 *p4;
308 struct iface_info_ipv6 *p6;
309 struct cifs_server_iface *info;
310 ssize_t bytes_left;
311 size_t next = 0;
312 int nb_iface = 0;
313 int rc = 0;
314
315 *iface_list = NULL;
316 *iface_count = 0;
317
318 /*
319 * Fist pass: count and sanity check
320 */
321
322 bytes_left = buf_len;
323 p = buf;
324 while (bytes_left >= sizeof(*p)) {
325 nb_iface++;
326 next = le32_to_cpu(p->Next);
327 if (!next) {
328 bytes_left -= sizeof(*p);
329 break;
330 }
331 p = (struct network_interface_info_ioctl_rsp *)((u8 *)p+next);
332 bytes_left -= next;
333 }
334
335 if (!nb_iface) {
336 cifs_dbg(VFS, "%s: malformed interface info\n", __func__);
337 rc = -EINVAL;
338 goto out;
339 }
340
341 if (bytes_left || p->Next)
342 cifs_dbg(VFS, "%s: incomplete interface info\n", __func__);
343
344
345 /*
346 * Second pass: extract info to internal structure
347 */
348
349 *iface_list = kcalloc(nb_iface, sizeof(**iface_list), GFP_KERNEL);
350 if (!*iface_list) {
351 rc = -ENOMEM;
352 goto out;
353 }
354
355 info = *iface_list;
356 bytes_left = buf_len;
357 p = buf;
358 while (bytes_left >= sizeof(*p)) {
359 info->speed = le64_to_cpu(p->LinkSpeed);
360 info->rdma_capable = le32_to_cpu(p->Capability & RDMA_CAPABLE);
361 info->rss_capable = le32_to_cpu(p->Capability & RSS_CAPABLE);
362
363 cifs_dbg(FYI, "%s: adding iface %zu\n", __func__, *iface_count);
364 cifs_dbg(FYI, "%s: speed %zu bps\n", __func__, info->speed);
365 cifs_dbg(FYI, "%s: capabilities 0x%08x\n", __func__,
366 le32_to_cpu(p->Capability));
367
368 switch (p->Family) {
369 /*
370 * The kernel and wire socket structures have the same
371 * layout and use network byte order but make the
372 * conversion explicit in case either one changes.
373 */
374 case INTERNETWORK:
375 addr4 = (struct sockaddr_in *)&info->sockaddr;
376 p4 = (struct iface_info_ipv4 *)p->Buffer;
377 addr4->sin_family = AF_INET;
378 memcpy(&addr4->sin_addr, &p4->IPv4Address, 4);
379
380 /* [MS-SMB2] 2.2.32.5.1.1 Clients MUST ignore these */
381 addr4->sin_port = cpu_to_be16(CIFS_PORT);
382
383 cifs_dbg(FYI, "%s: ipv4 %pI4\n", __func__,
384 &addr4->sin_addr);
385 break;
386 case INTERNETWORKV6:
387 addr6 = (struct sockaddr_in6 *)&info->sockaddr;
388 p6 = (struct iface_info_ipv6 *)p->Buffer;
389 addr6->sin6_family = AF_INET6;
390 memcpy(&addr6->sin6_addr, &p6->IPv6Address, 16);
391
392 /* [MS-SMB2] 2.2.32.5.1.2 Clients MUST ignore these */
393 addr6->sin6_flowinfo = 0;
394 addr6->sin6_scope_id = 0;
395 addr6->sin6_port = cpu_to_be16(CIFS_PORT);
396
397 cifs_dbg(FYI, "%s: ipv6 %pI6\n", __func__,
398 &addr6->sin6_addr);
399 break;
400 default:
401 cifs_dbg(VFS,
402 "%s: skipping unsupported socket family\n",
403 __func__);
404 goto next_iface;
405 }
406
407 (*iface_count)++;
408 info++;
409next_iface:
410 next = le32_to_cpu(p->Next);
411 if (!next)
412 break;
413 p = (struct network_interface_info_ioctl_rsp *)((u8 *)p+next);
414 bytes_left -= next;
415 }
416
417 if (!*iface_count) {
418 rc = -EINVAL;
419 goto out;
420 }
421
422out:
423 if (rc) {
424 kfree(*iface_list);
425 *iface_count = 0;
426 *iface_list = NULL;
427 }
428 return rc;
429}
430
431
298static int 432static int
299SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) 433SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
300{ 434{
301 int rc; 435 int rc;
302 unsigned int ret_data_len = 0; 436 unsigned int ret_data_len = 0;
303 struct network_interface_info_ioctl_rsp *out_buf; 437 struct network_interface_info_ioctl_rsp *out_buf = NULL;
438 struct cifs_server_iface *iface_list;
439 size_t iface_count;
440 struct cifs_ses *ses = tcon->ses;
304 441
305 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, 442 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
306 FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */, 443 FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */,
307 NULL /* no data input */, 0 /* no data input */, 444 NULL /* no data input */, 0 /* no data input */,
308 (char **)&out_buf, &ret_data_len); 445 (char **)&out_buf, &ret_data_len);
309 if (rc != 0) 446 if (rc != 0) {
310 cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc); 447 cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
311 else if (ret_data_len < sizeof(struct network_interface_info_ioctl_rsp)) { 448 goto out;
312 cifs_dbg(VFS, "server returned bad net interface info buf\n");
313 rc = -EINVAL;
314 } else {
315 /* Dump info on first interface */
316 cifs_dbg(FYI, "Adapter Capability 0x%x\t",
317 le32_to_cpu(out_buf->Capability));
318 cifs_dbg(FYI, "Link Speed %lld\n",
319 le64_to_cpu(out_buf->LinkSpeed));
320 } 449 }
450
451 rc = parse_server_interfaces(out_buf, ret_data_len,
452 &iface_list, &iface_count);
453 if (rc)
454 goto out;
455
456 spin_lock(&ses->iface_lock);
457 kfree(ses->iface_list);
458 ses->iface_list = iface_list;
459 ses->iface_count = iface_count;
460 ses->iface_last_update = jiffies;
461 spin_unlock(&ses->iface_lock);
462
463out:
321 kfree(out_buf); 464 kfree(out_buf);
322 return rc; 465 return rc;
323} 466}
324#endif /* STATS2 */ 467
468void
469smb2_cached_lease_break(struct work_struct *work)
470{
471 struct cached_fid *cfid = container_of(work,
472 struct cached_fid, lease_break);
473 mutex_lock(&cfid->fid_mutex);
474 if (cfid->is_valid) {
475 cifs_dbg(FYI, "clear cached root file handle\n");
476 SMB2_close(0, cfid->tcon, cfid->fid->persistent_fid,
477 cfid->fid->volatile_fid);
478 cfid->is_valid = false;
479 }
480 mutex_unlock(&cfid->fid_mutex);
481}
325 482
326/* 483/*
327 * Open the directory at the root of a share 484 * Open the directory at the root of a share
@@ -331,13 +488,13 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
331 struct cifs_open_parms oparams; 488 struct cifs_open_parms oparams;
332 int rc; 489 int rc;
333 __le16 srch_path = 0; /* Null - since an open of top of share */ 490 __le16 srch_path = 0; /* Null - since an open of top of share */
334 u8 oplock = SMB2_OPLOCK_LEVEL_NONE; 491 u8 oplock = SMB2_OPLOCK_LEVEL_II;
335 492
336 mutex_lock(&tcon->prfid_mutex); 493 mutex_lock(&tcon->crfid.fid_mutex);
337 if (tcon->valid_root_fid) { 494 if (tcon->crfid.is_valid) {
338 cifs_dbg(FYI, "found a cached root file handle\n"); 495 cifs_dbg(FYI, "found a cached root file handle\n");
339 memcpy(pfid, tcon->prfid, sizeof(struct cifs_fid)); 496 memcpy(pfid, tcon->crfid.fid, sizeof(struct cifs_fid));
340 mutex_unlock(&tcon->prfid_mutex); 497 mutex_unlock(&tcon->crfid.fid_mutex);
341 return 0; 498 return 0;
342 } 499 }
343 500
@@ -350,10 +507,11 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid)
350 507
351 rc = SMB2_open(xid, &oparams, &srch_path, &oplock, NULL, NULL, NULL); 508 rc = SMB2_open(xid, &oparams, &srch_path, &oplock, NULL, NULL, NULL);
352 if (rc == 0) { 509 if (rc == 0) {
353 memcpy(tcon->prfid, pfid, sizeof(struct cifs_fid)); 510 memcpy(tcon->crfid.fid, pfid, sizeof(struct cifs_fid));
354 tcon->valid_root_fid = true; 511 tcon->crfid.tcon = tcon;
512 tcon->crfid.is_valid = true;
355 } 513 }
356 mutex_unlock(&tcon->prfid_mutex); 514 mutex_unlock(&tcon->crfid.fid_mutex);
357 return rc; 515 return rc;
358} 516}
359 517
@@ -383,9 +541,7 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
383 if (rc) 541 if (rc)
384 return; 542 return;
385 543
386#ifdef CONFIG_CIFS_STATS2
387 SMB3_request_interfaces(xid, tcon); 544 SMB3_request_interfaces(xid, tcon);
388#endif /* STATS2 */
389 545
390 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, 546 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
391 FS_ATTRIBUTE_INFORMATION); 547 FS_ATTRIBUTE_INFORMATION);
@@ -436,7 +592,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
436 struct cifs_open_parms oparms; 592 struct cifs_open_parms oparms;
437 struct cifs_fid fid; 593 struct cifs_fid fid;
438 594
439 if ((*full_path == 0) && tcon->valid_root_fid) 595 if ((*full_path == 0) && tcon->crfid.is_valid)
440 return 0; 596 return 0;
441 597
442 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); 598 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
@@ -2151,7 +2307,7 @@ fill_transform_hdr(struct smb2_transform_hdr *tr_hdr, unsigned int orig_len,
2151 struct smb_rqst *old_rq) 2307 struct smb_rqst *old_rq)
2152{ 2308{
2153 struct smb2_sync_hdr *shdr = 2309 struct smb2_sync_hdr *shdr =
2154 (struct smb2_sync_hdr *)old_rq->rq_iov[1].iov_base; 2310 (struct smb2_sync_hdr *)old_rq->rq_iov[0].iov_base;
2155 2311
2156 memset(tr_hdr, 0, sizeof(struct smb2_transform_hdr)); 2312 memset(tr_hdr, 0, sizeof(struct smb2_transform_hdr));
2157 tr_hdr->ProtocolId = SMB2_TRANSFORM_PROTO_NUM; 2313 tr_hdr->ProtocolId = SMB2_TRANSFORM_PROTO_NUM;
@@ -2171,14 +2327,13 @@ static inline void smb2_sg_set_buf(struct scatterlist *sg, const void *buf,
2171} 2327}
2172 2328
2173/* Assumes: 2329/* Assumes:
2174 * rqst->rq_iov[0] is rfc1002 length 2330 * rqst->rq_iov[0] is transform header
2175 * rqst->rq_iov[1] is tranform header 2331 * rqst->rq_iov[1+] data to be encrypted/decrypted
2176 * rqst->rq_iov[2+] data to be encrypted/decrypted
2177 */ 2332 */
2178static struct scatterlist * 2333static struct scatterlist *
2179init_sg(struct smb_rqst *rqst, u8 *sign) 2334init_sg(struct smb_rqst *rqst, u8 *sign)
2180{ 2335{
2181 unsigned int sg_len = rqst->rq_nvec + rqst->rq_npages; 2336 unsigned int sg_len = rqst->rq_nvec + rqst->rq_npages + 1;
2182 unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20; 2337 unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20;
2183 struct scatterlist *sg; 2338 struct scatterlist *sg;
2184 unsigned int i; 2339 unsigned int i;
@@ -2189,10 +2344,10 @@ init_sg(struct smb_rqst *rqst, u8 *sign)
2189 return NULL; 2344 return NULL;
2190 2345
2191 sg_init_table(sg, sg_len); 2346 sg_init_table(sg, sg_len);
2192 smb2_sg_set_buf(&sg[0], rqst->rq_iov[1].iov_base + 20, assoc_data_len); 2347 smb2_sg_set_buf(&sg[0], rqst->rq_iov[0].iov_base + 20, assoc_data_len);
2193 for (i = 1; i < rqst->rq_nvec - 1; i++) 2348 for (i = 1; i < rqst->rq_nvec; i++)
2194 smb2_sg_set_buf(&sg[i], rqst->rq_iov[i+1].iov_base, 2349 smb2_sg_set_buf(&sg[i], rqst->rq_iov[i].iov_base,
2195 rqst->rq_iov[i+1].iov_len); 2350 rqst->rq_iov[i].iov_len);
2196 for (j = 0; i < sg_len - 1; i++, j++) { 2351 for (j = 0; i < sg_len - 1; i++, j++) {
2197 unsigned int len, offset; 2352 unsigned int len, offset;
2198 2353
@@ -2224,18 +2379,17 @@ smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key)
2224 return 1; 2379 return 1;
2225} 2380}
2226/* 2381/*
2227 * Encrypt or decrypt @rqst message. @rqst has the following format: 2382 * Encrypt or decrypt @rqst message. @rqst[0] has the following format:
2228 * iov[0] - rfc1002 length 2383 * iov[0] - transform header (associate data),
2229 * iov[1] - transform header (associate data), 2384 * iov[1-N] - SMB2 header and pages - data to encrypt.
2230 * iov[2-N] and pages - data to encrypt. 2385 * On success return encrypted data in iov[1-N] and pages, leave iov[0]
2231 * On success return encrypted data in iov[2-N] and pages, leave iov[0-1]
2232 * untouched. 2386 * untouched.
2233 */ 2387 */
2234static int 2388static int
2235crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) 2389crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc)
2236{ 2390{
2237 struct smb2_transform_hdr *tr_hdr = 2391 struct smb2_transform_hdr *tr_hdr =
2238 (struct smb2_transform_hdr *)rqst->rq_iov[1].iov_base; 2392 (struct smb2_transform_hdr *)rqst->rq_iov[0].iov_base;
2239 unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20; 2393 unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20;
2240 int rc = 0; 2394 int rc = 0;
2241 struct scatterlist *sg; 2395 struct scatterlist *sg;
@@ -2323,10 +2477,6 @@ free_req:
2323 return rc; 2477 return rc;
2324} 2478}
2325 2479
2326/*
2327 * This is called from smb_send_rqst. At this point we have the rfc1002
2328 * header as the first element in the vector.
2329 */
2330static int 2480static int
2331smb3_init_transform_rq(struct TCP_Server_Info *server, struct smb_rqst *new_rq, 2481smb3_init_transform_rq(struct TCP_Server_Info *server, struct smb_rqst *new_rq,
2332 struct smb_rqst *old_rq) 2482 struct smb_rqst *old_rq)
@@ -2335,7 +2485,7 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, struct smb_rqst *new_rq,
2335 struct page **pages; 2485 struct page **pages;
2336 struct smb2_transform_hdr *tr_hdr; 2486 struct smb2_transform_hdr *tr_hdr;
2337 unsigned int npages = old_rq->rq_npages; 2487 unsigned int npages = old_rq->rq_npages;
2338 unsigned int orig_len = get_rfc1002_length(old_rq->rq_iov[0].iov_base); 2488 unsigned int orig_len;
2339 int i; 2489 int i;
2340 int rc = -ENOMEM; 2490 int rc = -ENOMEM;
2341 2491
@@ -2355,18 +2505,14 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, struct smb_rqst *new_rq,
2355 goto err_free_pages; 2505 goto err_free_pages;
2356 } 2506 }
2357 2507
2358 /* Make space for one extra iov to hold the transform header */
2359 iov = kmalloc_array(old_rq->rq_nvec + 1, sizeof(struct kvec), 2508 iov = kmalloc_array(old_rq->rq_nvec + 1, sizeof(struct kvec),
2360 GFP_KERNEL); 2509 GFP_KERNEL);
2361 if (!iov) 2510 if (!iov)
2362 goto err_free_pages; 2511 goto err_free_pages;
2363 2512
2364 /* copy all iovs from the old except the 1st one (rfc1002 length) */ 2513 /* copy all iovs from the old */
2365 memcpy(&iov[2], &old_rq->rq_iov[1], 2514 memcpy(&iov[1], &old_rq->rq_iov[0],
2366 sizeof(struct kvec) * (old_rq->rq_nvec - 1)); 2515 sizeof(struct kvec) * old_rq->rq_nvec);
2367 /* copy the rfc1002 iov */
2368 iov[0].iov_base = old_rq->rq_iov[0].iov_base;
2369 iov[0].iov_len = old_rq->rq_iov[0].iov_len;
2370 2516
2371 new_rq->rq_iov = iov; 2517 new_rq->rq_iov = iov;
2372 new_rq->rq_nvec = old_rq->rq_nvec + 1; 2518 new_rq->rq_nvec = old_rq->rq_nvec + 1;
@@ -2375,14 +2521,12 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, struct smb_rqst *new_rq,
2375 if (!tr_hdr) 2521 if (!tr_hdr)
2376 goto err_free_iov; 2522 goto err_free_iov;
2377 2523
2524 orig_len = smb2_rqst_len(old_rq, false);
2525
2378 /* fill the 2nd iov with a transform header */ 2526 /* fill the 2nd iov with a transform header */
2379 fill_transform_hdr(tr_hdr, orig_len, old_rq); 2527 fill_transform_hdr(tr_hdr, orig_len, old_rq);
2380 new_rq->rq_iov[1].iov_base = tr_hdr; 2528 new_rq->rq_iov[0].iov_base = tr_hdr;
2381 new_rq->rq_iov[1].iov_len = sizeof(struct smb2_transform_hdr); 2529 new_rq->rq_iov[0].iov_len = sizeof(struct smb2_transform_hdr);
2382
2383 /* Update rfc1002 header */
2384 inc_rfc1001_len(new_rq->rq_iov[0].iov_base,
2385 sizeof(struct smb2_transform_hdr));
2386 2530
2387 /* copy pages form the old */ 2531 /* copy pages form the old */
2388 for (i = 0; i < npages; i++) { 2532 for (i = 0; i < npages; i++) {
@@ -2426,7 +2570,7 @@ smb3_free_transform_rq(struct smb_rqst *rqst)
2426 put_page(rqst->rq_pages[i]); 2570 put_page(rqst->rq_pages[i]);
2427 kfree(rqst->rq_pages); 2571 kfree(rqst->rq_pages);
2428 /* free transform header */ 2572 /* free transform header */
2429 kfree(rqst->rq_iov[1].iov_base); 2573 kfree(rqst->rq_iov[0].iov_base);
2430 kfree(rqst->rq_iov); 2574 kfree(rqst->rq_iov);
2431} 2575}
2432 2576
@@ -2443,19 +2587,17 @@ decrypt_raw_data(struct TCP_Server_Info *server, char *buf,
2443 unsigned int buf_data_size, struct page **pages, 2587 unsigned int buf_data_size, struct page **pages,
2444 unsigned int npages, unsigned int page_data_size) 2588 unsigned int npages, unsigned int page_data_size)
2445{ 2589{
2446 struct kvec iov[3]; 2590 struct kvec iov[2];
2447 struct smb_rqst rqst = {NULL}; 2591 struct smb_rqst rqst = {NULL};
2448 int rc; 2592 int rc;
2449 2593
2450 iov[0].iov_base = NULL; 2594 iov[0].iov_base = buf;
2451 iov[0].iov_len = 0; 2595 iov[0].iov_len = sizeof(struct smb2_transform_hdr);
2452 iov[1].iov_base = buf; 2596 iov[1].iov_base = buf + sizeof(struct smb2_transform_hdr);
2453 iov[1].iov_len = sizeof(struct smb2_transform_hdr); 2597 iov[1].iov_len = buf_data_size;
2454 iov[2].iov_base = buf + sizeof(struct smb2_transform_hdr);
2455 iov[2].iov_len = buf_data_size;
2456 2598
2457 rqst.rq_iov = iov; 2599 rqst.rq_iov = iov;
2458 rqst.rq_nvec = 3; 2600 rqst.rq_nvec = 2;
2459 rqst.rq_pages = pages; 2601 rqst.rq_pages = pages;
2460 rqst.rq_npages = npages; 2602 rqst.rq_npages = npages;
2461 rqst.rq_pagesz = PAGE_SIZE; 2603 rqst.rq_pagesz = PAGE_SIZE;
@@ -2467,7 +2609,7 @@ decrypt_raw_data(struct TCP_Server_Info *server, char *buf,
2467 if (rc) 2609 if (rc)
2468 return rc; 2610 return rc;
2469 2611
2470 memmove(buf, iov[2].iov_base, buf_data_size); 2612 memmove(buf, iov[1].iov_base, buf_data_size);
2471 2613
2472 server->total_read = buf_data_size + page_data_size; 2614 server->total_read = buf_data_size + page_data_size;
2473 2615
@@ -3170,6 +3312,7 @@ struct smb_version_operations smb311_operations = {
3170 .set_compression = smb2_set_compression, 3312 .set_compression = smb2_set_compression,
3171 .mkdir = smb2_mkdir, 3313 .mkdir = smb2_mkdir,
3172 .mkdir_setinfo = smb2_mkdir_setinfo, 3314 .mkdir_setinfo = smb2_mkdir_setinfo,
3315 .posix_mkdir = smb311_posix_mkdir,
3173 .rmdir = smb2_rmdir, 3316 .rmdir = smb2_rmdir,
3174 .unlink = smb2_unlink, 3317 .unlink = smb2_unlink,
3175 .rename = smb2_rename_path, 3318 .rename = smb2_rename_path,
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index af032e1a3eac..810b85787c91 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -602,6 +602,7 @@ static void assemble_neg_contexts(struct smb2_negotiate_req *req,
602int 602int
603SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) 603SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
604{ 604{
605 struct smb_rqst rqst;
605 struct smb2_negotiate_req *req; 606 struct smb2_negotiate_req *req;
606 struct smb2_negotiate_rsp *rsp; 607 struct smb2_negotiate_rsp *rsp;
607 struct kvec iov[1]; 608 struct kvec iov[1];
@@ -673,7 +674,11 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
673 iov[0].iov_base = (char *)req; 674 iov[0].iov_base = (char *)req;
674 iov[0].iov_len = total_len; 675 iov[0].iov_len = total_len;
675 676
676 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); 677 memset(&rqst, 0, sizeof(struct smb_rqst));
678 rqst.rq_iov = iov;
679 rqst.rq_nvec = 1;
680
681 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
677 cifs_small_buf_release(req); 682 cifs_small_buf_release(req);
678 rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base; 683 rsp = (struct smb2_negotiate_rsp *)rsp_iov.iov_base;
679 /* 684 /*
@@ -990,8 +995,9 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data)
990 req->PreviousSessionId = sess_data->previous_session; 995 req->PreviousSessionId = sess_data->previous_session;
991 996
992 req->Flags = 0; /* MBZ */ 997 req->Flags = 0; /* MBZ */
993 /* to enable echos and oplocks */ 998
994 req->sync_hdr.CreditRequest = cpu_to_le16(3); 999 /* enough to enable echos and oplocks and one max size write */
1000 req->sync_hdr.CreditRequest = cpu_to_le16(130);
995 1001
996 /* only one of SMB2 signing flags may be set in SMB2 request */ 1002 /* only one of SMB2 signing flags may be set in SMB2 request */
997 if (server->sign) 1003 if (server->sign)
@@ -1027,6 +1033,7 @@ static int
1027SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data) 1033SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data)
1028{ 1034{
1029 int rc; 1035 int rc;
1036 struct smb_rqst rqst;
1030 struct smb2_sess_setup_req *req = sess_data->iov[0].iov_base; 1037 struct smb2_sess_setup_req *req = sess_data->iov[0].iov_base;
1031 struct kvec rsp_iov = { NULL, 0 }; 1038 struct kvec rsp_iov = { NULL, 0 };
1032 1039
@@ -1035,10 +1042,13 @@ SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data)
1035 cpu_to_le16(sizeof(struct smb2_sess_setup_req) - 1 /* pad */); 1042 cpu_to_le16(sizeof(struct smb2_sess_setup_req) - 1 /* pad */);
1036 req->SecurityBufferLength = cpu_to_le16(sess_data->iov[1].iov_len); 1043 req->SecurityBufferLength = cpu_to_le16(sess_data->iov[1].iov_len);
1037 1044
1038 /* BB add code to build os and lm fields */ 1045 memset(&rqst, 0, sizeof(struct smb_rqst));
1046 rqst.rq_iov = sess_data->iov;
1047 rqst.rq_nvec = 2;
1039 1048
1040 rc = smb2_send_recv(sess_data->xid, sess_data->ses, 1049 /* BB add code to build os and lm fields */
1041 sess_data->iov, 2, 1050 rc = cifs_send_recv(sess_data->xid, sess_data->ses,
1051 &rqst,
1042 &sess_data->buf0_type, 1052 &sess_data->buf0_type,
1043 CIFS_LOG_ERROR | CIFS_NEG_OP, &rsp_iov); 1053 CIFS_LOG_ERROR | CIFS_NEG_OP, &rsp_iov);
1044 cifs_small_buf_release(sess_data->iov[0].iov_base); 1054 cifs_small_buf_release(sess_data->iov[0].iov_base);
@@ -1376,6 +1386,7 @@ out:
1376int 1386int
1377SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) 1387SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
1378{ 1388{
1389 struct smb_rqst rqst;
1379 struct smb2_logoff_req *req; /* response is also trivial struct */ 1390 struct smb2_logoff_req *req; /* response is also trivial struct */
1380 int rc = 0; 1391 int rc = 0;
1381 struct TCP_Server_Info *server; 1392 struct TCP_Server_Info *server;
@@ -1413,7 +1424,11 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
1413 iov[0].iov_base = (char *)req; 1424 iov[0].iov_base = (char *)req;
1414 iov[0].iov_len = total_len; 1425 iov[0].iov_len = total_len;
1415 1426
1416 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); 1427 memset(&rqst, 0, sizeof(struct smb_rqst));
1428 rqst.rq_iov = iov;
1429 rqst.rq_nvec = 1;
1430
1431 rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
1417 cifs_small_buf_release(req); 1432 cifs_small_buf_release(req);
1418 /* 1433 /*
1419 * No tcon so can't do 1434 * No tcon so can't do
@@ -1443,6 +1458,7 @@ int
1443SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, 1458SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
1444 struct cifs_tcon *tcon, const struct nls_table *cp) 1459 struct cifs_tcon *tcon, const struct nls_table *cp)
1445{ 1460{
1461 struct smb_rqst rqst;
1446 struct smb2_tree_connect_req *req; 1462 struct smb2_tree_connect_req *req;
1447 struct smb2_tree_connect_rsp *rsp = NULL; 1463 struct smb2_tree_connect_rsp *rsp = NULL;
1448 struct kvec iov[2]; 1464 struct kvec iov[2];
@@ -1499,7 +1515,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
1499 !smb3_encryption_required(tcon)) 1515 !smb3_encryption_required(tcon))
1500 req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 1516 req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
1501 1517
1502 rc = smb2_send_recv(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); 1518 memset(&rqst, 0, sizeof(struct smb_rqst));
1519 rqst.rq_iov = iov;
1520 rqst.rq_nvec = 2;
1521
1522 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
1503 cifs_small_buf_release(req); 1523 cifs_small_buf_release(req);
1504 rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; 1524 rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base;
1505 1525
@@ -1563,6 +1583,7 @@ tcon_error_exit:
1563int 1583int
1564SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon) 1584SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
1565{ 1585{
1586 struct smb_rqst rqst;
1566 struct smb2_tree_disconnect_req *req; /* response is trivial */ 1587 struct smb2_tree_disconnect_req *req; /* response is trivial */
1567 int rc = 0; 1588 int rc = 0;
1568 struct cifs_ses *ses = tcon->ses; 1589 struct cifs_ses *ses = tcon->ses;
@@ -1593,7 +1614,11 @@ SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon)
1593 iov[0].iov_base = (char *)req; 1614 iov[0].iov_base = (char *)req;
1594 iov[0].iov_len = total_len; 1615 iov[0].iov_len = total_len;
1595 1616
1596 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); 1617 memset(&rqst, 0, sizeof(struct smb_rqst));
1618 rqst.rq_iov = iov;
1619 rqst.rq_nvec = 1;
1620
1621 rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
1597 cifs_small_buf_release(req); 1622 cifs_small_buf_release(req);
1598 if (rc) 1623 if (rc)
1599 cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE); 1624 cifs_stats_fail_inc(tcon, SMB2_TREE_DISCONNECT_HE);
@@ -1886,11 +1911,165 @@ alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len,
1886 return 0; 1911 return 0;
1887} 1912}
1888 1913
1914#ifdef CONFIG_CIFS_SMB311
1915int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
1916 umode_t mode, struct cifs_tcon *tcon,
1917 const char *full_path,
1918 struct cifs_sb_info *cifs_sb)
1919{
1920 struct smb_rqst rqst;
1921 struct smb2_create_req *req;
1922 struct smb2_create_rsp *rsp;
1923 struct TCP_Server_Info *server;
1924 struct cifs_ses *ses = tcon->ses;
1925 struct kvec iov[3]; /* make sure at least one for each open context */
1926 struct kvec rsp_iov = {NULL, 0};
1927 int resp_buftype;
1928 int uni_path_len;
1929 __le16 *copy_path = NULL;
1930 int copy_size;
1931 int rc = 0;
1932 unsigned int n_iov = 2;
1933 __u32 file_attributes = 0;
1934 char *pc_buf = NULL;
1935 int flags = 0;
1936 unsigned int total_len;
1937 __le16 *path = cifs_convert_path_to_utf16(full_path, cifs_sb);
1938
1939 if (!path)
1940 return -ENOMEM;
1941
1942 cifs_dbg(FYI, "mkdir\n");
1943
1944 if (ses && (ses->server))
1945 server = ses->server;
1946 else
1947 return -EIO;
1948
1949 rc = smb2_plain_req_init(SMB2_CREATE, tcon, (void **) &req, &total_len);
1950
1951 if (rc)
1952 return rc;
1953
1954 if (smb3_encryption_required(tcon))
1955 flags |= CIFS_TRANSFORM_REQ;
1956
1957
1958 req->ImpersonationLevel = IL_IMPERSONATION;
1959 req->DesiredAccess = cpu_to_le32(FILE_WRITE_ATTRIBUTES);
1960 /* File attributes ignored on open (used in create though) */
1961 req->FileAttributes = cpu_to_le32(file_attributes);
1962 req->ShareAccess = FILE_SHARE_ALL_LE;
1963 req->CreateDisposition = cpu_to_le32(FILE_CREATE);
1964 req->CreateOptions = cpu_to_le32(CREATE_NOT_FILE);
1965
1966 iov[0].iov_base = (char *)req;
1967 /* -1 since last byte is buf[0] which is sent below (path) */
1968 iov[0].iov_len = total_len - 1;
1969
1970 req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req));
1971
1972 /* [MS-SMB2] 2.2.13 NameOffset:
1973 * If SMB2_FLAGS_DFS_OPERATIONS is set in the Flags field of
1974 * the SMB2 header, the file name includes a prefix that will
1975 * be processed during DFS name normalization as specified in
1976 * section 3.3.5.9. Otherwise, the file name is relative to
1977 * the share that is identified by the TreeId in the SMB2
1978 * header.
1979 */
1980 if (tcon->share_flags & SHI1005_FLAGS_DFS) {
1981 int name_len;
1982
1983 req->sync_hdr.Flags |= SMB2_FLAGS_DFS_OPERATIONS;
1984 rc = alloc_path_with_tree_prefix(&copy_path, &copy_size,
1985 &name_len,
1986 tcon->treeName, path);
1987 if (rc) {
1988 cifs_small_buf_release(req);
1989 return rc;
1990 }
1991 req->NameLength = cpu_to_le16(name_len * 2);
1992 uni_path_len = copy_size;
1993 path = copy_path;
1994 } else {
1995 uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2;
1996 /* MUST set path len (NameLength) to 0 opening root of share */
1997 req->NameLength = cpu_to_le16(uni_path_len - 2);
1998 if (uni_path_len % 8 != 0) {
1999 copy_size = roundup(uni_path_len, 8);
2000 copy_path = kzalloc(copy_size, GFP_KERNEL);
2001 if (!copy_path) {
2002 cifs_small_buf_release(req);
2003 return -ENOMEM;
2004 }
2005 memcpy((char *)copy_path, (const char *)path,
2006 uni_path_len);
2007 uni_path_len = copy_size;
2008 path = copy_path;
2009 }
2010 }
2011
2012 iov[1].iov_len = uni_path_len;
2013 iov[1].iov_base = path;
2014 req->RequestedOplockLevel = SMB2_OPLOCK_LEVEL_NONE;
2015
2016 if (tcon->posix_extensions) {
2017 if (n_iov > 2) {
2018 struct create_context *ccontext =
2019 (struct create_context *)iov[n_iov-1].iov_base;
2020 ccontext->Next =
2021 cpu_to_le32(iov[n_iov-1].iov_len);
2022 }
2023
2024 rc = add_posix_context(iov, &n_iov, mode);
2025 if (rc) {
2026 cifs_small_buf_release(req);
2027 kfree(copy_path);
2028 return rc;
2029 }
2030 pc_buf = iov[n_iov-1].iov_base;
2031 }
2032
2033
2034 memset(&rqst, 0, sizeof(struct smb_rqst));
2035 rqst.rq_iov = iov;
2036 rqst.rq_nvec = n_iov;
2037
2038 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags,
2039 &rsp_iov);
2040
2041 cifs_small_buf_release(req);
2042 rsp = (struct smb2_create_rsp *)rsp_iov.iov_base;
2043
2044 if (rc != 0) {
2045 cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
2046 trace_smb3_posix_mkdir_err(xid, tcon->tid, ses->Suid,
2047 CREATE_NOT_FILE, FILE_WRITE_ATTRIBUTES, rc);
2048 goto smb311_mkdir_exit;
2049 } else
2050 trace_smb3_posix_mkdir_done(xid, rsp->PersistentFileId, tcon->tid,
2051 ses->Suid, CREATE_NOT_FILE,
2052 FILE_WRITE_ATTRIBUTES);
2053
2054 SMB2_close(xid, tcon, rsp->PersistentFileId, rsp->VolatileFileId);
2055
2056 /* Eventually save off posix specific response info and timestaps */
2057
2058smb311_mkdir_exit:
2059 kfree(copy_path);
2060 kfree(pc_buf);
2061 free_rsp_buf(resp_buftype, rsp);
2062 return rc;
2063
2064}
2065#endif /* SMB311 */
2066
1889int 2067int
1890SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, 2068SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
1891 __u8 *oplock, struct smb2_file_all_info *buf, 2069 __u8 *oplock, struct smb2_file_all_info *buf,
1892 struct kvec *err_iov, int *buftype) 2070 struct kvec *err_iov, int *buftype)
1893{ 2071{
2072 struct smb_rqst rqst;
1894 struct smb2_create_req *req; 2073 struct smb2_create_req *req;
1895 struct smb2_create_rsp *rsp; 2074 struct smb2_create_rsp *rsp;
1896 struct TCP_Server_Info *server; 2075 struct TCP_Server_Info *server;
@@ -2043,7 +2222,11 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
2043 } 2222 }
2044#endif /* SMB311 */ 2223#endif /* SMB311 */
2045 2224
2046 rc = smb2_send_recv(xid, ses, iov, n_iov, &resp_buftype, flags, 2225 memset(&rqst, 0, sizeof(struct smb_rqst));
2226 rqst.rq_iov = iov;
2227 rqst.rq_nvec = n_iov;
2228
2229 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags,
2047 &rsp_iov); 2230 &rsp_iov);
2048 cifs_small_buf_release(req); 2231 cifs_small_buf_release(req);
2049 rsp = (struct smb2_create_rsp *)rsp_iov.iov_base; 2232 rsp = (struct smb2_create_rsp *)rsp_iov.iov_base;
@@ -2099,6 +2282,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
2099 char *in_data, u32 indatalen, 2282 char *in_data, u32 indatalen,
2100 char **out_data, u32 *plen /* returned data len */) 2283 char **out_data, u32 *plen /* returned data len */)
2101{ 2284{
2285 struct smb_rqst rqst;
2102 struct smb2_ioctl_req *req; 2286 struct smb2_ioctl_req *req;
2103 struct smb2_ioctl_rsp *rsp; 2287 struct smb2_ioctl_rsp *rsp;
2104 struct cifs_ses *ses; 2288 struct cifs_ses *ses;
@@ -2189,7 +2373,11 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
2189 if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) 2373 if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO)
2190 req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; 2374 req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
2191 2375
2192 rc = smb2_send_recv(xid, ses, iov, n_iov, &resp_buftype, flags, 2376 memset(&rqst, 0, sizeof(struct smb_rqst));
2377 rqst.rq_iov = iov;
2378 rqst.rq_nvec = n_iov;
2379
2380 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags,
2193 &rsp_iov); 2381 &rsp_iov);
2194 cifs_small_buf_release(req); 2382 cifs_small_buf_release(req);
2195 rsp = (struct smb2_ioctl_rsp *)rsp_iov.iov_base; 2383 rsp = (struct smb2_ioctl_rsp *)rsp_iov.iov_base;
@@ -2274,6 +2462,7 @@ int
2274SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, 2462SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
2275 u64 persistent_fid, u64 volatile_fid, int flags) 2463 u64 persistent_fid, u64 volatile_fid, int flags)
2276{ 2464{
2465 struct smb_rqst rqst;
2277 struct smb2_close_req *req; 2466 struct smb2_close_req *req;
2278 struct smb2_close_rsp *rsp; 2467 struct smb2_close_rsp *rsp;
2279 struct cifs_ses *ses = tcon->ses; 2468 struct cifs_ses *ses = tcon->ses;
@@ -2301,7 +2490,11 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
2301 iov[0].iov_base = (char *)req; 2490 iov[0].iov_base = (char *)req;
2302 iov[0].iov_len = total_len; 2491 iov[0].iov_len = total_len;
2303 2492
2304 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); 2493 memset(&rqst, 0, sizeof(struct smb_rqst));
2494 rqst.rq_iov = iov;
2495 rqst.rq_nvec = 1;
2496
2497 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
2305 cifs_small_buf_release(req); 2498 cifs_small_buf_release(req);
2306 rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; 2499 rsp = (struct smb2_close_rsp *)rsp_iov.iov_base;
2307 2500
@@ -2387,6 +2580,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
2387 u32 additional_info, size_t output_len, size_t min_len, void **data, 2580 u32 additional_info, size_t output_len, size_t min_len, void **data,
2388 u32 *dlen) 2581 u32 *dlen)
2389{ 2582{
2583 struct smb_rqst rqst;
2390 struct smb2_query_info_req *req; 2584 struct smb2_query_info_req *req;
2391 struct smb2_query_info_rsp *rsp = NULL; 2585 struct smb2_query_info_rsp *rsp = NULL;
2392 struct kvec iov[2]; 2586 struct kvec iov[2];
@@ -2427,7 +2621,11 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
2427 /* 1 for Buffer */ 2621 /* 1 for Buffer */
2428 iov[0].iov_len = total_len - 1; 2622 iov[0].iov_len = total_len - 1;
2429 2623
2430 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); 2624 memset(&rqst, 0, sizeof(struct smb_rqst));
2625 rqst.rq_iov = iov;
2626 rqst.rq_nvec = 1;
2627
2628 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
2431 cifs_small_buf_release(req); 2629 cifs_small_buf_release(req);
2432 rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; 2630 rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;
2433 2631
@@ -2594,11 +2792,10 @@ SMB2_echo(struct TCP_Server_Info *server)
2594{ 2792{
2595 struct smb2_echo_req *req; 2793 struct smb2_echo_req *req;
2596 int rc = 0; 2794 int rc = 0;
2597 struct kvec iov[2]; 2795 struct kvec iov[1];
2598 struct smb_rqst rqst = { .rq_iov = iov, 2796 struct smb_rqst rqst = { .rq_iov = iov,
2599 .rq_nvec = 2 }; 2797 .rq_nvec = 1 };
2600 unsigned int total_len; 2798 unsigned int total_len;
2601 __be32 rfc1002_marker;
2602 2799
2603 cifs_dbg(FYI, "In echo request\n"); 2800 cifs_dbg(FYI, "In echo request\n");
2604 2801
@@ -2614,11 +2811,8 @@ SMB2_echo(struct TCP_Server_Info *server)
2614 2811
2615 req->sync_hdr.CreditRequest = cpu_to_le16(1); 2812 req->sync_hdr.CreditRequest = cpu_to_le16(1);
2616 2813
2617 iov[0].iov_len = 4; 2814 iov[0].iov_len = total_len;
2618 rfc1002_marker = cpu_to_be32(total_len); 2815 iov[0].iov_base = (char *)req;
2619 iov[0].iov_base = &rfc1002_marker;
2620 iov[1].iov_len = total_len;
2621 iov[1].iov_base = (char *)req;
2622 2816
2623 rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, NULL, 2817 rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, NULL,
2624 server, CIFS_ECHO_OP); 2818 server, CIFS_ECHO_OP);
@@ -2633,6 +2827,7 @@ int
2633SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, 2827SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
2634 u64 volatile_fid) 2828 u64 volatile_fid)
2635{ 2829{
2830 struct smb_rqst rqst;
2636 struct smb2_flush_req *req; 2831 struct smb2_flush_req *req;
2637 struct cifs_ses *ses = tcon->ses; 2832 struct cifs_ses *ses = tcon->ses;
2638 struct kvec iov[1]; 2833 struct kvec iov[1];
@@ -2660,7 +2855,11 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
2660 iov[0].iov_base = (char *)req; 2855 iov[0].iov_base = (char *)req;
2661 iov[0].iov_len = total_len; 2856 iov[0].iov_len = total_len;
2662 2857
2663 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); 2858 memset(&rqst, 0, sizeof(struct smb_rqst));
2859 rqst.rq_iov = iov;
2860 rqst.rq_nvec = 1;
2861
2862 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
2664 cifs_small_buf_release(req); 2863 cifs_small_buf_release(req);
2665 2864
2666 if (rc != 0) { 2865 if (rc != 0) {
@@ -2848,10 +3047,9 @@ smb2_async_readv(struct cifs_readdata *rdata)
2848 struct smb2_sync_hdr *shdr; 3047 struct smb2_sync_hdr *shdr;
2849 struct cifs_io_parms io_parms; 3048 struct cifs_io_parms io_parms;
2850 struct smb_rqst rqst = { .rq_iov = rdata->iov, 3049 struct smb_rqst rqst = { .rq_iov = rdata->iov,
2851 .rq_nvec = 2 }; 3050 .rq_nvec = 1 };
2852 struct TCP_Server_Info *server; 3051 struct TCP_Server_Info *server;
2853 unsigned int total_len; 3052 unsigned int total_len;
2854 __be32 req_len;
2855 3053
2856 cifs_dbg(FYI, "%s: offset=%llu bytes=%u\n", 3054 cifs_dbg(FYI, "%s: offset=%llu bytes=%u\n",
2857 __func__, rdata->offset, rdata->bytes); 3055 __func__, rdata->offset, rdata->bytes);
@@ -2882,12 +3080,8 @@ smb2_async_readv(struct cifs_readdata *rdata)
2882 if (smb3_encryption_required(io_parms.tcon)) 3080 if (smb3_encryption_required(io_parms.tcon))
2883 flags |= CIFS_TRANSFORM_REQ; 3081 flags |= CIFS_TRANSFORM_REQ;
2884 3082
2885 req_len = cpu_to_be32(total_len); 3083 rdata->iov[0].iov_base = buf;
2886 3084 rdata->iov[0].iov_len = total_len;
2887 rdata->iov[0].iov_base = &req_len;
2888 rdata->iov[0].iov_len = sizeof(__be32);
2889 rdata->iov[1].iov_base = buf;
2890 rdata->iov[1].iov_len = total_len;
2891 3085
2892 shdr = (struct smb2_sync_hdr *)buf; 3086 shdr = (struct smb2_sync_hdr *)buf;
2893 3087
@@ -2926,6 +3120,7 @@ int
2926SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, 3120SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
2927 unsigned int *nbytes, char **buf, int *buf_type) 3121 unsigned int *nbytes, char **buf, int *buf_type)
2928{ 3122{
3123 struct smb_rqst rqst;
2929 int resp_buftype, rc = -EACCES; 3124 int resp_buftype, rc = -EACCES;
2930 struct smb2_read_plain_req *req = NULL; 3125 struct smb2_read_plain_req *req = NULL;
2931 struct smb2_read_rsp *rsp = NULL; 3126 struct smb2_read_rsp *rsp = NULL;
@@ -2946,7 +3141,11 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
2946 iov[0].iov_base = (char *)req; 3141 iov[0].iov_base = (char *)req;
2947 iov[0].iov_len = total_len; 3142 iov[0].iov_len = total_len;
2948 3143
2949 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov); 3144 memset(&rqst, 0, sizeof(struct smb_rqst));
3145 rqst.rq_iov = iov;
3146 rqst.rq_nvec = 1;
3147
3148 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
2950 cifs_small_buf_release(req); 3149 cifs_small_buf_release(req);
2951 3150
2952 rsp = (struct smb2_read_rsp *)rsp_iov.iov_base; 3151 rsp = (struct smb2_read_rsp *)rsp_iov.iov_base;
@@ -3062,10 +3261,9 @@ smb2_async_writev(struct cifs_writedata *wdata,
3062 struct smb2_sync_hdr *shdr; 3261 struct smb2_sync_hdr *shdr;
3063 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 3262 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
3064 struct TCP_Server_Info *server = tcon->ses->server; 3263 struct TCP_Server_Info *server = tcon->ses->server;
3065 struct kvec iov[2]; 3264 struct kvec iov[1];
3066 struct smb_rqst rqst = { }; 3265 struct smb_rqst rqst = { };
3067 unsigned int total_len; 3266 unsigned int total_len;
3068 __be32 rfc1002_marker;
3069 3267
3070 rc = smb2_plain_req_init(SMB2_WRITE, tcon, (void **) &req, &total_len); 3268 rc = smb2_plain_req_init(SMB2_WRITE, tcon, (void **) &req, &total_len);
3071 if (rc) { 3269 if (rc) {
@@ -3137,15 +3335,11 @@ smb2_async_writev(struct cifs_writedata *wdata,
3137 v1->length = cpu_to_le32(wdata->mr->mr->length); 3335 v1->length = cpu_to_le32(wdata->mr->mr->length);
3138 } 3336 }
3139#endif 3337#endif
3140 /* 4 for rfc1002 length field and 1 for Buffer */ 3338 iov[0].iov_len = total_len - 1;
3141 iov[0].iov_len = 4; 3339 iov[0].iov_base = (char *)req;
3142 rfc1002_marker = cpu_to_be32(total_len - 1 + wdata->bytes);
3143 iov[0].iov_base = &rfc1002_marker;
3144 iov[1].iov_len = total_len - 1;
3145 iov[1].iov_base = (char *)req;
3146 3340
3147 rqst.rq_iov = iov; 3341 rqst.rq_iov = iov;
3148 rqst.rq_nvec = 2; 3342 rqst.rq_nvec = 1;
3149 rqst.rq_pages = wdata->pages; 3343 rqst.rq_pages = wdata->pages;
3150 rqst.rq_offset = wdata->page_offset; 3344 rqst.rq_offset = wdata->page_offset;
3151 rqst.rq_npages = wdata->nr_pages; 3345 rqst.rq_npages = wdata->nr_pages;
@@ -3153,7 +3347,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
3153 rqst.rq_tailsz = wdata->tailsz; 3347 rqst.rq_tailsz = wdata->tailsz;
3154#ifdef CONFIG_CIFS_SMB_DIRECT 3348#ifdef CONFIG_CIFS_SMB_DIRECT
3155 if (wdata->mr) { 3349 if (wdata->mr) {
3156 iov[1].iov_len += sizeof(struct smbd_buffer_descriptor_v1); 3350 iov[0].iov_len += sizeof(struct smbd_buffer_descriptor_v1);
3157 rqst.rq_npages = 0; 3351 rqst.rq_npages = 0;
3158 } 3352 }
3159#endif 3353#endif
@@ -3210,6 +3404,7 @@ int
3210SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, 3404SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
3211 unsigned int *nbytes, struct kvec *iov, int n_vec) 3405 unsigned int *nbytes, struct kvec *iov, int n_vec)
3212{ 3406{
3407 struct smb_rqst rqst;
3213 int rc = 0; 3408 int rc = 0;
3214 struct smb2_write_req *req = NULL; 3409 struct smb2_write_req *req = NULL;
3215 struct smb2_write_rsp *rsp = NULL; 3410 struct smb2_write_rsp *rsp = NULL;
@@ -3251,7 +3446,11 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
3251 /* 1 for Buffer */ 3446 /* 1 for Buffer */
3252 iov[0].iov_len = total_len - 1; 3447 iov[0].iov_len = total_len - 1;
3253 3448
3254 rc = smb2_send_recv(xid, io_parms->tcon->ses, iov, n_vec + 1, 3449 memset(&rqst, 0, sizeof(struct smb_rqst));
3450 rqst.rq_iov = iov;
3451 rqst.rq_nvec = n_vec + 1;
3452
3453 rc = cifs_send_recv(xid, io_parms->tcon->ses, &rqst,
3255 &resp_buftype, flags, &rsp_iov); 3454 &resp_buftype, flags, &rsp_iov);
3256 cifs_small_buf_release(req); 3455 cifs_small_buf_release(req);
3257 rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; 3456 rsp = (struct smb2_write_rsp *)rsp_iov.iov_base;
@@ -3323,6 +3522,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
3323 u64 persistent_fid, u64 volatile_fid, int index, 3522 u64 persistent_fid, u64 volatile_fid, int index,
3324 struct cifs_search_info *srch_inf) 3523 struct cifs_search_info *srch_inf)
3325{ 3524{
3525 struct smb_rqst rqst;
3326 struct smb2_query_directory_req *req; 3526 struct smb2_query_directory_req *req;
3327 struct smb2_query_directory_rsp *rsp = NULL; 3527 struct smb2_query_directory_rsp *rsp = NULL;
3328 struct kvec iov[2]; 3528 struct kvec iov[2];
@@ -3395,7 +3595,11 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
3395 iov[1].iov_base = (char *)(req->Buffer); 3595 iov[1].iov_base = (char *)(req->Buffer);
3396 iov[1].iov_len = len; 3596 iov[1].iov_len = len;
3397 3597
3398 rc = smb2_send_recv(xid, ses, iov, 2, &resp_buftype, flags, &rsp_iov); 3598 memset(&rqst, 0, sizeof(struct smb_rqst));
3599 rqst.rq_iov = iov;
3600 rqst.rq_nvec = 2;
3601
3602 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
3399 cifs_small_buf_release(req); 3603 cifs_small_buf_release(req);
3400 rsp = (struct smb2_query_directory_rsp *)rsp_iov.iov_base; 3604 rsp = (struct smb2_query_directory_rsp *)rsp_iov.iov_base;
3401 3605
@@ -3454,6 +3658,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
3454 u8 info_type, u32 additional_info, unsigned int num, 3658 u8 info_type, u32 additional_info, unsigned int num,
3455 void **data, unsigned int *size) 3659 void **data, unsigned int *size)
3456{ 3660{
3661 struct smb_rqst rqst;
3457 struct smb2_set_info_req *req; 3662 struct smb2_set_info_req *req;
3458 struct smb2_set_info_rsp *rsp = NULL; 3663 struct smb2_set_info_rsp *rsp = NULL;
3459 struct kvec *iov; 3664 struct kvec *iov;
@@ -3509,7 +3714,11 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
3509 iov[i].iov_len = size[i]; 3714 iov[i].iov_len = size[i];
3510 } 3715 }
3511 3716
3512 rc = smb2_send_recv(xid, ses, iov, num, &resp_buftype, flags, 3717 memset(&rqst, 0, sizeof(struct smb_rqst));
3718 rqst.rq_iov = iov;
3719 rqst.rq_nvec = num;
3720
3721 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags,
3513 &rsp_iov); 3722 &rsp_iov);
3514 cifs_small_buf_release(req); 3723 cifs_small_buf_release(req);
3515 rsp = (struct smb2_set_info_rsp *)rsp_iov.iov_base; 3724 rsp = (struct smb2_set_info_rsp *)rsp_iov.iov_base;
@@ -3664,6 +3873,7 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
3664 const u64 persistent_fid, const u64 volatile_fid, 3873 const u64 persistent_fid, const u64 volatile_fid,
3665 __u8 oplock_level) 3874 __u8 oplock_level)
3666{ 3875{
3876 struct smb_rqst rqst;
3667 int rc; 3877 int rc;
3668 struct smb2_oplock_break *req = NULL; 3878 struct smb2_oplock_break *req = NULL;
3669 struct cifs_ses *ses = tcon->ses; 3879 struct cifs_ses *ses = tcon->ses;
@@ -3692,7 +3902,11 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
3692 iov[0].iov_base = (char *)req; 3902 iov[0].iov_base = (char *)req;
3693 iov[0].iov_len = total_len; 3903 iov[0].iov_len = total_len;
3694 3904
3695 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); 3905 memset(&rqst, 0, sizeof(struct smb_rqst));
3906 rqst.rq_iov = iov;
3907 rqst.rq_nvec = 1;
3908
3909 rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
3696 cifs_small_buf_release(req); 3910 cifs_small_buf_release(req);
3697 3911
3698 if (rc) { 3912 if (rc) {
@@ -3755,6 +3969,7 @@ int
3755SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, 3969SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
3756 u64 persistent_fid, u64 volatile_fid, struct kstatfs *fsdata) 3970 u64 persistent_fid, u64 volatile_fid, struct kstatfs *fsdata)
3757{ 3971{
3972 struct smb_rqst rqst;
3758 struct smb2_query_info_rsp *rsp = NULL; 3973 struct smb2_query_info_rsp *rsp = NULL;
3759 struct kvec iov; 3974 struct kvec iov;
3760 struct kvec rsp_iov; 3975 struct kvec rsp_iov;
@@ -3773,7 +3988,11 @@ SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
3773 if (smb3_encryption_required(tcon)) 3988 if (smb3_encryption_required(tcon))
3774 flags |= CIFS_TRANSFORM_REQ; 3989 flags |= CIFS_TRANSFORM_REQ;
3775 3990
3776 rc = smb2_send_recv(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); 3991 memset(&rqst, 0, sizeof(struct smb_rqst));
3992 rqst.rq_iov = &iov;
3993 rqst.rq_nvec = 1;
3994
3995 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
3777 cifs_small_buf_release(iov.iov_base); 3996 cifs_small_buf_release(iov.iov_base);
3778 if (rc) { 3997 if (rc) {
3779 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); 3998 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
@@ -3798,6 +4017,7 @@ int
3798SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, 4017SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
3799 u64 persistent_fid, u64 volatile_fid, int level) 4018 u64 persistent_fid, u64 volatile_fid, int level)
3800{ 4019{
4020 struct smb_rqst rqst;
3801 struct smb2_query_info_rsp *rsp = NULL; 4021 struct smb2_query_info_rsp *rsp = NULL;
3802 struct kvec iov; 4022 struct kvec iov;
3803 struct kvec rsp_iov; 4023 struct kvec rsp_iov;
@@ -3829,7 +4049,11 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
3829 if (smb3_encryption_required(tcon)) 4049 if (smb3_encryption_required(tcon))
3830 flags |= CIFS_TRANSFORM_REQ; 4050 flags |= CIFS_TRANSFORM_REQ;
3831 4051
3832 rc = smb2_send_recv(xid, ses, &iov, 1, &resp_buftype, flags, &rsp_iov); 4052 memset(&rqst, 0, sizeof(struct smb_rqst));
4053 rqst.rq_iov = &iov;
4054 rqst.rq_nvec = 1;
4055
4056 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
3833 cifs_small_buf_release(iov.iov_base); 4057 cifs_small_buf_release(iov.iov_base);
3834 if (rc) { 4058 if (rc) {
3835 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE); 4059 cifs_stats_fail_inc(tcon, SMB2_QUERY_INFO_HE);
@@ -3868,6 +4092,7 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
3868 const __u64 persist_fid, const __u64 volatile_fid, const __u32 pid, 4092 const __u64 persist_fid, const __u64 volatile_fid, const __u32 pid,
3869 const __u32 num_lock, struct smb2_lock_element *buf) 4093 const __u32 num_lock, struct smb2_lock_element *buf)
3870{ 4094{
4095 struct smb_rqst rqst;
3871 int rc = 0; 4096 int rc = 0;
3872 struct smb2_lock_req *req = NULL; 4097 struct smb2_lock_req *req = NULL;
3873 struct kvec iov[2]; 4098 struct kvec iov[2];
@@ -3900,7 +4125,12 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
3900 iov[1].iov_len = count; 4125 iov[1].iov_len = count;
3901 4126
3902 cifs_stats_inc(&tcon->stats.cifs_stats.num_locks); 4127 cifs_stats_inc(&tcon->stats.cifs_stats.num_locks);
3903 rc = smb2_send_recv(xid, tcon->ses, iov, 2, &resp_buf_type, flags, 4128
4129 memset(&rqst, 0, sizeof(struct smb_rqst));
4130 rqst.rq_iov = iov;
4131 rqst.rq_nvec = 2;
4132
4133 rc = cifs_send_recv(xid, tcon->ses, &rqst, &resp_buf_type, flags,
3904 &rsp_iov); 4134 &rsp_iov);
3905 cifs_small_buf_release(req); 4135 cifs_small_buf_release(req);
3906 if (rc) { 4136 if (rc) {
@@ -3934,6 +4164,7 @@ int
3934SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon, 4164SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
3935 __u8 *lease_key, const __le32 lease_state) 4165 __u8 *lease_key, const __le32 lease_state)
3936{ 4166{
4167 struct smb_rqst rqst;
3937 int rc; 4168 int rc;
3938 struct smb2_lease_ack *req = NULL; 4169 struct smb2_lease_ack *req = NULL;
3939 struct cifs_ses *ses = tcon->ses; 4170 struct cifs_ses *ses = tcon->ses;
@@ -3964,7 +4195,11 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
3964 iov[0].iov_base = (char *)req; 4195 iov[0].iov_base = (char *)req;
3965 iov[0].iov_len = total_len; 4196 iov[0].iov_len = total_len;
3966 4197
3967 rc = smb2_send_recv(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); 4198 memset(&rqst, 0, sizeof(struct smb_rqst));
4199 rqst.rq_iov = iov;
4200 rqst.rq_nvec = 1;
4201
4202 rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
3968 cifs_small_buf_release(req); 4203 cifs_small_buf_release(req);
3969 4204
3970 if (rc) { 4205 if (rc) {
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index a345560001ce..824dddeee3f2 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -851,8 +851,11 @@ struct validate_negotiate_info_rsp {
851 __le16 Dialect; /* Dialect in use for the connection */ 851 __le16 Dialect; /* Dialect in use for the connection */
852} __packed; 852} __packed;
853 853
854#define RSS_CAPABLE 0x00000001 854#define RSS_CAPABLE cpu_to_le32(0x00000001)
855#define RDMA_CAPABLE 0x00000002 855#define RDMA_CAPABLE cpu_to_le32(0x00000002)
856
857#define INTERNETWORK cpu_to_le16(0x0002)
858#define INTERNETWORKV6 cpu_to_le16(0x0017)
856 859
857struct network_interface_info_ioctl_rsp { 860struct network_interface_info_ioctl_rsp {
858 __le32 Next; /* next interface. zero if this is last one */ 861 __le32 Next; /* next interface. zero if this is last one */
@@ -860,7 +863,21 @@ struct network_interface_info_ioctl_rsp {
860 __le32 Capability; /* RSS or RDMA Capable */ 863 __le32 Capability; /* RSS or RDMA Capable */
861 __le32 Reserved; 864 __le32 Reserved;
862 __le64 LinkSpeed; 865 __le64 LinkSpeed;
863 char SockAddr_Storage[128]; 866 __le16 Family;
867 __u8 Buffer[126];
868} __packed;
869
870struct iface_info_ipv4 {
871 __be16 Port;
872 __be32 IPv4Address;
873 __be64 Reserved;
874} __packed;
875
876struct iface_info_ipv6 {
877 __be16 Port;
878 __be32 FlowInfo;
879 __u8 IPv6Address[16];
880 __be32 ScopeId;
864} __packed; 881} __packed;
865 882
866#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ 883#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index c84020057bd8..3ae208ac2a77 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -79,6 +79,10 @@ extern int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
79 struct cifs_sb_info *cifs_sb, bool set_alloc); 79 struct cifs_sb_info *cifs_sb, bool set_alloc);
80extern int smb2_set_file_info(struct inode *inode, const char *full_path, 80extern int smb2_set_file_info(struct inode *inode, const char *full_path,
81 FILE_BASIC_INFO *buf, const unsigned int xid); 81 FILE_BASIC_INFO *buf, const unsigned int xid);
82extern int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
83 umode_t mode, struct cifs_tcon *tcon,
84 const char *full_path,
85 struct cifs_sb_info *cifs_sb);
82extern int smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon, 86extern int smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon,
83 const char *name, struct cifs_sb_info *cifs_sb); 87 const char *name, struct cifs_sb_info *cifs_sb);
84extern void smb2_mkdir_setinfo(struct inode *inode, const char *full_path, 88extern void smb2_mkdir_setinfo(struct inode *inode, const char *full_path,
@@ -109,6 +113,8 @@ extern int smb2_unlock_range(struct cifsFileInfo *cfile,
109extern int smb2_push_mandatory_locks(struct cifsFileInfo *cfile); 113extern int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
110extern void smb2_reconnect_server(struct work_struct *work); 114extern void smb2_reconnect_server(struct work_struct *work);
111extern int smb3_crypto_aead_allocate(struct TCP_Server_Info *server); 115extern int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
116extern unsigned long
117smb2_rqst_len(struct smb_rqst *rqst, bool skip_rfc1002_marker);
112 118
113/* 119/*
114 * SMB2 Worker functions - most of protocol specific implementation details 120 * SMB2 Worker functions - most of protocol specific implementation details
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 349d5ccf854c..51b9437c3c7b 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -171,9 +171,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
171 unsigned char smb2_signature[SMB2_HMACSHA256_SIZE]; 171 unsigned char smb2_signature[SMB2_HMACSHA256_SIZE];
172 unsigned char *sigptr = smb2_signature; 172 unsigned char *sigptr = smb2_signature;
173 struct kvec *iov = rqst->rq_iov; 173 struct kvec *iov = rqst->rq_iov;
174 int iov_hdr_index = rqst->rq_nvec > 1 ? 1 : 0; 174 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
175 struct smb2_sync_hdr *shdr =
176 (struct smb2_sync_hdr *)iov[iov_hdr_index].iov_base;
177 struct cifs_ses *ses; 175 struct cifs_ses *ses;
178 176
179 ses = smb2_find_smb_ses(server, shdr->SessionId); 177 ses = smb2_find_smb_ses(server, shdr->SessionId);
@@ -204,7 +202,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
204 return rc; 202 return rc;
205 } 203 }
206 204
207 rc = __cifs_calc_signature(rqst, iov_hdr_index, server, sigptr, 205 rc = __cifs_calc_signature(rqst, server, sigptr,
208 &server->secmech.sdeschmacsha256->shash); 206 &server->secmech.sdeschmacsha256->shash);
209 207
210 if (!rc) 208 if (!rc)
@@ -414,9 +412,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
414 unsigned char smb3_signature[SMB2_CMACAES_SIZE]; 412 unsigned char smb3_signature[SMB2_CMACAES_SIZE];
415 unsigned char *sigptr = smb3_signature; 413 unsigned char *sigptr = smb3_signature;
416 struct kvec *iov = rqst->rq_iov; 414 struct kvec *iov = rqst->rq_iov;
417 int iov_hdr_index = rqst->rq_nvec > 1 ? 1 : 0; 415 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
418 struct smb2_sync_hdr *shdr =
419 (struct smb2_sync_hdr *)iov[iov_hdr_index].iov_base;
420 struct cifs_ses *ses; 416 struct cifs_ses *ses;
421 417
422 ses = smb2_find_smb_ses(server, shdr->SessionId); 418 ses = smb2_find_smb_ses(server, shdr->SessionId);
@@ -447,7 +443,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
447 return rc; 443 return rc;
448 } 444 }
449 445
450 rc = __cifs_calc_signature(rqst, iov_hdr_index, server, sigptr, 446 rc = __cifs_calc_signature(rqst, server, sigptr,
451 &server->secmech.sdesccmacaes->shash); 447 &server->secmech.sdesccmacaes->shash);
452 448
453 if (!rc) 449 if (!rc)
@@ -462,7 +458,7 @@ smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
462{ 458{
463 int rc = 0; 459 int rc = 0;
464 struct smb2_sync_hdr *shdr = 460 struct smb2_sync_hdr *shdr =
465 (struct smb2_sync_hdr *)rqst->rq_iov[1].iov_base; 461 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
466 462
467 if (!(shdr->Flags & SMB2_FLAGS_SIGNED) || 463 if (!(shdr->Flags & SMB2_FLAGS_SIGNED) ||
468 server->tcpStatus == CifsNeedNegotiate) 464 server->tcpStatus == CifsNeedNegotiate)
@@ -635,7 +631,7 @@ smb2_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
635{ 631{
636 int rc; 632 int rc;
637 struct smb2_sync_hdr *shdr = 633 struct smb2_sync_hdr *shdr =
638 (struct smb2_sync_hdr *)rqst->rq_iov[1].iov_base; 634 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
639 struct mid_q_entry *mid; 635 struct mid_q_entry *mid;
640 636
641 smb2_seq_num_into_buf(ses->server, shdr); 637 smb2_seq_num_into_buf(ses->server, shdr);
@@ -656,7 +652,7 @@ smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
656{ 652{
657 int rc; 653 int rc;
658 struct smb2_sync_hdr *shdr = 654 struct smb2_sync_hdr *shdr =
659 (struct smb2_sync_hdr *)rqst->rq_iov[1].iov_base; 655 (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base;
660 struct mid_q_entry *mid; 656 struct mid_q_entry *mid;
661 657
662 smb2_seq_num_into_buf(server, shdr); 658 smb2_seq_num_into_buf(server, shdr);
diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c
index e459c97151b3..6fd94d9ffac2 100644
--- a/fs/cifs/smbdirect.c
+++ b/fs/cifs/smbdirect.c
@@ -18,6 +18,7 @@
18#include "smbdirect.h" 18#include "smbdirect.h"
19#include "cifs_debug.h" 19#include "cifs_debug.h"
20#include "cifsproto.h" 20#include "cifsproto.h"
21#include "smb2proto.h"
21 22
22static struct smbd_response *get_empty_queue_buffer( 23static struct smbd_response *get_empty_queue_buffer(
23 struct smbd_connection *info); 24 struct smbd_connection *info);
@@ -2087,7 +2088,7 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2087 struct kvec vec; 2088 struct kvec vec;
2088 int nvecs; 2089 int nvecs;
2089 int size; 2090 int size;
2090 unsigned int buflen = 0, remaining_data_length; 2091 unsigned int buflen, remaining_data_length;
2091 int start, i, j; 2092 int start, i, j;
2092 int max_iov_size = 2093 int max_iov_size =
2093 info->max_send_size - sizeof(struct smbd_data_transfer); 2094 info->max_send_size - sizeof(struct smbd_data_transfer);
@@ -2111,25 +2112,13 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2111 log_write(ERR, "expected the pdu length in 1st iov, but got %zu\n", rqst->rq_iov[0].iov_len); 2112 log_write(ERR, "expected the pdu length in 1st iov, but got %zu\n", rqst->rq_iov[0].iov_len);
2112 return -EINVAL; 2113 return -EINVAL;
2113 } 2114 }
2114 iov = &rqst->rq_iov[1];
2115
2116 /* total up iov array first */
2117 for (i = 0; i < rqst->rq_nvec-1; i++) {
2118 buflen += iov[i].iov_len;
2119 }
2120 2115
2121 /* 2116 /*
2122 * Add in the page array if there is one. The caller needs to set 2117 * Add in the page array if there is one. The caller needs to set
2123 * rq_tailsz to PAGE_SIZE when the buffer has multiple pages and 2118 * rq_tailsz to PAGE_SIZE when the buffer has multiple pages and
2124 * ends at page boundary 2119 * ends at page boundary
2125 */ 2120 */
2126 if (rqst->rq_npages) { 2121 buflen = smb2_rqst_len(rqst, true);
2127 if (rqst->rq_npages == 1)
2128 buflen += rqst->rq_tailsz;
2129 else
2130 buflen += rqst->rq_pagesz * (rqst->rq_npages - 1) -
2131 rqst->rq_offset + rqst->rq_tailsz;
2132 }
2133 2122
2134 if (buflen + sizeof(struct smbd_data_transfer) > 2123 if (buflen + sizeof(struct smbd_data_transfer) >
2135 info->max_fragmented_send_size) { 2124 info->max_fragmented_send_size) {
@@ -2139,6 +2128,8 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst)
2139 goto done; 2128 goto done;
2140 } 2129 }
2141 2130
2131 iov = &rqst->rq_iov[1];
2132
2142 cifs_dbg(FYI, "Sending smb (RDMA): smb_len=%u\n", buflen); 2133 cifs_dbg(FYI, "Sending smb (RDMA): smb_len=%u\n", buflen);
2143 for (i = 0; i < rqst->rq_nvec-1; i++) 2134 for (i = 0; i < rqst->rq_nvec-1; i++)
2144 dump_smb(iov[i].iov_base, iov[i].iov_len); 2135 dump_smb(iov[i].iov_base, iov[i].iov_len);
diff --git a/fs/cifs/trace.h b/fs/cifs/trace.h
index 61e74d455d90..67e413f6ee4d 100644
--- a/fs/cifs/trace.h
+++ b/fs/cifs/trace.h
@@ -378,7 +378,7 @@ DEFINE_EVENT(smb3_open_err_class, smb3_##name, \
378 TP_ARGS(xid, tid, sesid, create_options, desired_access, rc)) 378 TP_ARGS(xid, tid, sesid, create_options, desired_access, rc))
379 379
380DEFINE_SMB3_OPEN_ERR_EVENT(open_err); 380DEFINE_SMB3_OPEN_ERR_EVENT(open_err);
381 381DEFINE_SMB3_OPEN_ERR_EVENT(posix_mkdir_err);
382 382
383DECLARE_EVENT_CLASS(smb3_open_done_class, 383DECLARE_EVENT_CLASS(smb3_open_done_class,
384 TP_PROTO(unsigned int xid, 384 TP_PROTO(unsigned int xid,
@@ -420,6 +420,7 @@ DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
420 TP_ARGS(xid, fid, tid, sesid, create_options, desired_access)) 420 TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
421 421
422DEFINE_SMB3_OPEN_DONE_EVENT(open_done); 422DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
423DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
423 424
424#endif /* _CIFS_TRACE_H */ 425#endif /* _CIFS_TRACE_H */
425 426
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 1f1a68f89110..fb57dfbfb749 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -201,15 +201,24 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
201 return 0; 201 return 0;
202} 202}
203 203
204static unsigned long 204unsigned long
205rqst_len(struct smb_rqst *rqst) 205smb2_rqst_len(struct smb_rqst *rqst, bool skip_rfc1002_marker)
206{ 206{
207 unsigned int i; 207 unsigned int i;
208 struct kvec *iov = rqst->rq_iov; 208 struct kvec *iov;
209 int nvec;
209 unsigned long buflen = 0; 210 unsigned long buflen = 0;
210 211
212 if (skip_rfc1002_marker && rqst->rq_iov[0].iov_len == 4) {
213 iov = &rqst->rq_iov[1];
214 nvec = rqst->rq_nvec - 1;
215 } else {
216 iov = rqst->rq_iov;
217 nvec = rqst->rq_nvec;
218 }
219
211 /* total up iov array first */ 220 /* total up iov array first */
212 for (i = 0; i < rqst->rq_nvec; i++) 221 for (i = 0; i < nvec; i++)
213 buflen += iov[i].iov_len; 222 buflen += iov[i].iov_len;
214 223
215 /* 224 /*
@@ -236,18 +245,20 @@ rqst_len(struct smb_rqst *rqst)
236} 245}
237 246
238static int 247static int
239__smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) 248__smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
249 struct smb_rqst *rqst)
240{ 250{
241 int rc; 251 int rc = 0;
242 struct kvec *iov = rqst->rq_iov; 252 struct kvec *iov;
243 int n_vec = rqst->rq_nvec; 253 int n_vec;
244 unsigned int smb_buf_length = get_rfc1002_length(iov[0].iov_base); 254 unsigned int send_length = 0;
245 unsigned long send_length; 255 unsigned int i, j;
246 unsigned int i;
247 size_t total_len = 0, sent, size; 256 size_t total_len = 0, sent, size;
248 struct socket *ssocket = server->ssocket; 257 struct socket *ssocket = server->ssocket;
249 struct msghdr smb_msg; 258 struct msghdr smb_msg;
250 int val = 1; 259 int val = 1;
260 __be32 rfc1002_marker;
261
251 if (cifs_rdma_enabled(server) && server->smbd_conn) { 262 if (cifs_rdma_enabled(server) && server->smbd_conn) {
252 rc = smbd_send(server->smbd_conn, rqst); 263 rc = smbd_send(server->smbd_conn, rqst);
253 goto smbd_done; 264 goto smbd_done;
@@ -255,51 +266,67 @@ __smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
255 if (ssocket == NULL) 266 if (ssocket == NULL)
256 return -ENOTSOCK; 267 return -ENOTSOCK;
257 268
258 /* sanity check send length */
259 send_length = rqst_len(rqst);
260 if (send_length != smb_buf_length + 4) {
261 WARN(1, "Send length mismatch(send_length=%lu smb_buf_length=%u)\n",
262 send_length, smb_buf_length);
263 return -EIO;
264 }
265
266 if (n_vec < 2)
267 return -EIO;
268
269 cifs_dbg(FYI, "Sending smb: smb_len=%u\n", smb_buf_length);
270 dump_smb(iov[0].iov_base, iov[0].iov_len);
271 dump_smb(iov[1].iov_base, iov[1].iov_len);
272
273 /* cork the socket */ 269 /* cork the socket */
274 kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK, 270 kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
275 (char *)&val, sizeof(val)); 271 (char *)&val, sizeof(val));
276 272
277 size = 0; 273 for (j = 0; j < num_rqst; j++)
278 for (i = 0; i < n_vec; i++) 274 send_length += smb2_rqst_len(&rqst[j], true);
279 size += iov[i].iov_len; 275 rfc1002_marker = cpu_to_be32(send_length);
280 276
281 iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC, iov, n_vec, size); 277 /* Generate a rfc1002 marker for SMB2+ */
278 if (server->vals->header_preamble_size == 0) {
279 struct kvec hiov = {
280 .iov_base = &rfc1002_marker,
281 .iov_len = 4
282 };
283 iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC, &hiov,
284 1, 4);
285 rc = smb_send_kvec(server, &smb_msg, &sent);
286 if (rc < 0)
287 goto uncork;
282 288
283 rc = smb_send_kvec(server, &smb_msg, &sent); 289 total_len += sent;
284 if (rc < 0) 290 send_length += 4;
285 goto uncork; 291 }
286 292
287 total_len += sent; 293 cifs_dbg(FYI, "Sending smb: smb_len=%u\n", send_length);
288 294
289 /* now walk the page array and send each page in it */ 295 for (j = 0; j < num_rqst; j++) {
290 for (i = 0; i < rqst->rq_npages; i++) { 296 iov = rqst[j].rq_iov;
291 struct bio_vec bvec; 297 n_vec = rqst[j].rq_nvec;
292 298
293 bvec.bv_page = rqst->rq_pages[i]; 299 size = 0;
294 rqst_page_get_length(rqst, i, &bvec.bv_len, &bvec.bv_offset); 300 for (i = 0; i < n_vec; i++) {
301 dump_smb(iov[i].iov_base, iov[i].iov_len);
302 size += iov[i].iov_len;
303 }
304
305 iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC,
306 iov, n_vec, size);
295 307
296 iov_iter_bvec(&smb_msg.msg_iter, WRITE | ITER_BVEC,
297 &bvec, 1, bvec.bv_len);
298 rc = smb_send_kvec(server, &smb_msg, &sent); 308 rc = smb_send_kvec(server, &smb_msg, &sent);
299 if (rc < 0) 309 if (rc < 0)
300 break; 310 goto uncork;
301 311
302 total_len += sent; 312 total_len += sent;
313
314 /* now walk the page array and send each page in it */
315 for (i = 0; i < rqst[j].rq_npages; i++) {
316 struct bio_vec bvec;
317
318 bvec.bv_page = rqst[j].rq_pages[i];
319 rqst_page_get_length(&rqst[j], i, &bvec.bv_len,
320 &bvec.bv_offset);
321
322 iov_iter_bvec(&smb_msg.msg_iter, WRITE | ITER_BVEC,
323 &bvec, 1, bvec.bv_len);
324 rc = smb_send_kvec(server, &smb_msg, &sent);
325 if (rc < 0)
326 break;
327
328 total_len += sent;
329 }
303 } 330 }
304 331
305uncork: 332uncork:
@@ -308,9 +335,9 @@ uncork:
308 kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK, 335 kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
309 (char *)&val, sizeof(val)); 336 (char *)&val, sizeof(val));
310 337
311 if ((total_len > 0) && (total_len != smb_buf_length + 4)) { 338 if ((total_len > 0) && (total_len != send_length)) {
312 cifs_dbg(FYI, "partial send (wanted=%u sent=%zu): terminating session\n", 339 cifs_dbg(FYI, "partial send (wanted=%u sent=%zu): terminating session\n",
313 smb_buf_length + 4, total_len); 340 send_length, total_len);
314 /* 341 /*
315 * If we have only sent part of an SMB then the next SMB could 342 * If we have only sent part of an SMB then the next SMB could
316 * be taken as the remainder of this one. We need to kill the 343 * be taken as the remainder of this one. We need to kill the
@@ -335,7 +362,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
335 int rc; 362 int rc;
336 363
337 if (!(flags & CIFS_TRANSFORM_REQ)) 364 if (!(flags & CIFS_TRANSFORM_REQ))
338 return __smb_send_rqst(server, rqst); 365 return __smb_send_rqst(server, 1, rqst);
339 366
340 if (!server->ops->init_transform_rq || 367 if (!server->ops->init_transform_rq ||
341 !server->ops->free_transform_rq) { 368 !server->ops->free_transform_rq) {
@@ -347,7 +374,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
347 if (rc) 374 if (rc)
348 return rc; 375 return rc;
349 376
350 rc = __smb_send_rqst(server, &cur_rqst); 377 rc = __smb_send_rqst(server, 1, &cur_rqst);
351 server->ops->free_transform_rq(&cur_rqst); 378 server->ops->free_transform_rq(&cur_rqst);
352 return rc; 379 return rc;
353} 380}
@@ -365,7 +392,7 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
365 iov[1].iov_base = (char *)smb_buffer + 4; 392 iov[1].iov_base = (char *)smb_buffer + 4;
366 iov[1].iov_len = smb_buf_length; 393 iov[1].iov_len = smb_buf_length;
367 394
368 return __smb_send_rqst(server, &rqst); 395 return __smb_send_rqst(server, 1, &rqst);
369} 396}
370 397
371static int 398static int
@@ -730,7 +757,6 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
730 * to the same server. We may make this configurable later or 757 * to the same server. We may make this configurable later or
731 * use ses->maxReq. 758 * use ses->maxReq.
732 */ 759 */
733
734 rc = wait_for_free_request(ses->server, timeout, optype); 760 rc = wait_for_free_request(ses->server, timeout, optype);
735 if (rc) 761 if (rc)
736 return rc; 762 return rc;
@@ -766,8 +792,8 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
766 792
767#ifdef CONFIG_CIFS_SMB311 793#ifdef CONFIG_CIFS_SMB311
768 if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) 794 if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP))
769 smb311_update_preauth_hash(ses, rqst->rq_iov+1, 795 smb311_update_preauth_hash(ses, rqst->rq_iov,
770 rqst->rq_nvec-1); 796 rqst->rq_nvec);
771#endif 797#endif
772 798
773 if (timeout == CIFS_ASYNC_OP) 799 if (timeout == CIFS_ASYNC_OP)
@@ -812,8 +838,8 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
812#ifdef CONFIG_CIFS_SMB311 838#ifdef CONFIG_CIFS_SMB311
813 if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) { 839 if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) {
814 struct kvec iov = { 840 struct kvec iov = {
815 .iov_base = buf, 841 .iov_base = resp_iov->iov_base,
816 .iov_len = midQ->resp_buf_size 842 .iov_len = resp_iov->iov_len
817 }; 843 };
818 smb311_update_preauth_hash(ses, &iov, 1); 844 smb311_update_preauth_hash(ses, &iov, 1);
819 } 845 }
@@ -872,49 +898,6 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
872 return rc; 898 return rc;
873} 899}
874 900
875/* Like SendReceive2 but iov[0] does not contain an rfc1002 header */
876int
877smb2_send_recv(const unsigned int xid, struct cifs_ses *ses,
878 struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
879 const int flags, struct kvec *resp_iov)
880{
881 struct smb_rqst rqst;
882 struct kvec s_iov[CIFS_MAX_IOV_SIZE], *new_iov;
883 int rc;
884 int i;
885 __u32 count;
886 __be32 rfc1002_marker;
887
888 if (n_vec + 1 > CIFS_MAX_IOV_SIZE) {
889 new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec),
890 GFP_KERNEL);
891 if (!new_iov)
892 return -ENOMEM;
893 } else
894 new_iov = s_iov;
895
896 /* 1st iov is an RFC1002 Session Message length */
897 memcpy(new_iov + 1, iov, (sizeof(struct kvec) * n_vec));
898
899 count = 0;
900 for (i = 1; i < n_vec + 1; i++)
901 count += new_iov[i].iov_len;
902
903 rfc1002_marker = cpu_to_be32(count);
904
905 new_iov[0].iov_base = &rfc1002_marker;
906 new_iov[0].iov_len = 4;
907
908 memset(&rqst, 0, sizeof(struct smb_rqst));
909 rqst.rq_iov = new_iov;
910 rqst.rq_nvec = n_vec + 1;
911
912 rc = cifs_send_recv(xid, ses, &rqst, resp_buf_type, flags, resp_iov);
913 if (n_vec + 1 > CIFS_MAX_IOV_SIZE)
914 kfree(new_iov);
915 return rc;
916}
917
918int 901int
919SendReceive(const unsigned int xid, struct cifs_ses *ses, 902SendReceive(const unsigned int xid, struct cifs_ses *ses,
920 struct smb_hdr *in_buf, struct smb_hdr *out_buf, 903 struct smb_hdr *in_buf, struct smb_hdr *out_buf,
diff --git a/fs/eventfd.c b/fs/eventfd.c
index ceb1031f1cac..08d3bd602f73 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -101,20 +101,14 @@ static int eventfd_release(struct inode *inode, struct file *file)
101 return 0; 101 return 0;
102} 102}
103 103
104static struct wait_queue_head * 104static __poll_t eventfd_poll(struct file *file, poll_table *wait)
105eventfd_get_poll_head(struct file *file, __poll_t events)
106{
107 struct eventfd_ctx *ctx = file->private_data;
108
109 return &ctx->wqh;
110}
111
112static __poll_t eventfd_poll_mask(struct file *file, __poll_t eventmask)
113{ 105{
114 struct eventfd_ctx *ctx = file->private_data; 106 struct eventfd_ctx *ctx = file->private_data;
115 __poll_t events = 0; 107 __poll_t events = 0;
116 u64 count; 108 u64 count;
117 109
110 poll_wait(file, &ctx->wqh, wait);
111
118 /* 112 /*
119 * All writes to ctx->count occur within ctx->wqh.lock. This read 113 * All writes to ctx->count occur within ctx->wqh.lock. This read
120 * can be done outside ctx->wqh.lock because we know that poll_wait 114 * can be done outside ctx->wqh.lock because we know that poll_wait
@@ -156,11 +150,11 @@ static __poll_t eventfd_poll_mask(struct file *file, __poll_t eventmask)
156 count = READ_ONCE(ctx->count); 150 count = READ_ONCE(ctx->count);
157 151
158 if (count > 0) 152 if (count > 0)
159 events |= (EPOLLIN & eventmask); 153 events |= EPOLLIN;
160 if (count == ULLONG_MAX) 154 if (count == ULLONG_MAX)
161 events |= EPOLLERR; 155 events |= EPOLLERR;
162 if (ULLONG_MAX - 1 > count) 156 if (ULLONG_MAX - 1 > count)
163 events |= (EPOLLOUT & eventmask); 157 events |= EPOLLOUT;
164 158
165 return events; 159 return events;
166} 160}
@@ -311,8 +305,7 @@ static const struct file_operations eventfd_fops = {
311 .show_fdinfo = eventfd_show_fdinfo, 305 .show_fdinfo = eventfd_show_fdinfo,
312#endif 306#endif
313 .release = eventfd_release, 307 .release = eventfd_release,
314 .get_poll_head = eventfd_get_poll_head, 308 .poll = eventfd_poll,
315 .poll_mask = eventfd_poll_mask,
316 .read = eventfd_read, 309 .read = eventfd_read,
317 .write = eventfd_write, 310 .write = eventfd_write,
318 .llseek = noop_llseek, 311 .llseek = noop_llseek,
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ea4436f409fb..67db22fe99c5 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -922,18 +922,14 @@ static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head
922 return 0; 922 return 0;
923} 923}
924 924
925static struct wait_queue_head *ep_eventpoll_get_poll_head(struct file *file, 925static __poll_t ep_eventpoll_poll(struct file *file, poll_table *wait)
926 __poll_t eventmask)
927{
928 struct eventpoll *ep = file->private_data;
929 return &ep->poll_wait;
930}
931
932static __poll_t ep_eventpoll_poll_mask(struct file *file, __poll_t eventmask)
933{ 926{
934 struct eventpoll *ep = file->private_data; 927 struct eventpoll *ep = file->private_data;
935 int depth = 0; 928 int depth = 0;
936 929
930 /* Insert inside our poll wait queue */
931 poll_wait(file, &ep->poll_wait, wait);
932
937 /* 933 /*
938 * Proceed to find out if wanted events are really available inside 934 * Proceed to find out if wanted events are really available inside
939 * the ready list. 935 * the ready list.
@@ -972,8 +968,7 @@ static const struct file_operations eventpoll_fops = {
972 .show_fdinfo = ep_show_fdinfo, 968 .show_fdinfo = ep_show_fdinfo,
973#endif 969#endif
974 .release = ep_eventpoll_release, 970 .release = ep_eventpoll_release,
975 .get_poll_head = ep_eventpoll_get_poll_head, 971 .poll = ep_eventpoll_poll,
976 .poll_mask = ep_eventpoll_poll_mask,
977 .llseek = noop_llseek, 972 .llseek = noop_llseek,
978}; 973};
979 974
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index cc40802ddfa8..00e759f05161 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -748,7 +748,6 @@ extern void ext2_free_blocks (struct inode *, unsigned long,
748 unsigned long); 748 unsigned long);
749extern unsigned long ext2_count_free_blocks (struct super_block *); 749extern unsigned long ext2_count_free_blocks (struct super_block *);
750extern unsigned long ext2_count_dirs (struct super_block *); 750extern unsigned long ext2_count_dirs (struct super_block *);
751extern void ext2_check_blocks_bitmap (struct super_block *);
752extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, 751extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
753 unsigned int block_group, 752 unsigned int block_group,
754 struct buffer_head ** bh); 753 struct buffer_head ** bh);
@@ -771,7 +770,6 @@ extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page
771extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); 770extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *);
772extern void ext2_free_inode (struct inode *); 771extern void ext2_free_inode (struct inode *);
773extern unsigned long ext2_count_free_inodes (struct super_block *); 772extern unsigned long ext2_count_free_inodes (struct super_block *);
774extern void ext2_check_inodes_bitmap (struct super_block *);
775extern unsigned long ext2_count_free (struct buffer_head *, unsigned); 773extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
776 774
777/* inode.c */ 775/* inode.c */
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 25ab1274090f..8ff53f8da3bc 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -557,6 +557,9 @@ static int parse_options(char *options, struct super_block *sb,
557 set_opt (opts->s_mount_opt, NO_UID32); 557 set_opt (opts->s_mount_opt, NO_UID32);
558 break; 558 break;
559 case Opt_nocheck: 559 case Opt_nocheck:
560 ext2_msg(sb, KERN_WARNING,
561 "Option nocheck/check=none is deprecated and"
562 " will be removed in June 2020.");
560 clear_opt (opts->s_mount_opt, CHECK); 563 clear_opt (opts->s_mount_opt, CHECK);
561 break; 564 break;
562 case Opt_debug: 565 case Opt_debug:
@@ -1335,9 +1338,6 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1335 new_opts.s_resgid = sbi->s_resgid; 1338 new_opts.s_resgid = sbi->s_resgid;
1336 spin_unlock(&sbi->s_lock); 1339 spin_unlock(&sbi->s_lock);
1337 1340
1338 /*
1339 * Allow the "check" option to be passed as a remount option.
1340 */
1341 if (!parse_options(data, sb, &new_opts)) 1341 if (!parse_options(data, sb, &new_opts))
1342 return -EINVAL; 1342 return -EINVAL;
1343 1343
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index c60f3d32ee91..a6797986b625 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -491,15 +491,17 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
491 if (size > PSIZE) { 491 if (size > PSIZE) {
492 /* 492 /*
493 * To keep the rest of the code simple. Allocate a 493 * To keep the rest of the code simple. Allocate a
494 * contiguous buffer to work with 494 * contiguous buffer to work with. Make the buffer large
495 * enough to make use of the whole extent.
495 */ 496 */
496 ea_buf->xattr = kmalloc(size, GFP_KERNEL); 497 ea_buf->max_size = (size + sb->s_blocksize - 1) &
498 ~(sb->s_blocksize - 1);
499
500 ea_buf->xattr = kmalloc(ea_buf->max_size, GFP_KERNEL);
497 if (ea_buf->xattr == NULL) 501 if (ea_buf->xattr == NULL)
498 return -ENOMEM; 502 return -ENOMEM;
499 503
500 ea_buf->flag = EA_MALLOC; 504 ea_buf->flag = EA_MALLOC;
501 ea_buf->max_size = (size + sb->s_blocksize - 1) &
502 ~(sb->s_blocksize - 1);
503 505
504 if (ea_size == 0) 506 if (ea_size == 0)
505 return 0; 507 return 0;
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index bbd0465535eb..f033f3a69a3b 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -883,8 +883,10 @@ struct inode *nfs_delegation_find_inode(struct nfs_client *clp,
883 rcu_read_lock(); 883 rcu_read_lock();
884 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { 884 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
885 res = nfs_delegation_find_inode_server(server, fhandle); 885 res = nfs_delegation_find_inode_server(server, fhandle);
886 if (res != ERR_PTR(-ENOENT)) 886 if (res != ERR_PTR(-ENOENT)) {
887 rcu_read_unlock();
887 return res; 888 return res;
889 }
888 } 890 }
889 rcu_read_unlock(); 891 rcu_read_unlock();
890 return ERR_PTR(-ENOENT); 892 return ERR_PTR(-ENOENT);
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index d4a07acad598..8f003792ccde 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1243,17 +1243,18 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
1243 hdr->ds_clp, hdr->lseg, 1243 hdr->ds_clp, hdr->lseg,
1244 hdr->pgio_mirror_idx); 1244 hdr->pgio_mirror_idx);
1245 1245
1246 clear_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags);
1247 clear_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags);
1246 switch (err) { 1248 switch (err) {
1247 case -NFS4ERR_RESET_TO_PNFS: 1249 case -NFS4ERR_RESET_TO_PNFS:
1248 if (ff_layout_choose_best_ds_for_read(hdr->lseg, 1250 if (ff_layout_choose_best_ds_for_read(hdr->lseg,
1249 hdr->pgio_mirror_idx + 1, 1251 hdr->pgio_mirror_idx + 1,
1250 &hdr->pgio_mirror_idx)) 1252 &hdr->pgio_mirror_idx))
1251 goto out_eagain; 1253 goto out_eagain;
1252 ff_layout_read_record_layoutstats_done(task, hdr); 1254 set_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags);
1253 pnfs_read_resend_pnfs(hdr);
1254 return task->tk_status; 1255 return task->tk_status;
1255 case -NFS4ERR_RESET_TO_MDS: 1256 case -NFS4ERR_RESET_TO_MDS:
1256 ff_layout_reset_read(hdr); 1257 set_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags);
1257 return task->tk_status; 1258 return task->tk_status;
1258 case -EAGAIN: 1259 case -EAGAIN:
1259 goto out_eagain; 1260 goto out_eagain;
@@ -1403,6 +1404,10 @@ static void ff_layout_read_release(void *data)
1403 struct nfs_pgio_header *hdr = data; 1404 struct nfs_pgio_header *hdr = data;
1404 1405
1405 ff_layout_read_record_layoutstats_done(&hdr->task, hdr); 1406 ff_layout_read_record_layoutstats_done(&hdr->task, hdr);
1407 if (test_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags))
1408 pnfs_read_resend_pnfs(hdr);
1409 else if (test_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags))
1410 ff_layout_reset_read(hdr);
1406 pnfs_generic_rw_release(data); 1411 pnfs_generic_rw_release(data);
1407} 1412}
1408 1413
@@ -1423,12 +1428,14 @@ static int ff_layout_write_done_cb(struct rpc_task *task,
1423 hdr->ds_clp, hdr->lseg, 1428 hdr->ds_clp, hdr->lseg,
1424 hdr->pgio_mirror_idx); 1429 hdr->pgio_mirror_idx);
1425 1430
1431 clear_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags);
1432 clear_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags);
1426 switch (err) { 1433 switch (err) {
1427 case -NFS4ERR_RESET_TO_PNFS: 1434 case -NFS4ERR_RESET_TO_PNFS:
1428 ff_layout_reset_write(hdr, true); 1435 set_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags);
1429 return task->tk_status; 1436 return task->tk_status;
1430 case -NFS4ERR_RESET_TO_MDS: 1437 case -NFS4ERR_RESET_TO_MDS:
1431 ff_layout_reset_write(hdr, false); 1438 set_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags);
1432 return task->tk_status; 1439 return task->tk_status;
1433 case -EAGAIN: 1440 case -EAGAIN:
1434 return -EAGAIN; 1441 return -EAGAIN;
@@ -1575,6 +1582,10 @@ static void ff_layout_write_release(void *data)
1575 struct nfs_pgio_header *hdr = data; 1582 struct nfs_pgio_header *hdr = data;
1576 1583
1577 ff_layout_write_record_layoutstats_done(&hdr->task, hdr); 1584 ff_layout_write_record_layoutstats_done(&hdr->task, hdr);
1585 if (test_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags))
1586 ff_layout_reset_write(hdr, true);
1587 else if (test_bit(NFS_IOHDR_RESEND_MDS, &hdr->flags))
1588 ff_layout_reset_write(hdr, false);
1578 pnfs_generic_rw_release(data); 1589 pnfs_generic_rw_release(data);
1579} 1590}
1580 1591
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ed45090e4df6..6dd146885da9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3294,6 +3294,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
3294 struct nfs4_closedata *calldata = data; 3294 struct nfs4_closedata *calldata = data;
3295 struct nfs4_state *state = calldata->state; 3295 struct nfs4_state *state = calldata->state;
3296 struct inode *inode = calldata->inode; 3296 struct inode *inode = calldata->inode;
3297 struct pnfs_layout_hdr *lo;
3297 bool is_rdonly, is_wronly, is_rdwr; 3298 bool is_rdonly, is_wronly, is_rdwr;
3298 int call_close = 0; 3299 int call_close = 0;
3299 3300
@@ -3337,6 +3338,12 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
3337 goto out_wait; 3338 goto out_wait;
3338 } 3339 }
3339 3340
3341 lo = calldata->arg.lr_args ? calldata->arg.lr_args->layout : NULL;
3342 if (lo && !pnfs_layout_is_valid(lo)) {
3343 calldata->arg.lr_args = NULL;
3344 calldata->res.lr_res = NULL;
3345 }
3346
3340 if (calldata->arg.fmode == 0) 3347 if (calldata->arg.fmode == 0)
3341 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE]; 3348 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE];
3342 3349
@@ -5972,12 +5979,19 @@ static void nfs4_delegreturn_release(void *calldata)
5972static void nfs4_delegreturn_prepare(struct rpc_task *task, void *data) 5979static void nfs4_delegreturn_prepare(struct rpc_task *task, void *data)
5973{ 5980{
5974 struct nfs4_delegreturndata *d_data; 5981 struct nfs4_delegreturndata *d_data;
5982 struct pnfs_layout_hdr *lo;
5975 5983
5976 d_data = (struct nfs4_delegreturndata *)data; 5984 d_data = (struct nfs4_delegreturndata *)data;
5977 5985
5978 if (!d_data->lr.roc && nfs4_wait_on_layoutreturn(d_data->inode, task)) 5986 if (!d_data->lr.roc && nfs4_wait_on_layoutreturn(d_data->inode, task))
5979 return; 5987 return;
5980 5988
5989 lo = d_data->args.lr_args ? d_data->args.lr_args->layout : NULL;
5990 if (lo && !pnfs_layout_is_valid(lo)) {
5991 d_data->args.lr_args = NULL;
5992 d_data->res.lr_res = NULL;
5993 }
5994
5981 nfs4_setup_sequence(d_data->res.server->nfs_client, 5995 nfs4_setup_sequence(d_data->res.server->nfs_client,
5982 &d_data->args.seq_args, 5996 &d_data->args.seq_args,
5983 &d_data->res.seq_res, 5997 &d_data->res.seq_res,
@@ -8650,6 +8664,8 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
8650 8664
8651 dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status); 8665 dprintk("--> %s tk_status => %d\n", __func__, -task->tk_status);
8652 8666
8667 nfs4_sequence_free_slot(&lgp->res.seq_res);
8668
8653 switch (nfs4err) { 8669 switch (nfs4err) {
8654 case 0: 8670 case 0:
8655 goto out; 8671 goto out;
@@ -8714,7 +8730,6 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
8714 goto out; 8730 goto out;
8715 } 8731 }
8716 8732
8717 nfs4_sequence_free_slot(&lgp->res.seq_res);
8718 err = nfs4_handle_exception(server, nfs4err, exception); 8733 err = nfs4_handle_exception(server, nfs4err, exception);
8719 if (!status) { 8734 if (!status) {
8720 if (exception->retry) 8735 if (exception->retry)
@@ -8786,20 +8801,22 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout)
8786 if (IS_ERR(task)) 8801 if (IS_ERR(task))
8787 return ERR_CAST(task); 8802 return ERR_CAST(task);
8788 status = rpc_wait_for_completion_task(task); 8803 status = rpc_wait_for_completion_task(task);
8789 if (status == 0) { 8804 if (status != 0)
8805 goto out;
8806
8807 /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
8808 if (task->tk_status < 0 || lgp->res.layoutp->len == 0) {
8790 status = nfs4_layoutget_handle_exception(task, lgp, &exception); 8809 status = nfs4_layoutget_handle_exception(task, lgp, &exception);
8791 *timeout = exception.timeout; 8810 *timeout = exception.timeout;
8792 } 8811 } else
8793 8812 lseg = pnfs_layout_process(lgp);
8813out:
8794 trace_nfs4_layoutget(lgp->args.ctx, 8814 trace_nfs4_layoutget(lgp->args.ctx,
8795 &lgp->args.range, 8815 &lgp->args.range,
8796 &lgp->res.range, 8816 &lgp->res.range,
8797 &lgp->res.stateid, 8817 &lgp->res.stateid,
8798 status); 8818 status);
8799 8819
8800 /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
8801 if (status == 0 && lgp->res.layoutp->len)
8802 lseg = pnfs_layout_process(lgp);
8803 rpc_put_task(task); 8820 rpc_put_task(task);
8804 dprintk("<-- %s status=%d\n", __func__, status); 8821 dprintk("<-- %s status=%d\n", __func__, status);
8805 if (status) 8822 if (status)
@@ -8817,6 +8834,8 @@ nfs4_layoutreturn_prepare(struct rpc_task *task, void *calldata)
8817 &lrp->args.seq_args, 8834 &lrp->args.seq_args,
8818 &lrp->res.seq_res, 8835 &lrp->res.seq_res,
8819 task); 8836 task);
8837 if (!pnfs_layout_is_valid(lrp->args.layout))
8838 rpc_exit(task, 0);
8820} 8839}
8821 8840
8822static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) 8841static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index a8f5e6b16749..3fe81424337d 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -801,6 +801,11 @@ static inline void nfs4_lgopen_release(struct nfs4_layoutget *lgp)
801{ 801{
802} 802}
803 803
804static inline bool pnfs_layout_is_valid(const struct pnfs_layout_hdr *lo)
805{
806 return false;
807}
808
804#endif /* CONFIG_NFS_V4_1 */ 809#endif /* CONFIG_NFS_V4_1 */
805 810
806#if IS_ENABLED(CONFIG_NFS_V4_2) 811#if IS_ENABLED(CONFIG_NFS_V4_2)
diff --git a/fs/pipe.c b/fs/pipe.c
index bb0840e234f3..39d6f431da83 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -509,22 +509,19 @@ static long pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
509 } 509 }
510} 510}
511 511
512static struct wait_queue_head *
513pipe_get_poll_head(struct file *filp, __poll_t events)
514{
515 struct pipe_inode_info *pipe = filp->private_data;
516
517 return &pipe->wait;
518}
519
520/* No kernel lock held - fine */ 512/* No kernel lock held - fine */
521static __poll_t pipe_poll_mask(struct file *filp, __poll_t events) 513static __poll_t
514pipe_poll(struct file *filp, poll_table *wait)
522{ 515{
516 __poll_t mask;
523 struct pipe_inode_info *pipe = filp->private_data; 517 struct pipe_inode_info *pipe = filp->private_data;
524 int nrbufs = pipe->nrbufs; 518 int nrbufs;
525 __poll_t mask = 0; 519
520 poll_wait(filp, &pipe->wait, wait);
526 521
527 /* Reading only -- no need for acquiring the semaphore. */ 522 /* Reading only -- no need for acquiring the semaphore. */
523 nrbufs = pipe->nrbufs;
524 mask = 0;
528 if (filp->f_mode & FMODE_READ) { 525 if (filp->f_mode & FMODE_READ) {
529 mask = (nrbufs > 0) ? EPOLLIN | EPOLLRDNORM : 0; 526 mask = (nrbufs > 0) ? EPOLLIN | EPOLLRDNORM : 0;
530 if (!pipe->writers && filp->f_version != pipe->w_counter) 527 if (!pipe->writers && filp->f_version != pipe->w_counter)
@@ -1023,8 +1020,7 @@ const struct file_operations pipefifo_fops = {
1023 .llseek = no_llseek, 1020 .llseek = no_llseek,
1024 .read_iter = pipe_read, 1021 .read_iter = pipe_read,
1025 .write_iter = pipe_write, 1022 .write_iter = pipe_write,
1026 .get_poll_head = pipe_get_poll_head, 1023 .poll = pipe_poll,
1027 .poll_mask = pipe_poll_mask,
1028 .unlocked_ioctl = pipe_ioctl, 1024 .unlocked_ioctl = pipe_ioctl,
1029 .release = pipe_release, 1025 .release = pipe_release,
1030 .fasync = pipe_fasync, 1026 .fasync = pipe_fasync,
diff --git a/fs/proc/base.c b/fs/proc/base.c
index b6572944efc3..aaffc0c30216 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -235,6 +235,10 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, char __user *buf,
235 if (env_start != arg_end || env_start >= env_end) 235 if (env_start != arg_end || env_start >= env_end)
236 env_start = env_end = arg_end; 236 env_start = env_end = arg_end;
237 237
238 /* .. and limit it to a maximum of one page of slop */
239 if (env_end >= arg_end + PAGE_SIZE)
240 env_end = arg_end + PAGE_SIZE - 1;
241
238 /* We're not going to care if "*ppos" has high bits set */ 242 /* We're not going to care if "*ppos" has high bits set */
239 pos = arg_start + *ppos; 243 pos = arg_start + *ppos;
240 244
@@ -254,10 +258,19 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, char __user *buf,
254 while (count) { 258 while (count) {
255 int got; 259 int got;
256 size_t size = min_t(size_t, PAGE_SIZE, count); 260 size_t size = min_t(size_t, PAGE_SIZE, count);
261 long offset;
257 262
258 got = access_remote_vm(mm, pos, page, size, FOLL_ANON); 263 /*
259 if (got <= 0) 264 * Are we already starting past the official end?
265 * We always include the last byte that is *supposed*
266 * to be NUL
267 */
268 offset = (pos >= arg_end) ? pos - arg_end + 1 : 0;
269
270 got = access_remote_vm(mm, pos - offset, page, size + offset, FOLL_ANON);
271 if (got <= offset)
260 break; 272 break;
273 got -= offset;
261 274
262 /* Don't walk past a NUL character once you hit arg_end */ 275 /* Don't walk past a NUL character once you hit arg_end */
263 if (pos + got >= arg_end) { 276 if (pos + got >= arg_end) {
@@ -276,12 +289,17 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, char __user *buf,
276 n = arg_end - pos - 1; 289 n = arg_end - pos - 1;
277 290
278 /* Cut off at first NUL after 'n' */ 291 /* Cut off at first NUL after 'n' */
279 got = n + strnlen(page+n, got-n); 292 got = n + strnlen(page+n, offset+got-n);
280 if (!got) 293 if (got < offset)
281 break; 294 break;
295 got -= offset;
296
297 /* Include the NUL if it existed */
298 if (got < size)
299 got++;
282 } 300 }
283 301
284 got -= copy_to_user(buf, page, got); 302 got -= copy_to_user(buf, page+offset, got);
285 if (unlikely(!got)) { 303 if (unlikely(!got)) {
286 if (!len) 304 if (!len)
287 len = -EFAULT; 305 len = -EFAULT;
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 6ac1c92997ea..bb1c1625b158 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -564,11 +564,20 @@ static int proc_seq_open(struct inode *inode, struct file *file)
564 return seq_open(file, de->seq_ops); 564 return seq_open(file, de->seq_ops);
565} 565}
566 566
567static int proc_seq_release(struct inode *inode, struct file *file)
568{
569 struct proc_dir_entry *de = PDE(inode);
570
571 if (de->state_size)
572 return seq_release_private(inode, file);
573 return seq_release(inode, file);
574}
575
567static const struct file_operations proc_seq_fops = { 576static const struct file_operations proc_seq_fops = {
568 .open = proc_seq_open, 577 .open = proc_seq_open,
569 .read = seq_read, 578 .read = seq_read,
570 .llseek = seq_lseek, 579 .llseek = seq_lseek,
571 .release = seq_release, 580 .release = proc_seq_release,
572}; 581};
573 582
574struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode, 583struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index d88231e3b2be..fc20e06c56ba 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -711,21 +711,18 @@ EXPORT_SYMBOL(dquot_quota_sync);
711static unsigned long 711static unsigned long
712dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) 712dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
713{ 713{
714 struct list_head *head;
715 struct dquot *dquot; 714 struct dquot *dquot;
716 unsigned long freed = 0; 715 unsigned long freed = 0;
717 716
718 spin_lock(&dq_list_lock); 717 spin_lock(&dq_list_lock);
719 head = free_dquots.prev; 718 while (!list_empty(&free_dquots) && sc->nr_to_scan) {
720 while (head != &free_dquots && sc->nr_to_scan) { 719 dquot = list_first_entry(&free_dquots, struct dquot, dq_free);
721 dquot = list_entry(head, struct dquot, dq_free);
722 remove_dquot_hash(dquot); 720 remove_dquot_hash(dquot);
723 remove_free_dquot(dquot); 721 remove_free_dquot(dquot);
724 remove_inuse(dquot); 722 remove_inuse(dquot);
725 do_destroy_dquot(dquot); 723 do_destroy_dquot(dquot);
726 sc->nr_to_scan--; 724 sc->nr_to_scan--;
727 freed++; 725 freed++;
728 head = free_dquots.prev;
729 } 726 }
730 spin_unlock(&dq_list_lock); 727 spin_unlock(&dq_list_lock);
731 return freed; 728 return freed;
diff --git a/fs/select.c b/fs/select.c
index 317891ff8165..4a6b6e4b21cb 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -34,29 +34,6 @@
34 34
35#include <linux/uaccess.h> 35#include <linux/uaccess.h>
36 36
37__poll_t vfs_poll(struct file *file, struct poll_table_struct *pt)
38{
39 if (file->f_op->poll) {
40 return file->f_op->poll(file, pt);
41 } else if (file_has_poll_mask(file)) {
42 unsigned int events = poll_requested_events(pt);
43 struct wait_queue_head *head;
44
45 if (pt && pt->_qproc) {
46 head = file->f_op->get_poll_head(file, events);
47 if (!head)
48 return DEFAULT_POLLMASK;
49 if (IS_ERR(head))
50 return EPOLLERR;
51 pt->_qproc(file, head, pt);
52 }
53
54 return file->f_op->poll_mask(file, events);
55 } else {
56 return DEFAULT_POLLMASK;
57 }
58}
59EXPORT_SYMBOL_GPL(vfs_poll);
60 37
61/* 38/*
62 * Estimate expected accuracy in ns from a timeval. 39 * Estimate expected accuracy in ns from a timeval.
diff --git a/fs/timerfd.c b/fs/timerfd.c
index d84a2bee4f82..cdad49da3ff7 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -226,20 +226,21 @@ static int timerfd_release(struct inode *inode, struct file *file)
226 kfree_rcu(ctx, rcu); 226 kfree_rcu(ctx, rcu);
227 return 0; 227 return 0;
228} 228}
229 229
230static struct wait_queue_head *timerfd_get_poll_head(struct file *file, 230static __poll_t timerfd_poll(struct file *file, poll_table *wait)
231 __poll_t eventmask)
232{ 231{
233 struct timerfd_ctx *ctx = file->private_data; 232 struct timerfd_ctx *ctx = file->private_data;
233 __poll_t events = 0;
234 unsigned long flags;
234 235
235 return &ctx->wqh; 236 poll_wait(file, &ctx->wqh, wait);
236}
237 237
238static __poll_t timerfd_poll_mask(struct file *file, __poll_t eventmask) 238 spin_lock_irqsave(&ctx->wqh.lock, flags);
239{ 239 if (ctx->ticks)
240 struct timerfd_ctx *ctx = file->private_data; 240 events |= EPOLLIN;
241 spin_unlock_irqrestore(&ctx->wqh.lock, flags);
241 242
242 return ctx->ticks ? EPOLLIN : 0; 243 return events;
243} 244}
244 245
245static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, 246static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
@@ -363,8 +364,7 @@ static long timerfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg
363 364
364static const struct file_operations timerfd_fops = { 365static const struct file_operations timerfd_fops = {
365 .release = timerfd_release, 366 .release = timerfd_release,
366 .get_poll_head = timerfd_get_poll_head, 367 .poll = timerfd_poll,
367 .poll_mask = timerfd_poll_mask,
368 .read = timerfd_read, 368 .read = timerfd_read,
369 .llseek = noop_llseek, 369 .llseek = noop_llseek,
370 .show_fdinfo = timerfd_show, 370 .show_fdinfo = timerfd_show,
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 1b961b1d9699..fcda0fc97b90 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -533,8 +533,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
533 udf_write_aext(table, &epos, &eloc, 533 udf_write_aext(table, &epos, &eloc,
534 (etype << 30) | elen, 1); 534 (etype << 30) | elen, 1);
535 } else 535 } else
536 udf_delete_aext(table, epos, eloc, 536 udf_delete_aext(table, epos);
537 (etype << 30) | elen);
538 } else { 537 } else {
539 alloc_count = 0; 538 alloc_count = 0;
540 } 539 }
@@ -630,7 +629,7 @@ static udf_pblk_t udf_table_new_block(struct super_block *sb,
630 if (goal_elen) 629 if (goal_elen)
631 udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1); 630 udf_write_aext(table, &goal_epos, &goal_eloc, goal_elen, 1);
632 else 631 else
633 udf_delete_aext(table, goal_epos, goal_eloc, goal_elen); 632 udf_delete_aext(table, goal_epos);
634 brelse(goal_epos.bh); 633 brelse(goal_epos.bh);
635 634
636 udf_add_free_space(sb, partition, -1); 635 udf_add_free_space(sb, partition, -1);
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 0a98a2369738..d9523013096f 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -141,10 +141,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
141 fibh->ebh->b_data, 141 fibh->ebh->b_data,
142 sizeof(struct fileIdentDesc) + fibh->soffset); 142 sizeof(struct fileIdentDesc) + fibh->soffset);
143 143
144 fi_len = (sizeof(struct fileIdentDesc) + 144 fi_len = udf_dir_entry_len(cfi);
145 cfi->lengthFileIdent +
146 le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
147
148 *nf_pos += fi_len - (fibh->eoffset - fibh->soffset); 145 *nf_pos += fi_len - (fibh->eoffset - fibh->soffset);
149 fibh->eoffset = fibh->soffset + fi_len; 146 fibh->eoffset = fibh->soffset + fi_len;
150 } else { 147 } else {
@@ -152,6 +149,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
152 sizeof(struct fileIdentDesc)); 149 sizeof(struct fileIdentDesc));
153 } 150 }
154 } 151 }
152 /* Got last entry outside of dir size - fs is corrupted! */
153 if (*nf_pos > dir->i_size)
154 return NULL;
155 return fi; 155 return fi;
156} 156}
157 157
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 7f39d17352c9..9915a58fbabd 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1147,8 +1147,7 @@ static void udf_update_extents(struct inode *inode, struct kernel_long_ad *laarr
1147 1147
1148 if (startnum > endnum) { 1148 if (startnum > endnum) {
1149 for (i = 0; i < (startnum - endnum); i++) 1149 for (i = 0; i < (startnum - endnum); i++)
1150 udf_delete_aext(inode, *epos, laarr[i].extLocation, 1150 udf_delete_aext(inode, *epos);
1151 laarr[i].extLength);
1152 } else if (startnum < endnum) { 1151 } else if (startnum < endnum) {
1153 for (i = 0; i < (endnum - startnum); i++) { 1152 for (i = 0; i < (endnum - startnum); i++) {
1154 udf_insert_aext(inode, *epos, laarr[i].extLocation, 1153 udf_insert_aext(inode, *epos, laarr[i].extLocation,
@@ -2176,14 +2175,15 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos,
2176 return (nelen >> 30); 2175 return (nelen >> 30);
2177} 2176}
2178 2177
2179int8_t udf_delete_aext(struct inode *inode, struct extent_position epos, 2178int8_t udf_delete_aext(struct inode *inode, struct extent_position epos)
2180 struct kernel_lb_addr eloc, uint32_t elen)
2181{ 2179{
2182 struct extent_position oepos; 2180 struct extent_position oepos;
2183 int adsize; 2181 int adsize;
2184 int8_t etype; 2182 int8_t etype;
2185 struct allocExtDesc *aed; 2183 struct allocExtDesc *aed;
2186 struct udf_inode_info *iinfo; 2184 struct udf_inode_info *iinfo;
2185 struct kernel_lb_addr eloc;
2186 uint32_t elen;
2187 2187
2188 if (epos.bh) { 2188 if (epos.bh) {
2189 get_bh(epos.bh); 2189 get_bh(epos.bh);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index c586026508db..06f37ddd2997 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -351,8 +351,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
351 loff_t f_pos; 351 loff_t f_pos;
352 loff_t size = udf_ext0_offset(dir) + dir->i_size; 352 loff_t size = udf_ext0_offset(dir) + dir->i_size;
353 int nfidlen; 353 int nfidlen;
354 uint8_t lfi;
355 uint16_t liu;
356 udf_pblk_t block; 354 udf_pblk_t block;
357 struct kernel_lb_addr eloc; 355 struct kernel_lb_addr eloc;
358 uint32_t elen = 0; 356 uint32_t elen = 0;
@@ -383,7 +381,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
383 namelen = 0; 381 namelen = 0;
384 } 382 }
385 383
386 nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; 384 nfidlen = ALIGN(sizeof(struct fileIdentDesc) + namelen, UDF_NAME_PAD);
387 385
388 f_pos = udf_ext0_offset(dir); 386 f_pos = udf_ext0_offset(dir);
389 387
@@ -424,12 +422,8 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
424 goto out_err; 422 goto out_err;
425 } 423 }
426 424
427 liu = le16_to_cpu(cfi->lengthOfImpUse);
428 lfi = cfi->lengthFileIdent;
429
430 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 425 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
431 if (((sizeof(struct fileIdentDesc) + 426 if (udf_dir_entry_len(cfi) == nfidlen) {
432 liu + lfi + 3) & ~3) == nfidlen) {
433 cfi->descTag.tagSerialNum = cpu_to_le16(1); 427 cfi->descTag.tagSerialNum = cpu_to_le16(1);
434 cfi->fileVersionNum = cpu_to_le16(1); 428 cfi->fileVersionNum = cpu_to_le16(1);
435 cfi->fileCharacteristics = 0; 429 cfi->fileCharacteristics = 0;
@@ -1201,9 +1195,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1201 1195
1202 if (dir_fi) { 1196 if (dir_fi) {
1203 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location); 1197 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location);
1204 udf_update_tag((char *)dir_fi, 1198 udf_update_tag((char *)dir_fi, udf_dir_entry_len(dir_fi));
1205 (sizeof(struct fileIdentDesc) +
1206 le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3);
1207 if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 1199 if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
1208 mark_inode_dirty(old_inode); 1200 mark_inode_dirty(old_inode);
1209 else 1201 else
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index bae311b59400..84c47dde4d26 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -132,6 +132,12 @@ struct inode *udf_find_metadata_inode_efe(struct super_block *sb,
132extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, 132extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
133 struct fileIdentDesc *, struct udf_fileident_bh *, 133 struct fileIdentDesc *, struct udf_fileident_bh *,
134 uint8_t *, uint8_t *); 134 uint8_t *, uint8_t *);
135static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi)
136{
137 return ALIGN(sizeof(struct fileIdentDesc) +
138 le16_to_cpu(cfi->lengthOfImpUse) + cfi->lengthFileIdent,
139 UDF_NAME_PAD);
140}
135 141
136/* file.c */ 142/* file.c */
137extern long udf_ioctl(struct file *, unsigned int, unsigned long); 143extern long udf_ioctl(struct file *, unsigned int, unsigned long);
@@ -167,8 +173,7 @@ extern int udf_add_aext(struct inode *, struct extent_position *,
167 struct kernel_lb_addr *, uint32_t, int); 173 struct kernel_lb_addr *, uint32_t, int);
168extern void udf_write_aext(struct inode *, struct extent_position *, 174extern void udf_write_aext(struct inode *, struct extent_position *,
169 struct kernel_lb_addr *, uint32_t, int); 175 struct kernel_lb_addr *, uint32_t, int);
170extern int8_t udf_delete_aext(struct inode *, struct extent_position, 176extern int8_t udf_delete_aext(struct inode *, struct extent_position);
171 struct kernel_lb_addr, uint32_t);
172extern int8_t udf_next_aext(struct inode *, struct extent_position *, 177extern int8_t udf_next_aext(struct inode *, struct extent_position *,
173 struct kernel_lb_addr *, uint32_t *, int); 178 struct kernel_lb_addr *, uint32_t *, int);
174extern int8_t udf_current_aext(struct inode *, struct extent_position *, 179extern int8_t udf_current_aext(struct inode *, struct extent_position *,
diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index 84db76e0e3e3..fecd187fcf2c 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -157,6 +157,7 @@ __xfs_ag_resv_free(
157 error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true); 157 error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
158 resv->ar_reserved = 0; 158 resv->ar_reserved = 0;
159 resv->ar_asked = 0; 159 resv->ar_asked = 0;
160 resv->ar_orig_reserved = 0;
160 161
161 if (error) 162 if (error)
162 trace_xfs_ag_resv_free_error(pag->pag_mount, pag->pag_agno, 163 trace_xfs_ag_resv_free_error(pag->pag_mount, pag->pag_agno,
@@ -189,13 +190,34 @@ __xfs_ag_resv_init(
189 struct xfs_mount *mp = pag->pag_mount; 190 struct xfs_mount *mp = pag->pag_mount;
190 struct xfs_ag_resv *resv; 191 struct xfs_ag_resv *resv;
191 int error; 192 int error;
192 xfs_extlen_t reserved; 193 xfs_extlen_t hidden_space;
193 194
194 if (used > ask) 195 if (used > ask)
195 ask = used; 196 ask = used;
196 reserved = ask - used;
197 197
198 error = xfs_mod_fdblocks(mp, -(int64_t)reserved, true); 198 switch (type) {
199 case XFS_AG_RESV_RMAPBT:
200 /*
201 * Space taken by the rmapbt is not subtracted from fdblocks
202 * because the rmapbt lives in the free space. Here we must
203 * subtract the entire reservation from fdblocks so that we
204 * always have blocks available for rmapbt expansion.
205 */
206 hidden_space = ask;
207 break;
208 case XFS_AG_RESV_METADATA:
209 /*
210 * Space taken by all other metadata btrees are accounted
211 * on-disk as used space. We therefore only hide the space
212 * that is reserved but not used by the trees.
213 */
214 hidden_space = ask - used;
215 break;
216 default:
217 ASSERT(0);
218 return -EINVAL;
219 }
220 error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true);
199 if (error) { 221 if (error) {
200 trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno, 222 trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
201 error, _RET_IP_); 223 error, _RET_IP_);
@@ -216,7 +238,8 @@ __xfs_ag_resv_init(
216 238
217 resv = xfs_perag_resv(pag, type); 239 resv = xfs_perag_resv(pag, type);
218 resv->ar_asked = ask; 240 resv->ar_asked = ask;
219 resv->ar_reserved = resv->ar_orig_reserved = reserved; 241 resv->ar_orig_reserved = hidden_space;
242 resv->ar_reserved = ask - used;
220 243
221 trace_xfs_ag_resv_init(pag, type, ask); 244 trace_xfs_ag_resv_init(pag, type, ask);
222 return 0; 245 return 0;
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 01628f0c9a0c..7205268b30bc 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5780,6 +5780,32 @@ del_cursor:
5780 return error; 5780 return error;
5781} 5781}
5782 5782
5783/* Make sure we won't be right-shifting an extent past the maximum bound. */
5784int
5785xfs_bmap_can_insert_extents(
5786 struct xfs_inode *ip,
5787 xfs_fileoff_t off,
5788 xfs_fileoff_t shift)
5789{
5790 struct xfs_bmbt_irec got;
5791 int is_empty;
5792 int error = 0;
5793
5794 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
5795
5796 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
5797 return -EIO;
5798
5799 xfs_ilock(ip, XFS_ILOCK_EXCL);
5800 error = xfs_bmap_last_extent(NULL, ip, XFS_DATA_FORK, &got, &is_empty);
5801 if (!error && !is_empty && got.br_startoff >= off &&
5802 ((got.br_startoff + shift) & BMBT_STARTOFF_MASK) < got.br_startoff)
5803 error = -EINVAL;
5804 xfs_iunlock(ip, XFS_ILOCK_EXCL);
5805
5806 return error;
5807}
5808
5783int 5809int
5784xfs_bmap_insert_extents( 5810xfs_bmap_insert_extents(
5785 struct xfs_trans *tp, 5811 struct xfs_trans *tp,
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 99dddbd0fcc6..9b49ddf99c41 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -227,6 +227,8 @@ int xfs_bmap_collapse_extents(struct xfs_trans *tp, struct xfs_inode *ip,
227 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, 227 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
228 bool *done, xfs_fsblock_t *firstblock, 228 bool *done, xfs_fsblock_t *firstblock,
229 struct xfs_defer_ops *dfops); 229 struct xfs_defer_ops *dfops);
230int xfs_bmap_can_insert_extents(struct xfs_inode *ip, xfs_fileoff_t off,
231 xfs_fileoff_t shift);
230int xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip, 232int xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip,
231 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, 233 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
232 bool *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock, 234 bool *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock,
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 1c5a8aaf2bfc..059bc44c27e8 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -962,6 +962,9 @@ typedef enum xfs_dinode_fmt {
962 XFS_DFORK_DSIZE(dip, mp) : \ 962 XFS_DFORK_DSIZE(dip, mp) : \
963 XFS_DFORK_ASIZE(dip, mp)) 963 XFS_DFORK_ASIZE(dip, mp))
964 964
965#define XFS_DFORK_MAXEXT(dip, mp, w) \
966 (XFS_DFORK_SIZE(dip, mp, w) / sizeof(struct xfs_bmbt_rec))
967
965/* 968/*
966 * Return pointers to the data or attribute forks. 969 * Return pointers to the data or attribute forks.
967 */ 970 */
@@ -1526,6 +1529,8 @@ typedef struct xfs_bmdr_block {
1526#define BMBT_STARTBLOCK_BITLEN 52 1529#define BMBT_STARTBLOCK_BITLEN 52
1527#define BMBT_BLOCKCOUNT_BITLEN 21 1530#define BMBT_BLOCKCOUNT_BITLEN 21
1528 1531
1532#define BMBT_STARTOFF_MASK ((1ULL << BMBT_STARTOFF_BITLEN) - 1)
1533
1529typedef struct xfs_bmbt_rec { 1534typedef struct xfs_bmbt_rec {
1530 __be64 l0, l1; 1535 __be64 l0, l1;
1531} xfs_bmbt_rec_t; 1536} xfs_bmbt_rec_t;
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index d38d724534c4..33dc34655ac3 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -374,6 +374,47 @@ xfs_log_dinode_to_disk(
374 } 374 }
375} 375}
376 376
377static xfs_failaddr_t
378xfs_dinode_verify_fork(
379 struct xfs_dinode *dip,
380 struct xfs_mount *mp,
381 int whichfork)
382{
383 uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork);
384
385 switch (XFS_DFORK_FORMAT(dip, whichfork)) {
386 case XFS_DINODE_FMT_LOCAL:
387 /*
388 * no local regular files yet
389 */
390 if (whichfork == XFS_DATA_FORK) {
391 if (S_ISREG(be16_to_cpu(dip->di_mode)))
392 return __this_address;
393 if (be64_to_cpu(dip->di_size) >
394 XFS_DFORK_SIZE(dip, mp, whichfork))
395 return __this_address;
396 }
397 if (di_nextents)
398 return __this_address;
399 break;
400 case XFS_DINODE_FMT_EXTENTS:
401 if (di_nextents > XFS_DFORK_MAXEXT(dip, mp, whichfork))
402 return __this_address;
403 break;
404 case XFS_DINODE_FMT_BTREE:
405 if (whichfork == XFS_ATTR_FORK) {
406 if (di_nextents > MAXAEXTNUM)
407 return __this_address;
408 } else if (di_nextents > MAXEXTNUM) {
409 return __this_address;
410 }
411 break;
412 default:
413 return __this_address;
414 }
415 return NULL;
416}
417
377xfs_failaddr_t 418xfs_failaddr_t
378xfs_dinode_verify( 419xfs_dinode_verify(
379 struct xfs_mount *mp, 420 struct xfs_mount *mp,
@@ -441,24 +482,9 @@ xfs_dinode_verify(
441 case S_IFREG: 482 case S_IFREG:
442 case S_IFLNK: 483 case S_IFLNK:
443 case S_IFDIR: 484 case S_IFDIR:
444 switch (dip->di_format) { 485 fa = xfs_dinode_verify_fork(dip, mp, XFS_DATA_FORK);
445 case XFS_DINODE_FMT_LOCAL: 486 if (fa)
446 /* 487 return fa;
447 * no local regular files yet
448 */
449 if (S_ISREG(mode))
450 return __this_address;
451 if (di_size > XFS_DFORK_DSIZE(dip, mp))
452 return __this_address;
453 if (dip->di_nextents)
454 return __this_address;
455 /* fall through */
456 case XFS_DINODE_FMT_EXTENTS:
457 case XFS_DINODE_FMT_BTREE:
458 break;
459 default:
460 return __this_address;
461 }
462 break; 488 break;
463 case 0: 489 case 0:
464 /* Uninitialized inode ok. */ 490 /* Uninitialized inode ok. */
@@ -468,17 +494,9 @@ xfs_dinode_verify(
468 } 494 }
469 495
470 if (XFS_DFORK_Q(dip)) { 496 if (XFS_DFORK_Q(dip)) {
471 switch (dip->di_aformat) { 497 fa = xfs_dinode_verify_fork(dip, mp, XFS_ATTR_FORK);
472 case XFS_DINODE_FMT_LOCAL: 498 if (fa)
473 if (dip->di_anextents) 499 return fa;
474 return __this_address;
475 /* fall through */
476 case XFS_DINODE_FMT_EXTENTS:
477 case XFS_DINODE_FMT_BTREE:
478 break;
479 default:
480 return __this_address;
481 }
482 } else { 500 } else {
483 /* 501 /*
484 * If there is no fork offset, this may be a freshly-made inode 502 * If there is no fork offset, this may be a freshly-made inode
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 65fc4ed2e9a1..b228c821bae6 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1029,8 +1029,8 @@ xfs_rtalloc_query_range(
1029 if (low_rec->ar_startext >= mp->m_sb.sb_rextents || 1029 if (low_rec->ar_startext >= mp->m_sb.sb_rextents ||
1030 low_rec->ar_startext == high_rec->ar_startext) 1030 low_rec->ar_startext == high_rec->ar_startext)
1031 return 0; 1031 return 0;
1032 if (high_rec->ar_startext >= mp->m_sb.sb_rextents) 1032 if (high_rec->ar_startext > mp->m_sb.sb_rextents)
1033 high_rec->ar_startext = mp->m_sb.sb_rextents - 1; 1033 high_rec->ar_startext = mp->m_sb.sb_rextents;
1034 1034
1035 /* Iterate the bitmap, looking for discrepancies. */ 1035 /* Iterate the bitmap, looking for discrepancies. */
1036 rtstart = low_rec->ar_startext; 1036 rtstart = low_rec->ar_startext;
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index c35009a86699..83b1e8c6c18f 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -685,12 +685,10 @@ out_unlock_iolock:
685} 685}
686 686
687/* 687/*
688 * dead simple method of punching delalyed allocation blocks from a range in 688 * Dead simple method of punching delalyed allocation blocks from a range in
689 * the inode. Walks a block at a time so will be slow, but is only executed in 689 * the inode. This will always punch out both the start and end blocks, even
690 * rare error cases so the overhead is not critical. This will always punch out 690 * if the ranges only partially overlap them, so it is up to the caller to
691 * both the start and end blocks, even if the ranges only partially overlap 691 * ensure that partial blocks are not passed in.
692 * them, so it is up to the caller to ensure that partial blocks are not
693 * passed in.
694 */ 692 */
695int 693int
696xfs_bmap_punch_delalloc_range( 694xfs_bmap_punch_delalloc_range(
@@ -698,63 +696,44 @@ xfs_bmap_punch_delalloc_range(
698 xfs_fileoff_t start_fsb, 696 xfs_fileoff_t start_fsb,
699 xfs_fileoff_t length) 697 xfs_fileoff_t length)
700{ 698{
701 xfs_fileoff_t remaining = length; 699 struct xfs_ifork *ifp = &ip->i_df;
700 xfs_fileoff_t end_fsb = start_fsb + length;
701 struct xfs_bmbt_irec got, del;
702 struct xfs_iext_cursor icur;
702 int error = 0; 703 int error = 0;
703 704
704 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 705 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
705 706
706 do { 707 if (!(ifp->if_flags & XFS_IFEXTENTS)) {
707 int done; 708 error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
708 xfs_bmbt_irec_t imap; 709 if (error)
709 int nimaps = 1; 710 return error;
710 xfs_fsblock_t firstblock; 711 }
711 struct xfs_defer_ops dfops;
712 712
713 /* 713 if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got))
714 * Map the range first and check that it is a delalloc extent 714 return 0;
715 * before trying to unmap the range. Otherwise we will be
716 * trying to remove a real extent (which requires a
717 * transaction) or a hole, which is probably a bad idea...
718 */
719 error = xfs_bmapi_read(ip, start_fsb, 1, &imap, &nimaps,
720 XFS_BMAPI_ENTIRE);
721 715
722 if (error) { 716 while (got.br_startoff + got.br_blockcount > start_fsb) {
723 /* something screwed, just bail */ 717 del = got;
724 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) { 718 xfs_trim_extent(&del, start_fsb, length);
725 xfs_alert(ip->i_mount,
726 "Failed delalloc mapping lookup ino %lld fsb %lld.",
727 ip->i_ino, start_fsb);
728 }
729 break;
730 }
731 if (!nimaps) {
732 /* nothing there */
733 goto next_block;
734 }
735 if (imap.br_startblock != DELAYSTARTBLOCK) {
736 /* been converted, ignore */
737 goto next_block;
738 }
739 WARN_ON(imap.br_blockcount == 0);
740 719
741 /* 720 /*
742 * Note: while we initialise the firstblock/dfops pair, they 721 * A delete can push the cursor forward. Step back to the
743 * should never be used because blocks should never be 722 * previous extent on non-delalloc or extents outside the
744 * allocated or freed for a delalloc extent and hence we need 723 * target range.
745 * don't cancel or finish them after the xfs_bunmapi() call.
746 */ 724 */
747 xfs_defer_init(&dfops, &firstblock); 725 if (!del.br_blockcount ||
748 error = xfs_bunmapi(NULL, ip, start_fsb, 1, 0, 1, &firstblock, 726 !isnullstartblock(del.br_startblock)) {
749 &dfops, &done); 727 if (!xfs_iext_prev_extent(ifp, &icur, &got))
750 if (error) 728 break;
751 break; 729 continue;
730 }
752 731
753 ASSERT(!xfs_defer_has_unfinished_work(&dfops)); 732 error = xfs_bmap_del_extent_delay(ip, XFS_DATA_FORK, &icur,
754next_block: 733 &got, &del);
755 start_fsb++; 734 if (error || !xfs_iext_get_extent(ifp, &icur, &got))
756 remaining--; 735 break;
757 } while(remaining > 0); 736 }
758 737
759 return error; 738 return error;
760} 739}
@@ -1208,7 +1187,22 @@ xfs_free_file_space(
1208 return 0; 1187 return 0;
1209 if (offset + len > XFS_ISIZE(ip)) 1188 if (offset + len > XFS_ISIZE(ip))
1210 len = XFS_ISIZE(ip) - offset; 1189 len = XFS_ISIZE(ip) - offset;
1211 return iomap_zero_range(VFS_I(ip), offset, len, NULL, &xfs_iomap_ops); 1190 error = iomap_zero_range(VFS_I(ip), offset, len, NULL, &xfs_iomap_ops);
1191 if (error)
1192 return error;
1193
1194 /*
1195 * If we zeroed right up to EOF and EOF straddles a page boundary we
1196 * must make sure that the post-EOF area is also zeroed because the
1197 * page could be mmap'd and iomap_zero_range doesn't do that for us.
1198 * Writeback of the eof page will do this, albeit clumsily.
1199 */
1200 if (offset + len >= XFS_ISIZE(ip) && ((offset + len) & PAGE_MASK)) {
1201 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1202 (offset + len) & ~PAGE_MASK, LLONG_MAX);
1203 }
1204
1205 return error;
1212} 1206}
1213 1207
1214/* 1208/*
@@ -1404,6 +1398,10 @@ xfs_insert_file_space(
1404 1398
1405 trace_xfs_insert_file_space(ip); 1399 trace_xfs_insert_file_space(ip);
1406 1400
1401 error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb);
1402 if (error)
1403 return error;
1404
1407 error = xfs_prepare_shift(ip, offset); 1405 error = xfs_prepare_shift(ip, offset);
1408 if (error) 1406 if (error)
1409 return error; 1407 return error;
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index c34fa9c342f2..c7157bc48bd1 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -513,8 +513,8 @@ xfs_getfsmap_rtdev_rtbitmap_query(
513 struct xfs_trans *tp, 513 struct xfs_trans *tp,
514 struct xfs_getfsmap_info *info) 514 struct xfs_getfsmap_info *info)
515{ 515{
516 struct xfs_rtalloc_rec alow; 516 struct xfs_rtalloc_rec alow = { 0 };
517 struct xfs_rtalloc_rec ahigh; 517 struct xfs_rtalloc_rec ahigh = { 0 };
518 int error; 518 int error;
519 519
520 xfs_ilock(tp->t_mountp->m_rbmip, XFS_ILOCK_SHARED); 520 xfs_ilock(tp->t_mountp->m_rbmip, XFS_ILOCK_SHARED);
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index a7afcad6b711..3f2bd6032cf8 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -387,7 +387,7 @@ xfs_reserve_blocks(
387 do { 387 do {
388 free = percpu_counter_sum(&mp->m_fdblocks) - 388 free = percpu_counter_sum(&mp->m_fdblocks) -
389 mp->m_alloc_set_aside; 389 mp->m_alloc_set_aside;
390 if (!free) 390 if (free <= 0)
391 break; 391 break;
392 392
393 delta = request - mp->m_resblks; 393 delta = request - mp->m_resblks;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 7a96c4e0ab5c..5df4de666cc1 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3236,7 +3236,6 @@ xfs_iflush_cluster(
3236 struct xfs_inode *cip; 3236 struct xfs_inode *cip;
3237 int nr_found; 3237 int nr_found;
3238 int clcount = 0; 3238 int clcount = 0;
3239 int bufwasdelwri;
3240 int i; 3239 int i;
3241 3240
3242 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); 3241 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
@@ -3360,37 +3359,22 @@ cluster_corrupt_out:
3360 * inode buffer and shut down the filesystem. 3359 * inode buffer and shut down the filesystem.
3361 */ 3360 */
3362 rcu_read_unlock(); 3361 rcu_read_unlock();
3363 /*
3364 * Clean up the buffer. If it was delwri, just release it --
3365 * brelse can handle it with no problems. If not, shut down the
3366 * filesystem before releasing the buffer.
3367 */
3368 bufwasdelwri = (bp->b_flags & _XBF_DELWRI_Q);
3369 if (bufwasdelwri)
3370 xfs_buf_relse(bp);
3371
3372 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 3362 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
3373 3363
3374 if (!bufwasdelwri) {
3375 /*
3376 * Just like incore_relse: if we have b_iodone functions,
3377 * mark the buffer as an error and call them. Otherwise
3378 * mark it as stale and brelse.
3379 */
3380 if (bp->b_iodone) {
3381 bp->b_flags &= ~XBF_DONE;
3382 xfs_buf_stale(bp);
3383 xfs_buf_ioerror(bp, -EIO);
3384 xfs_buf_ioend(bp);
3385 } else {
3386 xfs_buf_stale(bp);
3387 xfs_buf_relse(bp);
3388 }
3389 }
3390
3391 /* 3364 /*
3392 * Unlocks the flush lock 3365 * We'll always have an inode attached to the buffer for completion
3366 * process by the time we are called from xfs_iflush(). Hence we have
3367 * always need to do IO completion processing to abort the inodes
3368 * attached to the buffer. handle them just like the shutdown case in
3369 * xfs_buf_submit().
3393 */ 3370 */
3371 ASSERT(bp->b_iodone);
3372 bp->b_flags &= ~XBF_DONE;
3373 xfs_buf_stale(bp);
3374 xfs_buf_ioerror(bp, -EIO);
3375 xfs_buf_ioend(bp);
3376
3377 /* abort the corrupt inode, as it was not attached to the buffer */
3394 xfs_iflush_abort(cip, false); 3378 xfs_iflush_abort(cip, false);
3395 kmem_free(cilist); 3379 kmem_free(cilist);
3396 xfs_perag_put(pag); 3380 xfs_perag_put(pag);
@@ -3486,12 +3470,17 @@ xfs_iflush(
3486 xfs_log_force(mp, 0); 3470 xfs_log_force(mp, 0);
3487 3471
3488 /* 3472 /*
3489 * inode clustering: 3473 * inode clustering: try to gather other inodes into this write
3490 * see if other inodes can be gathered into this write 3474 *
3475 * Note: Any error during clustering will result in the filesystem
3476 * being shut down and completion callbacks run on the cluster buffer.
3477 * As we have already flushed and attached this inode to the buffer,
3478 * it has already been aborted and released by xfs_iflush_cluster() and
3479 * so we have no further error handling to do here.
3491 */ 3480 */
3492 error = xfs_iflush_cluster(ip, bp); 3481 error = xfs_iflush_cluster(ip, bp);
3493 if (error) 3482 if (error)
3494 goto cluster_corrupt_out; 3483 return error;
3495 3484
3496 *bpp = bp; 3485 *bpp = bp;
3497 return 0; 3486 return 0;
@@ -3500,12 +3489,8 @@ corrupt_out:
3500 if (bp) 3489 if (bp)
3501 xfs_buf_relse(bp); 3490 xfs_buf_relse(bp);
3502 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 3491 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
3503cluster_corrupt_out:
3504 error = -EFSCORRUPTED;
3505abort_out: 3492abort_out:
3506 /* 3493 /* abort the corrupt inode, as it was not attached to the buffer */
3507 * Unlocks the flush lock
3508 */
3509 xfs_iflush_abort(ip, false); 3494 xfs_iflush_abort(ip, false);
3510 return error; 3495 return error;
3511} 3496}
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 49f5492eed3b..55876dd02f0c 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -963,12 +963,13 @@ xfs_ilock_for_iomap(
963 unsigned *lockmode) 963 unsigned *lockmode)
964{ 964{
965 unsigned mode = XFS_ILOCK_SHARED; 965 unsigned mode = XFS_ILOCK_SHARED;
966 bool is_write = flags & (IOMAP_WRITE | IOMAP_ZERO);
966 967
967 /* 968 /*
968 * COW writes may allocate delalloc space or convert unwritten COW 969 * COW writes may allocate delalloc space or convert unwritten COW
969 * extents, so we need to make sure to take the lock exclusively here. 970 * extents, so we need to make sure to take the lock exclusively here.
970 */ 971 */
971 if (xfs_is_reflink_inode(ip) && (flags & (IOMAP_WRITE | IOMAP_ZERO))) { 972 if (xfs_is_reflink_inode(ip) && is_write) {
972 /* 973 /*
973 * FIXME: It could still overwrite on unshared extents and not 974 * FIXME: It could still overwrite on unshared extents and not
974 * need allocation. 975 * need allocation.
@@ -989,6 +990,7 @@ xfs_ilock_for_iomap(
989 mode = XFS_ILOCK_EXCL; 990 mode = XFS_ILOCK_EXCL;
990 } 991 }
991 992
993relock:
992 if (flags & IOMAP_NOWAIT) { 994 if (flags & IOMAP_NOWAIT) {
993 if (!xfs_ilock_nowait(ip, mode)) 995 if (!xfs_ilock_nowait(ip, mode))
994 return -EAGAIN; 996 return -EAGAIN;
@@ -996,6 +998,17 @@ xfs_ilock_for_iomap(
996 xfs_ilock(ip, mode); 998 xfs_ilock(ip, mode);
997 } 999 }
998 1000
1001 /*
1002 * The reflink iflag could have changed since the earlier unlocked
1003 * check, so if we got ILOCK_SHARED for a write and but we're now a
1004 * reflink inode we have to switch to ILOCK_EXCL and relock.
1005 */
1006 if (mode == XFS_ILOCK_SHARED && is_write && xfs_is_reflink_inode(ip)) {
1007 xfs_iunlock(ip, mode);
1008 mode = XFS_ILOCK_EXCL;
1009 goto relock;
1010 }
1011
999 *lockmode = mode; 1012 *lockmode = mode;
1000 return 0; 1013 return 0;
1001} 1014}
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index e040af120b69..524f543c5b82 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -258,7 +258,12 @@ xfs_trans_alloc(
258 if (!(flags & XFS_TRANS_NO_WRITECOUNT)) 258 if (!(flags & XFS_TRANS_NO_WRITECOUNT))
259 sb_start_intwrite(mp->m_super); 259 sb_start_intwrite(mp->m_super);
260 260
261 WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE); 261 /*
262 * Zero-reservation ("empty") transactions can't modify anything, so
263 * they're allowed to run while we're frozen.
264 */
265 WARN_ON(resp->tr_logres > 0 &&
266 mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
262 atomic_inc(&mp->m_active_trans); 267 atomic_inc(&mp->m_active_trans);
263 268
264 tp = kmem_zone_zalloc(xfs_trans_zone, 269 tp = kmem_zone_zalloc(xfs_trans_zone,
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 40a916efd7c0..1194a4c78d55 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -309,7 +309,7 @@ static inline void acpi_processor_ppc_exit(void)
309{ 309{
310 return; 310 return;
311} 311}
312static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr, 312static inline void acpi_processor_ppc_has_changed(struct acpi_processor *pr,
313 int event_flag) 313 int event_flag)
314{ 314{
315 static unsigned int printout = 1; 315 static unsigned int printout = 1;
@@ -320,7 +320,6 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr,
320 "Consider compiling CPUfreq support into your kernel.\n"); 320 "Consider compiling CPUfreq support into your kernel.\n");
321 printout = 0; 321 printout = 0;
322 } 322 }
323 return 0;
324} 323}
325static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit) 324static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
326{ 325{
diff --git a/include/asm-generic/qspinlock_types.h b/include/asm-generic/qspinlock_types.h
index 0763f065b975..d10f1e7d6ba8 100644
--- a/include/asm-generic/qspinlock_types.h
+++ b/include/asm-generic/qspinlock_types.h
@@ -63,7 +63,7 @@ typedef struct qspinlock {
63/* 63/*
64 * Initializier 64 * Initializier
65 */ 65 */
66#define __ARCH_SPIN_LOCK_UNLOCKED { .val = ATOMIC_INIT(0) } 66#define __ARCH_SPIN_LOCK_UNLOCKED { { .val = ATOMIC_INIT(0) } }
67 67
68/* 68/*
69 * Bitfields in the atomic value: 69 * Bitfields in the atomic value:
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
index cc414db9da0a..482461d8931d 100644
--- a/include/crypto/if_alg.h
+++ b/include/crypto/if_alg.h
@@ -245,7 +245,8 @@ ssize_t af_alg_sendpage(struct socket *sock, struct page *page,
245 int offset, size_t size, int flags); 245 int offset, size_t size, int flags);
246void af_alg_free_resources(struct af_alg_async_req *areq); 246void af_alg_free_resources(struct af_alg_async_req *areq);
247void af_alg_async_cb(struct crypto_async_request *_req, int err); 247void af_alg_async_cb(struct crypto_async_request *_req, int err);
248__poll_t af_alg_poll_mask(struct socket *sock, __poll_t events); 248__poll_t af_alg_poll(struct file *file, struct socket *sock,
249 poll_table *wait);
249struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk, 250struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,
250 unsigned int areqlen); 251 unsigned int areqlen);
251int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags, 252int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,
diff --git a/include/dt-bindings/bus/ti-sysc.h b/include/dt-bindings/bus/ti-sysc.h
index 2c005376ac0e..7138384e2ef9 100644
--- a/include/dt-bindings/bus/ti-sysc.h
+++ b/include/dt-bindings/bus/ti-sysc.h
@@ -15,6 +15,8 @@
15/* SmartReflex sysc found on 36xx and later */ 15/* SmartReflex sysc found on 36xx and later */
16#define SYSC_OMAP3_SR_ENAWAKEUP (1 << 26) 16#define SYSC_OMAP3_SR_ENAWAKEUP (1 << 26)
17 17
18#define SYSC_DRA7_MCAN_ENAWAKEUP (1 << 4)
19
18/* SYSCONFIG STANDBYMODE/MIDLEMODE/SIDLEMODE supported by hardware */ 20/* SYSCONFIG STANDBYMODE/MIDLEMODE/SIDLEMODE supported by hardware */
19#define SYSC_IDLE_FORCE 0 21#define SYSC_IDLE_FORCE 0
20#define SYSC_IDLE_NO 1 22#define SYSC_IDLE_NO 1
diff --git a/include/dt-bindings/clock/dra7.h b/include/dt-bindings/clock/dra7.h
index 5e1061b15aed..d7549c57cac3 100644
--- a/include/dt-bindings/clock/dra7.h
+++ b/include/dt-bindings/clock/dra7.h
@@ -168,5 +168,6 @@
168#define DRA7_COUNTER_32K_CLKCTRL DRA7_CLKCTRL_INDEX(0x50) 168#define DRA7_COUNTER_32K_CLKCTRL DRA7_CLKCTRL_INDEX(0x50)
169#define DRA7_UART10_CLKCTRL DRA7_CLKCTRL_INDEX(0x80) 169#define DRA7_UART10_CLKCTRL DRA7_CLKCTRL_INDEX(0x80)
170#define DRA7_DCAN1_CLKCTRL DRA7_CLKCTRL_INDEX(0x88) 170#define DRA7_DCAN1_CLKCTRL DRA7_CLKCTRL_INDEX(0x88)
171#define DRA7_ADC_CLKCTRL DRA7_CLKCTRL_INDEX(0xa0)
171 172
172#endif 173#endif
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4b35a66383f9..e54f40974eb0 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -443,6 +443,9 @@ int acpi_check_resource_conflict(const struct resource *res);
443int acpi_check_region(resource_size_t start, resource_size_t n, 443int acpi_check_region(resource_size_t start, resource_size_t n,
444 const char *name); 444 const char *name);
445 445
446acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
447 u32 level);
448
446int acpi_resources_are_enforced(void); 449int acpi_resources_are_enforced(void);
447 450
448#ifdef CONFIG_HIBERNATION 451#ifdef CONFIG_HIBERNATION
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 0c27515d2cf6..8124815eb121 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -214,6 +214,7 @@ struct atmphy_ops {
214struct atm_skb_data { 214struct atm_skb_data {
215 struct atm_vcc *vcc; /* ATM VCC */ 215 struct atm_vcc *vcc; /* ATM VCC */
216 unsigned long atm_options; /* ATM layer options */ 216 unsigned long atm_options; /* ATM layer options */
217 unsigned int acct_truesize; /* truesize accounted to vcc */
217}; 218};
218 219
219#define VCC_HTABLE_SIZE 32 220#define VCC_HTABLE_SIZE 32
@@ -241,6 +242,20 @@ void vcc_insert_socket(struct sock *sk);
241 242
242void atm_dev_release_vccs(struct atm_dev *dev); 243void atm_dev_release_vccs(struct atm_dev *dev);
243 244
245static inline void atm_account_tx(struct atm_vcc *vcc, struct sk_buff *skb)
246{
247 /*
248 * Because ATM skbs may not belong to a sock (and we don't
249 * necessarily want to), skb->truesize may be adjusted,
250 * escaping the hack in pskb_expand_head() which avoids
251 * doing so for some cases. So stash the value of truesize
252 * at the time we accounted it, and atm_pop_raw() can use
253 * that value later, in case it changes.
254 */
255 refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
256 ATM_SKB(skb)->acct_truesize = skb->truesize;
257 ATM_SKB(skb)->atm_options = vcc->atm_options;
258}
244 259
245static inline void atm_force_charge(struct atm_vcc *vcc,int truesize) 260static inline void atm_force_charge(struct atm_vcc *vcc,int truesize)
246{ 261{
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index 0bd432a4d7bd..24251762c20c 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -22,7 +22,6 @@ struct dentry;
22 */ 22 */
23enum wb_state { 23enum wb_state {
24 WB_registered, /* bdi_register() was done */ 24 WB_registered, /* bdi_register() was done */
25 WB_shutting_down, /* wb_shutdown() in progress */
26 WB_writeback_running, /* Writeback is in progress */ 25 WB_writeback_running, /* Writeback is in progress */
27 WB_has_dirty_io, /* Dirty inodes on ->b_{dirty|io|more_io} */ 26 WB_has_dirty_io, /* Dirty inodes on ->b_{dirty|io|more_io} */
28 WB_start_all, /* nr_pages == 0 (all) work pending */ 27 WB_start_all, /* nr_pages == 0 (all) work pending */
@@ -189,6 +188,7 @@ struct backing_dev_info {
189#ifdef CONFIG_CGROUP_WRITEBACK 188#ifdef CONFIG_CGROUP_WRITEBACK
190 struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */ 189 struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */
191 struct rb_root cgwb_congested_tree; /* their congested states */ 190 struct rb_root cgwb_congested_tree; /* their congested states */
191 struct mutex cgwb_release_mutex; /* protect shutdown of wb structs */
192#else 192#else
193 struct bdi_writeback_congested *wb_congested; 193 struct bdi_writeback_congested *wb_congested;
194#endif 194#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 9154570edf29..79226ca8f80f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1119,8 +1119,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
1119 if (!q->limits.chunk_sectors) 1119 if (!q->limits.chunk_sectors)
1120 return q->limits.max_sectors; 1120 return q->limits.max_sectors;
1121 1121
1122 return q->limits.chunk_sectors - 1122 return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors -
1123 (offset & (q->limits.chunk_sectors - 1)); 1123 (offset & (q->limits.chunk_sectors - 1))));
1124} 1124}
1125 1125
1126static inline unsigned int blk_rq_get_max_sectors(struct request *rq, 1126static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 995c3b1e59bf..7df32a3200f7 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -488,12 +488,15 @@ void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth);
488 488
489/* Map specifics */ 489/* Map specifics */
490struct xdp_buff; 490struct xdp_buff;
491struct sk_buff;
491 492
492struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key); 493struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key);
493void __dev_map_insert_ctx(struct bpf_map *map, u32 index); 494void __dev_map_insert_ctx(struct bpf_map *map, u32 index);
494void __dev_map_flush(struct bpf_map *map); 495void __dev_map_flush(struct bpf_map *map);
495int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp, 496int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp,
496 struct net_device *dev_rx); 497 struct net_device *dev_rx);
498int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb,
499 struct bpf_prog *xdp_prog);
497 500
498struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key); 501struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key);
499void __cpu_map_insert_ctx(struct bpf_map *map, u32 index); 502void __cpu_map_insert_ctx(struct bpf_map *map, u32 index);
@@ -586,6 +589,15 @@ int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp,
586 return 0; 589 return 0;
587} 590}
588 591
592struct sk_buff;
593
594static inline int dev_map_generic_redirect(struct bpf_dtab_netdev *dst,
595 struct sk_buff *skb,
596 struct bpf_prog *xdp_prog)
597{
598 return 0;
599}
600
589static inline 601static inline
590struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key) 602struct bpf_cpu_map_entry *__cpu_map_lookup_elem(struct bpf_map *map, u32 key)
591{ 603{
diff --git a/include/linux/compat.h b/include/linux/compat.h
index b1a5562b3215..c68acc47da57 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -72,6 +72,9 @@
72 */ 72 */
73#ifndef COMPAT_SYSCALL_DEFINEx 73#ifndef COMPAT_SYSCALL_DEFINEx
74#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ 74#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
75 __diag_push(); \
76 __diag_ignore(GCC, 8, "-Wattribute-alias", \
77 "Type aliasing is used to sanitize syscall arguments");\
75 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ 78 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
76 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ 79 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
77 __attribute__((alias(__stringify(__se_compat_sys##name)))); \ 80 __attribute__((alias(__stringify(__se_compat_sys##name)))); \
@@ -80,8 +83,11 @@
80 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ 83 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
81 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ 84 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
82 { \ 85 { \
83 return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\ 86 long ret = __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
87 __MAP(x,__SC_TEST,__VA_ARGS__); \
88 return ret; \
84 } \ 89 } \
90 __diag_pop(); \
85 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 91 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
86#endif /* COMPAT_SYSCALL_DEFINEx */ 92#endif /* COMPAT_SYSCALL_DEFINEx */
87 93
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index f1a7492a5cc8..fd282c7d3e5e 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -347,3 +347,28 @@
347#if GCC_VERSION >= 50100 347#if GCC_VERSION >= 50100
348#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 348#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
349#endif 349#endif
350
351/*
352 * Turn individual warnings and errors on and off locally, depending
353 * on version.
354 */
355#define __diag_GCC(version, severity, s) \
356 __diag_GCC_ ## version(__diag_GCC_ ## severity s)
357
358/* Severity used in pragma directives */
359#define __diag_GCC_ignore ignored
360#define __diag_GCC_warn warning
361#define __diag_GCC_error error
362
363/* Compilers before gcc-4.6 do not understand "#pragma GCC diagnostic push" */
364#if GCC_VERSION >= 40600
365#define __diag_str1(s) #s
366#define __diag_str(s) __diag_str1(s)
367#define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
368#endif
369
370#if GCC_VERSION >= 80000
371#define __diag_GCC_8(s) __diag(s)
372#else
373#define __diag_GCC_8(s)
374#endif
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 6b79a9bba9a7..a8ba6b04152c 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -271,4 +271,22 @@ struct ftrace_likely_data {
271# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) 271# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long))
272#endif 272#endif
273 273
274#ifndef __diag
275#define __diag(string)
276#endif
277
278#ifndef __diag_GCC
279#define __diag_GCC(version, severity, string)
280#endif
281
282#define __diag_push() __diag(push)
283#define __diag_pop() __diag(pop)
284
285#define __diag_ignore(compiler, version, option, comment) \
286 __diag_ ## compiler(version, ignore, option)
287#define __diag_warn(compiler, version, option, comment) \
288 __diag_ ## compiler(version, warn, option)
289#define __diag_error(compiler, version, option, comment) \
290 __diag_ ## compiler(version, error, option)
291
274#endif /* __LINUX_COMPILER_TYPES_H */ 292#endif /* __LINUX_COMPILER_TYPES_H */
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 3855e3800f48..deb0f663252f 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -135,7 +135,7 @@ void dax_flush(struct dax_device *dax_dev, void *addr, size_t size);
135 135
136ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, 136ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
137 const struct iomap_ops *ops); 137 const struct iomap_ops *ops);
138int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, 138vm_fault_t dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
139 pfn_t *pfnp, int *errp, const struct iomap_ops *ops); 139 pfn_t *pfnp, int *errp, const struct iomap_ops *ops);
140vm_fault_t dax_finish_sync_fault(struct vm_fault *vmf, 140vm_fault_t dax_finish_sync_fault(struct vm_fault *vmf,
141 enum page_entry_size pe_size, pfn_t pfn); 141 enum page_entry_size pe_size, pfn_t pfn);
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
index b67bf6ac907d..3c5a4cb3eb95 100644
--- a/include/linux/dma-contiguous.h
+++ b/include/linux/dma-contiguous.h
@@ -48,7 +48,7 @@
48 * CMA should not be used by the device drivers directly. It is 48 * CMA should not be used by the device drivers directly. It is
49 * only a helper framework for dma-mapping subsystem. 49 * only a helper framework for dma-mapping subsystem.
50 * 50 *
51 * For more information, see kernel-docs in drivers/base/dma-contiguous.c 51 * For more information, see kernel-docs in kernel/dma/contiguous.c
52 */ 52 */
53 53
54#ifdef __KERNEL__ 54#ifdef __KERNEL__
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 45fc0f5000d8..20f2659dd829 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -19,6 +19,7 @@
19#include <linux/cryptohash.h> 19#include <linux/cryptohash.h>
20#include <linux/set_memory.h> 20#include <linux/set_memory.h>
21#include <linux/kallsyms.h> 21#include <linux/kallsyms.h>
22#include <linux/if_vlan.h>
22 23
23#include <net/sch_generic.h> 24#include <net/sch_generic.h>
24 25
@@ -469,8 +470,11 @@ struct sock_fprog_kern {
469}; 470};
470 471
471struct bpf_binary_header { 472struct bpf_binary_header {
472 unsigned int pages; 473 u16 pages;
473 u8 image[]; 474 u16 locked:1;
475
476 /* Some arches need word alignment for their instructions */
477 u8 image[] __aligned(4);
474}; 478};
475 479
476struct bpf_prog { 480struct bpf_prog {
@@ -671,15 +675,18 @@ bpf_ctx_narrow_access_ok(u32 off, u32 size, u32 size_default)
671 675
672#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0])) 676#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))
673 677
674#ifdef CONFIG_ARCH_HAS_SET_MEMORY
675static inline void bpf_prog_lock_ro(struct bpf_prog *fp) 678static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
676{ 679{
680#ifdef CONFIG_ARCH_HAS_SET_MEMORY
677 fp->locked = 1; 681 fp->locked = 1;
678 WARN_ON_ONCE(set_memory_ro((unsigned long)fp, fp->pages)); 682 if (set_memory_ro((unsigned long)fp, fp->pages))
683 fp->locked = 0;
684#endif
679} 685}
680 686
681static inline void bpf_prog_unlock_ro(struct bpf_prog *fp) 687static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
682{ 688{
689#ifdef CONFIG_ARCH_HAS_SET_MEMORY
683 if (fp->locked) { 690 if (fp->locked) {
684 WARN_ON_ONCE(set_memory_rw((unsigned long)fp, fp->pages)); 691 WARN_ON_ONCE(set_memory_rw((unsigned long)fp, fp->pages));
685 /* In case set_memory_rw() fails, we want to be the first 692 /* In case set_memory_rw() fails, we want to be the first
@@ -687,34 +694,30 @@ static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
687 */ 694 */
688 fp->locked = 0; 695 fp->locked = 0;
689 } 696 }
697#endif
690} 698}
691 699
692static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr) 700static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
693{ 701{
694 WARN_ON_ONCE(set_memory_ro((unsigned long)hdr, hdr->pages)); 702#ifdef CONFIG_ARCH_HAS_SET_MEMORY
695} 703 hdr->locked = 1;
696 704 if (set_memory_ro((unsigned long)hdr, hdr->pages))
697static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 705 hdr->locked = 0;
698{ 706#endif
699 WARN_ON_ONCE(set_memory_rw((unsigned long)hdr, hdr->pages));
700}
701#else
702static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
703{
704}
705
706static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
707{
708}
709
710static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
711{
712} 707}
713 708
714static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 709static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr)
715{ 710{
711#ifdef CONFIG_ARCH_HAS_SET_MEMORY
712 if (hdr->locked) {
713 WARN_ON_ONCE(set_memory_rw((unsigned long)hdr, hdr->pages));
714 /* In case set_memory_rw() fails, we want to be the first
715 * to crash here instead of some random place later on.
716 */
717 hdr->locked = 0;
718 }
719#endif
716} 720}
717#endif /* CONFIG_ARCH_HAS_SET_MEMORY */
718 721
719static inline struct bpf_binary_header * 722static inline struct bpf_binary_header *
720bpf_jit_binary_hdr(const struct bpf_prog *fp) 723bpf_jit_binary_hdr(const struct bpf_prog *fp)
@@ -725,6 +728,22 @@ bpf_jit_binary_hdr(const struct bpf_prog *fp)
725 return (void *)addr; 728 return (void *)addr;
726} 729}
727 730
731#ifdef CONFIG_ARCH_HAS_SET_MEMORY
732static inline int bpf_prog_check_pages_ro_single(const struct bpf_prog *fp)
733{
734 if (!fp->locked)
735 return -ENOLCK;
736 if (fp->jited) {
737 const struct bpf_binary_header *hdr = bpf_jit_binary_hdr(fp);
738
739 if (!hdr->locked)
740 return -ENOLCK;
741 }
742
743 return 0;
744}
745#endif
746
728int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap); 747int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap);
729static inline int sk_filter(struct sock *sk, struct sk_buff *skb) 748static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
730{ 749{
@@ -786,6 +805,21 @@ static inline bool bpf_dump_raw_ok(void)
786struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, 805struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
787 const struct bpf_insn *patch, u32 len); 806 const struct bpf_insn *patch, u32 len);
788 807
808static inline int __xdp_generic_ok_fwd_dev(struct sk_buff *skb,
809 struct net_device *fwd)
810{
811 unsigned int len;
812
813 if (unlikely(!(fwd->flags & IFF_UP)))
814 return -ENETDOWN;
815
816 len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN;
817 if (skb->len > len)
818 return -EMSGSIZE;
819
820 return 0;
821}
822
789/* The pair of xdp_do_redirect and xdp_do_flush_map MUST be called in the 823/* The pair of xdp_do_redirect and xdp_do_flush_map MUST be called in the
790 * same cpu context. Further for best results no more than a single map 824 * same cpu context. Further for best results no more than a single map
791 * for the do_redirect/do_flush pair should be used. This limitation is 825 * for the do_redirect/do_flush pair should be used. This limitation is
@@ -961,6 +995,9 @@ static inline void bpf_prog_kallsyms_del(struct bpf_prog *fp)
961} 995}
962#endif /* CONFIG_BPF_JIT */ 996#endif /* CONFIG_BPF_JIT */
963 997
998void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp);
999void bpf_prog_kallsyms_del_all(struct bpf_prog *fp);
1000
964#define BPF_ANC BIT(15) 1001#define BPF_ANC BIT(15)
965 1002
966static inline bool bpf_needs_clear_a(const struct sock_filter *first) 1003static inline bool bpf_needs_clear_a(const struct sock_filter *first)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5c91108846db..d78d146a98da 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1720,8 +1720,6 @@ struct file_operations {
1720 int (*iterate) (struct file *, struct dir_context *); 1720 int (*iterate) (struct file *, struct dir_context *);
1721 int (*iterate_shared) (struct file *, struct dir_context *); 1721 int (*iterate_shared) (struct file *, struct dir_context *);
1722 __poll_t (*poll) (struct file *, struct poll_table_struct *); 1722 __poll_t (*poll) (struct file *, struct poll_table_struct *);
1723 struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
1724 __poll_t (*poll_mask) (struct file *, __poll_t);
1725 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1723 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
1726 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1724 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
1727 int (*mmap) (struct file *, struct vm_area_struct *); 1725 int (*mmap) (struct file *, struct vm_area_struct *);
diff --git a/include/linux/iio/buffer-dma.h b/include/linux/iio/buffer-dma.h
index 767467d886de..67c75372b691 100644
--- a/include/linux/iio/buffer-dma.h
+++ b/include/linux/iio/buffer-dma.h
@@ -141,7 +141,7 @@ int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n,
141 char __user *user_buffer); 141 char __user *user_buffer);
142size_t iio_dma_buffer_data_available(struct iio_buffer *buffer); 142size_t iio_dma_buffer_data_available(struct iio_buffer *buffer);
143int iio_dma_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd); 143int iio_dma_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd);
144int iio_dma_buffer_set_length(struct iio_buffer *buffer, int length); 144int iio_dma_buffer_set_length(struct iio_buffer *buffer, unsigned int length);
145int iio_dma_buffer_request_update(struct iio_buffer *buffer); 145int iio_dma_buffer_request_update(struct iio_buffer *buffer);
146 146
147int iio_dma_buffer_init(struct iio_dma_buffer_queue *queue, 147int iio_dma_buffer_init(struct iio_dma_buffer_queue *queue,
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index d7188de4db96..3f4bf60b0bb5 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -100,7 +100,7 @@ static inline bool input_is_mt_axis(int axis)
100 return axis == ABS_MT_SLOT || input_is_mt_value(axis); 100 return axis == ABS_MT_SLOT || input_is_mt_value(axis);
101} 101}
102 102
103void input_mt_report_slot_state(struct input_dev *dev, 103bool input_mt_report_slot_state(struct input_dev *dev,
104 unsigned int tool_type, bool active); 104 unsigned int tool_type, bool active);
105 105
106void input_mt_report_finger_count(struct input_dev *dev, int count); 106void input_mt_report_finger_count(struct input_dev *dev, int count);
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 4bd2f34947f4..201de12a9957 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -503,6 +503,7 @@ struct irq_chip {
503 * IRQCHIP_SKIP_SET_WAKE: Skip chip.irq_set_wake(), for this irq chip 503 * IRQCHIP_SKIP_SET_WAKE: Skip chip.irq_set_wake(), for this irq chip
504 * IRQCHIP_ONESHOT_SAFE: One shot does not require mask/unmask 504 * IRQCHIP_ONESHOT_SAFE: One shot does not require mask/unmask
505 * IRQCHIP_EOI_THREADED: Chip requires eoi() on unmask in threaded mode 505 * IRQCHIP_EOI_THREADED: Chip requires eoi() on unmask in threaded mode
506 * IRQCHIP_SUPPORTS_LEVEL_MSI Chip can provide two doorbells for Level MSIs
506 */ 507 */
507enum { 508enum {
508 IRQCHIP_SET_TYPE_MASKED = (1 << 0), 509 IRQCHIP_SET_TYPE_MASKED = (1 << 0),
diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index 25b33b664537..dd1e40ddac7d 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -145,11 +145,6 @@ static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
145 return desc->irq_common_data.handler_data; 145 return desc->irq_common_data.handler_data;
146} 146}
147 147
148static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
149{
150 return desc->irq_common_data.msi_desc;
151}
152
153/* 148/*
154 * Architectures call this to let the generic IRQ layer 149 * Architectures call this to let the generic IRQ layer
155 * handle an interrupt. 150 * handle an interrupt.
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d23123238534..941dc0a5a877 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -666,7 +666,7 @@ do { \
666 * your code. (Extra memory is used for special buffers that are 666 * your code. (Extra memory is used for special buffers that are
667 * allocated when trace_printk() is used.) 667 * allocated when trace_printk() is used.)
668 * 668 *
669 * A little optization trick is done here. If there's only one 669 * A little optimization trick is done here. If there's only one
670 * argument, there's no need to scan the string for printf formats. 670 * argument, there's no need to scan the string for printf formats.
671 * The trace_puts() will suffice. But how can we take advantage of 671 * The trace_puts() will suffice. But how can we take advantage of
672 * using trace_puts() when trace_printk() has only one argument? 672 * using trace_puts() when trace_printk() has only one argument?
diff --git a/include/linux/memory.h b/include/linux/memory.h
index 31ca3e28b0eb..a6ddefc60517 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -38,6 +38,7 @@ struct memory_block {
38 38
39int arch_get_memory_phys_device(unsigned long start_pfn); 39int arch_get_memory_phys_device(unsigned long start_pfn);
40unsigned long memory_block_size_bytes(void); 40unsigned long memory_block_size_bytes(void);
41int set_memory_block_size_order(unsigned int order);
41 42
42/* These states are exposed to userspace as text strings in sysfs */ 43/* These states are exposed to userspace as text strings in sysfs */
43#define MEM_ONLINE (1<<0) /* exposed to userspace */ 44#define MEM_ONLINE (1<<0) /* exposed to userspace */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 2014bd19f28e..96a71a648eed 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -501,6 +501,7 @@ enum dmi_field {
501 DMI_PRODUCT_VERSION, 501 DMI_PRODUCT_VERSION,
502 DMI_PRODUCT_SERIAL, 502 DMI_PRODUCT_SERIAL,
503 DMI_PRODUCT_UUID, 503 DMI_PRODUCT_UUID,
504 DMI_PRODUCT_SKU,
504 DMI_PRODUCT_FAMILY, 505 DMI_PRODUCT_FAMILY,
505 DMI_BOARD_VENDOR, 506 DMI_BOARD_VENDOR,
506 DMI_BOARD_NAME, 507 DMI_BOARD_NAME,
diff --git a/include/linux/net.h b/include/linux/net.h
index 08b6eb964dd6..6554d3ba4396 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -147,7 +147,6 @@ struct proto_ops {
147 int (*getname) (struct socket *sock, 147 int (*getname) (struct socket *sock,
148 struct sockaddr *addr, 148 struct sockaddr *addr,
149 int peer); 149 int peer);
150 __poll_t (*poll_mask) (struct socket *sock, __poll_t events);
151 __poll_t (*poll) (struct file *file, struct socket *sock, 150 __poll_t (*poll) (struct file *file, struct socket *sock,
152 struct poll_table_struct *wait); 151 struct poll_table_struct *wait);
153 int (*ioctl) (struct socket *sock, unsigned int cmd, 152 int (*ioctl) (struct socket *sock, unsigned int cmd,
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 9dee3c23895d..712eed156d09 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1438,6 +1438,8 @@ enum {
1438 NFS_IOHDR_EOF, 1438 NFS_IOHDR_EOF,
1439 NFS_IOHDR_REDO, 1439 NFS_IOHDR_REDO,
1440 NFS_IOHDR_STAT, 1440 NFS_IOHDR_STAT,
1441 NFS_IOHDR_RESEND_PNFS,
1442 NFS_IOHDR_RESEND_MDS,
1441}; 1443};
1442 1444
1443struct nfs_io_completion; 1445struct nfs_io_completion;
diff --git a/include/linux/platform_data/ti-sysc.h b/include/linux/platform_data/ti-sysc.h
index 990aad477458..2efa3470a451 100644
--- a/include/linux/platform_data/ti-sysc.h
+++ b/include/linux/platform_data/ti-sysc.h
@@ -14,6 +14,7 @@ enum ti_sysc_module_type {
14 TI_SYSC_OMAP4_SR, 14 TI_SYSC_OMAP4_SR,
15 TI_SYSC_OMAP4_MCASP, 15 TI_SYSC_OMAP4_MCASP,
16 TI_SYSC_OMAP4_USB_HOST_FS, 16 TI_SYSC_OMAP4_USB_HOST_FS,
17 TI_SYSC_DRA7_MCAN,
17}; 18};
18 19
19struct ti_sysc_cookie { 20struct ti_sysc_cookie {
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 9206a4fef9ac..cb8d84090cfb 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -234,7 +234,7 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
234int of_genpd_parse_idle_states(struct device_node *dn, 234int of_genpd_parse_idle_states(struct device_node *dn,
235 struct genpd_power_state **states, int *n); 235 struct genpd_power_state **states, int *n);
236unsigned int of_genpd_opp_to_performance_state(struct device *dev, 236unsigned int of_genpd_opp_to_performance_state(struct device *dev,
237 struct device_node *opp_node); 237 struct device_node *np);
238 238
239int genpd_dev_pm_attach(struct device *dev); 239int genpd_dev_pm_attach(struct device *dev);
240struct device *genpd_dev_pm_attach_by_id(struct device *dev, 240struct device *genpd_dev_pm_attach_by_id(struct device *dev,
@@ -274,9 +274,9 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn,
274 274
275static inline unsigned int 275static inline unsigned int
276of_genpd_opp_to_performance_state(struct device *dev, 276of_genpd_opp_to_performance_state(struct device *dev,
277 struct device_node *opp_node) 277 struct device_node *np)
278{ 278{
279 return -ENODEV; 279 return 0;
280} 280}
281 281
282static inline int genpd_dev_pm_attach(struct device *dev) 282static inline int genpd_dev_pm_attach(struct device *dev)
diff --git a/include/linux/poll.h b/include/linux/poll.h
index fdf86b4cbc71..7e0fdcf905d2 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -74,18 +74,18 @@ static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
74 pt->_key = ~(__poll_t)0; /* all events enabled */ 74 pt->_key = ~(__poll_t)0; /* all events enabled */
75} 75}
76 76
77static inline bool file_has_poll_mask(struct file *file) 77static inline bool file_can_poll(struct file *file)
78{ 78{
79 return file->f_op->get_poll_head && file->f_op->poll_mask; 79 return file->f_op->poll;
80} 80}
81 81
82static inline bool file_can_poll(struct file *file) 82static inline __poll_t vfs_poll(struct file *file, struct poll_table_struct *pt)
83{ 83{
84 return file->f_op->poll || file_has_poll_mask(file); 84 if (unlikely(!file->f_op->poll))
85 return DEFAULT_POLLMASK;
86 return file->f_op->poll(file, pt);
85} 87}
86 88
87__poll_t vfs_poll(struct file *file, struct poll_table_struct *pt);
88
89struct poll_table_entry { 89struct poll_table_entry {
90 struct file *filp; 90 struct file *filp;
91 __poll_t key; 91 __poll_t key;
diff --git a/include/linux/refcount.h b/include/linux/refcount.h
index 4193c41e383a..a685da2c4522 100644
--- a/include/linux/refcount.h
+++ b/include/linux/refcount.h
@@ -98,5 +98,7 @@ extern __must_check bool refcount_dec_if_one(refcount_t *r);
98extern __must_check bool refcount_dec_not_one(refcount_t *r); 98extern __must_check bool refcount_dec_not_one(refcount_t *r);
99extern __must_check bool refcount_dec_and_mutex_lock(refcount_t *r, struct mutex *lock); 99extern __must_check bool refcount_dec_and_mutex_lock(refcount_t *r, struct mutex *lock);
100extern __must_check bool refcount_dec_and_lock(refcount_t *r, spinlock_t *lock); 100extern __must_check bool refcount_dec_and_lock(refcount_t *r, spinlock_t *lock);
101 101extern __must_check bool refcount_dec_and_lock_irqsave(refcount_t *r,
102 spinlock_t *lock,
103 unsigned long *flags);
102#endif /* _LINUX_REFCOUNT_H */ 104#endif /* _LINUX_REFCOUNT_H */
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 64125443f8a6..5ef5c7c412a7 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -354,6 +354,8 @@ struct rmi_driver_data {
354 struct mutex irq_mutex; 354 struct mutex irq_mutex;
355 struct input_dev *input; 355 struct input_dev *input;
356 356
357 struct irq_domain *irqdomain;
358
357 u8 pdt_props; 359 u8 pdt_props;
358 360
359 u8 num_rx_electrodes; 361 u8 num_rx_electrodes;
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 51f52020ad5f..093aa57120b0 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -9,9 +9,6 @@
9#include <asm/io.h> 9#include <asm/io.h>
10 10
11struct scatterlist { 11struct scatterlist {
12#ifdef CONFIG_DEBUG_SG
13 unsigned long sg_magic;
14#endif
15 unsigned long page_link; 12 unsigned long page_link;
16 unsigned int offset; 13 unsigned int offset;
17 unsigned int length; 14 unsigned int length;
@@ -64,7 +61,6 @@ struct sg_table {
64 * 61 *
65 */ 62 */
66 63
67#define SG_MAGIC 0x87654321
68#define SG_CHAIN 0x01UL 64#define SG_CHAIN 0x01UL
69#define SG_END 0x02UL 65#define SG_END 0x02UL
70 66
@@ -98,7 +94,6 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
98 */ 94 */
99 BUG_ON((unsigned long) page & (SG_CHAIN | SG_END)); 95 BUG_ON((unsigned long) page & (SG_CHAIN | SG_END));
100#ifdef CONFIG_DEBUG_SG 96#ifdef CONFIG_DEBUG_SG
101 BUG_ON(sg->sg_magic != SG_MAGIC);
102 BUG_ON(sg_is_chain(sg)); 97 BUG_ON(sg_is_chain(sg));
103#endif 98#endif
104 sg->page_link = page_link | (unsigned long) page; 99 sg->page_link = page_link | (unsigned long) page;
@@ -129,7 +124,6 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
129static inline struct page *sg_page(struct scatterlist *sg) 124static inline struct page *sg_page(struct scatterlist *sg)
130{ 125{
131#ifdef CONFIG_DEBUG_SG 126#ifdef CONFIG_DEBUG_SG
132 BUG_ON(sg->sg_magic != SG_MAGIC);
133 BUG_ON(sg_is_chain(sg)); 127 BUG_ON(sg_is_chain(sg));
134#endif 128#endif
135 return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_END)); 129 return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_END));
@@ -195,9 +189,6 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
195 **/ 189 **/
196static inline void sg_mark_end(struct scatterlist *sg) 190static inline void sg_mark_end(struct scatterlist *sg)
197{ 191{
198#ifdef CONFIG_DEBUG_SG
199 BUG_ON(sg->sg_magic != SG_MAGIC);
200#endif
201 /* 192 /*
202 * Set termination bit, clear potential chain bit 193 * Set termination bit, clear potential chain bit
203 */ 194 */
@@ -215,9 +206,6 @@ static inline void sg_mark_end(struct scatterlist *sg)
215 **/ 206 **/
216static inline void sg_unmark_end(struct scatterlist *sg) 207static inline void sg_unmark_end(struct scatterlist *sg)
217{ 208{
218#ifdef CONFIG_DEBUG_SG
219 BUG_ON(sg->sg_magic != SG_MAGIC);
220#endif
221 sg->page_link &= ~SG_END; 209 sg->page_link &= ~SG_END;
222} 210}
223 211
@@ -260,12 +248,6 @@ static inline void *sg_virt(struct scatterlist *sg)
260static inline void sg_init_marker(struct scatterlist *sgl, 248static inline void sg_init_marker(struct scatterlist *sgl,
261 unsigned int nents) 249 unsigned int nents)
262{ 250{
263#ifdef CONFIG_DEBUG_SG
264 unsigned int i;
265
266 for (i = 0; i < nents; i++)
267 sgl[i].sg_magic = SG_MAGIC;
268#endif
269 sg_mark_end(&sgl[nents - 1]); 251 sg_mark_end(&sgl[nents - 1]);
270} 252}
271 253
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 87bf02d93a27..9256118bd40c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1799,20 +1799,22 @@ static inline void rseq_set_notify_resume(struct task_struct *t)
1799 set_tsk_thread_flag(t, TIF_NOTIFY_RESUME); 1799 set_tsk_thread_flag(t, TIF_NOTIFY_RESUME);
1800} 1800}
1801 1801
1802void __rseq_handle_notify_resume(struct pt_regs *regs); 1802void __rseq_handle_notify_resume(struct ksignal *sig, struct pt_regs *regs);
1803 1803
1804static inline void rseq_handle_notify_resume(struct pt_regs *regs) 1804static inline void rseq_handle_notify_resume(struct ksignal *ksig,
1805 struct pt_regs *regs)
1805{ 1806{
1806 if (current->rseq) 1807 if (current->rseq)
1807 __rseq_handle_notify_resume(regs); 1808 __rseq_handle_notify_resume(ksig, regs);
1808} 1809}
1809 1810
1810static inline void rseq_signal_deliver(struct pt_regs *regs) 1811static inline void rseq_signal_deliver(struct ksignal *ksig,
1812 struct pt_regs *regs)
1811{ 1813{
1812 preempt_disable(); 1814 preempt_disable();
1813 __set_bit(RSEQ_EVENT_SIGNAL_BIT, &current->rseq_event_mask); 1815 __set_bit(RSEQ_EVENT_SIGNAL_BIT, &current->rseq_event_mask);
1814 preempt_enable(); 1816 preempt_enable();
1815 rseq_handle_notify_resume(regs); 1817 rseq_handle_notify_resume(ksig, regs);
1816} 1818}
1817 1819
1818/* rseq_preempt() requires preemption to be disabled. */ 1820/* rseq_preempt() requires preemption to be disabled. */
@@ -1831,9 +1833,7 @@ static inline void rseq_migrate(struct task_struct *t)
1831 1833
1832/* 1834/*
1833 * If parent process has a registered restartable sequences area, the 1835 * If parent process has a registered restartable sequences area, the
1834 * child inherits. Only applies when forking a process, not a thread. In 1836 * child inherits. Only applies when forking a process, not a thread.
1835 * case a parent fork() in the middle of a restartable sequence, set the
1836 * resume notifier to force the child to retry.
1837 */ 1837 */
1838static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags) 1838static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags)
1839{ 1839{
@@ -1847,7 +1847,6 @@ static inline void rseq_fork(struct task_struct *t, unsigned long clone_flags)
1847 t->rseq_len = current->rseq_len; 1847 t->rseq_len = current->rseq_len;
1848 t->rseq_sig = current->rseq_sig; 1848 t->rseq_sig = current->rseq_sig;
1849 t->rseq_event_mask = current->rseq_event_mask; 1849 t->rseq_event_mask = current->rseq_event_mask;
1850 rseq_preempt(t);
1851 } 1850 }
1852} 1851}
1853 1852
@@ -1864,10 +1863,12 @@ static inline void rseq_execve(struct task_struct *t)
1864static inline void rseq_set_notify_resume(struct task_struct *t) 1863static inline void rseq_set_notify_resume(struct task_struct *t)
1865{ 1864{
1866} 1865}
1867static inline void rseq_handle_notify_resume(struct pt_regs *regs) 1866static inline void rseq_handle_notify_resume(struct ksignal *ksig,
1867 struct pt_regs *regs)
1868{ 1868{
1869} 1869}
1870static inline void rseq_signal_deliver(struct pt_regs *regs) 1870static inline void rseq_signal_deliver(struct ksignal *ksig,
1871 struct pt_regs *regs)
1871{ 1872{
1872} 1873}
1873static inline void rseq_preempt(struct task_struct *t) 1874static inline void rseq_preempt(struct task_struct *t)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c86885954994..164cdedf6012 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3252,7 +3252,8 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
3252 int *peeked, int *off, int *err); 3252 int *peeked, int *off, int *err);
3253struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock, 3253struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
3254 int *err); 3254 int *err);
3255__poll_t datagram_poll_mask(struct socket *sock, __poll_t events); 3255__poll_t datagram_poll(struct file *file, struct socket *sock,
3256 struct poll_table_struct *wait);
3256int skb_copy_datagram_iter(const struct sk_buff *from, int offset, 3257int skb_copy_datagram_iter(const struct sk_buff *from, int offset,
3257 struct iov_iter *to, int size); 3258 struct iov_iter *to, int size);
3258static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset, 3259static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 09fa2c6f0e68..3a1a1dbc6f49 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -155,8 +155,12 @@ struct kmem_cache {
155 155
156#ifdef CONFIG_SYSFS 156#ifdef CONFIG_SYSFS
157#define SLAB_SUPPORTS_SYSFS 157#define SLAB_SUPPORTS_SYSFS
158void sysfs_slab_unlink(struct kmem_cache *);
158void sysfs_slab_release(struct kmem_cache *); 159void sysfs_slab_release(struct kmem_cache *);
159#else 160#else
161static inline void sysfs_slab_unlink(struct kmem_cache *s)
162{
163}
160static inline void sysfs_slab_release(struct kmem_cache *s) 164static inline void sysfs_slab_release(struct kmem_cache *s)
161{ 165{
162} 166}
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 1e8a46435838..fd57888d4942 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -427,6 +427,11 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
427#define atomic_dec_and_lock(atomic, lock) \ 427#define atomic_dec_and_lock(atomic, lock) \
428 __cond_lock(lock, _atomic_dec_and_lock(atomic, lock)) 428 __cond_lock(lock, _atomic_dec_and_lock(atomic, lock))
429 429
430extern int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock,
431 unsigned long *flags);
432#define atomic_dec_and_lock_irqsave(atomic, lock, flags) \
433 __cond_lock(lock, _atomic_dec_and_lock_irqsave(atomic, lock, &(flags)))
434
430int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask, 435int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
431 size_t max_size, unsigned int cpu_mult, 436 size_t max_size, unsigned int cpu_mult,
432 gfp_t gfp); 437 gfp_t gfp);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 73810808cdf2..a368a68cb667 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -231,6 +231,9 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
231 */ 231 */
232#ifndef __SYSCALL_DEFINEx 232#ifndef __SYSCALL_DEFINEx
233#define __SYSCALL_DEFINEx(x, name, ...) \ 233#define __SYSCALL_DEFINEx(x, name, ...) \
234 __diag_push(); \
235 __diag_ignore(GCC, 8, "-Wattribute-alias", \
236 "Type aliasing is used to sanitize syscall arguments");\
234 asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ 237 asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
235 __attribute__((alias(__stringify(__se_sys##name)))); \ 238 __attribute__((alias(__stringify(__se_sys##name)))); \
236 ALLOW_ERROR_INJECTION(sys##name, ERRNO); \ 239 ALLOW_ERROR_INJECTION(sys##name, ERRNO); \
@@ -243,6 +246,7 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
243 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ 246 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
244 return ret; \ 247 return ret; \
245 } \ 248 } \
249 __diag_pop(); \
246 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 250 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
247#endif /* __SYSCALL_DEFINEx */ 251#endif /* __SYSCALL_DEFINEx */
248 252
diff --git a/include/linux/wkup_m3_ipc.h b/include/linux/wkup_m3_ipc.h
index d6ba7d39a62f..e497e621dbb7 100644
--- a/include/linux/wkup_m3_ipc.h
+++ b/include/linux/wkup_m3_ipc.h
@@ -40,6 +40,12 @@ struct wkup_m3_ipc {
40 struct mbox_chan *mbox; 40 struct mbox_chan *mbox;
41 41
42 struct wkup_m3_ipc_ops *ops; 42 struct wkup_m3_ipc_ops *ops;
43 int is_rtc_only;
44};
45
46struct wkup_m3_wakeup_src {
47 int irq_nr;
48 char src[10];
43}; 49};
44 50
45struct wkup_m3_ipc_ops { 51struct wkup_m3_ipc_ops {
@@ -48,8 +54,11 @@ struct wkup_m3_ipc_ops {
48 int (*prepare_low_power)(struct wkup_m3_ipc *m3_ipc, int state); 54 int (*prepare_low_power)(struct wkup_m3_ipc *m3_ipc, int state);
49 int (*finish_low_power)(struct wkup_m3_ipc *m3_ipc); 55 int (*finish_low_power)(struct wkup_m3_ipc *m3_ipc);
50 int (*request_pm_status)(struct wkup_m3_ipc *m3_ipc); 56 int (*request_pm_status)(struct wkup_m3_ipc *m3_ipc);
57 const char *(*request_wake_src)(struct wkup_m3_ipc *m3_ipc);
58 void (*set_rtc_only)(struct wkup_m3_ipc *m3_ipc);
51}; 59};
52 60
53struct wkup_m3_ipc *wkup_m3_ipc_get(void); 61struct wkup_m3_ipc *wkup_m3_ipc_get(void);
54void wkup_m3_ipc_put(struct wkup_m3_ipc *m3_ipc); 62void wkup_m3_ipc_put(struct wkup_m3_ipc *m3_ipc);
63void wkup_m3_set_rtc_only_mode(void);
55#endif /* _LINUX_WKUP_M3_IPC_H */ 64#endif /* _LINUX_WKUP_M3_IPC_H */
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 53ce8176c313..ec9d6bc65855 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -271,7 +271,7 @@ int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
271 int flags); 271 int flags);
272int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg, 272int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
273 size_t len, int flags); 273 size_t len, int flags);
274__poll_t bt_sock_poll_mask(struct socket *sock, __poll_t events); 274__poll_t bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
275int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 275int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
276int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); 276int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
277int bt_sock_wait_ready(struct sock *sk, unsigned long flags); 277int bt_sock_wait_ready(struct sock *sk, unsigned long flags);
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 5cba71d2dc44..71b9043aa0e7 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -170,6 +170,7 @@ struct fib6_info {
170 unused:3; 170 unused:3;
171 171
172 struct fib6_nh fib6_nh; 172 struct fib6_nh fib6_nh;
173 struct rcu_head rcu;
173}; 174};
174 175
175struct rt6_info { 176struct rt6_info {
@@ -273,7 +274,7 @@ static inline void ip6_rt_put(struct rt6_info *rt)
273} 274}
274 275
275struct fib6_info *fib6_info_alloc(gfp_t gfp_flags); 276struct fib6_info *fib6_info_alloc(gfp_t gfp_flags);
276void fib6_info_destroy(struct fib6_info *f6i); 277void fib6_info_destroy_rcu(struct rcu_head *head);
277 278
278static inline void fib6_info_hold(struct fib6_info *f6i) 279static inline void fib6_info_hold(struct fib6_info *f6i)
279{ 280{
@@ -283,7 +284,7 @@ static inline void fib6_info_hold(struct fib6_info *f6i)
283static inline void fib6_info_release(struct fib6_info *f6i) 284static inline void fib6_info_release(struct fib6_info *f6i)
284{ 285{
285 if (f6i && atomic_dec_and_test(&f6i->fib6_ref)) 286 if (f6i && atomic_dec_and_test(&f6i->fib6_ref))
286 fib6_info_destroy(f6i); 287 call_rcu(&f6i->rcu, fib6_info_destroy_rcu);
287} 288}
288 289
289enum fib6_walk_state { 290enum fib6_walk_state {
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
index b0eaeb02d46d..f4c21b5a1242 100644
--- a/include/net/iucv/af_iucv.h
+++ b/include/net/iucv/af_iucv.h
@@ -153,6 +153,8 @@ struct iucv_sock_list {
153 atomic_t autobind_name; 153 atomic_t autobind_name;
154}; 154};
155 155
156__poll_t iucv_sock_poll(struct file *file, struct socket *sock,
157 poll_table *wait);
156void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); 158void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
157void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); 159void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
158void iucv_accept_enqueue(struct sock *parent, struct sock *sk); 160void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 30b3e2fe240a..8c2caa370e0f 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -109,7 +109,8 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
109int sctp_inet_listen(struct socket *sock, int backlog); 109int sctp_inet_listen(struct socket *sock, int backlog);
110void sctp_write_space(struct sock *sk); 110void sctp_write_space(struct sock *sk);
111void sctp_data_ready(struct sock *sk); 111void sctp_data_ready(struct sock *sk);
112__poll_t sctp_poll_mask(struct socket *sock, __poll_t events); 112__poll_t sctp_poll(struct file *file, struct socket *sock,
113 poll_table *wait);
113void sctp_sock_rfree(struct sk_buff *skb); 114void sctp_sock_rfree(struct sk_buff *skb);
114void sctp_copy_sock(struct sock *newsk, struct sock *sk, 115void sctp_copy_sock(struct sock *newsk, struct sock *sk,
115 struct sctp_association *asoc); 116 struct sctp_association *asoc);
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 0448e7c5d2b4..800582b5dd54 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -388,7 +388,8 @@ bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst);
388void tcp_close(struct sock *sk, long timeout); 388void tcp_close(struct sock *sk, long timeout);
389void tcp_init_sock(struct sock *sk); 389void tcp_init_sock(struct sock *sk);
390void tcp_init_transfer(struct sock *sk, int bpf_op); 390void tcp_init_transfer(struct sock *sk, int bpf_op);
391__poll_t tcp_poll_mask(struct socket *sock, __poll_t events); 391__poll_t tcp_poll(struct file *file, struct socket *sock,
392 struct poll_table_struct *wait);
392int tcp_getsockopt(struct sock *sk, int level, int optname, 393int tcp_getsockopt(struct sock *sk, int level, int optname,
393 char __user *optval, int __user *optlen); 394 char __user *optval, int __user *optlen);
394int tcp_setsockopt(struct sock *sk, int level, int optname, 395int tcp_setsockopt(struct sock *sk, int level, int optname,
diff --git a/include/net/tls.h b/include/net/tls.h
index 7f84ea3e217c..70c273777fe9 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -109,7 +109,8 @@ struct tls_sw_context_rx {
109 109
110 struct strparser strp; 110 struct strparser strp;
111 void (*saved_data_ready)(struct sock *sk); 111 void (*saved_data_ready)(struct sock *sk);
112 __poll_t (*sk_poll_mask)(struct socket *sock, __poll_t events); 112 unsigned int (*sk_poll)(struct file *file, struct socket *sock,
113 struct poll_table_struct *wait);
113 struct sk_buff *recv_pkt; 114 struct sk_buff *recv_pkt;
114 u8 control; 115 u8 control;
115 bool decrypted; 116 bool decrypted;
@@ -224,7 +225,8 @@ void tls_sw_free_resources_tx(struct sock *sk);
224void tls_sw_free_resources_rx(struct sock *sk); 225void tls_sw_free_resources_rx(struct sock *sk);
225int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, 226int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
226 int nonblock, int flags, int *addr_len); 227 int nonblock, int flags, int *addr_len);
227__poll_t tls_sw_poll_mask(struct socket *sock, __poll_t events); 228unsigned int tls_sw_poll(struct file *file, struct socket *sock,
229 struct poll_table_struct *wait);
228ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, 230ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
229 struct pipe_inode_info *pipe, 231 struct pipe_inode_info *pipe,
230 size_t len, unsigned int flags); 232 size_t len, unsigned int flags);
diff --git a/include/net/udp.h b/include/net/udp.h
index b1ea8b0f5e6a..81afdacd4fff 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -285,7 +285,7 @@ int udp_init_sock(struct sock *sk);
285int udp_pre_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len); 285int udp_pre_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
286int __udp_disconnect(struct sock *sk, int flags); 286int __udp_disconnect(struct sock *sk, int flags);
287int udp_disconnect(struct sock *sk, int flags); 287int udp_disconnect(struct sock *sk, int flags);
288__poll_t udp_poll_mask(struct socket *sock, __poll_t events); 288__poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait);
289struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, 289struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
290 netdev_features_t features, 290 netdev_features_t features,
291 bool is_ipv6); 291 bool is_ipv6);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 4c6241bc2039..6c003995347a 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -3391,11 +3391,14 @@ int ib_process_cq_direct(struct ib_cq *cq, int budget);
3391 * 3391 *
3392 * Users can examine the cq structure to determine the actual CQ size. 3392 * Users can examine the cq structure to determine the actual CQ size.
3393 */ 3393 */
3394struct ib_cq *ib_create_cq(struct ib_device *device, 3394struct ib_cq *__ib_create_cq(struct ib_device *device,
3395 ib_comp_handler comp_handler, 3395 ib_comp_handler comp_handler,
3396 void (*event_handler)(struct ib_event *, void *), 3396 void (*event_handler)(struct ib_event *, void *),
3397 void *cq_context, 3397 void *cq_context,
3398 const struct ib_cq_init_attr *cq_attr); 3398 const struct ib_cq_init_attr *cq_attr,
3399 const char *caller);
3400#define ib_create_cq(device, cmp_hndlr, evt_hndlr, cq_ctxt, cq_attr) \
3401 __ib_create_cq((device), (cmp_hndlr), (evt_hndlr), (cq_ctxt), (cq_attr), KBUILD_MODNAME)
3399 3402
3400/** 3403/**
3401 * ib_resize_cq - Modifies the capacity of the CQ. 3404 * ib_resize_cq - Modifies the capacity of the CQ.
diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
index 8ee8991aa099..c4a5c9e9fb47 100644
--- a/include/soc/bcm2835/raspberrypi-firmware.h
+++ b/include/soc/bcm2835/raspberrypi-firmware.h
@@ -75,6 +75,7 @@ enum rpi_firmware_property_tag {
75 RPI_FIRMWARE_GET_EDID_BLOCK = 0x00030020, 75 RPI_FIRMWARE_GET_EDID_BLOCK = 0x00030020,
76 RPI_FIRMWARE_GET_CUSTOMER_OTP = 0x00030021, 76 RPI_FIRMWARE_GET_CUSTOMER_OTP = 0x00030021,
77 RPI_FIRMWARE_GET_DOMAIN_STATE = 0x00030030, 77 RPI_FIRMWARE_GET_DOMAIN_STATE = 0x00030030,
78 RPI_FIRMWARE_GET_THROTTLED = 0x00030046,
78 RPI_FIRMWARE_SET_CLOCK_STATE = 0x00038001, 79 RPI_FIRMWARE_SET_CLOCK_STATE = 0x00038001,
79 RPI_FIRMWARE_SET_CLOCK_RATE = 0x00038002, 80 RPI_FIRMWARE_SET_CLOCK_RATE = 0x00038002,
80 RPI_FIRMWARE_SET_VOLTAGE = 0x00038003, 81 RPI_FIRMWARE_SET_VOLTAGE = 0x00038003,
diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h
index d00221345c19..3c5038b587ba 100644
--- a/include/uapi/linux/aio_abi.h
+++ b/include/uapi/linux/aio_abi.h
@@ -39,8 +39,10 @@ enum {
39 IOCB_CMD_PWRITE = 1, 39 IOCB_CMD_PWRITE = 1,
40 IOCB_CMD_FSYNC = 2, 40 IOCB_CMD_FSYNC = 2,
41 IOCB_CMD_FDSYNC = 3, 41 IOCB_CMD_FDSYNC = 3,
42 /* 4 was the experimental IOCB_CMD_PREADX */ 42 /* These two are experimental.
43 IOCB_CMD_POLL = 5, 43 * IOCB_CMD_PREADX = 4,
44 * IOCB_CMD_POLL = 5,
45 */
44 IOCB_CMD_NOOP = 6, 46 IOCB_CMD_NOOP = 6,
45 IOCB_CMD_PREADV = 7, 47 IOCB_CMD_PREADV = 7,
46 IOCB_CMD_PWRITEV = 8, 48 IOCB_CMD_PWRITEV = 8,
diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h
index 85a3fb65e40a..20d6cc91435d 100644
--- a/include/uapi/linux/nbd.h
+++ b/include/uapi/linux/nbd.h
@@ -53,6 +53,9 @@ enum {
53/* These are client behavior specific flags. */ 53/* These are client behavior specific flags. */
54#define NBD_CFLAG_DESTROY_ON_DISCONNECT (1 << 0) /* delete the nbd device on 54#define NBD_CFLAG_DESTROY_ON_DISCONNECT (1 << 0) /* delete the nbd device on
55 disconnect. */ 55 disconnect. */
56#define NBD_CFLAG_DISCONNECT_ON_CLOSE (1 << 1) /* disconnect the nbd device on
57 * close by last opener.
58 */
56 59
57/* userspace doesn't need the nbd_device structure */ 60/* userspace doesn't need the nbd_device structure */
58 61
diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h
index 6e299349b158..b7b57967d90f 100644
--- a/include/uapi/linux/target_core_user.h
+++ b/include/uapi/linux/target_core_user.h
@@ -44,6 +44,7 @@
44#define TCMU_MAILBOX_VERSION 2 44#define TCMU_MAILBOX_VERSION 2
45#define ALIGN_SIZE 64 /* Should be enough for most CPUs */ 45#define ALIGN_SIZE 64 /* Should be enough for most CPUs */
46#define TCMU_MAILBOX_FLAG_CAP_OOOC (1 << 0) /* Out-of-order completions */ 46#define TCMU_MAILBOX_FLAG_CAP_OOOC (1 << 0) /* Out-of-order completions */
47#define TCMU_MAILBOX_FLAG_CAP_READ_LEN (1 << 1) /* Read data length */
47 48
48struct tcmu_mailbox { 49struct tcmu_mailbox {
49 __u16 version; 50 __u16 version;
@@ -71,6 +72,7 @@ struct tcmu_cmd_entry_hdr {
71 __u16 cmd_id; 72 __u16 cmd_id;
72 __u8 kflags; 73 __u8 kflags;
73#define TCMU_UFLAG_UNKNOWN_OP 0x1 74#define TCMU_UFLAG_UNKNOWN_OP 0x1
75#define TCMU_UFLAG_READ_LEN 0x2
74 __u8 uflags; 76 __u8 uflags;
75 77
76} __packed; 78} __packed;
@@ -119,7 +121,7 @@ struct tcmu_cmd_entry {
119 __u8 scsi_status; 121 __u8 scsi_status;
120 __u8 __pad1; 122 __u8 __pad1;
121 __u16 __pad2; 123 __u16 __pad2;
122 __u32 __pad3; 124 __u32 read_len;
123 char sense_buffer[TCMU_SENSE_BUFFERSIZE]; 125 char sense_buffer[TCMU_SENSE_BUFFERSIZE];
124 } rsp; 126 } rsp;
125 }; 127 };
diff --git a/include/xen/xen.h b/include/xen/xen.h
index 9d4340c907d1..1e1d9bd0bd37 100644
--- a/include/xen/xen.h
+++ b/include/xen/xen.h
@@ -25,12 +25,16 @@ extern bool xen_pvh;
25#define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN) 25#define xen_hvm_domain() (xen_domain_type == XEN_HVM_DOMAIN)
26#define xen_pvh_domain() (xen_pvh) 26#define xen_pvh_domain() (xen_pvh)
27 27
28#include <linux/types.h>
29
30extern uint32_t xen_start_flags;
31
28#ifdef CONFIG_XEN_DOM0 32#ifdef CONFIG_XEN_DOM0
29#include <xen/interface/xen.h> 33#include <xen/interface/xen.h>
30#include <asm/xen/hypervisor.h> 34#include <asm/xen/hypervisor.h>
31 35
32#define xen_initial_domain() (xen_domain() && \ 36#define xen_initial_domain() (xen_domain() && \
33 xen_start_info && xen_start_info->flags & SIF_INITDOMAIN) 37 (xen_start_flags & SIF_INITDOMAIN))
34#else /* !CONFIG_XEN_DOM0 */ 38#else /* !CONFIG_XEN_DOM0 */
35#define xen_initial_domain() (0) 39#define xen_initial_domain() (0)
36#endif /* CONFIG_XEN_DOM0 */ 40#endif /* CONFIG_XEN_DOM0 */
diff --git a/init/Kconfig b/init/Kconfig
index 5a52f07259a2..041f3a022122 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1051,10 +1051,9 @@ config LD_DEAD_CODE_DATA_ELIMINATION
1051 depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION 1051 depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION
1052 depends on EXPERT 1052 depends on EXPERT
1053 help 1053 help
1054 Select this if the architecture wants to do dead code and 1054 Enable this if you want to do dead code and data elimination with
1055 data elimination with the linker by compiling with 1055 the linker by compiling with -ffunction-sections -fdata-sections,
1056 -ffunction-sections -fdata-sections, and linking with 1056 and linking with --gc-sections.
1057 --gc-sections.
1058 1057
1059 This can reduce on disk and in-memory size of the kernel 1058 This can reduce on disk and in-memory size of the kernel
1060 code and static data, particularly for small configs and 1059 code and static data, particularly for small configs and
@@ -1719,10 +1718,6 @@ source "arch/Kconfig"
1719 1718
1720endmenu # General setup 1719endmenu # General setup
1721 1720
1722config HAVE_GENERIC_DMA_COHERENT
1723 bool
1724 default n
1725
1726config RT_MUTEXES 1721config RT_MUTEXES
1727 bool 1722 bool
1728 1723
diff --git a/kernel/Makefile b/kernel/Makefile
index d2001624fe7a..04bc07c2b42a 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -41,6 +41,7 @@ obj-y += printk/
41obj-y += irq/ 41obj-y += irq/
42obj-y += rcu/ 42obj-y += rcu/
43obj-y += livepatch/ 43obj-y += livepatch/
44obj-y += dma/
44 45
45obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o 46obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
46obj-$(CONFIG_FREEZER) += freezer.o 47obj-$(CONFIG_FREEZER) += freezer.o
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 9f1493705f40..a9e6c04d0f4a 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -350,6 +350,20 @@ struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
350 return prog_adj; 350 return prog_adj;
351} 351}
352 352
353void bpf_prog_kallsyms_del_subprogs(struct bpf_prog *fp)
354{
355 int i;
356
357 for (i = 0; i < fp->aux->func_cnt; i++)
358 bpf_prog_kallsyms_del(fp->aux->func[i]);
359}
360
361void bpf_prog_kallsyms_del_all(struct bpf_prog *fp)
362{
363 bpf_prog_kallsyms_del_subprogs(fp);
364 bpf_prog_kallsyms_del(fp);
365}
366
353#ifdef CONFIG_BPF_JIT 367#ifdef CONFIG_BPF_JIT
354/* All BPF JIT sysctl knobs here. */ 368/* All BPF JIT sysctl knobs here. */
355int bpf_jit_enable __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_ALWAYS_ON); 369int bpf_jit_enable __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_ALWAYS_ON);
@@ -584,6 +598,8 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
584 bpf_fill_ill_insns(hdr, size); 598 bpf_fill_ill_insns(hdr, size);
585 599
586 hdr->pages = size / PAGE_SIZE; 600 hdr->pages = size / PAGE_SIZE;
601 hdr->locked = 0;
602
587 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)), 603 hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)),
588 PAGE_SIZE - sizeof(*hdr)); 604 PAGE_SIZE - sizeof(*hdr));
589 start = (get_random_int() % hole) & ~(alignment - 1); 605 start = (get_random_int() % hole) & ~(alignment - 1);
@@ -1434,6 +1450,33 @@ static int bpf_check_tail_call(const struct bpf_prog *fp)
1434 return 0; 1450 return 0;
1435} 1451}
1436 1452
1453static int bpf_prog_check_pages_ro_locked(const struct bpf_prog *fp)
1454{
1455#ifdef CONFIG_ARCH_HAS_SET_MEMORY
1456 int i, err;
1457
1458 for (i = 0; i < fp->aux->func_cnt; i++) {
1459 err = bpf_prog_check_pages_ro_single(fp->aux->func[i]);
1460 if (err)
1461 return err;
1462 }
1463
1464 return bpf_prog_check_pages_ro_single(fp);
1465#endif
1466 return 0;
1467}
1468
1469static void bpf_prog_select_func(struct bpf_prog *fp)
1470{
1471#ifndef CONFIG_BPF_JIT_ALWAYS_ON
1472 u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1);
1473
1474 fp->bpf_func = interpreters[(round_up(stack_depth, 32) / 32) - 1];
1475#else
1476 fp->bpf_func = __bpf_prog_ret0_warn;
1477#endif
1478}
1479
1437/** 1480/**
1438 * bpf_prog_select_runtime - select exec runtime for BPF program 1481 * bpf_prog_select_runtime - select exec runtime for BPF program
1439 * @fp: bpf_prog populated with internal BPF program 1482 * @fp: bpf_prog populated with internal BPF program
@@ -1444,13 +1487,13 @@ static int bpf_check_tail_call(const struct bpf_prog *fp)
1444 */ 1487 */
1445struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err) 1488struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)
1446{ 1489{
1447#ifndef CONFIG_BPF_JIT_ALWAYS_ON 1490 /* In case of BPF to BPF calls, verifier did all the prep
1448 u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1); 1491 * work with regards to JITing, etc.
1492 */
1493 if (fp->bpf_func)
1494 goto finalize;
1449 1495
1450 fp->bpf_func = interpreters[(round_up(stack_depth, 32) / 32) - 1]; 1496 bpf_prog_select_func(fp);
1451#else
1452 fp->bpf_func = __bpf_prog_ret0_warn;
1453#endif
1454 1497
1455 /* eBPF JITs can rewrite the program in case constant 1498 /* eBPF JITs can rewrite the program in case constant
1456 * blinding is active. However, in case of error during 1499 * blinding is active. However, in case of error during
@@ -1471,6 +1514,8 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)
1471 if (*err) 1514 if (*err)
1472 return fp; 1515 return fp;
1473 } 1516 }
1517
1518finalize:
1474 bpf_prog_lock_ro(fp); 1519 bpf_prog_lock_ro(fp);
1475 1520
1476 /* The tail call compatibility check can only be done at 1521 /* The tail call compatibility check can only be done at
@@ -1479,7 +1524,17 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)
1479 * all eBPF JITs might immediately support all features. 1524 * all eBPF JITs might immediately support all features.
1480 */ 1525 */
1481 *err = bpf_check_tail_call(fp); 1526 *err = bpf_check_tail_call(fp);
1482 1527 if (*err)
1528 return fp;
1529
1530 /* Checkpoint: at this point onwards any cBPF -> eBPF or
1531 * native eBPF program is read-only. If we failed to change
1532 * the page attributes (e.g. allocation failure from
1533 * splitting large pages), then reject the whole program
1534 * in order to guarantee not ending up with any W+X pages
1535 * from BPF side in kernel.
1536 */
1537 *err = bpf_prog_check_pages_ro_locked(fp);
1483 return fp; 1538 return fp;
1484} 1539}
1485EXPORT_SYMBOL_GPL(bpf_prog_select_runtime); 1540EXPORT_SYMBOL_GPL(bpf_prog_select_runtime);
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index a7cc7b3494a9..642c97f6d1b8 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -345,6 +345,20 @@ int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp,
345 return bq_enqueue(dst, xdpf, dev_rx); 345 return bq_enqueue(dst, xdpf, dev_rx);
346} 346}
347 347
348int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb,
349 struct bpf_prog *xdp_prog)
350{
351 int err;
352
353 err = __xdp_generic_ok_fwd_dev(skb, dst->dev);
354 if (unlikely(err))
355 return err;
356 skb->dev = dst->dev;
357 generic_xdp_tx(skb, xdp_prog);
358
359 return 0;
360}
361
348static void *dev_map_lookup_elem(struct bpf_map *map, void *key) 362static void *dev_map_lookup_elem(struct bpf_map *map, void *key)
349{ 363{
350 struct bpf_dtab_netdev *obj = __dev_map_lookup_elem(map, *(u32 *)key); 364 struct bpf_dtab_netdev *obj = __dev_map_lookup_elem(map, *(u32 *)key);
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0fa20624707f..35dc466641f2 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1034,14 +1034,9 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu)
1034static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) 1034static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock)
1035{ 1035{
1036 if (atomic_dec_and_test(&prog->aux->refcnt)) { 1036 if (atomic_dec_and_test(&prog->aux->refcnt)) {
1037 int i;
1038
1039 /* bpf_prog_free_id() must be called first */ 1037 /* bpf_prog_free_id() must be called first */
1040 bpf_prog_free_id(prog, do_idr_lock); 1038 bpf_prog_free_id(prog, do_idr_lock);
1041 1039 bpf_prog_kallsyms_del_all(prog);
1042 for (i = 0; i < prog->aux->func_cnt; i++)
1043 bpf_prog_kallsyms_del(prog->aux->func[i]);
1044 bpf_prog_kallsyms_del(prog);
1045 1040
1046 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); 1041 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu);
1047 } 1042 }
@@ -1358,9 +1353,7 @@ static int bpf_prog_load(union bpf_attr *attr)
1358 if (err < 0) 1353 if (err < 0)
1359 goto free_used_maps; 1354 goto free_used_maps;
1360 1355
1361 /* eBPF program is ready to be JITed */ 1356 prog = bpf_prog_select_runtime(prog, &err);
1362 if (!prog->bpf_func)
1363 prog = bpf_prog_select_runtime(prog, &err);
1364 if (err < 0) 1357 if (err < 0)
1365 goto free_used_maps; 1358 goto free_used_maps;
1366 1359
@@ -1384,6 +1377,7 @@ static int bpf_prog_load(union bpf_attr *attr)
1384 return err; 1377 return err;
1385 1378
1386free_used_maps: 1379free_used_maps:
1380 bpf_prog_kallsyms_del_subprogs(prog);
1387 free_used_maps(prog->aux); 1381 free_used_maps(prog->aux);
1388free_prog: 1382free_prog:
1389 bpf_prog_uncharge_memlock(prog); 1383 bpf_prog_uncharge_memlock(prog);
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
new file mode 100644
index 000000000000..9bd54304446f
--- /dev/null
+++ b/kernel/dma/Kconfig
@@ -0,0 +1,50 @@
1
2config HAS_DMA
3 bool
4 depends on !NO_DMA
5 default y
6
7config NEED_SG_DMA_LENGTH
8 bool
9
10config NEED_DMA_MAP_STATE
11 bool
12
13config ARCH_DMA_ADDR_T_64BIT
14 def_bool 64BIT || PHYS_ADDR_T_64BIT
15
16config HAVE_GENERIC_DMA_COHERENT
17 bool
18
19config ARCH_HAS_SYNC_DMA_FOR_DEVICE
20 bool
21
22config ARCH_HAS_SYNC_DMA_FOR_CPU
23 bool
24 select NEED_DMA_MAP_STATE
25
26config DMA_DIRECT_OPS
27 bool
28 depends on HAS_DMA
29
30config DMA_NONCOHERENT_OPS
31 bool
32 depends on HAS_DMA
33 select DMA_DIRECT_OPS
34
35config DMA_NONCOHERENT_MMAP
36 bool
37 depends on DMA_NONCOHERENT_OPS
38
39config DMA_NONCOHERENT_CACHE_SYNC
40 bool
41 depends on DMA_NONCOHERENT_OPS
42
43config DMA_VIRT_OPS
44 bool
45 depends on HAS_DMA
46
47config SWIOTLB
48 bool
49 select DMA_DIRECT_OPS
50 select NEED_DMA_MAP_STATE
diff --git a/kernel/dma/Makefile b/kernel/dma/Makefile
new file mode 100644
index 000000000000..6de44e4eb454
--- /dev/null
+++ b/kernel/dma/Makefile
@@ -0,0 +1,11 @@
1# SPDX-License-Identifier: GPL-2.0
2
3obj-$(CONFIG_HAS_DMA) += mapping.o
4obj-$(CONFIG_DMA_CMA) += contiguous.o
5obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += coherent.o
6obj-$(CONFIG_DMA_DIRECT_OPS) += direct.o
7obj-$(CONFIG_DMA_NONCOHERENT_OPS) += noncoherent.o
8obj-$(CONFIG_DMA_VIRT_OPS) += virt.o
9obj-$(CONFIG_DMA_API_DEBUG) += debug.o
10obj-$(CONFIG_SWIOTLB) += swiotlb.o
11
diff --git a/drivers/base/dma-coherent.c b/kernel/dma/coherent.c
index 597d40893862..597d40893862 100644
--- a/drivers/base/dma-coherent.c
+++ b/kernel/dma/coherent.c
diff --git a/drivers/base/dma-contiguous.c b/kernel/dma/contiguous.c
index d987dcd1bd56..d987dcd1bd56 100644
--- a/drivers/base/dma-contiguous.c
+++ b/kernel/dma/contiguous.c
diff --git a/lib/dma-debug.c b/kernel/dma/debug.c
index c007d25bee09..c007d25bee09 100644
--- a/lib/dma-debug.c
+++ b/kernel/dma/debug.c
diff --git a/lib/dma-direct.c b/kernel/dma/direct.c
index 8be8106270c2..8be8106270c2 100644
--- a/lib/dma-direct.c
+++ b/kernel/dma/direct.c
diff --git a/drivers/base/dma-mapping.c b/kernel/dma/mapping.c
index f831a582209c..d2a92ddaac4d 100644
--- a/drivers/base/dma-mapping.c
+++ b/kernel/dma/mapping.c
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* 2/*
3 * drivers/base/dma-mapping.c - arch-independent dma-mapping routines 3 * arch-independent dma-mapping routines
4 * 4 *
5 * Copyright (c) 2006 SUSE Linux Products GmbH 5 * Copyright (c) 2006 SUSE Linux Products GmbH
6 * Copyright (c) 2006 Tejun Heo <teheo@suse.de> 6 * Copyright (c) 2006 Tejun Heo <teheo@suse.de>
diff --git a/lib/dma-noncoherent.c b/kernel/dma/noncoherent.c
index 79e9a757387f..79e9a757387f 100644
--- a/lib/dma-noncoherent.c
+++ b/kernel/dma/noncoherent.c
diff --git a/lib/swiotlb.c b/kernel/dma/swiotlb.c
index 04b68d9dffac..904541055792 100644
--- a/lib/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -1085,3 +1085,4 @@ const struct dma_map_ops swiotlb_dma_ops = {
1085 .unmap_page = swiotlb_unmap_page, 1085 .unmap_page = swiotlb_unmap_page,
1086 .dma_supported = dma_direct_supported, 1086 .dma_supported = dma_direct_supported,
1087}; 1087};
1088EXPORT_SYMBOL(swiotlb_dma_ops);
diff --git a/lib/dma-virt.c b/kernel/dma/virt.c
index 8e61a02ef9ca..631ddec4b60a 100644
--- a/lib/dma-virt.c
+++ b/kernel/dma/virt.c
@@ -1,7 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* 2/*
3 * lib/dma-virt.c
4 *
5 * DMA operations that map to virtual addresses without flushing memory. 3 * DMA operations that map to virtual addresses without flushing memory.
6 */ 4 */
7#include <linux/export.h> 5#include <linux/export.h>
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 80cca2b30c4f..8f0434a9951a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6482,7 +6482,7 @@ void perf_prepare_sample(struct perf_event_header *header,
6482 data->phys_addr = perf_virt_to_phys(data->addr); 6482 data->phys_addr = perf_virt_to_phys(data->addr);
6483} 6483}
6484 6484
6485static void __always_inline 6485static __always_inline void
6486__perf_event_output(struct perf_event *event, 6486__perf_event_output(struct perf_event *event,
6487 struct perf_sample_data *data, 6487 struct perf_sample_data *data,
6488 struct pt_regs *regs, 6488 struct pt_regs *regs,
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 045a37e9ddee..5d3cf407e374 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -103,7 +103,7 @@ out:
103 preempt_enable(); 103 preempt_enable();
104} 104}
105 105
106static bool __always_inline 106static __always_inline bool
107ring_buffer_has_space(unsigned long head, unsigned long tail, 107ring_buffer_has_space(unsigned long head, unsigned long tail,
108 unsigned long data_size, unsigned int size, 108 unsigned long data_size, unsigned int size,
109 bool backward) 109 bool backward)
@@ -114,7 +114,7 @@ ring_buffer_has_space(unsigned long head, unsigned long tail,
114 return CIRC_SPACE(tail, head, data_size) >= size; 114 return CIRC_SPACE(tail, head, data_size) >= size;
115} 115}
116 116
117static int __always_inline 117static __always_inline int
118__perf_output_begin(struct perf_output_handle *handle, 118__perf_output_begin(struct perf_output_handle *handle,
119 struct perf_event *event, unsigned int size, 119 struct perf_event *event, unsigned int size,
120 bool backward) 120 bool backward)
@@ -414,7 +414,7 @@ err:
414} 414}
415EXPORT_SYMBOL_GPL(perf_aux_output_begin); 415EXPORT_SYMBOL_GPL(perf_aux_output_begin);
416 416
417static bool __always_inline rb_need_aux_wakeup(struct ring_buffer *rb) 417static __always_inline bool rb_need_aux_wakeup(struct ring_buffer *rb)
418{ 418{
419 if (rb->aux_overwrite) 419 if (rb->aux_overwrite)
420 return false; 420 return false;
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index 4dadeb3d6666..6f636136cccc 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -55,6 +55,7 @@ static const struct irq_bit_descr irqchip_flags[] = {
55 BIT_MASK_DESCR(IRQCHIP_SKIP_SET_WAKE), 55 BIT_MASK_DESCR(IRQCHIP_SKIP_SET_WAKE),
56 BIT_MASK_DESCR(IRQCHIP_ONESHOT_SAFE), 56 BIT_MASK_DESCR(IRQCHIP_ONESHOT_SAFE),
57 BIT_MASK_DESCR(IRQCHIP_EOI_THREADED), 57 BIT_MASK_DESCR(IRQCHIP_EOI_THREADED),
58 BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI),
58}; 59};
59 60
60static void 61static void
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index edcac5de7ebc..5fa4d3138bf1 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1265,11 +1265,11 @@ unsigned long lockdep_count_forward_deps(struct lock_class *class)
1265 this.parent = NULL; 1265 this.parent = NULL;
1266 this.class = class; 1266 this.class = class;
1267 1267
1268 local_irq_save(flags); 1268 raw_local_irq_save(flags);
1269 arch_spin_lock(&lockdep_lock); 1269 arch_spin_lock(&lockdep_lock);
1270 ret = __lockdep_count_forward_deps(&this); 1270 ret = __lockdep_count_forward_deps(&this);
1271 arch_spin_unlock(&lockdep_lock); 1271 arch_spin_unlock(&lockdep_lock);
1272 local_irq_restore(flags); 1272 raw_local_irq_restore(flags);
1273 1273
1274 return ret; 1274 return ret;
1275} 1275}
@@ -1292,11 +1292,11 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class)
1292 this.parent = NULL; 1292 this.parent = NULL;
1293 this.class = class; 1293 this.class = class;
1294 1294
1295 local_irq_save(flags); 1295 raw_local_irq_save(flags);
1296 arch_spin_lock(&lockdep_lock); 1296 arch_spin_lock(&lockdep_lock);
1297 ret = __lockdep_count_backward_deps(&this); 1297 ret = __lockdep_count_backward_deps(&this);
1298 arch_spin_unlock(&lockdep_lock); 1298 arch_spin_unlock(&lockdep_lock);
1299 local_irq_restore(flags); 1299 raw_local_irq_restore(flags);
1300 1300
1301 return ret; 1301 return ret;
1302} 1302}
@@ -4411,7 +4411,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
4411 if (unlikely(!debug_locks)) 4411 if (unlikely(!debug_locks))
4412 return; 4412 return;
4413 4413
4414 local_irq_save(flags); 4414 raw_local_irq_save(flags);
4415 for (i = 0; i < curr->lockdep_depth; i++) { 4415 for (i = 0; i < curr->lockdep_depth; i++) {
4416 hlock = curr->held_locks + i; 4416 hlock = curr->held_locks + i;
4417 4417
@@ -4422,7 +4422,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
4422 print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock); 4422 print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
4423 break; 4423 break;
4424 } 4424 }
4425 local_irq_restore(flags); 4425 raw_local_irq_restore(flags);
4426} 4426}
4427EXPORT_SYMBOL_GPL(debug_check_no_locks_freed); 4427EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
4428 4428
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index bc1e507be9ff..776308d2fa9e 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -181,6 +181,7 @@ void down_read_non_owner(struct rw_semaphore *sem)
181 might_sleep(); 181 might_sleep();
182 182
183 __down_read(sem); 183 __down_read(sem);
184 rwsem_set_reader_owned(sem);
184} 185}
185 186
186EXPORT_SYMBOL(down_read_non_owner); 187EXPORT_SYMBOL(down_read_non_owner);
diff --git a/kernel/rseq.c b/kernel/rseq.c
index ae306f90c514..22b6acf1ad63 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -251,10 +251,10 @@ static int rseq_ip_fixup(struct pt_regs *regs)
251 * respect to other threads scheduled on the same CPU, and with respect 251 * respect to other threads scheduled on the same CPU, and with respect
252 * to signal handlers. 252 * to signal handlers.
253 */ 253 */
254void __rseq_handle_notify_resume(struct pt_regs *regs) 254void __rseq_handle_notify_resume(struct ksignal *ksig, struct pt_regs *regs)
255{ 255{
256 struct task_struct *t = current; 256 struct task_struct *t = current;
257 int ret; 257 int ret, sig;
258 258
259 if (unlikely(t->flags & PF_EXITING)) 259 if (unlikely(t->flags & PF_EXITING))
260 return; 260 return;
@@ -268,7 +268,8 @@ void __rseq_handle_notify_resume(struct pt_regs *regs)
268 return; 268 return;
269 269
270error: 270error:
271 force_sig(SIGSEGV, t); 271 sig = ksig ? ksig->sig : 0;
272 force_sigsegv(sig, t);
272} 273}
273 274
274#ifdef CONFIG_DEBUG_RSEQ 275#ifdef CONFIG_DEBUG_RSEQ
diff --git a/kernel/softirq.c b/kernel/softirq.c
index de2f57fddc04..900dcfee542c 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -139,9 +139,13 @@ static void __local_bh_enable(unsigned int cnt)
139{ 139{
140 lockdep_assert_irqs_disabled(); 140 lockdep_assert_irqs_disabled();
141 141
142 if (preempt_count() == cnt)
143 trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip());
144
142 if (softirq_count() == (cnt & SOFTIRQ_MASK)) 145 if (softirq_count() == (cnt & SOFTIRQ_MASK))
143 trace_softirqs_on(_RET_IP_); 146 trace_softirqs_on(_RET_IP_);
144 preempt_count_sub(cnt); 147
148 __preempt_count_sub(cnt);
145} 149}
146 150
147/* 151/*
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 055a4a728c00..3e93c54bd3a1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1659,7 +1659,7 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
1659int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts) 1659int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
1660{ 1660{
1661 switch(restart->nanosleep.type) { 1661 switch(restart->nanosleep.type) {
1662#ifdef CONFIG_COMPAT 1662#ifdef CONFIG_COMPAT_32BIT_TIME
1663 case TT_COMPAT: 1663 case TT_COMPAT:
1664 if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp)) 1664 if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp))
1665 return -EFAULT; 1665 return -EFAULT;
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 5a6251ac6f7a..9cdf54b04ca8 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -604,7 +604,6 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
604 /* 604 /*
605 * Disarm any old timer after extracting its expiry time. 605 * Disarm any old timer after extracting its expiry time.
606 */ 606 */
607 lockdep_assert_irqs_disabled();
608 607
609 ret = 0; 608 ret = 0;
610 old_incr = timer->it.cpu.incr; 609 old_incr = timer->it.cpu.incr;
@@ -1049,7 +1048,6 @@ static void posix_cpu_timer_rearm(struct k_itimer *timer)
1049 /* 1048 /*
1050 * Now re-arm for the new expiry time. 1049 * Now re-arm for the new expiry time.
1051 */ 1050 */
1052 lockdep_assert_irqs_disabled();
1053 arm_timer(timer); 1051 arm_timer(timer);
1054unlock: 1052unlock:
1055 unlock_task_sighand(p, &flags); 1053 unlock_task_sighand(p, &flags);
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 6fa99213fc72..2b41e8e2d31d 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/export.h> 30#include <linux/export.h>
31#include <linux/kernel.h>
31#include <linux/timex.h> 32#include <linux/timex.h>
32#include <linux/capability.h> 33#include <linux/capability.h>
33#include <linux/timekeeper_internal.h> 34#include <linux/timekeeper_internal.h>
@@ -314,9 +315,10 @@ unsigned int jiffies_to_msecs(const unsigned long j)
314 return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); 315 return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
315#else 316#else
316# if BITS_PER_LONG == 32 317# if BITS_PER_LONG == 32
317 return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32; 318 return (HZ_TO_MSEC_MUL32 * j + (1ULL << HZ_TO_MSEC_SHR32) - 1) >>
319 HZ_TO_MSEC_SHR32;
318# else 320# else
319 return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN; 321 return DIV_ROUND_UP(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
320# endif 322# endif
321#endif 323#endif
322} 324}
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c9336e98ac59..a0079b4c7a49 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1360,8 +1360,6 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
1360void 1360void
1361update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) 1361update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
1362{ 1362{
1363 struct ring_buffer *buf;
1364
1365 if (tr->stop_count) 1363 if (tr->stop_count)
1366 return; 1364 return;
1367 1365
@@ -1375,9 +1373,7 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
1375 1373
1376 arch_spin_lock(&tr->max_lock); 1374 arch_spin_lock(&tr->max_lock);
1377 1375
1378 buf = tr->trace_buffer.buffer; 1376 swap(tr->trace_buffer.buffer, tr->max_buffer.buffer);
1379 tr->trace_buffer.buffer = tr->max_buffer.buffer;
1380 tr->max_buffer.buffer = buf;
1381 1377
1382 __update_max_tr(tr, tsk, cpu); 1378 __update_max_tr(tr, tsk, cpu);
1383 arch_spin_unlock(&tr->max_lock); 1379 arch_spin_unlock(&tr->max_lock);
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index e1c818dbc0d7..0dceb77d1d42 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -78,7 +78,8 @@ static const char * ops[] = { OPS };
78 C(TOO_MANY_PREDS, "Too many terms in predicate expression"), \ 78 C(TOO_MANY_PREDS, "Too many terms in predicate expression"), \
79 C(INVALID_FILTER, "Meaningless filter expression"), \ 79 C(INVALID_FILTER, "Meaningless filter expression"), \
80 C(IP_FIELD_ONLY, "Only 'ip' field is supported for function trace"), \ 80 C(IP_FIELD_ONLY, "Only 'ip' field is supported for function trace"), \
81 C(INVALID_VALUE, "Invalid value (did you forget quotes)?"), 81 C(INVALID_VALUE, "Invalid value (did you forget quotes)?"), \
82 C(NO_FILTER, "No filter found"),
82 83
83#undef C 84#undef C
84#define C(a, b) FILT_ERR_##a 85#define C(a, b) FILT_ERR_##a
@@ -550,6 +551,13 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
550 goto out_free; 551 goto out_free;
551 } 552 }
552 553
554 if (!N) {
555 /* No program? */
556 ret = -EINVAL;
557 parse_error(pe, FILT_ERR_NO_FILTER, ptr - str);
558 goto out_free;
559 }
560
553 prog[N].pred = NULL; /* #13 */ 561 prog[N].pred = NULL; /* #13 */
554 prog[N].target = 1; /* TRUE */ 562 prog[N].target = 1; /* TRUE */
555 prog[N+1].pred = NULL; 563 prog[N+1].pred = NULL;
diff --git a/lib/Kconfig b/lib/Kconfig
index e34b04b56057..706836ec314d 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -420,60 +420,15 @@ config HAS_IOPORT_MAP
420 depends on HAS_IOMEM && !NO_IOPORT_MAP 420 depends on HAS_IOMEM && !NO_IOPORT_MAP
421 default y 421 default y
422 422
423config HAS_DMA 423source "kernel/dma/Kconfig"
424 bool
425 depends on !NO_DMA
426 default y
427 424
428config SGL_ALLOC 425config SGL_ALLOC
429 bool 426 bool
430 default n 427 default n
431 428
432config NEED_SG_DMA_LENGTH
433 bool
434
435config NEED_DMA_MAP_STATE
436 bool
437
438config ARCH_DMA_ADDR_T_64BIT
439 def_bool 64BIT || PHYS_ADDR_T_64BIT
440
441config IOMMU_HELPER 429config IOMMU_HELPER
442 bool 430 bool
443 431
444config ARCH_HAS_SYNC_DMA_FOR_DEVICE
445 bool
446
447config ARCH_HAS_SYNC_DMA_FOR_CPU
448 bool
449 select NEED_DMA_MAP_STATE
450
451config DMA_DIRECT_OPS
452 bool
453 depends on HAS_DMA
454
455config DMA_NONCOHERENT_OPS
456 bool
457 depends on HAS_DMA
458 select DMA_DIRECT_OPS
459
460config DMA_NONCOHERENT_MMAP
461 bool
462 depends on DMA_NONCOHERENT_OPS
463
464config DMA_NONCOHERENT_CACHE_SYNC
465 bool
466 depends on DMA_NONCOHERENT_OPS
467
468config DMA_VIRT_OPS
469 bool
470 depends on HAS_DMA
471
472config SWIOTLB
473 bool
474 select DMA_DIRECT_OPS
475 select NEED_DMA_MAP_STATE
476
477config CHECK_SIGNATURE 432config CHECK_SIGNATURE
478 bool 433 bool
479 434
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index 3d35d062970d..c253c1b46c6b 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -6,6 +6,7 @@ if HAVE_ARCH_KASAN
6config KASAN 6config KASAN
7 bool "KASan: runtime memory debugger" 7 bool "KASan: runtime memory debugger"
8 depends on SLUB || (SLAB && !DEBUG_SLAB) 8 depends on SLUB || (SLAB && !DEBUG_SLAB)
9 select SLUB_DEBUG if SLUB
9 select CONSTRUCTORS 10 select CONSTRUCTORS
10 select STACKDEPOT 11 select STACKDEPOT
11 help 12 help
diff --git a/lib/Makefile b/lib/Makefile
index 956b320292fe..90dc5520b784 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -23,15 +23,12 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
23 sha1.o chacha20.o irq_regs.o argv_split.o \ 23 sha1.o chacha20.o irq_regs.o argv_split.o \
24 flex_proportions.o ratelimit.o show_mem.o \ 24 flex_proportions.o ratelimit.o show_mem.o \
25 is_single_threaded.o plist.o decompress.o kobject_uevent.o \ 25 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
26 earlycpio.o seq_buf.o siphash.o \ 26 earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
27 nmi_backtrace.o nodemask.o win_minmax.o 27 nmi_backtrace.o nodemask.o win_minmax.o
28 28
29lib-$(CONFIG_PRINTK) += dump_stack.o 29lib-$(CONFIG_PRINTK) += dump_stack.o
30lib-$(CONFIG_MMU) += ioremap.o 30lib-$(CONFIG_MMU) += ioremap.o
31lib-$(CONFIG_SMP) += cpumask.o 31lib-$(CONFIG_SMP) += cpumask.o
32lib-$(CONFIG_DMA_DIRECT_OPS) += dma-direct.o
33lib-$(CONFIG_DMA_NONCOHERENT_OPS) += dma-noncoherent.o
34lib-$(CONFIG_DMA_VIRT_OPS) += dma-virt.o
35 32
36lib-y += kobject.o klist.o 33lib-y += kobject.o klist.o
37obj-y += lockref.o 34obj-y += lockref.o
@@ -98,10 +95,6 @@ obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
98obj-$(CONFIG_DEBUG_LIST) += list_debug.o 95obj-$(CONFIG_DEBUG_LIST) += list_debug.o
99obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o 96obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
100 97
101ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
102 lib-y += dec_and_lock.o
103endif
104
105obj-$(CONFIG_BITREVERSE) += bitrev.o 98obj-$(CONFIG_BITREVERSE) += bitrev.o
106obj-$(CONFIG_RATIONAL) += rational.o 99obj-$(CONFIG_RATIONAL) += rational.o
107obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o 100obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o
@@ -148,7 +141,6 @@ obj-$(CONFIG_SMP) += percpu_counter.o
148obj-$(CONFIG_AUDIT_GENERIC) += audit.o 141obj-$(CONFIG_AUDIT_GENERIC) += audit.o
149obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o 142obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += compat_audit.o
150 143
151obj-$(CONFIG_SWIOTLB) += swiotlb.o
152obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o 144obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o
153obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o 145obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
154obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o 146obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
@@ -169,8 +161,6 @@ obj-$(CONFIG_NLATTR) += nlattr.o
169 161
170obj-$(CONFIG_LRU_CACHE) += lru_cache.o 162obj-$(CONFIG_LRU_CACHE) += lru_cache.o
171 163
172obj-$(CONFIG_DMA_API_DEBUG) += dma-debug.o
173
174obj-$(CONFIG_GENERIC_CSUM) += checksum.o 164obj-$(CONFIG_GENERIC_CSUM) += checksum.o
175 165
176obj-$(CONFIG_GENERIC_ATOMIC64) += atomic64.o 166obj-$(CONFIG_GENERIC_ATOMIC64) += atomic64.o
diff --git a/lib/dec_and_lock.c b/lib/dec_and_lock.c
index 347fa7ac2e8a..9555b68bb774 100644
--- a/lib/dec_and_lock.c
+++ b/lib/dec_and_lock.c
@@ -33,3 +33,19 @@ int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock)
33} 33}
34 34
35EXPORT_SYMBOL(_atomic_dec_and_lock); 35EXPORT_SYMBOL(_atomic_dec_and_lock);
36
37int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock,
38 unsigned long *flags)
39{
40 /* Subtract 1 from counter unless that drops it to 0 (ie. it was 1) */
41 if (atomic_add_unless(atomic, -1, 1))
42 return 0;
43
44 /* Otherwise do it the slow way */
45 spin_lock_irqsave(lock, *flags);
46 if (atomic_dec_and_test(atomic))
47 return 1;
48 spin_unlock_irqrestore(lock, *flags);
49 return 0;
50}
51EXPORT_SYMBOL(_atomic_dec_and_lock_irqsave);
diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
index 9bbd9c5d375a..beb14839b41a 100644
--- a/lib/percpu_ida.c
+++ b/lib/percpu_ida.c
@@ -141,7 +141,7 @@ int percpu_ida_alloc(struct percpu_ida *pool, int state)
141 spin_lock_irqsave(&tags->lock, flags); 141 spin_lock_irqsave(&tags->lock, flags);
142 142
143 /* Fastpath */ 143 /* Fastpath */
144 if (likely(tags->nr_free >= 0)) { 144 if (likely(tags->nr_free)) {
145 tag = tags->freelist[--tags->nr_free]; 145 tag = tags->freelist[--tags->nr_free];
146 spin_unlock_irqrestore(&tags->lock, flags); 146 spin_unlock_irqrestore(&tags->lock, flags);
147 return tag; 147 return tag;
diff --git a/lib/refcount.c b/lib/refcount.c
index 0eb48353abe3..d3b81cefce91 100644
--- a/lib/refcount.c
+++ b/lib/refcount.c
@@ -350,3 +350,31 @@ bool refcount_dec_and_lock(refcount_t *r, spinlock_t *lock)
350} 350}
351EXPORT_SYMBOL(refcount_dec_and_lock); 351EXPORT_SYMBOL(refcount_dec_and_lock);
352 352
353/**
354 * refcount_dec_and_lock_irqsave - return holding spinlock with disabled
355 * interrupts if able to decrement refcount to 0
356 * @r: the refcount
357 * @lock: the spinlock to be locked
358 * @flags: saved IRQ-flags if the is acquired
359 *
360 * Same as refcount_dec_and_lock() above except that the spinlock is acquired
361 * with disabled interupts.
362 *
363 * Return: true and hold spinlock if able to decrement refcount to 0, false
364 * otherwise
365 */
366bool refcount_dec_and_lock_irqsave(refcount_t *r, spinlock_t *lock,
367 unsigned long *flags)
368{
369 if (refcount_dec_not_one(r))
370 return false;
371
372 spin_lock_irqsave(lock, *flags);
373 if (!refcount_dec_and_test(r)) {
374 spin_unlock_irqrestore(lock, *flags);
375 return false;
376 }
377
378 return true;
379}
380EXPORT_SYMBOL(refcount_dec_and_lock_irqsave);
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 1642fd507a96..7c6096a71704 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -24,9 +24,6 @@
24 **/ 24 **/
25struct scatterlist *sg_next(struct scatterlist *sg) 25struct scatterlist *sg_next(struct scatterlist *sg)
26{ 26{
27#ifdef CONFIG_DEBUG_SG
28 BUG_ON(sg->sg_magic != SG_MAGIC);
29#endif
30 if (sg_is_last(sg)) 27 if (sg_is_last(sg))
31 return NULL; 28 return NULL;
32 29
@@ -111,10 +108,7 @@ struct scatterlist *sg_last(struct scatterlist *sgl, unsigned int nents)
111 for_each_sg(sgl, sg, nents, i) 108 for_each_sg(sgl, sg, nents, i)
112 ret = sg; 109 ret = sg;
113 110
114#ifdef CONFIG_DEBUG_SG
115 BUG_ON(sgl[0].sg_magic != SG_MAGIC);
116 BUG_ON(!sg_is_last(ret)); 111 BUG_ON(!sg_is_last(ret));
117#endif
118 return ret; 112 return ret;
119} 113}
120EXPORT_SYMBOL(sg_last); 114EXPORT_SYMBOL(sg_last);
diff --git a/lib/test_printf.c b/lib/test_printf.c
index b2aa8f514844..cea592f402ed 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -260,13 +260,6 @@ plain(void)
260{ 260{
261 int err; 261 int err;
262 262
263 /*
264 * Make sure crng is ready. Otherwise we get "(ptrval)" instead
265 * of a hashed address when printing '%p' in plain_hash() and
266 * plain_format().
267 */
268 wait_for_random_bytes();
269
270 err = plain_hash(); 263 err = plain_hash();
271 if (err) { 264 if (err) {
272 pr_warn("plain 'p' does not appear to be hashed\n"); 265 pr_warn("plain 'p' does not appear to be hashed\n");
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 347cc834c04a..2e5d3df0853d 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -359,15 +359,8 @@ static void wb_shutdown(struct bdi_writeback *wb)
359 spin_lock_bh(&wb->work_lock); 359 spin_lock_bh(&wb->work_lock);
360 if (!test_and_clear_bit(WB_registered, &wb->state)) { 360 if (!test_and_clear_bit(WB_registered, &wb->state)) {
361 spin_unlock_bh(&wb->work_lock); 361 spin_unlock_bh(&wb->work_lock);
362 /*
363 * Wait for wb shutdown to finish if someone else is just
364 * running wb_shutdown(). Otherwise we could proceed to wb /
365 * bdi destruction before wb_shutdown() is finished.
366 */
367 wait_on_bit(&wb->state, WB_shutting_down, TASK_UNINTERRUPTIBLE);
368 return; 362 return;
369 } 363 }
370 set_bit(WB_shutting_down, &wb->state);
371 spin_unlock_bh(&wb->work_lock); 364 spin_unlock_bh(&wb->work_lock);
372 365
373 cgwb_remove_from_bdi_list(wb); 366 cgwb_remove_from_bdi_list(wb);
@@ -379,12 +372,6 @@ static void wb_shutdown(struct bdi_writeback *wb)
379 mod_delayed_work(bdi_wq, &wb->dwork, 0); 372 mod_delayed_work(bdi_wq, &wb->dwork, 0);
380 flush_delayed_work(&wb->dwork); 373 flush_delayed_work(&wb->dwork);
381 WARN_ON(!list_empty(&wb->work_list)); 374 WARN_ON(!list_empty(&wb->work_list));
382 /*
383 * Make sure bit gets cleared after shutdown is finished. Matches with
384 * the barrier provided by test_and_clear_bit() above.
385 */
386 smp_wmb();
387 clear_and_wake_up_bit(WB_shutting_down, &wb->state);
388} 375}
389 376
390static void wb_exit(struct bdi_writeback *wb) 377static void wb_exit(struct bdi_writeback *wb)
@@ -508,10 +495,12 @@ static void cgwb_release_workfn(struct work_struct *work)
508 struct bdi_writeback *wb = container_of(work, struct bdi_writeback, 495 struct bdi_writeback *wb = container_of(work, struct bdi_writeback,
509 release_work); 496 release_work);
510 497
498 mutex_lock(&wb->bdi->cgwb_release_mutex);
511 wb_shutdown(wb); 499 wb_shutdown(wb);
512 500
513 css_put(wb->memcg_css); 501 css_put(wb->memcg_css);
514 css_put(wb->blkcg_css); 502 css_put(wb->blkcg_css);
503 mutex_unlock(&wb->bdi->cgwb_release_mutex);
515 504
516 fprop_local_destroy_percpu(&wb->memcg_completions); 505 fprop_local_destroy_percpu(&wb->memcg_completions);
517 percpu_ref_exit(&wb->refcnt); 506 percpu_ref_exit(&wb->refcnt);
@@ -697,6 +686,7 @@ static int cgwb_bdi_init(struct backing_dev_info *bdi)
697 686
698 INIT_RADIX_TREE(&bdi->cgwb_tree, GFP_ATOMIC); 687 INIT_RADIX_TREE(&bdi->cgwb_tree, GFP_ATOMIC);
699 bdi->cgwb_congested_tree = RB_ROOT; 688 bdi->cgwb_congested_tree = RB_ROOT;
689 mutex_init(&bdi->cgwb_release_mutex);
700 690
701 ret = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL); 691 ret = wb_init(&bdi->wb, bdi, 1, GFP_KERNEL);
702 if (!ret) { 692 if (!ret) {
@@ -717,7 +707,10 @@ static void cgwb_bdi_unregister(struct backing_dev_info *bdi)
717 spin_lock_irq(&cgwb_lock); 707 spin_lock_irq(&cgwb_lock);
718 radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0) 708 radix_tree_for_each_slot(slot, &bdi->cgwb_tree, &iter, 0)
719 cgwb_kill(*slot); 709 cgwb_kill(*slot);
710 spin_unlock_irq(&cgwb_lock);
720 711
712 mutex_lock(&bdi->cgwb_release_mutex);
713 spin_lock_irq(&cgwb_lock);
721 while (!list_empty(&bdi->wb_list)) { 714 while (!list_empty(&bdi->wb_list)) {
722 wb = list_first_entry(&bdi->wb_list, struct bdi_writeback, 715 wb = list_first_entry(&bdi->wb_list, struct bdi_writeback,
723 bdi_node); 716 bdi_node);
@@ -726,6 +719,7 @@ static void cgwb_bdi_unregister(struct backing_dev_info *bdi)
726 spin_lock_irq(&cgwb_lock); 719 spin_lock_irq(&cgwb_lock);
727 } 720 }
728 spin_unlock_irq(&cgwb_lock); 721 spin_unlock_irq(&cgwb_lock);
722 mutex_unlock(&bdi->cgwb_release_mutex);
729} 723}
730 724
731/** 725/**
diff --git a/mm/memblock.c b/mm/memblock.c
index cc16d70b8333..03d48d8835ba 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -20,7 +20,6 @@
20#include <linux/kmemleak.h> 20#include <linux/kmemleak.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/memblock.h> 22#include <linux/memblock.h>
23#include <linux/bootmem.h>
24 23
25#include <asm/sections.h> 24#include <asm/sections.h>
26#include <linux/io.h> 25#include <linux/io.h>
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 890b1f04a03a..2296caf87bfb 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -567,10 +567,14 @@ static int shutdown_cache(struct kmem_cache *s)
567 list_del(&s->list); 567 list_del(&s->list);
568 568
569 if (s->flags & SLAB_TYPESAFE_BY_RCU) { 569 if (s->flags & SLAB_TYPESAFE_BY_RCU) {
570#ifdef SLAB_SUPPORTS_SYSFS
571 sysfs_slab_unlink(s);
572#endif
570 list_add_tail(&s->list, &slab_caches_to_rcu_destroy); 573 list_add_tail(&s->list, &slab_caches_to_rcu_destroy);
571 schedule_work(&slab_caches_to_rcu_destroy_work); 574 schedule_work(&slab_caches_to_rcu_destroy_work);
572 } else { 575 } else {
573#ifdef SLAB_SUPPORTS_SYSFS 576#ifdef SLAB_SUPPORTS_SYSFS
577 sysfs_slab_unlink(s);
574 sysfs_slab_release(s); 578 sysfs_slab_release(s);
575#else 579#else
576 slab_kmem_cache_release(s); 580 slab_kmem_cache_release(s);
diff --git a/mm/slub.c b/mm/slub.c
index a3b8467c14af..51258eff4178 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5667,7 +5667,6 @@ static void sysfs_slab_remove_workfn(struct work_struct *work)
5667 kset_unregister(s->memcg_kset); 5667 kset_unregister(s->memcg_kset);
5668#endif 5668#endif
5669 kobject_uevent(&s->kobj, KOBJ_REMOVE); 5669 kobject_uevent(&s->kobj, KOBJ_REMOVE);
5670 kobject_del(&s->kobj);
5671out: 5670out:
5672 kobject_put(&s->kobj); 5671 kobject_put(&s->kobj);
5673} 5672}
@@ -5752,6 +5751,12 @@ static void sysfs_slab_remove(struct kmem_cache *s)
5752 schedule_work(&s->kobj_remove_work); 5751 schedule_work(&s->kobj_remove_work);
5753} 5752}
5754 5753
5754void sysfs_slab_unlink(struct kmem_cache *s)
5755{
5756 if (slab_state >= FULL)
5757 kobject_del(&s->kobj);
5758}
5759
5755void sysfs_slab_release(struct kmem_cache *s) 5760void sysfs_slab_release(struct kmem_cache *s)
5756{ 5761{
5757 if (slab_state >= FULL) 5762 if (slab_state >= FULL)
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 75eda9c2b260..8ba0870ecddd 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1796,11 +1796,9 @@ static void vmstat_update(struct work_struct *w)
1796 * to occur in the future. Keep on running the 1796 * to occur in the future. Keep on running the
1797 * update worker thread. 1797 * update worker thread.
1798 */ 1798 */
1799 preempt_disable();
1800 queue_delayed_work_on(smp_processor_id(), mm_percpu_wq, 1799 queue_delayed_work_on(smp_processor_id(), mm_percpu_wq,
1801 this_cpu_ptr(&vmstat_work), 1800 this_cpu_ptr(&vmstat_work),
1802 round_jiffies_relative(sysctl_stat_interval)); 1801 round_jiffies_relative(sysctl_stat_interval));
1803 preempt_enable();
1804 } 1802 }
1805} 1803}
1806 1804
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 55fdba05d7d9..9b6bc5abe946 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1869,7 +1869,7 @@ static const struct proto_ops atalk_dgram_ops = {
1869 .socketpair = sock_no_socketpair, 1869 .socketpair = sock_no_socketpair,
1870 .accept = sock_no_accept, 1870 .accept = sock_no_accept,
1871 .getname = atalk_getname, 1871 .getname = atalk_getname,
1872 .poll_mask = datagram_poll_mask, 1872 .poll = datagram_poll,
1873 .ioctl = atalk_ioctl, 1873 .ioctl = atalk_ioctl,
1874#ifdef CONFIG_COMPAT 1874#ifdef CONFIG_COMPAT
1875 .compat_ioctl = atalk_compat_ioctl, 1875 .compat_ioctl = atalk_compat_ioctl,
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 36b3adacc0dd..10462de734ea 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -252,8 +252,7 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev,
252 252
253 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; 253 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
254 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); 254 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
255 refcount_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); 255 atm_account_tx(atmvcc, skb);
256 ATM_SKB(skb)->atm_options = atmvcc->atm_options;
257 dev->stats.tx_packets++; 256 dev->stats.tx_packets++;
258 dev->stats.tx_bytes += skb->len; 257 dev->stats.tx_bytes += skb->len;
259 258
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 66caa48a27c2..d795b9c5aea4 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -381,8 +381,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
381 memcpy(here, llc_oui, sizeof(llc_oui)); 381 memcpy(here, llc_oui, sizeof(llc_oui));
382 ((__be16 *) here)[3] = skb->protocol; 382 ((__be16 *) here)[3] = skb->protocol;
383 } 383 }
384 refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); 384 atm_account_tx(vcc, skb);
385 ATM_SKB(skb)->atm_options = vcc->atm_options;
386 entry->vccs->last_use = jiffies; 385 entry->vccs->last_use = jiffies;
387 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev); 386 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev);
388 old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ 387 old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */
diff --git a/net/atm/common.c b/net/atm/common.c
index 1f2af59935db..a7a68e509628 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -630,10 +630,9 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size)
630 goto out; 630 goto out;
631 } 631 }
632 pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize); 632 pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize);
633 refcount_add(skb->truesize, &sk->sk_wmem_alloc); 633 atm_account_tx(vcc, skb);
634 634
635 skb->dev = NULL; /* for paths shared with net_device interfaces */ 635 skb->dev = NULL; /* for paths shared with net_device interfaces */
636 ATM_SKB(skb)->atm_options = vcc->atm_options;
637 if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) { 636 if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) {
638 kfree_skb(skb); 637 kfree_skb(skb);
639 error = -EFAULT; 638 error = -EFAULT;
@@ -648,11 +647,16 @@ out:
648 return error; 647 return error;
649} 648}
650 649
651__poll_t vcc_poll_mask(struct socket *sock, __poll_t events) 650__poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
652{ 651{
653 struct sock *sk = sock->sk; 652 struct sock *sk = sock->sk;
654 struct atm_vcc *vcc = ATM_SD(sock); 653 struct atm_vcc *vcc;
655 __poll_t mask = 0; 654 __poll_t mask;
655
656 sock_poll_wait(file, sk_sleep(sk), wait);
657 mask = 0;
658
659 vcc = ATM_SD(sock);
656 660
657 /* exceptional events */ 661 /* exceptional events */
658 if (sk->sk_err) 662 if (sk->sk_err)
diff --git a/net/atm/common.h b/net/atm/common.h
index 526796ad230f..5850649068bb 100644
--- a/net/atm/common.h
+++ b/net/atm/common.h
@@ -17,7 +17,7 @@ int vcc_connect(struct socket *sock, int itf, short vpi, int vci);
17int vcc_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, 17int vcc_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
18 int flags); 18 int flags);
19int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len); 19int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len);
20__poll_t vcc_poll_mask(struct socket *sock, __poll_t events); 20__poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait);
21int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 21int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
22int vcc_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 22int vcc_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
23int vcc_setsockopt(struct socket *sock, int level, int optname, 23int vcc_setsockopt(struct socket *sock, int level, int optname,
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 5a95fcf6f9b6..d7f5cf5b7594 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -182,9 +182,8 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
182 struct net_device *dev = skb->dev; 182 struct net_device *dev = skb->dev;
183 183
184 ATM_SKB(skb)->vcc = vcc; 184 ATM_SKB(skb)->vcc = vcc;
185 ATM_SKB(skb)->atm_options = vcc->atm_options; 185 atm_account_tx(vcc, skb);
186 186
187 refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
188 if (vcc->send(vcc, skb) < 0) { 187 if (vcc->send(vcc, skb) < 0) {
189 dev->stats.tx_dropped++; 188 dev->stats.tx_dropped++;
190 return; 189 return;
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 75620c2f2617..24b53c4c39c6 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -555,8 +555,7 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc)
555 sizeof(struct llc_snap_hdr)); 555 sizeof(struct llc_snap_hdr));
556 } 556 }
557 557
558 refcount_add(skb->truesize, &sk_atm(entry->shortcut)->sk_wmem_alloc); 558 atm_account_tx(entry->shortcut, skb);
559 ATM_SKB(skb)->atm_options = entry->shortcut->atm_options;
560 entry->shortcut->send(entry->shortcut, skb); 559 entry->shortcut->send(entry->shortcut, skb);
561 entry->packets_fwded++; 560 entry->packets_fwded++;
562 mpc->in_ops->put(entry); 561 mpc->in_ops->put(entry);
diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c
index 21d9d341a619..af8c4b38b746 100644
--- a/net/atm/pppoatm.c
+++ b/net/atm/pppoatm.c
@@ -350,8 +350,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb)
350 return 1; 350 return 1;
351 } 351 }
352 352
353 refcount_add(skb->truesize, &sk_atm(ATM_SKB(skb)->vcc)->sk_wmem_alloc); 353 atm_account_tx(vcc, skb);
354 ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options;
355 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", 354 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n",
356 skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev); 355 skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev);
357 ret = ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb) 356 ret = ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb)
diff --git a/net/atm/pvc.c b/net/atm/pvc.c
index 9f75092fe778..2cb10af16afc 100644
--- a/net/atm/pvc.c
+++ b/net/atm/pvc.c
@@ -113,7 +113,7 @@ static const struct proto_ops pvc_proto_ops = {
113 .socketpair = sock_no_socketpair, 113 .socketpair = sock_no_socketpair,
114 .accept = sock_no_accept, 114 .accept = sock_no_accept,
115 .getname = pvc_getname, 115 .getname = pvc_getname,
116 .poll_mask = vcc_poll_mask, 116 .poll = vcc_poll,
117 .ioctl = vcc_ioctl, 117 .ioctl = vcc_ioctl,
118#ifdef CONFIG_COMPAT 118#ifdef CONFIG_COMPAT
119 .compat_ioctl = vcc_compat_ioctl, 119 .compat_ioctl = vcc_compat_ioctl,
diff --git a/net/atm/raw.c b/net/atm/raw.c
index ee10e8d46185..b3ba44aab0ee 100644
--- a/net/atm/raw.c
+++ b/net/atm/raw.c
@@ -35,8 +35,8 @@ static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb)
35 struct sock *sk = sk_atm(vcc); 35 struct sock *sk = sk_atm(vcc);
36 36
37 pr_debug("(%d) %d -= %d\n", 37 pr_debug("(%d) %d -= %d\n",
38 vcc->vci, sk_wmem_alloc_get(sk), skb->truesize); 38 vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize);
39 WARN_ON(refcount_sub_and_test(skb->truesize, &sk->sk_wmem_alloc)); 39 WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc));
40 dev_kfree_skb_any(skb); 40 dev_kfree_skb_any(skb);
41 sk->sk_write_space(sk); 41 sk->sk_write_space(sk);
42} 42}
diff --git a/net/atm/svc.c b/net/atm/svc.c
index 53f4ad7087b1..2f91b766ac42 100644
--- a/net/atm/svc.c
+++ b/net/atm/svc.c
@@ -636,7 +636,7 @@ static const struct proto_ops svc_proto_ops = {
636 .socketpair = sock_no_socketpair, 636 .socketpair = sock_no_socketpair,
637 .accept = svc_accept, 637 .accept = svc_accept,
638 .getname = svc_getname, 638 .getname = svc_getname,
639 .poll_mask = vcc_poll_mask, 639 .poll = vcc_poll,
640 .ioctl = svc_ioctl, 640 .ioctl = svc_ioctl,
641#ifdef CONFIG_COMPAT 641#ifdef CONFIG_COMPAT
642 .compat_ioctl = svc_compat_ioctl, 642 .compat_ioctl = svc_compat_ioctl,
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index d1d2442ce573..c603d33d5410 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1941,7 +1941,7 @@ static const struct proto_ops ax25_proto_ops = {
1941 .socketpair = sock_no_socketpair, 1941 .socketpair = sock_no_socketpair,
1942 .accept = ax25_accept, 1942 .accept = ax25_accept,
1943 .getname = ax25_getname, 1943 .getname = ax25_getname,
1944 .poll_mask = datagram_poll_mask, 1944 .poll = datagram_poll,
1945 .ioctl = ax25_ioctl, 1945 .ioctl = ax25_ioctl,
1946 .listen = ax25_listen, 1946 .listen = ax25_listen,
1947 .shutdown = ax25_shutdown, 1947 .shutdown = ax25_shutdown,
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 510ab4f55df5..3264e1873219 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -437,13 +437,16 @@ static inline __poll_t bt_accept_poll(struct sock *parent)
437 return 0; 437 return 0;
438} 438}
439 439
440__poll_t bt_sock_poll_mask(struct socket *sock, __poll_t events) 440__poll_t bt_sock_poll(struct file *file, struct socket *sock,
441 poll_table *wait)
441{ 442{
442 struct sock *sk = sock->sk; 443 struct sock *sk = sock->sk;
443 __poll_t mask = 0; 444 __poll_t mask = 0;
444 445
445 BT_DBG("sock %p, sk %p", sock, sk); 446 BT_DBG("sock %p, sk %p", sock, sk);
446 447
448 poll_wait(file, sk_sleep(sk), wait);
449
447 if (sk->sk_state == BT_LISTEN) 450 if (sk->sk_state == BT_LISTEN)
448 return bt_accept_poll(sk); 451 return bt_accept_poll(sk);
449 452
@@ -475,7 +478,7 @@ __poll_t bt_sock_poll_mask(struct socket *sock, __poll_t events)
475 478
476 return mask; 479 return mask;
477} 480}
478EXPORT_SYMBOL(bt_sock_poll_mask); 481EXPORT_SYMBOL(bt_sock_poll);
479 482
480int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 483int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
481{ 484{
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index d6c099861538..1506e1632394 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1975,7 +1975,7 @@ static const struct proto_ops hci_sock_ops = {
1975 .sendmsg = hci_sock_sendmsg, 1975 .sendmsg = hci_sock_sendmsg,
1976 .recvmsg = hci_sock_recvmsg, 1976 .recvmsg = hci_sock_recvmsg,
1977 .ioctl = hci_sock_ioctl, 1977 .ioctl = hci_sock_ioctl,
1978 .poll_mask = datagram_poll_mask, 1978 .poll = datagram_poll,
1979 .listen = sock_no_listen, 1979 .listen = sock_no_listen,
1980 .shutdown = sock_no_shutdown, 1980 .shutdown = sock_no_shutdown,
1981 .setsockopt = hci_sock_setsockopt, 1981 .setsockopt = hci_sock_setsockopt,
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 742a190034e6..686bdc6b35b0 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1653,7 +1653,7 @@ static const struct proto_ops l2cap_sock_ops = {
1653 .getname = l2cap_sock_getname, 1653 .getname = l2cap_sock_getname,
1654 .sendmsg = l2cap_sock_sendmsg, 1654 .sendmsg = l2cap_sock_sendmsg,
1655 .recvmsg = l2cap_sock_recvmsg, 1655 .recvmsg = l2cap_sock_recvmsg,
1656 .poll_mask = bt_sock_poll_mask, 1656 .poll = bt_sock_poll,
1657 .ioctl = bt_sock_ioctl, 1657 .ioctl = bt_sock_ioctl,
1658 .mmap = sock_no_mmap, 1658 .mmap = sock_no_mmap,
1659 .socketpair = sock_no_socketpair, 1659 .socketpair = sock_no_socketpair,
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 1cf57622473a..d606e9212291 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -1049,7 +1049,7 @@ static const struct proto_ops rfcomm_sock_ops = {
1049 .setsockopt = rfcomm_sock_setsockopt, 1049 .setsockopt = rfcomm_sock_setsockopt,
1050 .getsockopt = rfcomm_sock_getsockopt, 1050 .getsockopt = rfcomm_sock_getsockopt,
1051 .ioctl = rfcomm_sock_ioctl, 1051 .ioctl = rfcomm_sock_ioctl,
1052 .poll_mask = bt_sock_poll_mask, 1052 .poll = bt_sock_poll,
1053 .socketpair = sock_no_socketpair, 1053 .socketpair = sock_no_socketpair,
1054 .mmap = sock_no_mmap 1054 .mmap = sock_no_mmap
1055}; 1055};
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index d60dbc61d170..413b8ee49fec 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -1197,7 +1197,7 @@ static const struct proto_ops sco_sock_ops = {
1197 .getname = sco_sock_getname, 1197 .getname = sco_sock_getname,
1198 .sendmsg = sco_sock_sendmsg, 1198 .sendmsg = sco_sock_sendmsg,
1199 .recvmsg = sco_sock_recvmsg, 1199 .recvmsg = sco_sock_recvmsg,
1200 .poll_mask = bt_sock_poll_mask, 1200 .poll = bt_sock_poll,
1201 .ioctl = bt_sock_ioctl, 1201 .ioctl = bt_sock_ioctl,
1202 .mmap = sock_no_mmap, 1202 .mmap = sock_no_mmap,
1203 .socketpair = sock_no_socketpair, 1203 .socketpair = sock_no_socketpair,
diff --git a/net/bpfilter/.gitignore b/net/bpfilter/.gitignore
new file mode 100644
index 000000000000..e97084e3eea2
--- /dev/null
+++ b/net/bpfilter/.gitignore
@@ -0,0 +1 @@
bpfilter_umh
diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index e0bbe7583e58..051dc18b8ccb 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -21,8 +21,10 @@ endif
21# which bpfilter_kern.c passes further into umh blob loader at run-time 21# which bpfilter_kern.c passes further into umh blob loader at run-time
22quiet_cmd_copy_umh = GEN $@ 22quiet_cmd_copy_umh = GEN $@
23 cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \ 23 cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \
24 $(OBJCOPY) -I binary -O `$(OBJDUMP) -f $<|grep format|cut -d' ' -f8` \ 24 $(OBJCOPY) -I binary \
25 -B `$(OBJDUMP) -f $<|grep architecture|cut -d, -f1|cut -d' ' -f2` \ 25 `LC_ALL=C $(OBJDUMP) -f net/bpfilter/bpfilter_umh \
26 |awk -F' |,' '/file format/{print "-O",$$NF} \
27 /^architecture:/{print "-B",$$2}'` \
26 --rename-section .data=.init.rodata $< $@ 28 --rename-section .data=.init.rodata $< $@
27 29
28$(obj)/bpfilter_umh.o: $(obj)/bpfilter_umh 30$(obj)/bpfilter_umh.o: $(obj)/bpfilter_umh
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index c7991867d622..a6fb1b3bcad9 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -934,11 +934,15 @@ static int caif_release(struct socket *sock)
934} 934}
935 935
936/* Copied from af_unix.c:unix_poll(), added CAIF tx_flow handling */ 936/* Copied from af_unix.c:unix_poll(), added CAIF tx_flow handling */
937static __poll_t caif_poll_mask(struct socket *sock, __poll_t events) 937static __poll_t caif_poll(struct file *file,
938 struct socket *sock, poll_table *wait)
938{ 939{
939 struct sock *sk = sock->sk; 940 struct sock *sk = sock->sk;
941 __poll_t mask;
940 struct caifsock *cf_sk = container_of(sk, struct caifsock, sk); 942 struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
941 __poll_t mask = 0; 943
944 sock_poll_wait(file, sk_sleep(sk), wait);
945 mask = 0;
942 946
943 /* exceptional events? */ 947 /* exceptional events? */
944 if (sk->sk_err) 948 if (sk->sk_err)
@@ -972,7 +976,7 @@ static const struct proto_ops caif_seqpacket_ops = {
972 .socketpair = sock_no_socketpair, 976 .socketpair = sock_no_socketpair,
973 .accept = sock_no_accept, 977 .accept = sock_no_accept,
974 .getname = sock_no_getname, 978 .getname = sock_no_getname,
975 .poll_mask = caif_poll_mask, 979 .poll = caif_poll,
976 .ioctl = sock_no_ioctl, 980 .ioctl = sock_no_ioctl,
977 .listen = sock_no_listen, 981 .listen = sock_no_listen,
978 .shutdown = sock_no_shutdown, 982 .shutdown = sock_no_shutdown,
@@ -993,7 +997,7 @@ static const struct proto_ops caif_stream_ops = {
993 .socketpair = sock_no_socketpair, 997 .socketpair = sock_no_socketpair,
994 .accept = sock_no_accept, 998 .accept = sock_no_accept,
995 .getname = sock_no_getname, 999 .getname = sock_no_getname,
996 .poll_mask = caif_poll_mask, 1000 .poll = caif_poll,
997 .ioctl = sock_no_ioctl, 1001 .ioctl = sock_no_ioctl,
998 .listen = sock_no_listen, 1002 .listen = sock_no_listen,
999 .shutdown = sock_no_shutdown, 1003 .shutdown = sock_no_shutdown,
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 9393f25df08d..0af8f0db892a 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1660,7 +1660,7 @@ static const struct proto_ops bcm_ops = {
1660 .socketpair = sock_no_socketpair, 1660 .socketpair = sock_no_socketpair,
1661 .accept = sock_no_accept, 1661 .accept = sock_no_accept,
1662 .getname = sock_no_getname, 1662 .getname = sock_no_getname,
1663 .poll_mask = datagram_poll_mask, 1663 .poll = datagram_poll,
1664 .ioctl = can_ioctl, /* use can_ioctl() from af_can.c */ 1664 .ioctl = can_ioctl, /* use can_ioctl() from af_can.c */
1665 .listen = sock_no_listen, 1665 .listen = sock_no_listen,
1666 .shutdown = sock_no_shutdown, 1666 .shutdown = sock_no_shutdown,
diff --git a/net/can/raw.c b/net/can/raw.c
index fd7e2f49ea6a..1051eee82581 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -843,7 +843,7 @@ static const struct proto_ops raw_ops = {
843 .socketpair = sock_no_socketpair, 843 .socketpair = sock_no_socketpair,
844 .accept = sock_no_accept, 844 .accept = sock_no_accept,
845 .getname = raw_getname, 845 .getname = raw_getname,
846 .poll_mask = datagram_poll_mask, 846 .poll = datagram_poll,
847 .ioctl = can_ioctl, /* use can_ioctl() from af_can.c */ 847 .ioctl = can_ioctl, /* use can_ioctl() from af_can.c */
848 .listen = sock_no_listen, 848 .listen = sock_no_listen,
849 .shutdown = sock_no_shutdown, 849 .shutdown = sock_no_shutdown,
diff --git a/net/core/datagram.c b/net/core/datagram.c
index f19bf3dc2bd6..9938952c5c78 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -819,8 +819,9 @@ EXPORT_SYMBOL(skb_copy_and_csum_datagram_msg);
819 819
820/** 820/**
821 * datagram_poll - generic datagram poll 821 * datagram_poll - generic datagram poll
822 * @file: file struct
822 * @sock: socket 823 * @sock: socket
823 * @events to wait for 824 * @wait: poll table
824 * 825 *
825 * Datagram poll: Again totally generic. This also handles 826 * Datagram poll: Again totally generic. This also handles
826 * sequenced packet sockets providing the socket receive queue 827 * sequenced packet sockets providing the socket receive queue
@@ -830,10 +831,14 @@ EXPORT_SYMBOL(skb_copy_and_csum_datagram_msg);
830 * and you use a different write policy from sock_writeable() 831 * and you use a different write policy from sock_writeable()
831 * then please supply your own write_space callback. 832 * then please supply your own write_space callback.
832 */ 833 */
833__poll_t datagram_poll_mask(struct socket *sock, __poll_t events) 834__poll_t datagram_poll(struct file *file, struct socket *sock,
835 poll_table *wait)
834{ 836{
835 struct sock *sk = sock->sk; 837 struct sock *sk = sock->sk;
836 __poll_t mask = 0; 838 __poll_t mask;
839
840 sock_poll_wait(file, sk_sleep(sk), wait);
841 mask = 0;
837 842
838 /* exceptional events? */ 843 /* exceptional events? */
839 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 844 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
@@ -866,4 +871,4 @@ __poll_t datagram_poll_mask(struct socket *sock, __poll_t events)
866 871
867 return mask; 872 return mask;
868} 873}
869EXPORT_SYMBOL(datagram_poll_mask); 874EXPORT_SYMBOL(datagram_poll);
diff --git a/net/core/dev.c b/net/core/dev.c
index 57b7bab5f70b..a5aa1c7444e6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8643,7 +8643,8 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
8643 /* We get here if we can't use the current device name */ 8643 /* We get here if we can't use the current device name */
8644 if (!pat) 8644 if (!pat)
8645 goto out; 8645 goto out;
8646 if (dev_get_valid_name(net, dev, pat) < 0) 8646 err = dev_get_valid_name(net, dev, pat);
8647 if (err < 0)
8647 goto out; 8648 goto out;
8648 } 8649 }
8649 8650
@@ -8655,7 +8656,6 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
8655 dev_close(dev); 8656 dev_close(dev);
8656 8657
8657 /* And unlink it from device chain */ 8658 /* And unlink it from device chain */
8658 err = -ENODEV;
8659 unlist_netdevice(dev); 8659 unlist_netdevice(dev);
8660 8660
8661 synchronize_net(); 8661 synchronize_net();
diff --git a/net/core/filter.c b/net/core/filter.c
index 3d9ba7e5965a..e7f12e9f598c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3214,20 +3214,6 @@ err:
3214} 3214}
3215EXPORT_SYMBOL_GPL(xdp_do_redirect); 3215EXPORT_SYMBOL_GPL(xdp_do_redirect);
3216 3216
3217static int __xdp_generic_ok_fwd_dev(struct sk_buff *skb, struct net_device *fwd)
3218{
3219 unsigned int len;
3220
3221 if (unlikely(!(fwd->flags & IFF_UP)))
3222 return -ENETDOWN;
3223
3224 len = fwd->mtu + fwd->hard_header_len + VLAN_HLEN;
3225 if (skb->len > len)
3226 return -EMSGSIZE;
3227
3228 return 0;
3229}
3230
3231static int xdp_do_generic_redirect_map(struct net_device *dev, 3217static int xdp_do_generic_redirect_map(struct net_device *dev,
3232 struct sk_buff *skb, 3218 struct sk_buff *skb,
3233 struct xdp_buff *xdp, 3219 struct xdp_buff *xdp,
@@ -3256,10 +3242,11 @@ static int xdp_do_generic_redirect_map(struct net_device *dev,
3256 } 3242 }
3257 3243
3258 if (map->map_type == BPF_MAP_TYPE_DEVMAP) { 3244 if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
3259 if (unlikely((err = __xdp_generic_ok_fwd_dev(skb, fwd)))) 3245 struct bpf_dtab_netdev *dst = fwd;
3246
3247 err = dev_map_generic_redirect(dst, skb, xdp_prog);
3248 if (unlikely(err))
3260 goto err; 3249 goto err;
3261 skb->dev = fwd;
3262 generic_xdp_tx(skb, xdp_prog);
3263 } else if (map->map_type == BPF_MAP_TYPE_XSKMAP) { 3250 } else if (map->map_type == BPF_MAP_TYPE_XSKMAP) {
3264 struct xdp_sock *xs = fwd; 3251 struct xdp_sock *xs = fwd;
3265 3252
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 8b5ba6dffac7..12877a1514e7 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -600,7 +600,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
600{ 600{
601 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); 601 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
602 struct dccp_sock *dp = dccp_sk(sk); 602 struct dccp_sock *dp = dccp_sk(sk);
603 ktime_t now = ktime_get_real(); 603 ktime_t now = ktime_get();
604 s64 delta = 0; 604 s64 delta = 0;
605 605
606 switch (fbtype) { 606 switch (fbtype) {
@@ -625,15 +625,14 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
625 case CCID3_FBACK_PERIODIC: 625 case CCID3_FBACK_PERIODIC:
626 delta = ktime_us_delta(now, hc->rx_tstamp_last_feedback); 626 delta = ktime_us_delta(now, hc->rx_tstamp_last_feedback);
627 if (delta <= 0) 627 if (delta <= 0)
628 DCCP_BUG("delta (%ld) <= 0", (long)delta); 628 delta = 1;
629 else 629 hc->rx_x_recv = scaled_div32(hc->rx_bytes_recv, delta);
630 hc->rx_x_recv = scaled_div32(hc->rx_bytes_recv, delta);
631 break; 630 break;
632 default: 631 default:
633 return; 632 return;
634 } 633 }
635 634
636 ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", (long)delta, 635 ccid3_pr_debug("Interval %lldusec, X_recv=%u, 1/p=%u\n", delta,
637 hc->rx_x_recv, hc->rx_pinv); 636 hc->rx_x_recv, hc->rx_pinv);
638 637
639 hc->rx_tstamp_last_feedback = now; 638 hc->rx_tstamp_last_feedback = now;
@@ -680,7 +679,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
680static u32 ccid3_first_li(struct sock *sk) 679static u32 ccid3_first_li(struct sock *sk)
681{ 680{
682 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); 681 struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
683 u32 x_recv, p, delta; 682 u32 x_recv, p;
683 s64 delta;
684 u64 fval; 684 u64 fval;
685 685
686 if (hc->rx_rtt == 0) { 686 if (hc->rx_rtt == 0) {
@@ -688,7 +688,9 @@ static u32 ccid3_first_li(struct sock *sk)
688 hc->rx_rtt = DCCP_FALLBACK_RTT; 688 hc->rx_rtt = DCCP_FALLBACK_RTT;
689 } 689 }
690 690
691 delta = ktime_to_us(net_timedelta(hc->rx_tstamp_last_feedback)); 691 delta = ktime_us_delta(ktime_get(), hc->rx_tstamp_last_feedback);
692 if (delta <= 0)
693 delta = 1;
692 x_recv = scaled_div32(hc->rx_bytes_recv, delta); 694 x_recv = scaled_div32(hc->rx_bytes_recv, delta);
693 if (x_recv == 0) { /* would also trigger divide-by-zero */ 695 if (x_recv == 0) { /* would also trigger divide-by-zero */
694 DCCP_WARN("X_recv==0\n"); 696 DCCP_WARN("X_recv==0\n");
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 0ea2ee56ac1b..f91e3816806b 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -316,7 +316,8 @@ int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
316 int flags, int *addr_len); 316 int flags, int *addr_len);
317void dccp_shutdown(struct sock *sk, int how); 317void dccp_shutdown(struct sock *sk, int how);
318int inet_dccp_listen(struct socket *sock, int backlog); 318int inet_dccp_listen(struct socket *sock, int backlog);
319__poll_t dccp_poll_mask(struct socket *sock, __poll_t events); 319__poll_t dccp_poll(struct file *file, struct socket *sock,
320 poll_table *wait);
320int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len); 321int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len);
321void dccp_req_err(struct sock *sk, u64 seq); 322void dccp_req_err(struct sock *sk, u64 seq);
322 323
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index a9e478cd3787..b08feb219b44 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -984,7 +984,7 @@ static const struct proto_ops inet_dccp_ops = {
984 .accept = inet_accept, 984 .accept = inet_accept,
985 .getname = inet_getname, 985 .getname = inet_getname,
986 /* FIXME: work on tcp_poll to rename it to inet_csk_poll */ 986 /* FIXME: work on tcp_poll to rename it to inet_csk_poll */
987 .poll_mask = dccp_poll_mask, 987 .poll = dccp_poll,
988 .ioctl = inet_ioctl, 988 .ioctl = inet_ioctl,
989 /* FIXME: work on inet_listen to rename it to sock_common_listen */ 989 /* FIXME: work on inet_listen to rename it to sock_common_listen */
990 .listen = inet_dccp_listen, 990 .listen = inet_dccp_listen,
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 17fc4e0166ba..6344f1b18a6a 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1070,7 +1070,7 @@ static const struct proto_ops inet6_dccp_ops = {
1070 .socketpair = sock_no_socketpair, 1070 .socketpair = sock_no_socketpair,
1071 .accept = inet_accept, 1071 .accept = inet_accept,
1072 .getname = inet6_getname, 1072 .getname = inet6_getname,
1073 .poll_mask = dccp_poll_mask, 1073 .poll = dccp_poll,
1074 .ioctl = inet6_ioctl, 1074 .ioctl = inet6_ioctl,
1075 .listen = inet_dccp_listen, 1075 .listen = inet_dccp_listen,
1076 .shutdown = inet_shutdown, 1076 .shutdown = inet_shutdown,
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index ca21c1c76da0..0d56e36a6db7 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -312,11 +312,20 @@ int dccp_disconnect(struct sock *sk, int flags)
312 312
313EXPORT_SYMBOL_GPL(dccp_disconnect); 313EXPORT_SYMBOL_GPL(dccp_disconnect);
314 314
315__poll_t dccp_poll_mask(struct socket *sock, __poll_t events) 315/*
316 * Wait for a DCCP event.
317 *
318 * Note that we don't need to lock the socket, as the upper poll layers
319 * take care of normal races (between the test and the event) and we don't
320 * go look at any of the socket buffers directly.
321 */
322__poll_t dccp_poll(struct file *file, struct socket *sock,
323 poll_table *wait)
316{ 324{
317 __poll_t mask; 325 __poll_t mask;
318 struct sock *sk = sock->sk; 326 struct sock *sk = sock->sk;
319 327
328 sock_poll_wait(file, sk_sleep(sk), wait);
320 if (sk->sk_state == DCCP_LISTEN) 329 if (sk->sk_state == DCCP_LISTEN)
321 return inet_csk_listen_poll(sk); 330 return inet_csk_listen_poll(sk);
322 331
@@ -358,7 +367,7 @@ __poll_t dccp_poll_mask(struct socket *sock, __poll_t events)
358 return mask; 367 return mask;
359} 368}
360 369
361EXPORT_SYMBOL_GPL(dccp_poll_mask); 370EXPORT_SYMBOL_GPL(dccp_poll);
362 371
363int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) 372int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
364{ 373{
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 9a686d890bfa..7d6ff983ba2c 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -1207,11 +1207,11 @@ static int dn_getname(struct socket *sock, struct sockaddr *uaddr,int peer)
1207} 1207}
1208 1208
1209 1209
1210static __poll_t dn_poll_mask(struct socket *sock, __poll_t events) 1210static __poll_t dn_poll(struct file *file, struct socket *sock, poll_table *wait)
1211{ 1211{
1212 struct sock *sk = sock->sk; 1212 struct sock *sk = sock->sk;
1213 struct dn_scp *scp = DN_SK(sk); 1213 struct dn_scp *scp = DN_SK(sk);
1214 __poll_t mask = datagram_poll_mask(sock, events); 1214 __poll_t mask = datagram_poll(file, sock, wait);
1215 1215
1216 if (!skb_queue_empty(&scp->other_receive_queue)) 1216 if (!skb_queue_empty(&scp->other_receive_queue))
1217 mask |= EPOLLRDBAND; 1217 mask |= EPOLLRDBAND;
@@ -2331,7 +2331,7 @@ static const struct proto_ops dn_proto_ops = {
2331 .socketpair = sock_no_socketpair, 2331 .socketpair = sock_no_socketpair,
2332 .accept = dn_accept, 2332 .accept = dn_accept,
2333 .getname = dn_getname, 2333 .getname = dn_getname,
2334 .poll_mask = dn_poll_mask, 2334 .poll = dn_poll,
2335 .ioctl = dn_ioctl, 2335 .ioctl = dn_ioctl,
2336 .listen = dn_listen, 2336 .listen = dn_listen,
2337 .shutdown = dn_shutdown, 2337 .shutdown = dn_shutdown,
diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
index a0768d2759b8..a60658c85a9a 100644
--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
@@ -423,7 +423,7 @@ static const struct proto_ops ieee802154_raw_ops = {
423 .socketpair = sock_no_socketpair, 423 .socketpair = sock_no_socketpair,
424 .accept = sock_no_accept, 424 .accept = sock_no_accept,
425 .getname = sock_no_getname, 425 .getname = sock_no_getname,
426 .poll_mask = datagram_poll_mask, 426 .poll = datagram_poll,
427 .ioctl = ieee802154_sock_ioctl, 427 .ioctl = ieee802154_sock_ioctl,
428 .listen = sock_no_listen, 428 .listen = sock_no_listen,
429 .shutdown = sock_no_shutdown, 429 .shutdown = sock_no_shutdown,
@@ -969,7 +969,7 @@ static const struct proto_ops ieee802154_dgram_ops = {
969 .socketpair = sock_no_socketpair, 969 .socketpair = sock_no_socketpair,
970 .accept = sock_no_accept, 970 .accept = sock_no_accept,
971 .getname = sock_no_getname, 971 .getname = sock_no_getname,
972 .poll_mask = datagram_poll_mask, 972 .poll = datagram_poll,
973 .ioctl = ieee802154_sock_ioctl, 973 .ioctl = ieee802154_sock_ioctl,
974 .listen = sock_no_listen, 974 .listen = sock_no_listen,
975 .shutdown = sock_no_shutdown, 975 .shutdown = sock_no_shutdown,
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 15e125558c76..b403499fdabe 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -986,7 +986,7 @@ const struct proto_ops inet_stream_ops = {
986 .socketpair = sock_no_socketpair, 986 .socketpair = sock_no_socketpair,
987 .accept = inet_accept, 987 .accept = inet_accept,
988 .getname = inet_getname, 988 .getname = inet_getname,
989 .poll_mask = tcp_poll_mask, 989 .poll = tcp_poll,
990 .ioctl = inet_ioctl, 990 .ioctl = inet_ioctl,
991 .listen = inet_listen, 991 .listen = inet_listen,
992 .shutdown = inet_shutdown, 992 .shutdown = inet_shutdown,
@@ -1021,7 +1021,7 @@ const struct proto_ops inet_dgram_ops = {
1021 .socketpair = sock_no_socketpair, 1021 .socketpair = sock_no_socketpair,
1022 .accept = sock_no_accept, 1022 .accept = sock_no_accept,
1023 .getname = inet_getname, 1023 .getname = inet_getname,
1024 .poll_mask = udp_poll_mask, 1024 .poll = udp_poll,
1025 .ioctl = inet_ioctl, 1025 .ioctl = inet_ioctl,
1026 .listen = sock_no_listen, 1026 .listen = sock_no_listen,
1027 .shutdown = inet_shutdown, 1027 .shutdown = inet_shutdown,
@@ -1042,7 +1042,7 @@ EXPORT_SYMBOL(inet_dgram_ops);
1042 1042
1043/* 1043/*
1044 * For SOCK_RAW sockets; should be the same as inet_dgram_ops but without 1044 * For SOCK_RAW sockets; should be the same as inet_dgram_ops but without
1045 * udp_poll_mask 1045 * udp_poll
1046 */ 1046 */
1047static const struct proto_ops inet_sockraw_ops = { 1047static const struct proto_ops inet_sockraw_ops = {
1048 .family = PF_INET, 1048 .family = PF_INET,
@@ -1053,7 +1053,7 @@ static const struct proto_ops inet_sockraw_ops = {
1053 .socketpair = sock_no_socketpair, 1053 .socketpair = sock_no_socketpair,
1054 .accept = sock_no_accept, 1054 .accept = sock_no_accept,
1055 .getname = inet_getname, 1055 .getname = inet_getname,
1056 .poll_mask = datagram_poll_mask, 1056 .poll = datagram_poll,
1057 .ioctl = inet_ioctl, 1057 .ioctl = inet_ioctl,
1058 .listen = sock_no_listen, 1058 .listen = sock_no_listen,
1059 .shutdown = inet_shutdown, 1059 .shutdown = inet_shutdown,
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 31ff46daae97..3647167c8fa3 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -243,9 +243,9 @@ static inline int compute_score(struct sock *sk, struct net *net,
243 bool dev_match = (sk->sk_bound_dev_if == dif || 243 bool dev_match = (sk->sk_bound_dev_if == dif ||
244 sk->sk_bound_dev_if == sdif); 244 sk->sk_bound_dev_if == sdif);
245 245
246 if (exact_dif && !dev_match) 246 if (!dev_match)
247 return -1; 247 return -1;
248 if (sk->sk_bound_dev_if && dev_match) 248 if (sk->sk_bound_dev_if)
249 score += 4; 249 score += 4;
250 } 250 }
251 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 251 if (sk->sk_incoming_cpu == raw_smp_processor_id())
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index af5a830ff6ad..b3308e9d9762 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1145,7 +1145,8 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
1145 cork->fragsize = ip_sk_use_pmtu(sk) ? 1145 cork->fragsize = ip_sk_use_pmtu(sk) ?
1146 dst_mtu(&rt->dst) : rt->dst.dev->mtu; 1146 dst_mtu(&rt->dst) : rt->dst.dev->mtu;
1147 1147
1148 cork->gso_size = sk->sk_type == SOCK_DGRAM ? ipc->gso_size : 0; 1148 cork->gso_size = sk->sk_type == SOCK_DGRAM &&
1149 sk->sk_protocol == IPPROTO_UDP ? ipc->gso_size : 0;
1149 cork->dst = &rt->dst; 1150 cork->dst = &rt->dst;
1150 cork->length = 0; 1151 cork->length = 0;
1151 cork->ttl = ipc->ttl; 1152 cork->ttl = ipc->ttl;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 141acd92e58a..e7b53d2a971f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -494,21 +494,32 @@ static inline bool tcp_stream_is_readable(const struct tcp_sock *tp,
494} 494}
495 495
496/* 496/*
497 * Socket is not locked. We are protected from async events by poll logic and 497 * Wait for a TCP event.
498 * correct handling of state changes made by other threads is impossible in 498 *
499 * any case. 499 * Note that we don't need to lock the socket, as the upper poll layers
500 * take care of normal races (between the test and the event) and we don't
501 * go look at any of the socket buffers directly.
500 */ 502 */
501__poll_t tcp_poll_mask(struct socket *sock, __poll_t events) 503__poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
502{ 504{
505 __poll_t mask;
503 struct sock *sk = sock->sk; 506 struct sock *sk = sock->sk;
504 const struct tcp_sock *tp = tcp_sk(sk); 507 const struct tcp_sock *tp = tcp_sk(sk);
505 __poll_t mask = 0;
506 int state; 508 int state;
507 509
510 sock_poll_wait(file, sk_sleep(sk), wait);
511
508 state = inet_sk_state_load(sk); 512 state = inet_sk_state_load(sk);
509 if (state == TCP_LISTEN) 513 if (state == TCP_LISTEN)
510 return inet_csk_listen_poll(sk); 514 return inet_csk_listen_poll(sk);
511 515
516 /* Socket is not locked. We are protected from async events
517 * by poll logic and correct handling of state changes
518 * made by other threads is impossible in any case.
519 */
520
521 mask = 0;
522
512 /* 523 /*
513 * EPOLLHUP is certainly not done right. But poll() doesn't 524 * EPOLLHUP is certainly not done right. But poll() doesn't
514 * have a notion of HUP in just one direction, and for a 525 * have a notion of HUP in just one direction, and for a
@@ -589,7 +600,7 @@ __poll_t tcp_poll_mask(struct socket *sock, __poll_t events)
589 600
590 return mask; 601 return mask;
591} 602}
592EXPORT_SYMBOL(tcp_poll_mask); 603EXPORT_SYMBOL(tcp_poll);
593 604
594int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg) 605int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
595{ 606{
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 9bb27df4dac5..24e116ddae79 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2591,7 +2591,7 @@ int compat_udp_getsockopt(struct sock *sk, int level, int optname,
2591 * udp_poll - wait for a UDP event. 2591 * udp_poll - wait for a UDP event.
2592 * @file - file struct 2592 * @file - file struct
2593 * @sock - socket 2593 * @sock - socket
2594 * @events - events to wait for 2594 * @wait - poll table
2595 * 2595 *
2596 * This is same as datagram poll, except for the special case of 2596 * This is same as datagram poll, except for the special case of
2597 * blocking sockets. If application is using a blocking fd 2597 * blocking sockets. If application is using a blocking fd
@@ -2600,23 +2600,23 @@ int compat_udp_getsockopt(struct sock *sk, int level, int optname,
2600 * but then block when reading it. Add special case code 2600 * but then block when reading it. Add special case code
2601 * to work around these arguably broken applications. 2601 * to work around these arguably broken applications.
2602 */ 2602 */
2603__poll_t udp_poll_mask(struct socket *sock, __poll_t events) 2603__poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait)
2604{ 2604{
2605 __poll_t mask = datagram_poll_mask(sock, events); 2605 __poll_t mask = datagram_poll(file, sock, wait);
2606 struct sock *sk = sock->sk; 2606 struct sock *sk = sock->sk;
2607 2607
2608 if (!skb_queue_empty(&udp_sk(sk)->reader_queue)) 2608 if (!skb_queue_empty(&udp_sk(sk)->reader_queue))
2609 mask |= EPOLLIN | EPOLLRDNORM; 2609 mask |= EPOLLIN | EPOLLRDNORM;
2610 2610
2611 /* Check for false positives due to checksum errors */ 2611 /* Check for false positives due to checksum errors */
2612 if ((mask & EPOLLRDNORM) && !(sock->file->f_flags & O_NONBLOCK) && 2612 if ((mask & EPOLLRDNORM) && !(file->f_flags & O_NONBLOCK) &&
2613 !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1) 2613 !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1)
2614 mask &= ~(EPOLLIN | EPOLLRDNORM); 2614 mask &= ~(EPOLLIN | EPOLLRDNORM);
2615 2615
2616 return mask; 2616 return mask;
2617 2617
2618} 2618}
2619EXPORT_SYMBOL(udp_poll_mask); 2619EXPORT_SYMBOL(udp_poll);
2620 2620
2621int udp_abort(struct sock *sk, int err) 2621int udp_abort(struct sock *sk, int err)
2622{ 2622{
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 74f2a261e8df..9ed0eae91758 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -570,7 +570,7 @@ const struct proto_ops inet6_stream_ops = {
570 .socketpair = sock_no_socketpair, /* a do nothing */ 570 .socketpair = sock_no_socketpair, /* a do nothing */
571 .accept = inet_accept, /* ok */ 571 .accept = inet_accept, /* ok */
572 .getname = inet6_getname, 572 .getname = inet6_getname,
573 .poll_mask = tcp_poll_mask, /* ok */ 573 .poll = tcp_poll, /* ok */
574 .ioctl = inet6_ioctl, /* must change */ 574 .ioctl = inet6_ioctl, /* must change */
575 .listen = inet_listen, /* ok */ 575 .listen = inet_listen, /* ok */
576 .shutdown = inet_shutdown, /* ok */ 576 .shutdown = inet_shutdown, /* ok */
@@ -603,7 +603,7 @@ const struct proto_ops inet6_dgram_ops = {
603 .socketpair = sock_no_socketpair, /* a do nothing */ 603 .socketpair = sock_no_socketpair, /* a do nothing */
604 .accept = sock_no_accept, /* a do nothing */ 604 .accept = sock_no_accept, /* a do nothing */
605 .getname = inet6_getname, 605 .getname = inet6_getname,
606 .poll_mask = udp_poll_mask, /* ok */ 606 .poll = udp_poll, /* ok */
607 .ioctl = inet6_ioctl, /* must change */ 607 .ioctl = inet6_ioctl, /* must change */
608 .listen = sock_no_listen, /* ok */ 608 .listen = sock_no_listen, /* ok */
609 .shutdown = inet_shutdown, /* ok */ 609 .shutdown = inet_shutdown, /* ok */
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 2febe26de6a1..595ad408dba0 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -113,9 +113,9 @@ static inline int compute_score(struct sock *sk, struct net *net,
113 bool dev_match = (sk->sk_bound_dev_if == dif || 113 bool dev_match = (sk->sk_bound_dev_if == dif ||
114 sk->sk_bound_dev_if == sdif); 114 sk->sk_bound_dev_if == sdif);
115 115
116 if (exact_dif && !dev_match) 116 if (!dev_match)
117 return -1; 117 return -1;
118 if (sk->sk_bound_dev_if && dev_match) 118 if (sk->sk_bound_dev_if)
119 score++; 119 score++;
120 } 120 }
121 if (sk->sk_incoming_cpu == raw_smp_processor_id()) 121 if (sk->sk_incoming_cpu == raw_smp_processor_id())
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 39d1d487eca2..1fb2f3118d60 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -167,8 +167,9 @@ struct fib6_info *fib6_info_alloc(gfp_t gfp_flags)
167 return f6i; 167 return f6i;
168} 168}
169 169
170void fib6_info_destroy(struct fib6_info *f6i) 170void fib6_info_destroy_rcu(struct rcu_head *head)
171{ 171{
172 struct fib6_info *f6i = container_of(head, struct fib6_info, rcu);
172 struct rt6_exception_bucket *bucket; 173 struct rt6_exception_bucket *bucket;
173 struct dst_metrics *m; 174 struct dst_metrics *m;
174 175
@@ -206,7 +207,7 @@ void fib6_info_destroy(struct fib6_info *f6i)
206 207
207 kfree(f6i); 208 kfree(f6i);
208} 209}
209EXPORT_SYMBOL_GPL(fib6_info_destroy); 210EXPORT_SYMBOL_GPL(fib6_info_destroy_rcu);
210 211
211static struct fib6_node *node_alloc(struct net *net) 212static struct fib6_node *node_alloc(struct net *net)
212{ 213{
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 021e5aef6ba3..a14fb4fcdf18 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1219,7 +1219,8 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
1219 if (mtu < IPV6_MIN_MTU) 1219 if (mtu < IPV6_MIN_MTU)
1220 return -EINVAL; 1220 return -EINVAL;
1221 cork->base.fragsize = mtu; 1221 cork->base.fragsize = mtu;
1222 cork->base.gso_size = sk->sk_type == SOCK_DGRAM ? ipc6->gso_size : 0; 1222 cork->base.gso_size = sk->sk_type == SOCK_DGRAM &&
1223 sk->sk_protocol == IPPROTO_UDP ? ipc6->gso_size : 0;
1223 1224
1224 if (dst_allfrag(xfrm_dst_path(&rt->dst))) 1225 if (dst_allfrag(xfrm_dst_path(&rt->dst)))
1225 cork->base.flags |= IPCORK_ALLFRAG; 1226 cork->base.flags |= IPCORK_ALLFRAG;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 975021df7c1c..c0c74088f2af 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -2082,7 +2082,8 @@ void ipv6_mc_dad_complete(struct inet6_dev *idev)
2082 mld_send_initial_cr(idev); 2082 mld_send_initial_cr(idev);
2083 idev->mc_dad_count--; 2083 idev->mc_dad_count--;
2084 if (idev->mc_dad_count) 2084 if (idev->mc_dad_count)
2085 mld_dad_start_timer(idev, idev->mc_maxdelay); 2085 mld_dad_start_timer(idev,
2086 unsolicited_report_interval(idev));
2086 } 2087 }
2087} 2088}
2088 2089
@@ -2094,7 +2095,8 @@ static void mld_dad_timer_expire(struct timer_list *t)
2094 if (idev->mc_dad_count) { 2095 if (idev->mc_dad_count) {
2095 idev->mc_dad_count--; 2096 idev->mc_dad_count--;
2096 if (idev->mc_dad_count) 2097 if (idev->mc_dad_count)
2097 mld_dad_start_timer(idev, idev->mc_maxdelay); 2098 mld_dad_start_timer(idev,
2099 unsolicited_report_interval(idev));
2098 } 2100 }
2099 in6_dev_put(idev); 2101 in6_dev_put(idev);
2100} 2102}
@@ -2452,7 +2454,8 @@ static void mld_ifc_timer_expire(struct timer_list *t)
2452 if (idev->mc_ifc_count) { 2454 if (idev->mc_ifc_count) {
2453 idev->mc_ifc_count--; 2455 idev->mc_ifc_count--;
2454 if (idev->mc_ifc_count) 2456 if (idev->mc_ifc_count)
2455 mld_ifc_start_timer(idev, idev->mc_maxdelay); 2457 mld_ifc_start_timer(idev,
2458 unsolicited_report_interval(idev));
2456 } 2459 }
2457 in6_dev_put(idev); 2460 in6_dev_put(idev);
2458} 2461}
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index ce6f0d15b5dd..afc307c89d1a 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1334,7 +1334,7 @@ void raw6_proc_exit(void)
1334} 1334}
1335#endif /* CONFIG_PROC_FS */ 1335#endif /* CONFIG_PROC_FS */
1336 1336
1337/* Same as inet6_dgram_ops, sans udp_poll_mask. */ 1337/* Same as inet6_dgram_ops, sans udp_poll. */
1338const struct proto_ops inet6_sockraw_ops = { 1338const struct proto_ops inet6_sockraw_ops = {
1339 .family = PF_INET6, 1339 .family = PF_INET6,
1340 .owner = THIS_MODULE, 1340 .owner = THIS_MODULE,
@@ -1344,7 +1344,7 @@ const struct proto_ops inet6_sockraw_ops = {
1344 .socketpair = sock_no_socketpair, /* a do nothing */ 1344 .socketpair = sock_no_socketpair, /* a do nothing */
1345 .accept = sock_no_accept, /* a do nothing */ 1345 .accept = sock_no_accept, /* a do nothing */
1346 .getname = inet6_getname, 1346 .getname = inet6_getname,
1347 .poll_mask = datagram_poll_mask, /* ok */ 1347 .poll = datagram_poll, /* ok */
1348 .ioctl = inet6_ioctl, /* must change */ 1348 .ioctl = inet6_ioctl, /* must change */
1349 .listen = sock_no_listen, /* ok */ 1349 .listen = sock_no_listen, /* ok */
1350 .shutdown = inet_shutdown, /* ok */ 1350 .shutdown = inet_shutdown, /* ok */
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 68e86257a549..893a022f9620 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1488,11 +1488,14 @@ static inline __poll_t iucv_accept_poll(struct sock *parent)
1488 return 0; 1488 return 0;
1489} 1489}
1490 1490
1491static __poll_t iucv_sock_poll_mask(struct socket *sock, __poll_t events) 1491__poll_t iucv_sock_poll(struct file *file, struct socket *sock,
1492 poll_table *wait)
1492{ 1493{
1493 struct sock *sk = sock->sk; 1494 struct sock *sk = sock->sk;
1494 __poll_t mask = 0; 1495 __poll_t mask = 0;
1495 1496
1497 sock_poll_wait(file, sk_sleep(sk), wait);
1498
1496 if (sk->sk_state == IUCV_LISTEN) 1499 if (sk->sk_state == IUCV_LISTEN)
1497 return iucv_accept_poll(sk); 1500 return iucv_accept_poll(sk);
1498 1501
@@ -2385,7 +2388,7 @@ static const struct proto_ops iucv_sock_ops = {
2385 .getname = iucv_sock_getname, 2388 .getname = iucv_sock_getname,
2386 .sendmsg = iucv_sock_sendmsg, 2389 .sendmsg = iucv_sock_sendmsg,
2387 .recvmsg = iucv_sock_recvmsg, 2390 .recvmsg = iucv_sock_recvmsg,
2388 .poll_mask = iucv_sock_poll_mask, 2391 .poll = iucv_sock_poll,
2389 .ioctl = sock_no_ioctl, 2392 .ioctl = sock_no_ioctl,
2390 .mmap = sock_no_mmap, 2393 .mmap = sock_no_mmap,
2391 .socketpair = sock_no_socketpair, 2394 .socketpair = sock_no_socketpair,
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 84b7d5c6fec8..d3601d421571 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1336,9 +1336,9 @@ static void init_kcm_sock(struct kcm_sock *kcm, struct kcm_mux *mux)
1336 struct list_head *head; 1336 struct list_head *head;
1337 int index = 0; 1337 int index = 0;
1338 1338
1339 /* For SOCK_SEQPACKET sock type, datagram_poll_mask checks the sk_state, 1339 /* For SOCK_SEQPACKET sock type, datagram_poll checks the sk_state, so
1340 * so we set sk_state, otherwise epoll_wait always returns right away 1340 * we set sk_state, otherwise epoll_wait always returns right away with
1341 * with EPOLLHUP 1341 * EPOLLHUP
1342 */ 1342 */
1343 kcm->sk.sk_state = TCP_ESTABLISHED; 1343 kcm->sk.sk_state = TCP_ESTABLISHED;
1344 1344
@@ -1903,7 +1903,7 @@ static const struct proto_ops kcm_dgram_ops = {
1903 .socketpair = sock_no_socketpair, 1903 .socketpair = sock_no_socketpair,
1904 .accept = sock_no_accept, 1904 .accept = sock_no_accept,
1905 .getname = sock_no_getname, 1905 .getname = sock_no_getname,
1906 .poll_mask = datagram_poll_mask, 1906 .poll = datagram_poll,
1907 .ioctl = kcm_ioctl, 1907 .ioctl = kcm_ioctl,
1908 .listen = sock_no_listen, 1908 .listen = sock_no_listen,
1909 .shutdown = sock_no_shutdown, 1909 .shutdown = sock_no_shutdown,
@@ -1924,7 +1924,7 @@ static const struct proto_ops kcm_seqpacket_ops = {
1924 .socketpair = sock_no_socketpair, 1924 .socketpair = sock_no_socketpair,
1925 .accept = sock_no_accept, 1925 .accept = sock_no_accept,
1926 .getname = sock_no_getname, 1926 .getname = sock_no_getname,
1927 .poll_mask = datagram_poll_mask, 1927 .poll = datagram_poll,
1928 .ioctl = kcm_ioctl, 1928 .ioctl = kcm_ioctl,
1929 .listen = sock_no_listen, 1929 .listen = sock_no_listen,
1930 .shutdown = sock_no_shutdown, 1930 .shutdown = sock_no_shutdown,
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 8bdc1cbe490a..5e1d2946ffbf 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3751,7 +3751,7 @@ static const struct proto_ops pfkey_ops = {
3751 3751
3752 /* Now the operations that really occur. */ 3752 /* Now the operations that really occur. */
3753 .release = pfkey_release, 3753 .release = pfkey_release,
3754 .poll_mask = datagram_poll_mask, 3754 .poll = datagram_poll,
3755 .sendmsg = pfkey_sendmsg, 3755 .sendmsg = pfkey_sendmsg,
3756 .recvmsg = pfkey_recvmsg, 3756 .recvmsg = pfkey_recvmsg,
3757}; 3757};
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 181073bf6925..a9c05b2bc1b0 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -613,7 +613,7 @@ static const struct proto_ops l2tp_ip_ops = {
613 .socketpair = sock_no_socketpair, 613 .socketpair = sock_no_socketpair,
614 .accept = sock_no_accept, 614 .accept = sock_no_accept,
615 .getname = l2tp_ip_getname, 615 .getname = l2tp_ip_getname,
616 .poll_mask = datagram_poll_mask, 616 .poll = datagram_poll,
617 .ioctl = inet_ioctl, 617 .ioctl = inet_ioctl,
618 .listen = sock_no_listen, 618 .listen = sock_no_listen,
619 .shutdown = inet_shutdown, 619 .shutdown = inet_shutdown,
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index 336e4c00abbc..957369192ca1 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -754,7 +754,7 @@ static const struct proto_ops l2tp_ip6_ops = {
754 .socketpair = sock_no_socketpair, 754 .socketpair = sock_no_socketpair,
755 .accept = sock_no_accept, 755 .accept = sock_no_accept,
756 .getname = l2tp_ip6_getname, 756 .getname = l2tp_ip6_getname,
757 .poll_mask = datagram_poll_mask, 757 .poll = datagram_poll,
758 .ioctl = inet6_ioctl, 758 .ioctl = inet6_ioctl,
759 .listen = sock_no_listen, 759 .listen = sock_no_listen,
760 .shutdown = inet_shutdown, 760 .shutdown = inet_shutdown,
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 55188382845c..e398797878a9 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1818,7 +1818,7 @@ static const struct proto_ops pppol2tp_ops = {
1818 .socketpair = sock_no_socketpair, 1818 .socketpair = sock_no_socketpair,
1819 .accept = sock_no_accept, 1819 .accept = sock_no_accept,
1820 .getname = pppol2tp_getname, 1820 .getname = pppol2tp_getname,
1821 .poll_mask = datagram_poll_mask, 1821 .poll = datagram_poll,
1822 .listen = sock_no_listen, 1822 .listen = sock_no_listen,
1823 .shutdown = sock_no_shutdown, 1823 .shutdown = sock_no_shutdown,
1824 .setsockopt = pppol2tp_setsockopt, 1824 .setsockopt = pppol2tp_setsockopt,
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 804de8490186..1beeea9549fa 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -1192,7 +1192,7 @@ static const struct proto_ops llc_ui_ops = {
1192 .socketpair = sock_no_socketpair, 1192 .socketpair = sock_no_socketpair,
1193 .accept = llc_ui_accept, 1193 .accept = llc_ui_accept,
1194 .getname = llc_ui_getname, 1194 .getname = llc_ui_getname,
1195 .poll_mask = datagram_poll_mask, 1195 .poll = datagram_poll,
1196 .ioctl = llc_ui_ioctl, 1196 .ioctl = llc_ui_ioctl,
1197 .listen = llc_ui_listen, 1197 .listen = llc_ui_listen,
1198 .shutdown = llc_ui_shutdown, 1198 .shutdown = llc_ui_shutdown,
diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index e7b05de1e6d1..25e483e8278b 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -73,8 +73,8 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
73 ncm->data[2] = data; 73 ncm->data[2] = data;
74 ncm->data[4] = ntohl(lsc->oem_status); 74 ncm->data[4] = ntohl(lsc->oem_status);
75 75
76 netdev_info(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n", 76 netdev_dbg(ndp->ndev.dev, "NCSI: LSC AEN - channel %u state %s\n",
77 nc->id, data & 0x1 ? "up" : "down"); 77 nc->id, data & 0x1 ? "up" : "down");
78 78
79 chained = !list_empty(&nc->link); 79 chained = !list_empty(&nc->link);
80 state = nc->state; 80 state = nc->state;
@@ -148,9 +148,9 @@ static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp,
148 hncdsc = (struct ncsi_aen_hncdsc_pkt *)h; 148 hncdsc = (struct ncsi_aen_hncdsc_pkt *)h;
149 ncm->data[3] = ntohl(hncdsc->status); 149 ncm->data[3] = ntohl(hncdsc->status);
150 spin_unlock_irqrestore(&nc->lock, flags); 150 spin_unlock_irqrestore(&nc->lock, flags);
151 netdev_printk(KERN_DEBUG, ndp->ndev.dev, 151 netdev_dbg(ndp->ndev.dev,
152 "NCSI: host driver %srunning on channel %u\n", 152 "NCSI: host driver %srunning on channel %u\n",
153 ncm->data[3] & 0x1 ? "" : "not ", nc->id); 153 ncm->data[3] & 0x1 ? "" : "not ", nc->id);
154 154
155 return 0; 155 return 0;
156} 156}
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 5561e221b71f..091284760d21 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -788,8 +788,8 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
788 } 788 }
789 break; 789 break;
790 case ncsi_dev_state_config_done: 790 case ncsi_dev_state_config_done:
791 netdev_printk(KERN_DEBUG, ndp->ndev.dev, 791 netdev_dbg(ndp->ndev.dev, "NCSI: channel %u config done\n",
792 "NCSI: channel %u config done\n", nc->id); 792 nc->id);
793 spin_lock_irqsave(&nc->lock, flags); 793 spin_lock_irqsave(&nc->lock, flags);
794 if (nc->reconfigure_needed) { 794 if (nc->reconfigure_needed) {
795 /* This channel's configuration has been updated 795 /* This channel's configuration has been updated
@@ -804,8 +804,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
804 list_add_tail_rcu(&nc->link, &ndp->channel_queue); 804 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
805 spin_unlock_irqrestore(&ndp->lock, flags); 805 spin_unlock_irqrestore(&ndp->lock, flags);
806 806
807 netdev_printk(KERN_DEBUG, dev, 807 netdev_dbg(dev, "Dirty NCSI channel state reset\n");
808 "Dirty NCSI channel state reset\n");
809 ncsi_process_next_channel(ndp); 808 ncsi_process_next_channel(ndp);
810 break; 809 break;
811 } 810 }
@@ -816,9 +815,9 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
816 } else { 815 } else {
817 hot_nc = NULL; 816 hot_nc = NULL;
818 nc->state = NCSI_CHANNEL_INACTIVE; 817 nc->state = NCSI_CHANNEL_INACTIVE;
819 netdev_warn(ndp->ndev.dev, 818 netdev_dbg(ndp->ndev.dev,
820 "NCSI: channel %u link down after config\n", 819 "NCSI: channel %u link down after config\n",
821 nc->id); 820 nc->id);
822 } 821 }
823 spin_unlock_irqrestore(&nc->lock, flags); 822 spin_unlock_irqrestore(&nc->lock, flags);
824 823
@@ -908,9 +907,9 @@ static int ncsi_choose_active_channel(struct ncsi_dev_priv *ndp)
908 } 907 }
909 908
910 ncm = &found->modes[NCSI_MODE_LINK]; 909 ncm = &found->modes[NCSI_MODE_LINK];
911 netdev_printk(KERN_DEBUG, ndp->ndev.dev, 910 netdev_dbg(ndp->ndev.dev,
912 "NCSI: Channel %u added to queue (link %s)\n", 911 "NCSI: Channel %u added to queue (link %s)\n",
913 found->id, ncm->data[2] & 0x1 ? "up" : "down"); 912 found->id, ncm->data[2] & 0x1 ? "up" : "down");
914 913
915out: 914out:
916 spin_lock_irqsave(&ndp->lock, flags); 915 spin_lock_irqsave(&ndp->lock, flags);
@@ -1199,14 +1198,14 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp)
1199 switch (old_state) { 1198 switch (old_state) {
1200 case NCSI_CHANNEL_INACTIVE: 1199 case NCSI_CHANNEL_INACTIVE:
1201 ndp->ndev.state = ncsi_dev_state_config; 1200 ndp->ndev.state = ncsi_dev_state_config;
1202 netdev_info(ndp->ndev.dev, "NCSI: configuring channel %u\n", 1201 netdev_dbg(ndp->ndev.dev, "NCSI: configuring channel %u\n",
1203 nc->id); 1202 nc->id);
1204 ncsi_configure_channel(ndp); 1203 ncsi_configure_channel(ndp);
1205 break; 1204 break;
1206 case NCSI_CHANNEL_ACTIVE: 1205 case NCSI_CHANNEL_ACTIVE:
1207 ndp->ndev.state = ncsi_dev_state_suspend; 1206 ndp->ndev.state = ncsi_dev_state_suspend;
1208 netdev_info(ndp->ndev.dev, "NCSI: suspending channel %u\n", 1207 netdev_dbg(ndp->ndev.dev, "NCSI: suspending channel %u\n",
1209 nc->id); 1208 nc->id);
1210 ncsi_suspend_channel(ndp); 1209 ncsi_suspend_channel(ndp);
1211 break; 1210 break;
1212 default: 1211 default:
@@ -1226,8 +1225,6 @@ out:
1226 return ncsi_choose_active_channel(ndp); 1225 return ncsi_choose_active_channel(ndp);
1227 } 1226 }
1228 1227
1229 netdev_printk(KERN_DEBUG, ndp->ndev.dev,
1230 "NCSI: No more channels to process\n");
1231 ncsi_report_link(ndp, false); 1228 ncsi_report_link(ndp, false);
1232 return -ENODEV; 1229 return -ENODEV;
1233} 1230}
@@ -1318,9 +1315,9 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)
1318 if ((ndp->ndev.state & 0xff00) == 1315 if ((ndp->ndev.state & 0xff00) ==
1319 ncsi_dev_state_config || 1316 ncsi_dev_state_config ||
1320 !list_empty(&nc->link)) { 1317 !list_empty(&nc->link)) {
1321 netdev_printk(KERN_DEBUG, nd->dev, 1318 netdev_dbg(nd->dev,
1322 "NCSI: channel %p marked dirty\n", 1319 "NCSI: channel %p marked dirty\n",
1323 nc); 1320 nc);
1324 nc->reconfigure_needed = true; 1321 nc->reconfigure_needed = true;
1325 } 1322 }
1326 spin_unlock_irqrestore(&nc->lock, flags); 1323 spin_unlock_irqrestore(&nc->lock, flags);
@@ -1338,8 +1335,7 @@ static int ncsi_kick_channels(struct ncsi_dev_priv *ndp)
1338 list_add_tail_rcu(&nc->link, &ndp->channel_queue); 1335 list_add_tail_rcu(&nc->link, &ndp->channel_queue);
1339 spin_unlock_irqrestore(&ndp->lock, flags); 1336 spin_unlock_irqrestore(&ndp->lock, flags);
1340 1337
1341 netdev_printk(KERN_DEBUG, nd->dev, 1338 netdev_dbg(nd->dev, "NCSI: kicked channel %p\n", nc);
1342 "NCSI: kicked channel %p\n", nc);
1343 n++; 1339 n++;
1344 } 1340 }
1345 } 1341 }
@@ -1370,8 +1366,8 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1370 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) { 1366 list_for_each_entry_rcu(vlan, &ndp->vlan_vids, list) {
1371 n_vids++; 1367 n_vids++;
1372 if (vlan->vid == vid) { 1368 if (vlan->vid == vid) {
1373 netdev_printk(KERN_DEBUG, dev, 1369 netdev_dbg(dev, "NCSI: vid %u already registered\n",
1374 "NCSI: vid %u already registered\n", vid); 1370 vid);
1375 return 0; 1371 return 0;
1376 } 1372 }
1377 } 1373 }
@@ -1390,7 +1386,7 @@ int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1390 vlan->vid = vid; 1386 vlan->vid = vid;
1391 list_add_rcu(&vlan->list, &ndp->vlan_vids); 1387 list_add_rcu(&vlan->list, &ndp->vlan_vids);
1392 1388
1393 netdev_printk(KERN_DEBUG, dev, "NCSI: Added new vid %u\n", vid); 1389 netdev_dbg(dev, "NCSI: Added new vid %u\n", vid);
1394 1390
1395 found = ncsi_kick_channels(ndp) != 0; 1391 found = ncsi_kick_channels(ndp) != 0;
1396 1392
@@ -1419,8 +1415,7 @@ int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
1419 /* Remove the VLAN id from our internal list */ 1415 /* Remove the VLAN id from our internal list */
1420 list_for_each_entry_safe(vlan, tmp, &ndp->vlan_vids, list) 1416 list_for_each_entry_safe(vlan, tmp, &ndp->vlan_vids, list)
1421 if (vlan->vid == vid) { 1417 if (vlan->vid == vid) {
1422 netdev_printk(KERN_DEBUG, dev, 1418 netdev_dbg(dev, "NCSI: vid %u found, removing\n", vid);
1423 "NCSI: vid %u found, removing\n", vid);
1424 list_del_rcu(&vlan->list); 1419 list_del_rcu(&vlan->list);
1425 found = true; 1420 found = true;
1426 kfree(vlan); 1421 kfree(vlan);
@@ -1547,7 +1542,7 @@ void ncsi_stop_dev(struct ncsi_dev *nd)
1547 } 1542 }
1548 } 1543 }
1549 1544
1550 netdev_printk(KERN_DEBUG, ndp->ndev.dev, "NCSI: Stopping device\n"); 1545 netdev_dbg(ndp->ndev.dev, "NCSI: Stopping device\n");
1551 ncsi_report_link(ndp, true); 1546 ncsi_report_link(ndp, true);
1552} 1547}
1553EXPORT_SYMBOL_GPL(ncsi_stop_dev); 1548EXPORT_SYMBOL_GPL(ncsi_stop_dev);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 1189b84413d5..393573a99a5a 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2658,7 +2658,7 @@ static const struct proto_ops netlink_ops = {
2658 .socketpair = sock_no_socketpair, 2658 .socketpair = sock_no_socketpair,
2659 .accept = sock_no_accept, 2659 .accept = sock_no_accept,
2660 .getname = netlink_getname, 2660 .getname = netlink_getname,
2661 .poll_mask = datagram_poll_mask, 2661 .poll = datagram_poll,
2662 .ioctl = netlink_ioctl, 2662 .ioctl = netlink_ioctl,
2663 .listen = sock_no_listen, 2663 .listen = sock_no_listen,
2664 .shutdown = sock_no_shutdown, 2664 .shutdown = sock_no_shutdown,
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 93fbcafbf388..03f37c4e64fe 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1355,7 +1355,7 @@ static const struct proto_ops nr_proto_ops = {
1355 .socketpair = sock_no_socketpair, 1355 .socketpair = sock_no_socketpair,
1356 .accept = nr_accept, 1356 .accept = nr_accept,
1357 .getname = nr_getname, 1357 .getname = nr_getname,
1358 .poll_mask = datagram_poll_mask, 1358 .poll = datagram_poll,
1359 .ioctl = nr_ioctl, 1359 .ioctl = nr_ioctl,
1360 .listen = nr_listen, 1360 .listen = nr_listen,
1361 .shutdown = sock_no_shutdown, 1361 .shutdown = sock_no_shutdown,
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index ab5bb14b49af..ea0c0c6f1874 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -548,13 +548,16 @@ static inline __poll_t llcp_accept_poll(struct sock *parent)
548 return 0; 548 return 0;
549} 549}
550 550
551static __poll_t llcp_sock_poll_mask(struct socket *sock, __poll_t events) 551static __poll_t llcp_sock_poll(struct file *file, struct socket *sock,
552 poll_table *wait)
552{ 553{
553 struct sock *sk = sock->sk; 554 struct sock *sk = sock->sk;
554 __poll_t mask = 0; 555 __poll_t mask = 0;
555 556
556 pr_debug("%p\n", sk); 557 pr_debug("%p\n", sk);
557 558
559 sock_poll_wait(file, sk_sleep(sk), wait);
560
558 if (sk->sk_state == LLCP_LISTEN) 561 if (sk->sk_state == LLCP_LISTEN)
559 return llcp_accept_poll(sk); 562 return llcp_accept_poll(sk);
560 563
@@ -896,7 +899,7 @@ static const struct proto_ops llcp_sock_ops = {
896 .socketpair = sock_no_socketpair, 899 .socketpair = sock_no_socketpair,
897 .accept = llcp_sock_accept, 900 .accept = llcp_sock_accept,
898 .getname = llcp_sock_getname, 901 .getname = llcp_sock_getname,
899 .poll_mask = llcp_sock_poll_mask, 902 .poll = llcp_sock_poll,
900 .ioctl = sock_no_ioctl, 903 .ioctl = sock_no_ioctl,
901 .listen = llcp_sock_listen, 904 .listen = llcp_sock_listen,
902 .shutdown = sock_no_shutdown, 905 .shutdown = sock_no_shutdown,
@@ -916,7 +919,7 @@ static const struct proto_ops llcp_rawsock_ops = {
916 .socketpair = sock_no_socketpair, 919 .socketpair = sock_no_socketpair,
917 .accept = sock_no_accept, 920 .accept = sock_no_accept,
918 .getname = llcp_sock_getname, 921 .getname = llcp_sock_getname,
919 .poll_mask = llcp_sock_poll_mask, 922 .poll = llcp_sock_poll,
920 .ioctl = sock_no_ioctl, 923 .ioctl = sock_no_ioctl,
921 .listen = sock_no_listen, 924 .listen = sock_no_listen,
922 .shutdown = sock_no_shutdown, 925 .shutdown = sock_no_shutdown,
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index 60c322531c49..e2188deb08dc 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -284,7 +284,7 @@ static const struct proto_ops rawsock_ops = {
284 .socketpair = sock_no_socketpair, 284 .socketpair = sock_no_socketpair,
285 .accept = sock_no_accept, 285 .accept = sock_no_accept,
286 .getname = sock_no_getname, 286 .getname = sock_no_getname,
287 .poll_mask = datagram_poll_mask, 287 .poll = datagram_poll,
288 .ioctl = sock_no_ioctl, 288 .ioctl = sock_no_ioctl,
289 .listen = sock_no_listen, 289 .listen = sock_no_listen,
290 .shutdown = sock_no_shutdown, 290 .shutdown = sock_no_shutdown,
@@ -304,7 +304,7 @@ static const struct proto_ops rawsock_raw_ops = {
304 .socketpair = sock_no_socketpair, 304 .socketpair = sock_no_socketpair,
305 .accept = sock_no_accept, 305 .accept = sock_no_accept,
306 .getname = sock_no_getname, 306 .getname = sock_no_getname,
307 .poll_mask = datagram_poll_mask, 307 .poll = datagram_poll,
308 .ioctl = sock_no_ioctl, 308 .ioctl = sock_no_ioctl,
309 .listen = sock_no_listen, 309 .listen = sock_no_listen,
310 .shutdown = sock_no_shutdown, 310 .shutdown = sock_no_shutdown,
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 50809748c127..57634bc3da74 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2262,6 +2262,13 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
2262 if (po->stats.stats1.tp_drops) 2262 if (po->stats.stats1.tp_drops)
2263 status |= TP_STATUS_LOSING; 2263 status |= TP_STATUS_LOSING;
2264 } 2264 }
2265
2266 if (do_vnet &&
2267 virtio_net_hdr_from_skb(skb, h.raw + macoff -
2268 sizeof(struct virtio_net_hdr),
2269 vio_le(), true, 0))
2270 goto drop_n_account;
2271
2265 po->stats.stats1.tp_packets++; 2272 po->stats.stats1.tp_packets++;
2266 if (copy_skb) { 2273 if (copy_skb) {
2267 status |= TP_STATUS_COPY; 2274 status |= TP_STATUS_COPY;
@@ -2269,15 +2276,6 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
2269 } 2276 }
2270 spin_unlock(&sk->sk_receive_queue.lock); 2277 spin_unlock(&sk->sk_receive_queue.lock);
2271 2278
2272 if (do_vnet) {
2273 if (virtio_net_hdr_from_skb(skb, h.raw + macoff -
2274 sizeof(struct virtio_net_hdr),
2275 vio_le(), true, 0)) {
2276 spin_lock(&sk->sk_receive_queue.lock);
2277 goto drop_n_account;
2278 }
2279 }
2280
2281 skb_copy_bits(skb, 0, h.raw + macoff, snaplen); 2279 skb_copy_bits(skb, 0, h.raw + macoff, snaplen);
2282 2280
2283 if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) 2281 if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp)))
@@ -4078,11 +4076,12 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
4078 return 0; 4076 return 0;
4079} 4077}
4080 4078
4081static __poll_t packet_poll_mask(struct socket *sock, __poll_t events) 4079static __poll_t packet_poll(struct file *file, struct socket *sock,
4080 poll_table *wait)
4082{ 4081{
4083 struct sock *sk = sock->sk; 4082 struct sock *sk = sock->sk;
4084 struct packet_sock *po = pkt_sk(sk); 4083 struct packet_sock *po = pkt_sk(sk);
4085 __poll_t mask = datagram_poll_mask(sock, events); 4084 __poll_t mask = datagram_poll(file, sock, wait);
4086 4085
4087 spin_lock_bh(&sk->sk_receive_queue.lock); 4086 spin_lock_bh(&sk->sk_receive_queue.lock);
4088 if (po->rx_ring.pg_vec) { 4087 if (po->rx_ring.pg_vec) {
@@ -4424,7 +4423,7 @@ static const struct proto_ops packet_ops_spkt = {
4424 .socketpair = sock_no_socketpair, 4423 .socketpair = sock_no_socketpair,
4425 .accept = sock_no_accept, 4424 .accept = sock_no_accept,
4426 .getname = packet_getname_spkt, 4425 .getname = packet_getname_spkt,
4427 .poll_mask = datagram_poll_mask, 4426 .poll = datagram_poll,
4428 .ioctl = packet_ioctl, 4427 .ioctl = packet_ioctl,
4429 .listen = sock_no_listen, 4428 .listen = sock_no_listen,
4430 .shutdown = sock_no_shutdown, 4429 .shutdown = sock_no_shutdown,
@@ -4445,7 +4444,7 @@ static const struct proto_ops packet_ops = {
4445 .socketpair = sock_no_socketpair, 4444 .socketpair = sock_no_socketpair,
4446 .accept = sock_no_accept, 4445 .accept = sock_no_accept,
4447 .getname = packet_getname, 4446 .getname = packet_getname,
4448 .poll_mask = packet_poll_mask, 4447 .poll = packet_poll,
4449 .ioctl = packet_ioctl, 4448 .ioctl = packet_ioctl,
4450 .listen = sock_no_listen, 4449 .listen = sock_no_listen,
4451 .shutdown = sock_no_shutdown, 4450 .shutdown = sock_no_shutdown,
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index c295c4e20f01..30187990257f 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -340,12 +340,15 @@ static int pn_socket_getname(struct socket *sock, struct sockaddr *addr,
340 return sizeof(struct sockaddr_pn); 340 return sizeof(struct sockaddr_pn);
341} 341}
342 342
343static __poll_t pn_socket_poll_mask(struct socket *sock, __poll_t events) 343static __poll_t pn_socket_poll(struct file *file, struct socket *sock,
344 poll_table *wait)
344{ 345{
345 struct sock *sk = sock->sk; 346 struct sock *sk = sock->sk;
346 struct pep_sock *pn = pep_sk(sk); 347 struct pep_sock *pn = pep_sk(sk);
347 __poll_t mask = 0; 348 __poll_t mask = 0;
348 349
350 poll_wait(file, sk_sleep(sk), wait);
351
349 if (sk->sk_state == TCP_CLOSE) 352 if (sk->sk_state == TCP_CLOSE)
350 return EPOLLERR; 353 return EPOLLERR;
351 if (!skb_queue_empty(&sk->sk_receive_queue)) 354 if (!skb_queue_empty(&sk->sk_receive_queue))
@@ -445,7 +448,7 @@ const struct proto_ops phonet_dgram_ops = {
445 .socketpair = sock_no_socketpair, 448 .socketpair = sock_no_socketpair,
446 .accept = sock_no_accept, 449 .accept = sock_no_accept,
447 .getname = pn_socket_getname, 450 .getname = pn_socket_getname,
448 .poll_mask = datagram_poll_mask, 451 .poll = datagram_poll,
449 .ioctl = pn_socket_ioctl, 452 .ioctl = pn_socket_ioctl,
450 .listen = sock_no_listen, 453 .listen = sock_no_listen,
451 .shutdown = sock_no_shutdown, 454 .shutdown = sock_no_shutdown,
@@ -470,7 +473,7 @@ const struct proto_ops phonet_stream_ops = {
470 .socketpair = sock_no_socketpair, 473 .socketpair = sock_no_socketpair,
471 .accept = pn_socket_accept, 474 .accept = pn_socket_accept,
472 .getname = pn_socket_getname, 475 .getname = pn_socket_getname,
473 .poll_mask = pn_socket_poll_mask, 476 .poll = pn_socket_poll,
474 .ioctl = pn_socket_ioctl, 477 .ioctl = pn_socket_ioctl,
475 .listen = pn_socket_listen, 478 .listen = pn_socket_listen,
476 .shutdown = sock_no_shutdown, 479 .shutdown = sock_no_shutdown,
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 1b5025ea5b04..2aa07b547b16 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -1023,7 +1023,7 @@ static const struct proto_ops qrtr_proto_ops = {
1023 .recvmsg = qrtr_recvmsg, 1023 .recvmsg = qrtr_recvmsg,
1024 .getname = qrtr_getname, 1024 .getname = qrtr_getname,
1025 .ioctl = qrtr_ioctl, 1025 .ioctl = qrtr_ioctl,
1026 .poll_mask = datagram_poll_mask, 1026 .poll = datagram_poll,
1027 .shutdown = sock_no_shutdown, 1027 .shutdown = sock_no_shutdown,
1028 .setsockopt = sock_no_setsockopt, 1028 .setsockopt = sock_no_setsockopt,
1029 .getsockopt = sock_no_getsockopt, 1029 .getsockopt = sock_no_getsockopt,
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index ebe42e7eb456..d00a0ef39a56 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1470,7 +1470,7 @@ static const struct proto_ops rose_proto_ops = {
1470 .socketpair = sock_no_socketpair, 1470 .socketpair = sock_no_socketpair,
1471 .accept = rose_accept, 1471 .accept = rose_accept,
1472 .getname = rose_getname, 1472 .getname = rose_getname,
1473 .poll_mask = datagram_poll_mask, 1473 .poll = datagram_poll,
1474 .ioctl = rose_ioctl, 1474 .ioctl = rose_ioctl,
1475 .listen = rose_listen, 1475 .listen = rose_listen,
1476 .shutdown = sock_no_shutdown, 1476 .shutdown = sock_no_shutdown,
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 3b1ac93efee2..2b463047dd7b 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -734,11 +734,15 @@ static int rxrpc_getsockopt(struct socket *sock, int level, int optname,
734/* 734/*
735 * permit an RxRPC socket to be polled 735 * permit an RxRPC socket to be polled
736 */ 736 */
737static __poll_t rxrpc_poll_mask(struct socket *sock, __poll_t events) 737static __poll_t rxrpc_poll(struct file *file, struct socket *sock,
738 poll_table *wait)
738{ 739{
739 struct sock *sk = sock->sk; 740 struct sock *sk = sock->sk;
740 struct rxrpc_sock *rx = rxrpc_sk(sk); 741 struct rxrpc_sock *rx = rxrpc_sk(sk);
741 __poll_t mask = 0; 742 __poll_t mask;
743
744 sock_poll_wait(file, sk_sleep(sk), wait);
745 mask = 0;
742 746
743 /* the socket is readable if there are any messages waiting on the Rx 747 /* the socket is readable if there are any messages waiting on the Rx
744 * queue */ 748 * queue */
@@ -945,7 +949,7 @@ static const struct proto_ops rxrpc_rpc_ops = {
945 .socketpair = sock_no_socketpair, 949 .socketpair = sock_no_socketpair,
946 .accept = sock_no_accept, 950 .accept = sock_no_accept,
947 .getname = sock_no_getname, 951 .getname = sock_no_getname,
948 .poll_mask = rxrpc_poll_mask, 952 .poll = rxrpc_poll,
949 .ioctl = sock_no_ioctl, 953 .ioctl = sock_no_ioctl,
950 .listen = rxrpc_listen, 954 .listen = rxrpc_listen,
951 .shutdown = rxrpc_shutdown, 955 .shutdown = rxrpc_shutdown,
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 8527cfdc446d..20d7d36b2fc9 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -415,7 +415,8 @@ static void tcf_ife_cleanup(struct tc_action *a)
415 spin_unlock_bh(&ife->tcf_lock); 415 spin_unlock_bh(&ife->tcf_lock);
416 416
417 p = rcu_dereference_protected(ife->params, 1); 417 p = rcu_dereference_protected(ife->params, 1);
418 kfree_rcu(p, rcu); 418 if (p)
419 kfree_rcu(p, rcu);
419} 420}
420 421
421/* under ife->tcf_lock for existing action */ 422/* under ife->tcf_lock for existing action */
@@ -516,8 +517,6 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
516 saddr = nla_data(tb[TCA_IFE_SMAC]); 517 saddr = nla_data(tb[TCA_IFE_SMAC]);
517 } 518 }
518 519
519 ife->tcf_action = parm->action;
520
521 if (parm->flags & IFE_ENCODE) { 520 if (parm->flags & IFE_ENCODE) {
522 if (daddr) 521 if (daddr)
523 ether_addr_copy(p->eth_dst, daddr); 522 ether_addr_copy(p->eth_dst, daddr);
@@ -543,10 +542,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
543 NULL, NULL); 542 NULL, NULL);
544 if (err) { 543 if (err) {
545metadata_parse_err: 544metadata_parse_err:
546 if (exists)
547 tcf_idr_release(*a, bind);
548 if (ret == ACT_P_CREATED) 545 if (ret == ACT_P_CREATED)
549 _tcf_ife_cleanup(*a); 546 tcf_idr_release(*a, bind);
550 547
551 if (exists) 548 if (exists)
552 spin_unlock_bh(&ife->tcf_lock); 549 spin_unlock_bh(&ife->tcf_lock);
@@ -567,7 +564,7 @@ metadata_parse_err:
567 err = use_all_metadata(ife); 564 err = use_all_metadata(ife);
568 if (err) { 565 if (err) {
569 if (ret == ACT_P_CREATED) 566 if (ret == ACT_P_CREATED)
570 _tcf_ife_cleanup(*a); 567 tcf_idr_release(*a, bind);
571 568
572 if (exists) 569 if (exists)
573 spin_unlock_bh(&ife->tcf_lock); 570 spin_unlock_bh(&ife->tcf_lock);
@@ -576,6 +573,7 @@ metadata_parse_err:
576 } 573 }
577 } 574 }
578 575
576 ife->tcf_action = parm->action;
579 if (exists) 577 if (exists)
580 spin_unlock_bh(&ife->tcf_lock); 578 spin_unlock_bh(&ife->tcf_lock);
581 579
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 2b5be42a9f1c..9e8b26a80fb3 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -66,7 +66,7 @@ struct fl_flow_mask {
66 struct rhashtable_params filter_ht_params; 66 struct rhashtable_params filter_ht_params;
67 struct flow_dissector dissector; 67 struct flow_dissector dissector;
68 struct list_head filters; 68 struct list_head filters;
69 struct rcu_head rcu; 69 struct rcu_work rwork;
70 struct list_head list; 70 struct list_head list;
71}; 71};
72 72
@@ -203,6 +203,20 @@ static int fl_init(struct tcf_proto *tp)
203 return rhashtable_init(&head->ht, &mask_ht_params); 203 return rhashtable_init(&head->ht, &mask_ht_params);
204} 204}
205 205
206static void fl_mask_free(struct fl_flow_mask *mask)
207{
208 rhashtable_destroy(&mask->ht);
209 kfree(mask);
210}
211
212static void fl_mask_free_work(struct work_struct *work)
213{
214 struct fl_flow_mask *mask = container_of(to_rcu_work(work),
215 struct fl_flow_mask, rwork);
216
217 fl_mask_free(mask);
218}
219
206static bool fl_mask_put(struct cls_fl_head *head, struct fl_flow_mask *mask, 220static bool fl_mask_put(struct cls_fl_head *head, struct fl_flow_mask *mask,
207 bool async) 221 bool async)
208{ 222{
@@ -210,12 +224,11 @@ static bool fl_mask_put(struct cls_fl_head *head, struct fl_flow_mask *mask,
210 return false; 224 return false;
211 225
212 rhashtable_remove_fast(&head->ht, &mask->ht_node, mask_ht_params); 226 rhashtable_remove_fast(&head->ht, &mask->ht_node, mask_ht_params);
213 rhashtable_destroy(&mask->ht);
214 list_del_rcu(&mask->list); 227 list_del_rcu(&mask->list);
215 if (async) 228 if (async)
216 kfree_rcu(mask, rcu); 229 tcf_queue_work(&mask->rwork, fl_mask_free_work);
217 else 230 else
218 kfree(mask); 231 fl_mask_free(mask);
219 232
220 return true; 233 return true;
221} 234}
diff --git a/net/sched/sch_blackhole.c b/net/sched/sch_blackhole.c
index c98a61e980ba..9c4c2bb547d7 100644
--- a/net/sched/sch_blackhole.c
+++ b/net/sched/sch_blackhole.c
@@ -21,7 +21,7 @@ static int blackhole_enqueue(struct sk_buff *skb, struct Qdisc *sch,
21 struct sk_buff **to_free) 21 struct sk_buff **to_free)
22{ 22{
23 qdisc_drop(skb, sch, to_free); 23 qdisc_drop(skb, sch, to_free);
24 return NET_XMIT_SUCCESS; 24 return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
25} 25}
26 26
27static struct sk_buff *blackhole_dequeue(struct Qdisc *sch) 27static struct sk_buff *blackhole_dequeue(struct Qdisc *sch)
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 3ae9877ea205..3278a76f6861 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1385,8 +1385,8 @@ hfsc_schedule_watchdog(struct Qdisc *sch)
1385 if (next_time == 0 || next_time > q->root.cl_cfmin) 1385 if (next_time == 0 || next_time > q->root.cl_cfmin)
1386 next_time = q->root.cl_cfmin; 1386 next_time = q->root.cl_cfmin;
1387 } 1387 }
1388 WARN_ON(next_time == 0); 1388 if (next_time)
1389 qdisc_watchdog_schedule(&q->watchdog, next_time); 1389 qdisc_watchdog_schedule(&q->watchdog, next_time);
1390} 1390}
1391 1391
1392static int 1392static int
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 79daa98208c3..bfb9f812e2ef 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -237,7 +237,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
237 /* Account for a different sized first fragment */ 237 /* Account for a different sized first fragment */
238 if (msg_len >= first_len) { 238 if (msg_len >= first_len) {
239 msg->can_delay = 0; 239 msg->can_delay = 0;
240 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_FRAGUSRMSGS); 240 if (msg_len > first_len)
241 SCTP_INC_STATS(sock_net(asoc->base.sk),
242 SCTP_MIB_FRAGUSRMSGS);
241 } else { 243 } else {
242 /* Which may be the only one... */ 244 /* Which may be the only one... */
243 first_len = msg_len; 245 first_len = msg_len;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 7339918a805d..0cd2e764f47f 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -1010,7 +1010,7 @@ static const struct proto_ops inet6_seqpacket_ops = {
1010 .socketpair = sock_no_socketpair, 1010 .socketpair = sock_no_socketpair,
1011 .accept = inet_accept, 1011 .accept = inet_accept,
1012 .getname = sctp_getname, 1012 .getname = sctp_getname,
1013 .poll_mask = sctp_poll_mask, 1013 .poll = sctp_poll,
1014 .ioctl = inet6_ioctl, 1014 .ioctl = inet6_ioctl,
1015 .listen = sctp_inet_listen, 1015 .listen = sctp_inet_listen,
1016 .shutdown = inet_shutdown, 1016 .shutdown = inet_shutdown,
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 5dffbc493008..67f73d3a1356 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1016,7 +1016,7 @@ static const struct proto_ops inet_seqpacket_ops = {
1016 .socketpair = sock_no_socketpair, 1016 .socketpair = sock_no_socketpair,
1017 .accept = inet_accept, 1017 .accept = inet_accept,
1018 .getname = inet_getname, /* Semantics are different. */ 1018 .getname = inet_getname, /* Semantics are different. */
1019 .poll_mask = sctp_poll_mask, 1019 .poll = sctp_poll,
1020 .ioctl = inet_ioctl, 1020 .ioctl = inet_ioctl,
1021 .listen = sctp_inet_listen, 1021 .listen = sctp_inet_listen,
1022 .shutdown = inet_shutdown, /* Looks harmless. */ 1022 .shutdown = inet_shutdown, /* Looks harmless. */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index d20f7addee19..ce620e878538 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -7717,12 +7717,14 @@ out:
7717 * here, again, by modeling the current TCP/UDP code. We don't have 7717 * here, again, by modeling the current TCP/UDP code. We don't have
7718 * a good way to test with it yet. 7718 * a good way to test with it yet.
7719 */ 7719 */
7720__poll_t sctp_poll_mask(struct socket *sock, __poll_t events) 7720__poll_t sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
7721{ 7721{
7722 struct sock *sk = sock->sk; 7722 struct sock *sk = sock->sk;
7723 struct sctp_sock *sp = sctp_sk(sk); 7723 struct sctp_sock *sp = sctp_sk(sk);
7724 __poll_t mask; 7724 __poll_t mask;
7725 7725
7726 poll_wait(file, sk_sleep(sk), wait);
7727
7726 sock_rps_record_flow(sk); 7728 sock_rps_record_flow(sk);
7727 7729
7728 /* A TCP-style listening socket becomes readable when the accept queue 7730 /* A TCP-style listening socket becomes readable when the accept queue
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index da7f02edcd37..973b4471b532 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1273,7 +1273,8 @@ static __poll_t smc_accept_poll(struct sock *parent)
1273 return mask; 1273 return mask;
1274} 1274}
1275 1275
1276static __poll_t smc_poll_mask(struct socket *sock, __poll_t events) 1276static __poll_t smc_poll(struct file *file, struct socket *sock,
1277 poll_table *wait)
1277{ 1278{
1278 struct sock *sk = sock->sk; 1279 struct sock *sk = sock->sk;
1279 __poll_t mask = 0; 1280 __poll_t mask = 0;
@@ -1289,7 +1290,7 @@ static __poll_t smc_poll_mask(struct socket *sock, __poll_t events)
1289 if ((sk->sk_state == SMC_INIT) || smc->use_fallback) { 1290 if ((sk->sk_state == SMC_INIT) || smc->use_fallback) {
1290 /* delegate to CLC child sock */ 1291 /* delegate to CLC child sock */
1291 release_sock(sk); 1292 release_sock(sk);
1292 mask = smc->clcsock->ops->poll_mask(smc->clcsock, events); 1293 mask = smc->clcsock->ops->poll(file, smc->clcsock, wait);
1293 lock_sock(sk); 1294 lock_sock(sk);
1294 sk->sk_err = smc->clcsock->sk->sk_err; 1295 sk->sk_err = smc->clcsock->sk->sk_err;
1295 if (sk->sk_err) { 1296 if (sk->sk_err) {
@@ -1307,6 +1308,11 @@ static __poll_t smc_poll_mask(struct socket *sock, __poll_t events)
1307 } 1308 }
1308 } 1309 }
1309 } else { 1310 } else {
1311 if (sk->sk_state != SMC_CLOSED) {
1312 release_sock(sk);
1313 sock_poll_wait(file, sk_sleep(sk), wait);
1314 lock_sock(sk);
1315 }
1310 if (sk->sk_err) 1316 if (sk->sk_err)
1311 mask |= EPOLLERR; 1317 mask |= EPOLLERR;
1312 if ((sk->sk_shutdown == SHUTDOWN_MASK) || 1318 if ((sk->sk_shutdown == SHUTDOWN_MASK) ||
@@ -1619,7 +1625,7 @@ static const struct proto_ops smc_sock_ops = {
1619 .socketpair = sock_no_socketpair, 1625 .socketpair = sock_no_socketpair,
1620 .accept = smc_accept, 1626 .accept = smc_accept,
1621 .getname = smc_getname, 1627 .getname = smc_getname,
1622 .poll_mask = smc_poll_mask, 1628 .poll = smc_poll,
1623 .ioctl = smc_ioctl, 1629 .ioctl = smc_ioctl,
1624 .listen = smc_listen, 1630 .listen = smc_listen,
1625 .shutdown = smc_shutdown, 1631 .shutdown = smc_shutdown,
diff --git a/net/socket.c b/net/socket.c
index 8a109012608a..85633622c94d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -117,10 +117,8 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from);
117static int sock_mmap(struct file *file, struct vm_area_struct *vma); 117static int sock_mmap(struct file *file, struct vm_area_struct *vma);
118 118
119static int sock_close(struct inode *inode, struct file *file); 119static int sock_close(struct inode *inode, struct file *file);
120static struct wait_queue_head *sock_get_poll_head(struct file *file, 120static __poll_t sock_poll(struct file *file,
121 __poll_t events); 121 struct poll_table_struct *wait);
122static __poll_t sock_poll_mask(struct file *file, __poll_t);
123static __poll_t sock_poll(struct file *file, struct poll_table_struct *wait);
124static long sock_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 122static long sock_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
125#ifdef CONFIG_COMPAT 123#ifdef CONFIG_COMPAT
126static long compat_sock_ioctl(struct file *file, 124static long compat_sock_ioctl(struct file *file,
@@ -143,8 +141,6 @@ static const struct file_operations socket_file_ops = {
143 .llseek = no_llseek, 141 .llseek = no_llseek,
144 .read_iter = sock_read_iter, 142 .read_iter = sock_read_iter,
145 .write_iter = sock_write_iter, 143 .write_iter = sock_write_iter,
146 .get_poll_head = sock_get_poll_head,
147 .poll_mask = sock_poll_mask,
148 .poll = sock_poll, 144 .poll = sock_poll,
149 .unlocked_ioctl = sock_ioctl, 145 .unlocked_ioctl = sock_ioctl,
150#ifdef CONFIG_COMPAT 146#ifdef CONFIG_COMPAT
@@ -1130,48 +1126,16 @@ out_release:
1130} 1126}
1131EXPORT_SYMBOL(sock_create_lite); 1127EXPORT_SYMBOL(sock_create_lite);
1132 1128
1133static struct wait_queue_head *sock_get_poll_head(struct file *file,
1134 __poll_t events)
1135{
1136 struct socket *sock = file->private_data;
1137
1138 if (!sock->ops->poll_mask)
1139 return NULL;
1140 sock_poll_busy_loop(sock, events);
1141 return sk_sleep(sock->sk);
1142}
1143
1144static __poll_t sock_poll_mask(struct file *file, __poll_t events)
1145{
1146 struct socket *sock = file->private_data;
1147
1148 /*
1149 * We need to be sure we are in sync with the socket flags modification.
1150 *
1151 * This memory barrier is paired in the wq_has_sleeper.
1152 */
1153 smp_mb();
1154
1155 /* this socket can poll_ll so tell the system call */
1156 return sock->ops->poll_mask(sock, events) |
1157 (sk_can_busy_loop(sock->sk) ? POLL_BUSY_LOOP : 0);
1158}
1159
1160/* No kernel lock held - perfect */ 1129/* No kernel lock held - perfect */
1161static __poll_t sock_poll(struct file *file, poll_table *wait) 1130static __poll_t sock_poll(struct file *file, poll_table *wait)
1162{ 1131{
1163 struct socket *sock = file->private_data; 1132 struct socket *sock = file->private_data;
1164 __poll_t events = poll_requested_events(wait), mask = 0; 1133 __poll_t events = poll_requested_events(wait);
1165
1166 if (sock->ops->poll) {
1167 sock_poll_busy_loop(sock, events);
1168 mask = sock->ops->poll(file, sock, wait);
1169 } else if (sock->ops->poll_mask) {
1170 sock_poll_wait(file, sock_get_poll_head(file, events), wait);
1171 mask = sock->ops->poll_mask(sock, events);
1172 }
1173 1134
1174 return mask | sock_poll_busy_flag(sock); 1135 sock_poll_busy_loop(sock, events);
1136 if (!sock->ops->poll)
1137 return 0;
1138 return sock->ops->poll(file, sock, wait) | sock_poll_busy_flag(sock);
1175} 1139}
1176 1140
1177static int sock_mmap(struct file *file, struct vm_area_struct *vma) 1141static int sock_mmap(struct file *file, struct vm_area_struct *vma)
diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
index 1a9695183599..373836615c57 100644
--- a/net/strparser/strparser.c
+++ b/net/strparser/strparser.c
@@ -392,7 +392,7 @@ static int strp_read_sock(struct strparser *strp)
392/* Lower sock lock held */ 392/* Lower sock lock held */
393void strp_data_ready(struct strparser *strp) 393void strp_data_ready(struct strparser *strp)
394{ 394{
395 if (unlikely(strp->stopped)) 395 if (unlikely(strp->stopped) || strp->paused)
396 return; 396 return;
397 397
398 /* This check is needed to synchronize with do_strp_work. 398 /* This check is needed to synchronize with do_strp_work.
@@ -407,9 +407,6 @@ void strp_data_ready(struct strparser *strp)
407 return; 407 return;
408 } 408 }
409 409
410 if (strp->paused)
411 return;
412
413 if (strp->need_bytes) { 410 if (strp->need_bytes) {
414 if (strp_peek_len(strp) < strp->need_bytes) 411 if (strp_peek_len(strp) < strp->need_bytes)
415 return; 412 return;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 3c85af058227..3fabf9f6a0f9 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -987,8 +987,6 @@ bool xprt_prepare_transmit(struct rpc_task *task)
987 task->tk_status = -EAGAIN; 987 task->tk_status = -EAGAIN;
988 goto out_unlock; 988 goto out_unlock;
989 } 989 }
990 if (!bc_prealloc(req) && !req->rq_xmit_bytes_sent)
991 req->rq_xid = xprt_alloc_xid(xprt);
992 ret = true; 990 ret = true;
993out_unlock: 991out_unlock:
994 spin_unlock_bh(&xprt->transport_lock); 992 spin_unlock_bh(&xprt->transport_lock);
@@ -1298,7 +1296,12 @@ void xprt_retry_reserve(struct rpc_task *task)
1298 1296
1299static inline __be32 xprt_alloc_xid(struct rpc_xprt *xprt) 1297static inline __be32 xprt_alloc_xid(struct rpc_xprt *xprt)
1300{ 1298{
1301 return (__force __be32)xprt->xid++; 1299 __be32 xid;
1300
1301 spin_lock(&xprt->reserve_lock);
1302 xid = (__force __be32)xprt->xid++;
1303 spin_unlock(&xprt->reserve_lock);
1304 return xid;
1302} 1305}
1303 1306
1304static inline void xprt_init_xid(struct rpc_xprt *xprt) 1307static inline void xprt_init_xid(struct rpc_xprt *xprt)
@@ -1316,6 +1319,7 @@ void xprt_request_init(struct rpc_task *task)
1316 req->rq_task = task; 1319 req->rq_task = task;
1317 req->rq_xprt = xprt; 1320 req->rq_xprt = xprt;
1318 req->rq_buffer = NULL; 1321 req->rq_buffer = NULL;
1322 req->rq_xid = xprt_alloc_xid(xprt);
1319 req->rq_connect_cookie = xprt->connect_cookie - 1; 1323 req->rq_connect_cookie = xprt->connect_cookie - 1;
1320 req->rq_bytes_sent = 0; 1324 req->rq_bytes_sent = 0;
1321 req->rq_snd_buf.len = 0; 1325 req->rq_snd_buf.len = 0;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 14a5d055717d..930852c54d7a 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -692,9 +692,10 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,
692} 692}
693 693
694/** 694/**
695 * tipc_poll - read pollmask 695 * tipc_poll - read and possibly block on pollmask
696 * @file: file structure associated with the socket 696 * @file: file structure associated with the socket
697 * @sock: socket for which to calculate the poll bits 697 * @sock: socket for which to calculate the poll bits
698 * @wait: ???
698 * 699 *
699 * Returns pollmask value 700 * Returns pollmask value
700 * 701 *
@@ -708,12 +709,15 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,
708 * imply that the operation will succeed, merely that it should be performed 709 * imply that the operation will succeed, merely that it should be performed
709 * and will not block. 710 * and will not block.
710 */ 711 */
711static __poll_t tipc_poll_mask(struct socket *sock, __poll_t events) 712static __poll_t tipc_poll(struct file *file, struct socket *sock,
713 poll_table *wait)
712{ 714{
713 struct sock *sk = sock->sk; 715 struct sock *sk = sock->sk;
714 struct tipc_sock *tsk = tipc_sk(sk); 716 struct tipc_sock *tsk = tipc_sk(sk);
715 __poll_t revents = 0; 717 __poll_t revents = 0;
716 718
719 sock_poll_wait(file, sk_sleep(sk), wait);
720
717 if (sk->sk_shutdown & RCV_SHUTDOWN) 721 if (sk->sk_shutdown & RCV_SHUTDOWN)
718 revents |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM; 722 revents |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;
719 if (sk->sk_shutdown == SHUTDOWN_MASK) 723 if (sk->sk_shutdown == SHUTDOWN_MASK)
@@ -3033,7 +3037,7 @@ static const struct proto_ops msg_ops = {
3033 .socketpair = tipc_socketpair, 3037 .socketpair = tipc_socketpair,
3034 .accept = sock_no_accept, 3038 .accept = sock_no_accept,
3035 .getname = tipc_getname, 3039 .getname = tipc_getname,
3036 .poll_mask = tipc_poll_mask, 3040 .poll = tipc_poll,
3037 .ioctl = tipc_ioctl, 3041 .ioctl = tipc_ioctl,
3038 .listen = sock_no_listen, 3042 .listen = sock_no_listen,
3039 .shutdown = tipc_shutdown, 3043 .shutdown = tipc_shutdown,
@@ -3054,7 +3058,7 @@ static const struct proto_ops packet_ops = {
3054 .socketpair = tipc_socketpair, 3058 .socketpair = tipc_socketpair,
3055 .accept = tipc_accept, 3059 .accept = tipc_accept,
3056 .getname = tipc_getname, 3060 .getname = tipc_getname,
3057 .poll_mask = tipc_poll_mask, 3061 .poll = tipc_poll,
3058 .ioctl = tipc_ioctl, 3062 .ioctl = tipc_ioctl,
3059 .listen = tipc_listen, 3063 .listen = tipc_listen,
3060 .shutdown = tipc_shutdown, 3064 .shutdown = tipc_shutdown,
@@ -3075,7 +3079,7 @@ static const struct proto_ops stream_ops = {
3075 .socketpair = tipc_socketpair, 3079 .socketpair = tipc_socketpair,
3076 .accept = tipc_accept, 3080 .accept = tipc_accept,
3077 .getname = tipc_getname, 3081 .getname = tipc_getname,
3078 .poll_mask = tipc_poll_mask, 3082 .poll = tipc_poll,
3079 .ioctl = tipc_ioctl, 3083 .ioctl = tipc_ioctl,
3080 .listen = tipc_listen, 3084 .listen = tipc_listen,
3081 .shutdown = tipc_shutdown, 3085 .shutdown = tipc_shutdown,
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index a127d61e8af9..301f22430469 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -712,7 +712,7 @@ static int __init tls_register(void)
712 build_protos(tls_prots[TLSV4], &tcp_prot); 712 build_protos(tls_prots[TLSV4], &tcp_prot);
713 713
714 tls_sw_proto_ops = inet_stream_ops; 714 tls_sw_proto_ops = inet_stream_ops;
715 tls_sw_proto_ops.poll_mask = tls_sw_poll_mask; 715 tls_sw_proto_ops.poll = tls_sw_poll;
716 tls_sw_proto_ops.splice_read = tls_sw_splice_read; 716 tls_sw_proto_ops.splice_read = tls_sw_splice_read;
717 717
718#ifdef CONFIG_TLS_DEVICE 718#ifdef CONFIG_TLS_DEVICE
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index f127fac88acf..d2380548f8f6 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -919,22 +919,23 @@ splice_read_end:
919 return copied ? : err; 919 return copied ? : err;
920} 920}
921 921
922__poll_t tls_sw_poll_mask(struct socket *sock, __poll_t events) 922unsigned int tls_sw_poll(struct file *file, struct socket *sock,
923 struct poll_table_struct *wait)
923{ 924{
925 unsigned int ret;
924 struct sock *sk = sock->sk; 926 struct sock *sk = sock->sk;
925 struct tls_context *tls_ctx = tls_get_ctx(sk); 927 struct tls_context *tls_ctx = tls_get_ctx(sk);
926 struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx); 928 struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
927 __poll_t mask;
928 929
929 /* Grab EPOLLOUT and EPOLLHUP from the underlying socket */ 930 /* Grab POLLOUT and POLLHUP from the underlying socket */
930 mask = ctx->sk_poll_mask(sock, events); 931 ret = ctx->sk_poll(file, sock, wait);
931 932
932 /* Clear EPOLLIN bits, and set based on recv_pkt */ 933 /* Clear POLLIN bits, and set based on recv_pkt */
933 mask &= ~(EPOLLIN | EPOLLRDNORM); 934 ret &= ~(POLLIN | POLLRDNORM);
934 if (ctx->recv_pkt) 935 if (ctx->recv_pkt)
935 mask |= EPOLLIN | EPOLLRDNORM; 936 ret |= POLLIN | POLLRDNORM;
936 937
937 return mask; 938 return ret;
938} 939}
939 940
940static int tls_read_size(struct strparser *strp, struct sk_buff *skb) 941static int tls_read_size(struct strparser *strp, struct sk_buff *skb)
@@ -1191,7 +1192,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
1191 sk->sk_data_ready = tls_data_ready; 1192 sk->sk_data_ready = tls_data_ready;
1192 write_unlock_bh(&sk->sk_callback_lock); 1193 write_unlock_bh(&sk->sk_callback_lock);
1193 1194
1194 sw_ctx_rx->sk_poll_mask = sk->sk_socket->ops->poll_mask; 1195 sw_ctx_rx->sk_poll = sk->sk_socket->ops->poll;
1195 1196
1196 strp_check_rcv(&sw_ctx_rx->strp); 1197 strp_check_rcv(&sw_ctx_rx->strp);
1197 } 1198 }
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 95b02a71fd47..e5473c03d667 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -638,8 +638,9 @@ static int unix_stream_connect(struct socket *, struct sockaddr *,
638static int unix_socketpair(struct socket *, struct socket *); 638static int unix_socketpair(struct socket *, struct socket *);
639static int unix_accept(struct socket *, struct socket *, int, bool); 639static int unix_accept(struct socket *, struct socket *, int, bool);
640static int unix_getname(struct socket *, struct sockaddr *, int); 640static int unix_getname(struct socket *, struct sockaddr *, int);
641static __poll_t unix_poll_mask(struct socket *, __poll_t); 641static __poll_t unix_poll(struct file *, struct socket *, poll_table *);
642static __poll_t unix_dgram_poll_mask(struct socket *, __poll_t); 642static __poll_t unix_dgram_poll(struct file *, struct socket *,
643 poll_table *);
643static int unix_ioctl(struct socket *, unsigned int, unsigned long); 644static int unix_ioctl(struct socket *, unsigned int, unsigned long);
644static int unix_shutdown(struct socket *, int); 645static int unix_shutdown(struct socket *, int);
645static int unix_stream_sendmsg(struct socket *, struct msghdr *, size_t); 646static int unix_stream_sendmsg(struct socket *, struct msghdr *, size_t);
@@ -680,7 +681,7 @@ static const struct proto_ops unix_stream_ops = {
680 .socketpair = unix_socketpair, 681 .socketpair = unix_socketpair,
681 .accept = unix_accept, 682 .accept = unix_accept,
682 .getname = unix_getname, 683 .getname = unix_getname,
683 .poll_mask = unix_poll_mask, 684 .poll = unix_poll,
684 .ioctl = unix_ioctl, 685 .ioctl = unix_ioctl,
685 .listen = unix_listen, 686 .listen = unix_listen,
686 .shutdown = unix_shutdown, 687 .shutdown = unix_shutdown,
@@ -703,7 +704,7 @@ static const struct proto_ops unix_dgram_ops = {
703 .socketpair = unix_socketpair, 704 .socketpair = unix_socketpair,
704 .accept = sock_no_accept, 705 .accept = sock_no_accept,
705 .getname = unix_getname, 706 .getname = unix_getname,
706 .poll_mask = unix_dgram_poll_mask, 707 .poll = unix_dgram_poll,
707 .ioctl = unix_ioctl, 708 .ioctl = unix_ioctl,
708 .listen = sock_no_listen, 709 .listen = sock_no_listen,
709 .shutdown = unix_shutdown, 710 .shutdown = unix_shutdown,
@@ -725,7 +726,7 @@ static const struct proto_ops unix_seqpacket_ops = {
725 .socketpair = unix_socketpair, 726 .socketpair = unix_socketpair,
726 .accept = unix_accept, 727 .accept = unix_accept,
727 .getname = unix_getname, 728 .getname = unix_getname,
728 .poll_mask = unix_dgram_poll_mask, 729 .poll = unix_dgram_poll,
729 .ioctl = unix_ioctl, 730 .ioctl = unix_ioctl,
730 .listen = unix_listen, 731 .listen = unix_listen,
731 .shutdown = unix_shutdown, 732 .shutdown = unix_shutdown,
@@ -2629,10 +2630,13 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
2629 return err; 2630 return err;
2630} 2631}
2631 2632
2632static __poll_t unix_poll_mask(struct socket *sock, __poll_t events) 2633static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wait)
2633{ 2634{
2634 struct sock *sk = sock->sk; 2635 struct sock *sk = sock->sk;
2635 __poll_t mask = 0; 2636 __poll_t mask;
2637
2638 sock_poll_wait(file, sk_sleep(sk), wait);
2639 mask = 0;
2636 2640
2637 /* exceptional events? */ 2641 /* exceptional events? */
2638 if (sk->sk_err) 2642 if (sk->sk_err)
@@ -2661,11 +2665,15 @@ static __poll_t unix_poll_mask(struct socket *sock, __poll_t events)
2661 return mask; 2665 return mask;
2662} 2666}
2663 2667
2664static __poll_t unix_dgram_poll_mask(struct socket *sock, __poll_t events) 2668static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
2669 poll_table *wait)
2665{ 2670{
2666 struct sock *sk = sock->sk, *other; 2671 struct sock *sk = sock->sk, *other;
2667 int writable; 2672 unsigned int writable;
2668 __poll_t mask = 0; 2673 __poll_t mask;
2674
2675 sock_poll_wait(file, sk_sleep(sk), wait);
2676 mask = 0;
2669 2677
2670 /* exceptional events? */ 2678 /* exceptional events? */
2671 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 2679 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
@@ -2691,7 +2699,7 @@ static __poll_t unix_dgram_poll_mask(struct socket *sock, __poll_t events)
2691 } 2699 }
2692 2700
2693 /* No write status requested, avoid expensive OUT tests. */ 2701 /* No write status requested, avoid expensive OUT tests. */
2694 if (!(events & (EPOLLWRBAND|EPOLLWRNORM|EPOLLOUT))) 2702 if (!(poll_requested_events(wait) & (EPOLLWRBAND|EPOLLWRNORM|EPOLLOUT)))
2695 return mask; 2703 return mask;
2696 2704
2697 writable = unix_writable(sk); 2705 writable = unix_writable(sk);
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index bb5d5fa68c35..c1076c19b858 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -850,11 +850,18 @@ static int vsock_shutdown(struct socket *sock, int mode)
850 return err; 850 return err;
851} 851}
852 852
853static __poll_t vsock_poll_mask(struct socket *sock, __poll_t events) 853static __poll_t vsock_poll(struct file *file, struct socket *sock,
854 poll_table *wait)
854{ 855{
855 struct sock *sk = sock->sk; 856 struct sock *sk;
856 struct vsock_sock *vsk = vsock_sk(sk); 857 __poll_t mask;
857 __poll_t mask = 0; 858 struct vsock_sock *vsk;
859
860 sk = sock->sk;
861 vsk = vsock_sk(sk);
862
863 poll_wait(file, sk_sleep(sk), wait);
864 mask = 0;
858 865
859 if (sk->sk_err) 866 if (sk->sk_err)
860 /* Signify that there has been an error on this socket. */ 867 /* Signify that there has been an error on this socket. */
@@ -1084,7 +1091,7 @@ static const struct proto_ops vsock_dgram_ops = {
1084 .socketpair = sock_no_socketpair, 1091 .socketpair = sock_no_socketpair,
1085 .accept = sock_no_accept, 1092 .accept = sock_no_accept,
1086 .getname = vsock_getname, 1093 .getname = vsock_getname,
1087 .poll_mask = vsock_poll_mask, 1094 .poll = vsock_poll,
1088 .ioctl = sock_no_ioctl, 1095 .ioctl = sock_no_ioctl,
1089 .listen = sock_no_listen, 1096 .listen = sock_no_listen,
1090 .shutdown = vsock_shutdown, 1097 .shutdown = vsock_shutdown,
@@ -1842,7 +1849,7 @@ static const struct proto_ops vsock_stream_ops = {
1842 .socketpair = sock_no_socketpair, 1849 .socketpair = sock_no_socketpair,
1843 .accept = vsock_accept, 1850 .accept = vsock_accept,
1844 .getname = vsock_getname, 1851 .getname = vsock_getname,
1845 .poll_mask = vsock_poll_mask, 1852 .poll = vsock_poll,
1846 .ioctl = sock_no_ioctl, 1853 .ioctl = sock_no_ioctl,
1847 .listen = vsock_listen, 1854 .listen = vsock_listen,
1848 .shutdown = vsock_shutdown, 1855 .shutdown = vsock_shutdown,
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 8e03bd3f3668..5d3cce9e8744 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -201,7 +201,7 @@ virtio_transport_send_pkt(struct virtio_vsock_pkt *pkt)
201 return -ENODEV; 201 return -ENODEV;
202 } 202 }
203 203
204 if (le32_to_cpu(pkt->hdr.dst_cid) == vsock->guest_cid) 204 if (le64_to_cpu(pkt->hdr.dst_cid) == vsock->guest_cid)
205 return virtio_transport_send_pkt_loopback(vsock, pkt); 205 return virtio_transport_send_pkt_loopback(vsock, pkt);
206 206
207 if (pkt->reply) 207 if (pkt->reply)
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index f93365ae0fdd..d49aa79b7997 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -1750,7 +1750,7 @@ static const struct proto_ops x25_proto_ops = {
1750 .socketpair = sock_no_socketpair, 1750 .socketpair = sock_no_socketpair,
1751 .accept = x25_accept, 1751 .accept = x25_accept,
1752 .getname = x25_getname, 1752 .getname = x25_getname,
1753 .poll_mask = datagram_poll_mask, 1753 .poll = datagram_poll,
1754 .ioctl = x25_ioctl, 1754 .ioctl = x25_ioctl,
1755#ifdef CONFIG_COMPAT 1755#ifdef CONFIG_COMPAT
1756 .compat_ioctl = compat_x25_ioctl, 1756 .compat_ioctl = compat_x25_ioctl,
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 36919a254ba3..59fb7d3c36a3 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -118,6 +118,9 @@ int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
118 u64 addr; 118 u64 addr;
119 int err; 119 int err;
120 120
121 if (xs->dev != xdp->rxq->dev || xs->queue_id != xdp->rxq->queue_index)
122 return -EINVAL;
123
121 if (!xskq_peek_addr(xs->umem->fq, &addr) || 124 if (!xskq_peek_addr(xs->umem->fq, &addr) ||
122 len > xs->umem->chunk_size_nohr) { 125 len > xs->umem->chunk_size_nohr) {
123 xs->rx_dropped++; 126 xs->rx_dropped++;
@@ -300,9 +303,10 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len)
300 return (xs->zc) ? xsk_zc_xmit(sk) : xsk_generic_xmit(sk, m, total_len); 303 return (xs->zc) ? xsk_zc_xmit(sk) : xsk_generic_xmit(sk, m, total_len);
301} 304}
302 305
303static __poll_t xsk_poll_mask(struct socket *sock, __poll_t events) 306static unsigned int xsk_poll(struct file *file, struct socket *sock,
307 struct poll_table_struct *wait)
304{ 308{
305 __poll_t mask = datagram_poll_mask(sock, events); 309 unsigned int mask = datagram_poll(file, sock, wait);
306 struct sock *sk = sock->sk; 310 struct sock *sk = sock->sk;
307 struct xdp_sock *xs = xdp_sk(sk); 311 struct xdp_sock *xs = xdp_sk(sk);
308 312
@@ -693,7 +697,7 @@ static const struct proto_ops xsk_proto_ops = {
693 .socketpair = sock_no_socketpair, 697 .socketpair = sock_no_socketpair,
694 .accept = sock_no_accept, 698 .accept = sock_no_accept,
695 .getname = sock_no_getname, 699 .getname = sock_no_getname,
696 .poll_mask = xsk_poll_mask, 700 .poll = xsk_poll,
697 .ioctl = sock_no_ioctl, 701 .ioctl = sock_no_ioctl,
698 .listen = sock_no_listen, 702 .listen = sock_no_listen,
699 .shutdown = sock_no_shutdown, 703 .shutdown = sock_no_shutdown,
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 34d9e9ce97c2..e7889f486ca1 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -239,6 +239,7 @@ cmd_record_mcount = \
239 "$(CC_FLAGS_FTRACE)" ]; then \ 239 "$(CC_FLAGS_FTRACE)" ]; then \
240 $(sub_cmd_record_mcount) \ 240 $(sub_cmd_record_mcount) \
241 fi; 241 fi;
242endif # -record-mcount
242endif # CONFIG_FTRACE_MCOUNT_RECORD 243endif # CONFIG_FTRACE_MCOUNT_RECORD
243 244
244ifdef CONFIG_STACK_VALIDATION 245ifdef CONFIG_STACK_VALIDATION
@@ -263,7 +264,6 @@ ifneq ($(RETPOLINE_CFLAGS),)
263 objtool_args += --retpoline 264 objtool_args += --retpoline
264endif 265endif
265endif 266endif
266endif
267 267
268 268
269ifdef CONFIG_MODVERSIONS 269ifdef CONFIG_MODVERSIONS
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3b7362b0ee4..a9c05506e325 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2606,12 +2606,6 @@ sub process {
2606 "A patch subject line should describe the change not the tool that found it\n" . $herecurr); 2606 "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
2607 } 2607 }
2608 2608
2609# Check for old stable address
2610 if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) {
2611 ERROR("STABLE_ADDRESS",
2612 "The 'stable' address should be 'stable\@vger.kernel.org'\n" . $herecurr);
2613 }
2614
2615# Check for unwanted Gerrit info 2609# Check for unwanted Gerrit info
2616 if ($in_commit_log && $line =~ /^\s*change-id:/i) { 2610 if ($in_commit_log && $line =~ /^\s*change-id:/i) {
2617 ERROR("GERRIT_CHANGE_ID", 2611 ERROR("GERRIT_CHANGE_ID",
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
index 3755af0cd9f7..75e4e22b986a 100755
--- a/scripts/gcc-x86_64-has-stack-protector.sh
+++ b/scripts/gcc-x86_64-has-stack-protector.sh
@@ -1,4 +1,4 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3 3
4echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" 4echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m64 -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 94a383b21df6..f63b41b0dd49 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -171,6 +171,9 @@ struct symbol {
171 * config BAZ 171 * config BAZ
172 * int "BAZ Value" 172 * int "BAZ Value"
173 * range 1..255 173 * range 1..255
174 *
175 * Please, also check zconf.y:print_symbol() when modifying the
176 * list of property types!
174 */ 177 */
175enum prop_type { 178enum prop_type {
176 P_UNKNOWN, 179 P_UNKNOWN,
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 65da87fce907..5ca2df790d3c 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[])
156 nread--; 156 nread--;
157 157
158 /* remove trailing new lines */ 158 /* remove trailing new lines */
159 while (buf[nread - 1] == '\n') 159 while (nread > 0 && buf[nread - 1] == '\n')
160 nread--; 160 nread--;
161 161
162 buf[nread] = 0; 162 buf[nread] = 0;
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 6f9b0aa32a82..4b68272ebdb9 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
31static struct menu *current_menu, *current_entry; 31static struct menu *current_menu, *current_entry;
32 32
33%} 33%}
34%expect 32 34%expect 31
35 35
36%union 36%union
37{ 37{
@@ -337,7 +337,7 @@ choice_block:
337 337
338/* if entry */ 338/* if entry */
339 339
340if_entry: T_IF expr nl 340if_entry: T_IF expr T_EOL
341{ 341{
342 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 342 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
343 menu_add_entry(NULL); 343 menu_add_entry(NULL);
@@ -717,6 +717,10 @@ static void print_symbol(FILE *out, struct menu *menu)
717 print_quoted_string(out, prop->text); 717 print_quoted_string(out, prop->text);
718 fputc('\n', out); 718 fputc('\n', out);
719 break; 719 break;
720 case P_SYMBOL:
721 fputs( " symbol ", out);
722 fprintf(out, "%s\n", prop->sym->name);
723 break;
720 default: 724 default:
721 fprintf(out, " unknown prop %d!\n", prop->type); 725 fprintf(out, " unknown prop %d!\n", prop->type);
722 break; 726 break;
diff --git a/security/keys/dh.c b/security/keys/dh.c
index f7403821db7f..b203f7758f97 100644
--- a/security/keys/dh.c
+++ b/security/keys/dh.c
@@ -142,6 +142,8 @@ static void kdf_dealloc(struct kdf_sdesc *sdesc)
142 * The src pointer is defined as Z || other info where Z is the shared secret 142 * The src pointer is defined as Z || other info where Z is the shared secret
143 * from DH and other info is an arbitrary string (see SP800-56A section 143 * from DH and other info is an arbitrary string (see SP800-56A section
144 * 5.8.1.2). 144 * 5.8.1.2).
145 *
146 * 'dlen' must be a multiple of the digest size.
145 */ 147 */
146static int kdf_ctr(struct kdf_sdesc *sdesc, const u8 *src, unsigned int slen, 148static int kdf_ctr(struct kdf_sdesc *sdesc, const u8 *src, unsigned int slen,
147 u8 *dst, unsigned int dlen, unsigned int zlen) 149 u8 *dst, unsigned int dlen, unsigned int zlen)
@@ -205,8 +207,8 @@ static int keyctl_dh_compute_kdf(struct kdf_sdesc *sdesc,
205{ 207{
206 uint8_t *outbuf = NULL; 208 uint8_t *outbuf = NULL;
207 int ret; 209 int ret;
208 size_t outbuf_len = round_up(buflen, 210 size_t outbuf_len = roundup(buflen,
209 crypto_shash_digestsize(sdesc->shash.tfm)); 211 crypto_shash_digestsize(sdesc->shash.tfm));
210 212
211 outbuf = kmalloc(outbuf_len, GFP_KERNEL); 213 outbuf = kmalloc(outbuf_len, GFP_KERNEL);
212 if (!outbuf) { 214 if (!outbuf) {
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index f3d374d2ca04..79d3709b0671 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -441,22 +441,16 @@ static int sel_release_policy(struct inode *inode, struct file *filp)
441static ssize_t sel_read_policy(struct file *filp, char __user *buf, 441static ssize_t sel_read_policy(struct file *filp, char __user *buf,
442 size_t count, loff_t *ppos) 442 size_t count, loff_t *ppos)
443{ 443{
444 struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info;
445 struct policy_load_memory *plm = filp->private_data; 444 struct policy_load_memory *plm = filp->private_data;
446 int ret; 445 int ret;
447 446
448 mutex_lock(&fsi->mutex);
449
450 ret = avc_has_perm(&selinux_state, 447 ret = avc_has_perm(&selinux_state,
451 current_sid(), SECINITSID_SECURITY, 448 current_sid(), SECINITSID_SECURITY,
452 SECCLASS_SECURITY, SECURITY__READ_POLICY, NULL); 449 SECCLASS_SECURITY, SECURITY__READ_POLICY, NULL);
453 if (ret) 450 if (ret)
454 goto out; 451 return ret;
455 452
456 ret = simple_read_from_buffer(buf, count, ppos, plm->data, plm->len); 453 return simple_read_from_buffer(buf, count, ppos, plm->data, plm->len);
457out:
458 mutex_unlock(&fsi->mutex);
459 return ret;
460} 454}
461 455
462static vm_fault_t sel_mmap_policy_fault(struct vm_fault *vmf) 456static vm_fault_t sel_mmap_policy_fault(struct vm_fault *vmf)
@@ -1188,25 +1182,29 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf,
1188 ret = -EINVAL; 1182 ret = -EINVAL;
1189 if (index >= fsi->bool_num || strcmp(name, 1183 if (index >= fsi->bool_num || strcmp(name,
1190 fsi->bool_pending_names[index])) 1184 fsi->bool_pending_names[index]))
1191 goto out; 1185 goto out_unlock;
1192 1186
1193 ret = -ENOMEM; 1187 ret = -ENOMEM;
1194 page = (char *)get_zeroed_page(GFP_KERNEL); 1188 page = (char *)get_zeroed_page(GFP_KERNEL);
1195 if (!page) 1189 if (!page)
1196 goto out; 1190 goto out_unlock;
1197 1191
1198 cur_enforcing = security_get_bool_value(fsi->state, index); 1192 cur_enforcing = security_get_bool_value(fsi->state, index);
1199 if (cur_enforcing < 0) { 1193 if (cur_enforcing < 0) {
1200 ret = cur_enforcing; 1194 ret = cur_enforcing;
1201 goto out; 1195 goto out_unlock;
1202 } 1196 }
1203 length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing, 1197 length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing,
1204 fsi->bool_pending_values[index]); 1198 fsi->bool_pending_values[index]);
1205 ret = simple_read_from_buffer(buf, count, ppos, page, length);
1206out:
1207 mutex_unlock(&fsi->mutex); 1199 mutex_unlock(&fsi->mutex);
1200 ret = simple_read_from_buffer(buf, count, ppos, page, length);
1201out_free:
1208 free_page((unsigned long)page); 1202 free_page((unsigned long)page);
1209 return ret; 1203 return ret;
1204
1205out_unlock:
1206 mutex_unlock(&fsi->mutex);
1207 goto out_free;
1210} 1208}
1211 1209
1212static ssize_t sel_write_bool(struct file *filep, const char __user *buf, 1210static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
@@ -1219,6 +1217,17 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
1219 unsigned index = file_inode(filep)->i_ino & SEL_INO_MASK; 1217 unsigned index = file_inode(filep)->i_ino & SEL_INO_MASK;
1220 const char *name = filep->f_path.dentry->d_name.name; 1218 const char *name = filep->f_path.dentry->d_name.name;
1221 1219
1220 if (count >= PAGE_SIZE)
1221 return -ENOMEM;
1222
1223 /* No partial writes. */
1224 if (*ppos != 0)
1225 return -EINVAL;
1226
1227 page = memdup_user_nul(buf, count);
1228 if (IS_ERR(page))
1229 return PTR_ERR(page);
1230
1222 mutex_lock(&fsi->mutex); 1231 mutex_lock(&fsi->mutex);
1223 1232
1224 length = avc_has_perm(&selinux_state, 1233 length = avc_has_perm(&selinux_state,
@@ -1233,22 +1242,6 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
1233 fsi->bool_pending_names[index])) 1242 fsi->bool_pending_names[index]))
1234 goto out; 1243 goto out;
1235 1244
1236 length = -ENOMEM;
1237 if (count >= PAGE_SIZE)
1238 goto out;
1239
1240 /* No partial writes. */
1241 length = -EINVAL;
1242 if (*ppos != 0)
1243 goto out;
1244
1245 page = memdup_user_nul(buf, count);
1246 if (IS_ERR(page)) {
1247 length = PTR_ERR(page);
1248 page = NULL;
1249 goto out;
1250 }
1251
1252 length = -EINVAL; 1245 length = -EINVAL;
1253 if (sscanf(page, "%d", &new_value) != 1) 1246 if (sscanf(page, "%d", &new_value) != 1)
1254 goto out; 1247 goto out;
@@ -1280,6 +1273,17 @@ static ssize_t sel_commit_bools_write(struct file *filep,
1280 ssize_t length; 1273 ssize_t length;
1281 int new_value; 1274 int new_value;
1282 1275
1276 if (count >= PAGE_SIZE)
1277 return -ENOMEM;
1278
1279 /* No partial writes. */
1280 if (*ppos != 0)
1281 return -EINVAL;
1282
1283 page = memdup_user_nul(buf, count);
1284 if (IS_ERR(page))
1285 return PTR_ERR(page);
1286
1283 mutex_lock(&fsi->mutex); 1287 mutex_lock(&fsi->mutex);
1284 1288
1285 length = avc_has_perm(&selinux_state, 1289 length = avc_has_perm(&selinux_state,
@@ -1289,22 +1293,6 @@ static ssize_t sel_commit_bools_write(struct file *filep,
1289 if (length) 1293 if (length)
1290 goto out; 1294 goto out;
1291 1295
1292 length = -ENOMEM;
1293 if (count >= PAGE_SIZE)
1294 goto out;
1295
1296 /* No partial writes. */
1297 length = -EINVAL;
1298 if (*ppos != 0)
1299 goto out;
1300
1301 page = memdup_user_nul(buf, count);
1302 if (IS_ERR(page)) {
1303 length = PTR_ERR(page);
1304 page = NULL;
1305 goto out;
1306 }
1307
1308 length = -EINVAL; 1296 length = -EINVAL;
1309 if (sscanf(page, "%d", &new_value) != 1) 1297 if (sscanf(page, "%d", &new_value) != 1)
1310 goto out; 1298 goto out;
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 7ad226018f51..19de675d4504 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -2296,6 +2296,7 @@ static void smack_task_to_inode(struct task_struct *p, struct inode *inode)
2296 struct smack_known *skp = smk_of_task_struct(p); 2296 struct smack_known *skp = smk_of_task_struct(p);
2297 2297
2298 isp->smk_inode = skp; 2298 isp->smk_inode = skp;
2299 isp->smk_flags |= SMK_INODE_INSTANT;
2299} 2300}
2300 2301
2301/* 2302/*
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 61a07fe34cd2..56ca78423040 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -2004,7 +2004,8 @@ static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client,
2004 struct snd_seq_client *cptr = NULL; 2004 struct snd_seq_client *cptr = NULL;
2005 2005
2006 /* search for next client */ 2006 /* search for next client */
2007 info->client++; 2007 if (info->client < INT_MAX)
2008 info->client++;
2008 if (info->client < 0) 2009 if (info->client < 0)
2009 info->client = 0; 2010 info->client = 0;
2010 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) { 2011 for (; info->client < SNDRV_SEQ_MAX_CLIENTS; info->client++) {
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 665089c45560..b6f076bbc72d 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1520,7 +1520,7 @@ static int snd_timer_user_next_device(struct snd_timer_id __user *_tid)
1520 } else { 1520 } else {
1521 if (id.subdevice < 0) 1521 if (id.subdevice < 0)
1522 id.subdevice = 0; 1522 id.subdevice = 0;
1523 else 1523 else if (id.subdevice < INT_MAX)
1524 id.subdevice++; 1524 id.subdevice++;
1525 } 1525 }
1526 } 1526 }
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index d91c87e41756..20a171ac4bb2 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2899,8 +2899,9 @@ static int hda_codec_runtime_suspend(struct device *dev)
2899 list_for_each_entry(pcm, &codec->pcm_list_head, list) 2899 list_for_each_entry(pcm, &codec->pcm_list_head, list)
2900 snd_pcm_suspend_all(pcm->pcm); 2900 snd_pcm_suspend_all(pcm->pcm);
2901 state = hda_call_codec_suspend(codec); 2901 state = hda_call_codec_suspend(codec);
2902 if (codec_has_clkstop(codec) && codec_has_epss(codec) && 2902 if (codec->link_down_at_suspend ||
2903 (state & AC_PWRST_CLK_STOP_OK)) 2903 (codec_has_clkstop(codec) && codec_has_epss(codec) &&
2904 (state & AC_PWRST_CLK_STOP_OK)))
2904 snd_hdac_codec_link_down(&codec->core); 2905 snd_hdac_codec_link_down(&codec->core);
2905 snd_hdac_link_power(&codec->core, false); 2906 snd_hdac_link_power(&codec->core, false);
2906 return 0; 2907 return 0;
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 681c360f29f9..a8b1b31f161c 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -258,6 +258,7 @@ struct hda_codec {
258 unsigned int power_save_node:1; /* advanced PM for each widget */ 258 unsigned int power_save_node:1; /* advanced PM for each widget */
259 unsigned int auto_runtime_pm:1; /* enable automatic codec runtime pm */ 259 unsigned int auto_runtime_pm:1; /* enable automatic codec runtime pm */
260 unsigned int force_pin_prefix:1; /* Add location prefix */ 260 unsigned int force_pin_prefix:1; /* Add location prefix */
261 unsigned int link_down_at_suspend:1; /* link down at runtime suspend */
261#ifdef CONFIG_PM 262#ifdef CONFIG_PM
262 unsigned long power_on_acct; 263 unsigned long power_on_acct;
263 unsigned long power_off_acct; 264 unsigned long power_off_acct;
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 04e949aa01ad..4ff5320378e2 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -991,6 +991,7 @@ struct ca0132_spec {
991enum { 991enum {
992 QUIRK_NONE, 992 QUIRK_NONE,
993 QUIRK_ALIENWARE, 993 QUIRK_ALIENWARE,
994 QUIRK_ALIENWARE_M17XR4,
994 QUIRK_SBZ, 995 QUIRK_SBZ,
995 QUIRK_R3DI, 996 QUIRK_R3DI,
996}; 997};
@@ -1040,6 +1041,7 @@ static const struct hda_pintbl r3di_pincfgs[] = {
1040}; 1041};
1041 1042
1042static const struct snd_pci_quirk ca0132_quirks[] = { 1043static const struct snd_pci_quirk ca0132_quirks[] = {
1044 SND_PCI_QUIRK(0x1028, 0x057b, "Alienware M17x R4", QUIRK_ALIENWARE_M17XR4),
1043 SND_PCI_QUIRK(0x1028, 0x0685, "Alienware 15 2015", QUIRK_ALIENWARE), 1045 SND_PCI_QUIRK(0x1028, 0x0685, "Alienware 15 2015", QUIRK_ALIENWARE),
1044 SND_PCI_QUIRK(0x1028, 0x0688, "Alienware 17 2015", QUIRK_ALIENWARE), 1046 SND_PCI_QUIRK(0x1028, 0x0688, "Alienware 17 2015", QUIRK_ALIENWARE),
1045 SND_PCI_QUIRK(0x1028, 0x0708, "Alienware 15 R2 2016", QUIRK_ALIENWARE), 1047 SND_PCI_QUIRK(0x1028, 0x0708, "Alienware 15 R2 2016", QUIRK_ALIENWARE),
@@ -5663,7 +5665,7 @@ static const char * const ca0132_alt_slave_pfxs[] = {
5663 * I think this has to do with the pin for rear surround being 0x11, 5665 * I think this has to do with the pin for rear surround being 0x11,
5664 * and the center/lfe being 0x10. Usually the pin order is the opposite. 5666 * and the center/lfe being 0x10. Usually the pin order is the opposite.
5665 */ 5667 */
5666const struct snd_pcm_chmap_elem ca0132_alt_chmaps[] = { 5668static const struct snd_pcm_chmap_elem ca0132_alt_chmaps[] = {
5667 { .channels = 2, 5669 { .channels = 2,
5668 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, 5670 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
5669 { .channels = 4, 5671 { .channels = 4,
@@ -5966,7 +5968,7 @@ static int ca0132_build_pcms(struct hda_codec *codec)
5966 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[0]; 5968 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adcs[0];
5967 5969
5968 /* With the DSP enabled, desktops don't use this ADC. */ 5970 /* With the DSP enabled, desktops don't use this ADC. */
5969 if (spec->use_alt_functions) { 5971 if (!spec->use_alt_functions) {
5970 info = snd_hda_codec_pcm_new(codec, "CA0132 Analog Mic-In2"); 5972 info = snd_hda_codec_pcm_new(codec, "CA0132 Analog Mic-In2");
5971 if (!info) 5973 if (!info)
5972 return -ENOMEM; 5974 return -ENOMEM;
@@ -6130,7 +6132,10 @@ static void ca0132_init_dmic(struct hda_codec *codec)
6130 * Bit 6: set to select Data2, clear for Data1 6132 * Bit 6: set to select Data2, clear for Data1
6131 * Bit 7: set to enable DMic, clear for AMic 6133 * Bit 7: set to enable DMic, clear for AMic
6132 */ 6134 */
6133 val = 0x23; 6135 if (spec->quirk == QUIRK_ALIENWARE_M17XR4)
6136 val = 0x33;
6137 else
6138 val = 0x23;
6134 /* keep a copy of dmic ctl val for enable/disable dmic purpuse */ 6139 /* keep a copy of dmic ctl val for enable/disable dmic purpuse */
6135 spec->dmic_ctl = val; 6140 spec->dmic_ctl = val;
6136 snd_hda_codec_write(codec, spec->input_pins[0], 0, 6141 snd_hda_codec_write(codec, spec->input_pins[0], 0,
@@ -7223,7 +7228,7 @@ static int ca0132_init(struct hda_codec *codec)
7223 7228
7224 snd_hda_sequence_write(codec, spec->base_init_verbs); 7229 snd_hda_sequence_write(codec, spec->base_init_verbs);
7225 7230
7226 if (spec->quirk != QUIRK_NONE) 7231 if (spec->use_alt_functions)
7227 ca0132_alt_init(codec); 7232 ca0132_alt_init(codec);
7228 7233
7229 ca0132_download_dsp(codec); 7234 ca0132_download_dsp(codec);
@@ -7237,8 +7242,9 @@ static int ca0132_init(struct hda_codec *codec)
7237 case QUIRK_R3DI: 7242 case QUIRK_R3DI:
7238 r3di_setup_defaults(codec); 7243 r3di_setup_defaults(codec);
7239 break; 7244 break;
7240 case QUIRK_NONE: 7245 case QUIRK_SBZ:
7241 case QUIRK_ALIENWARE: 7246 break;
7247 default:
7242 ca0132_setup_defaults(codec); 7248 ca0132_setup_defaults(codec);
7243 ca0132_init_analog_mic2(codec); 7249 ca0132_init_analog_mic2(codec);
7244 ca0132_init_dmic(codec); 7250 ca0132_init_dmic(codec);
@@ -7343,7 +7349,6 @@ static const struct hda_codec_ops ca0132_patch_ops = {
7343static void ca0132_config(struct hda_codec *codec) 7349static void ca0132_config(struct hda_codec *codec)
7344{ 7350{
7345 struct ca0132_spec *spec = codec->spec; 7351 struct ca0132_spec *spec = codec->spec;
7346 struct auto_pin_cfg *cfg = &spec->autocfg;
7347 7352
7348 spec->dacs[0] = 0x2; 7353 spec->dacs[0] = 0x2;
7349 spec->dacs[1] = 0x3; 7354 spec->dacs[1] = 0x3;
@@ -7405,12 +7410,7 @@ static void ca0132_config(struct hda_codec *codec)
7405 /* SPDIF I/O */ 7410 /* SPDIF I/O */
7406 spec->dig_out = 0x05; 7411 spec->dig_out = 0x05;
7407 spec->multiout.dig_out_nid = spec->dig_out; 7412 spec->multiout.dig_out_nid = spec->dig_out;
7408 cfg->dig_out_pins[0] = 0x0c;
7409 cfg->dig_outs = 1;
7410 cfg->dig_out_type[0] = HDA_PCM_TYPE_SPDIF;
7411 spec->dig_in = 0x09; 7413 spec->dig_in = 0x09;
7412 cfg->dig_in_pin = 0x0e;
7413 cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
7414 break; 7414 break;
7415 case QUIRK_R3DI: 7415 case QUIRK_R3DI:
7416 codec_dbg(codec, "%s: QUIRK_R3DI applied.\n", __func__); 7416 codec_dbg(codec, "%s: QUIRK_R3DI applied.\n", __func__);
@@ -7438,9 +7438,6 @@ static void ca0132_config(struct hda_codec *codec)
7438 /* SPDIF I/O */ 7438 /* SPDIF I/O */
7439 spec->dig_out = 0x05; 7439 spec->dig_out = 0x05;
7440 spec->multiout.dig_out_nid = spec->dig_out; 7440 spec->multiout.dig_out_nid = spec->dig_out;
7441 cfg->dig_out_pins[0] = 0x0c;
7442 cfg->dig_outs = 1;
7443 cfg->dig_out_type[0] = HDA_PCM_TYPE_SPDIF;
7444 break; 7441 break;
7445 default: 7442 default:
7446 spec->num_outputs = 2; 7443 spec->num_outputs = 2;
@@ -7463,12 +7460,7 @@ static void ca0132_config(struct hda_codec *codec)
7463 /* SPDIF I/O */ 7460 /* SPDIF I/O */
7464 spec->dig_out = 0x05; 7461 spec->dig_out = 0x05;
7465 spec->multiout.dig_out_nid = spec->dig_out; 7462 spec->multiout.dig_out_nid = spec->dig_out;
7466 cfg->dig_out_pins[0] = 0x0c;
7467 cfg->dig_outs = 1;
7468 cfg->dig_out_type[0] = HDA_PCM_TYPE_SPDIF;
7469 spec->dig_in = 0x09; 7463 spec->dig_in = 0x09;
7470 cfg->dig_in_pin = 0x0e;
7471 cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
7472 break; 7464 break;
7473 } 7465 }
7474} 7466}
@@ -7476,7 +7468,7 @@ static void ca0132_config(struct hda_codec *codec)
7476static int ca0132_prepare_verbs(struct hda_codec *codec) 7468static int ca0132_prepare_verbs(struct hda_codec *codec)
7477{ 7469{
7478/* Verbs + terminator (an empty element) */ 7470/* Verbs + terminator (an empty element) */
7479#define NUM_SPEC_VERBS 4 7471#define NUM_SPEC_VERBS 2
7480 struct ca0132_spec *spec = codec->spec; 7472 struct ca0132_spec *spec = codec->spec;
7481 7473
7482 spec->chip_init_verbs = ca0132_init_verbs0; 7474 spec->chip_init_verbs = ca0132_init_verbs0;
@@ -7488,34 +7480,24 @@ static int ca0132_prepare_verbs(struct hda_codec *codec)
7488 if (!spec->spec_init_verbs) 7480 if (!spec->spec_init_verbs)
7489 return -ENOMEM; 7481 return -ENOMEM;
7490 7482
7491 /* HP jack autodetection */
7492 spec->spec_init_verbs[0].nid = spec->unsol_tag_hp;
7493 spec->spec_init_verbs[0].param = AC_VERB_SET_UNSOLICITED_ENABLE;
7494 spec->spec_init_verbs[0].verb = AC_USRSP_EN | spec->unsol_tag_hp;
7495
7496 /* MIC1 jack autodetection */
7497 spec->spec_init_verbs[1].nid = spec->unsol_tag_amic1;
7498 spec->spec_init_verbs[1].param = AC_VERB_SET_UNSOLICITED_ENABLE;
7499 spec->spec_init_verbs[1].verb = AC_USRSP_EN | spec->unsol_tag_amic1;
7500
7501 /* config EAPD */ 7483 /* config EAPD */
7502 spec->spec_init_verbs[2].nid = 0x0b; 7484 spec->spec_init_verbs[0].nid = 0x0b;
7503 spec->spec_init_verbs[2].param = 0x78D; 7485 spec->spec_init_verbs[0].param = 0x78D;
7504 spec->spec_init_verbs[2].verb = 0x00; 7486 spec->spec_init_verbs[0].verb = 0x00;
7505 7487
7506 /* Previously commented configuration */ 7488 /* Previously commented configuration */
7507 /* 7489 /*
7508 spec->spec_init_verbs[3].nid = 0x0b; 7490 spec->spec_init_verbs[2].nid = 0x0b;
7509 spec->spec_init_verbs[3].param = AC_VERB_SET_EAPD_BTLENABLE; 7491 spec->spec_init_verbs[2].param = AC_VERB_SET_EAPD_BTLENABLE;
7492 spec->spec_init_verbs[2].verb = 0x02;
7493
7494 spec->spec_init_verbs[3].nid = 0x10;
7495 spec->spec_init_verbs[3].param = 0x78D;
7510 spec->spec_init_verbs[3].verb = 0x02; 7496 spec->spec_init_verbs[3].verb = 0x02;
7511 7497
7512 spec->spec_init_verbs[4].nid = 0x10; 7498 spec->spec_init_verbs[4].nid = 0x10;
7513 spec->spec_init_verbs[4].param = 0x78D; 7499 spec->spec_init_verbs[4].param = AC_VERB_SET_EAPD_BTLENABLE;
7514 spec->spec_init_verbs[4].verb = 0x02; 7500 spec->spec_init_verbs[4].verb = 0x02;
7515
7516 spec->spec_init_verbs[5].nid = 0x10;
7517 spec->spec_init_verbs[5].param = AC_VERB_SET_EAPD_BTLENABLE;
7518 spec->spec_init_verbs[5].verb = 0x02;
7519 */ 7501 */
7520 7502
7521 /* Terminator: spec->spec_init_verbs[NUM_SPEC_VERBS-1] */ 7503 /* Terminator: spec->spec_init_verbs[NUM_SPEC_VERBS-1] */
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 8840daf9c6a3..98e1c411c56a 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -3741,6 +3741,11 @@ static int patch_atihdmi(struct hda_codec *codec)
3741 3741
3742 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u); 3742 spec->chmap.channels_max = max(spec->chmap.channels_max, 8u);
3743 3743
3744 /* AMD GPUs have neither EPSS nor CLKSTOP bits, hence preventing
3745 * the link-down as is. Tell the core to allow it.
3746 */
3747 codec->link_down_at_suspend = 1;
3748
3744 return 0; 3749 return 0;
3745} 3750}
3746 3751
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index e9bd33ea538f..5ad6c7e5f92e 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2545,6 +2545,7 @@ static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2545 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110), 2545 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2546 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), 2546 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2547 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), 2547 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2548 SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2548 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), 2549 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2549 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), 2550 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2550 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), 2551 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
@@ -4995,7 +4996,6 @@ static void alc_fixup_tpt440_dock(struct hda_codec *codec,
4995 struct alc_spec *spec = codec->spec; 4996 struct alc_spec *spec = codec->spec;
4996 4997
4997 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4998 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4998 spec->shutup = alc_no_shutup; /* reduce click noise */
4999 spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */ 4999 spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
5000 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; 5000 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5001 codec->power_save_node = 0; /* avoid click noises */ 5001 codec->power_save_node = 0; /* avoid click noises */
@@ -5394,6 +5394,13 @@ static void alc274_fixup_bind_dacs(struct hda_codec *codec,
5394/* for hda_fixup_thinkpad_acpi() */ 5394/* for hda_fixup_thinkpad_acpi() */
5395#include "thinkpad_helper.c" 5395#include "thinkpad_helper.c"
5396 5396
5397static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
5398 const struct hda_fixup *fix, int action)
5399{
5400 alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
5401 hda_fixup_thinkpad_acpi(codec, fix, action);
5402}
5403
5397/* for dell wmi mic mute led */ 5404/* for dell wmi mic mute led */
5398#include "dell_wmi_helper.c" 5405#include "dell_wmi_helper.c"
5399 5406
@@ -5946,7 +5953,7 @@ static const struct hda_fixup alc269_fixups[] = {
5946 }, 5953 },
5947 [ALC269_FIXUP_THINKPAD_ACPI] = { 5954 [ALC269_FIXUP_THINKPAD_ACPI] = {
5948 .type = HDA_FIXUP_FUNC, 5955 .type = HDA_FIXUP_FUNC,
5949 .v.func = hda_fixup_thinkpad_acpi, 5956 .v.func = alc_fixup_thinkpad_acpi,
5950 .chained = true, 5957 .chained = true,
5951 .chain_id = ALC269_FIXUP_SKU_IGNORE, 5958 .chain_id = ALC269_FIXUP_SKU_IGNORE,
5952 }, 5959 },
@@ -6603,8 +6610,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6603 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), 6610 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6604 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), 6611 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6605 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), 6612 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6613 SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6606 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), 6614 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6607 SND_PCI_QUIRK(0x17aa, 0x3138, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), 6615 SND_PCI_QUIRK(0x17aa, 0x3136, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6608 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION), 6616 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
6609 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 6617 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
6610 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), 6618 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
@@ -6782,6 +6790,12 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
6782 {0x14, 0x90170110}, 6790 {0x14, 0x90170110},
6783 {0x19, 0x02a11030}, 6791 {0x19, 0x02a11030},
6784 {0x21, 0x02211020}), 6792 {0x21, 0x02211020}),
6793 SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
6794 {0x14, 0x90170110},
6795 {0x19, 0x02a11030},
6796 {0x1a, 0x02a11040},
6797 {0x1b, 0x01014020},
6798 {0x21, 0x0221101f}),
6785 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 6799 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6786 {0x12, 0x90a60140}, 6800 {0x12, 0x90a60140},
6787 {0x14, 0x90170110}, 6801 {0x14, 0x90170110},
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 6c85f13ab23f..54f6252faca6 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1018,6 +1018,7 @@ static int snd_lx6464es_create(struct snd_card *card,
1018 chip->port_dsp_bar = pci_ioremap_bar(pci, 2); 1018 chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
1019 if (!chip->port_dsp_bar) { 1019 if (!chip->port_dsp_bar) {
1020 dev_err(card->dev, "cannot remap PCI memory region\n"); 1020 dev_err(card->dev, "cannot remap PCI memory region\n");
1021 err = -ENOMEM;
1021 goto remap_pci_failed; 1022 goto remap_pci_failed;
1022 } 1023 }
1023 1024
diff --git a/tools/arch/arm/include/uapi/asm/kvm.h b/tools/arch/arm/include/uapi/asm/kvm.h
index caae4843cb70..16e006f708ca 100644
--- a/tools/arch/arm/include/uapi/asm/kvm.h
+++ b/tools/arch/arm/include/uapi/asm/kvm.h
@@ -91,6 +91,7 @@ struct kvm_regs {
91#define KVM_VGIC_V3_ADDR_TYPE_DIST 2 91#define KVM_VGIC_V3_ADDR_TYPE_DIST 2
92#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 92#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3
93#define KVM_VGIC_ITS_ADDR_TYPE 4 93#define KVM_VGIC_ITS_ADDR_TYPE 4
94#define KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION 5
94 95
95#define KVM_VGIC_V3_DIST_SIZE SZ_64K 96#define KVM_VGIC_V3_DIST_SIZE SZ_64K
96#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K) 97#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K)
diff --git a/tools/arch/arm64/include/uapi/asm/kvm.h b/tools/arch/arm64/include/uapi/asm/kvm.h
index 04b3256f8e6d..4e76630dd655 100644
--- a/tools/arch/arm64/include/uapi/asm/kvm.h
+++ b/tools/arch/arm64/include/uapi/asm/kvm.h
@@ -91,6 +91,7 @@ struct kvm_regs {
91#define KVM_VGIC_V3_ADDR_TYPE_DIST 2 91#define KVM_VGIC_V3_ADDR_TYPE_DIST 2
92#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 92#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3
93#define KVM_VGIC_ITS_ADDR_TYPE 4 93#define KVM_VGIC_ITS_ADDR_TYPE 4
94#define KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION 5
94 95
95#define KVM_VGIC_V3_DIST_SIZE SZ_64K 96#define KVM_VGIC_V3_DIST_SIZE SZ_64K
96#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K) 97#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K)
diff --git a/tools/arch/powerpc/include/uapi/asm/kvm.h b/tools/arch/powerpc/include/uapi/asm/kvm.h
index 833ed9a16adf..1b32b56a03d3 100644
--- a/tools/arch/powerpc/include/uapi/asm/kvm.h
+++ b/tools/arch/powerpc/include/uapi/asm/kvm.h
@@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char {
633#define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) 633#define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd)
634 634
635#define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe) 635#define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
636#define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
636 637
637/* Transactional Memory checkpointed state: 638/* Transactional Memory checkpointed state:
638 * This is all GPRs, all VSX regs and a subset of SPRs 639 * This is all GPRs, all VSX regs and a subset of SPRs
diff --git a/tools/arch/powerpc/include/uapi/asm/unistd.h b/tools/arch/powerpc/include/uapi/asm/unistd.h
index 389c36fd8299..ac5ba55066dd 100644
--- a/tools/arch/powerpc/include/uapi/asm/unistd.h
+++ b/tools/arch/powerpc/include/uapi/asm/unistd.h
@@ -398,5 +398,6 @@
398#define __NR_pkey_alloc 384 398#define __NR_pkey_alloc 384
399#define __NR_pkey_free 385 399#define __NR_pkey_free 385
400#define __NR_pkey_mprotect 386 400#define __NR_pkey_mprotect 386
401#define __NR_rseq 387
401 402
402#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ 403#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index fb00a2fca990..5701f5cecd31 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -282,7 +282,9 @@
282#define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */ 282#define X86_FEATURE_AMD_IBPB (13*32+12) /* "" Indirect Branch Prediction Barrier */
283#define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */ 283#define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted Speculation */
284#define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */ 284#define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch Predictors */
285#define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Disable */
285#define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */ 286#define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store Bypass Disable */
287#define X86_FEATURE_AMD_SSB_NO (13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */
286 288
287/* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ 289/* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
288#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */ 290#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */
diff --git a/tools/bpf/bpftool/perf.c b/tools/bpf/bpftool/perf.c
index ac6b1a12c9b7..b76b77dcfd1f 100644
--- a/tools/bpf/bpftool/perf.c
+++ b/tools/bpf/bpftool/perf.c
@@ -29,9 +29,10 @@ static bool has_perf_query_support(void)
29 if (perf_query_supported) 29 if (perf_query_supported)
30 goto out; 30 goto out;
31 31
32 fd = open(bin_name, O_RDONLY); 32 fd = open("/", O_RDONLY);
33 if (fd < 0) { 33 if (fd < 0) {
34 p_err("perf_query_support: %s", strerror(errno)); 34 p_err("perf_query_support: cannot open directory \"/\" (%s)",
35 strerror(errno));
35 goto out; 36 goto out;
36 } 37 }
37 38
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index a4f435203fef..05f42a46d6ed 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -90,7 +90,9 @@ static void print_boot_time(__u64 nsecs, char *buf, unsigned int size)
90 } 90 }
91 91
92 wallclock_secs = (real_time_ts.tv_sec - boot_time_ts.tv_sec) + 92 wallclock_secs = (real_time_ts.tv_sec - boot_time_ts.tv_sec) +
93 nsecs / 1000000000; 93 (real_time_ts.tv_nsec - boot_time_ts.tv_nsec + nsecs) /
94 1000000000;
95
94 96
95 if (!localtime_r(&wallclock_secs, &load_tm)) { 97 if (!localtime_r(&wallclock_secs, &load_tm)) {
96 snprintf(buf, size, "%llu", nsecs / 1000000000); 98 snprintf(buf, size, "%llu", nsecs / 1000000000);
diff --git a/tools/include/uapi/drm/drm.h b/tools/include/uapi/drm/drm.h
index 6fdff5945c8a..9c660e1688ab 100644
--- a/tools/include/uapi/drm/drm.h
+++ b/tools/include/uapi/drm/drm.h
@@ -680,6 +680,13 @@ struct drm_get_cap {
680 */ 680 */
681#define DRM_CLIENT_CAP_ATOMIC 3 681#define DRM_CLIENT_CAP_ATOMIC 3
682 682
683/**
684 * DRM_CLIENT_CAP_ASPECT_RATIO
685 *
686 * If set to 1, the DRM core will provide aspect ratio information in modes.
687 */
688#define DRM_CLIENT_CAP_ASPECT_RATIO 4
689
683/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ 690/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
684struct drm_set_client_cap { 691struct drm_set_client_cap {
685 __u64 capability; 692 __u64 capability;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index e0b06784f227..59b19b6a40d7 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -2630,7 +2630,7 @@ struct bpf_fib_lookup {
2630 union { 2630 union {
2631 /* inputs to lookup */ 2631 /* inputs to lookup */
2632 __u8 tos; /* AF_INET */ 2632 __u8 tos; /* AF_INET */
2633 __be32 flowlabel; /* AF_INET6 */ 2633 __be32 flowinfo; /* AF_INET6, flow_label + priority */
2634 2634
2635 /* output: metric of fib result (IPv4/IPv6 only) */ 2635 /* output: metric of fib result (IPv4/IPv6 only) */
2636 __u32 rt_metric; 2636 __u32 rt_metric;
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index 68699f654118..cf01b6824244 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -333,6 +333,7 @@ enum {
333 IFLA_BRPORT_BCAST_FLOOD, 333 IFLA_BRPORT_BCAST_FLOOD,
334 IFLA_BRPORT_GROUP_FWD_MASK, 334 IFLA_BRPORT_GROUP_FWD_MASK,
335 IFLA_BRPORT_NEIGH_SUPPRESS, 335 IFLA_BRPORT_NEIGH_SUPPRESS,
336 IFLA_BRPORT_ISOLATED,
336 __IFLA_BRPORT_MAX 337 __IFLA_BRPORT_MAX
337}; 338};
338#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) 339#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
@@ -516,6 +517,7 @@ enum {
516 IFLA_VXLAN_COLLECT_METADATA, 517 IFLA_VXLAN_COLLECT_METADATA,
517 IFLA_VXLAN_LABEL, 518 IFLA_VXLAN_LABEL,
518 IFLA_VXLAN_GPE, 519 IFLA_VXLAN_GPE,
520 IFLA_VXLAN_TTL_INHERIT,
519 __IFLA_VXLAN_MAX 521 __IFLA_VXLAN_MAX
520}; 522};
521#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) 523#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 39e364c70caf..b6270a3b38e9 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -948,6 +948,7 @@ struct kvm_ppc_resize_hpt {
948#define KVM_CAP_S390_BPB 152 948#define KVM_CAP_S390_BPB 152
949#define KVM_CAP_GET_MSR_FEATURES 153 949#define KVM_CAP_GET_MSR_FEATURES 153
950#define KVM_CAP_HYPERV_EVENTFD 154 950#define KVM_CAP_HYPERV_EVENTFD 154
951#define KVM_CAP_HYPERV_TLBFLUSH 155
951 952
952#ifdef KVM_CAP_IRQ_ROUTING 953#ifdef KVM_CAP_IRQ_ROUTING
953 954
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 38047c6aa575..f4a25bd1871f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -164,6 +164,7 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func,
164 "lbug_with_loc", 164 "lbug_with_loc",
165 "fortify_panic", 165 "fortify_panic",
166 "usercopy_abort", 166 "usercopy_abort",
167 "machine_real_restart",
167 }; 168 };
168 169
169 if (func->bind == STB_WEAK) 170 if (func->bind == STB_WEAK)
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 5dfe102fb5b5..b10a90b6a718 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -178,6 +178,9 @@ Print count deltas for fixed number of times.
178This option should be used together with "-I" option. 178This option should be used together with "-I" option.
179 example: 'perf stat -I 1000 --interval-count 2 -e cycles -a' 179 example: 'perf stat -I 1000 --interval-count 2 -e cycles -a'
180 180
181--interval-clear::
182Clear the screen before next interval.
183
181--timeout msecs:: 184--timeout msecs::
182Stop the 'perf stat' session and print count deltas after N milliseconds (minimum: 10 ms). 185Stop the 'perf stat' session and print count deltas after N milliseconds (minimum: 10 ms).
183This option is not supported with the "-I" option. 186This option is not supported with the "-I" option.
diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index 3598b8b75d27..ef5d59a5742e 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -243,7 +243,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
243 u64 ip; 243 u64 ip;
244 u64 skip_slot = -1; 244 u64 skip_slot = -1;
245 245
246 if (chain->nr < 3) 246 if (!chain || chain->nr < 3)
247 return skip_slot; 247 return skip_slot;
248 248
249 ip = chain->ips[2]; 249 ip = chain->ips[2];
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index 4dfe42666d0c..f0b1709a5ffb 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -341,6 +341,8 @@
341330 common pkey_alloc __x64_sys_pkey_alloc 341330 common pkey_alloc __x64_sys_pkey_alloc
342331 common pkey_free __x64_sys_pkey_free 342331 common pkey_free __x64_sys_pkey_free
343332 common statx __x64_sys_statx 343332 common statx __x64_sys_statx
344333 common io_pgetevents __x64_sys_io_pgetevents
345334 common rseq __x64_sys_rseq
344 346
345# 347#
346# x32-specific system call numbers start at 512 to avoid cache impact 348# x32-specific system call numbers start at 512 to avoid cache impact
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 63eb49082774..44195514b19e 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -1098,7 +1098,7 @@ static void *worker_thread(void *__tdata)
1098 u8 *global_data; 1098 u8 *global_data;
1099 u8 *process_data; 1099 u8 *process_data;
1100 u8 *thread_data; 1100 u8 *thread_data;
1101 u64 bytes_done; 1101 u64 bytes_done, secs;
1102 long work_done; 1102 long work_done;
1103 u32 l; 1103 u32 l;
1104 struct rusage rusage; 1104 struct rusage rusage;
@@ -1254,7 +1254,8 @@ static void *worker_thread(void *__tdata)
1254 timersub(&stop, &start0, &diff); 1254 timersub(&stop, &start0, &diff);
1255 td->runtime_ns = diff.tv_sec * NSEC_PER_SEC; 1255 td->runtime_ns = diff.tv_sec * NSEC_PER_SEC;
1256 td->runtime_ns += diff.tv_usec * NSEC_PER_USEC; 1256 td->runtime_ns += diff.tv_usec * NSEC_PER_USEC;
1257 td->speed_gbs = bytes_done / (td->runtime_ns / NSEC_PER_SEC) / 1e9; 1257 secs = td->runtime_ns / NSEC_PER_SEC;
1258 td->speed_gbs = secs ? bytes_done / secs / 1e9 : 0;
1258 1259
1259 getrusage(RUSAGE_THREAD, &rusage); 1260 getrusage(RUSAGE_THREAD, &rusage);
1260 td->system_time_ns = rusage.ru_stime.tv_sec * NSEC_PER_SEC; 1261 td->system_time_ns = rusage.ru_stime.tv_sec * NSEC_PER_SEC;
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 5eb22cc56363..8180319285af 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -283,6 +283,15 @@ out_put:
283 return ret; 283 return ret;
284} 284}
285 285
286static int process_feature_event(struct perf_tool *tool,
287 union perf_event *event,
288 struct perf_session *session)
289{
290 if (event->feat.feat_id < HEADER_LAST_FEATURE)
291 return perf_event__process_feature(tool, event, session);
292 return 0;
293}
294
286static int hist_entry__tty_annotate(struct hist_entry *he, 295static int hist_entry__tty_annotate(struct hist_entry *he,
287 struct perf_evsel *evsel, 296 struct perf_evsel *evsel,
288 struct perf_annotate *ann) 297 struct perf_annotate *ann)
@@ -471,7 +480,7 @@ int cmd_annotate(int argc, const char **argv)
471 .attr = perf_event__process_attr, 480 .attr = perf_event__process_attr,
472 .build_id = perf_event__process_build_id, 481 .build_id = perf_event__process_build_id,
473 .tracing_data = perf_event__process_tracing_data, 482 .tracing_data = perf_event__process_tracing_data,
474 .feature = perf_event__process_feature, 483 .feature = process_feature_event,
475 .ordered_events = true, 484 .ordered_events = true,
476 .ordering_requires_timestamps = true, 485 .ordering_requires_timestamps = true,
477 }, 486 },
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 307b3594525f..6a8738f7ead3 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -56,16 +56,16 @@ struct c2c_hist_entry {
56 56
57 struct compute_stats cstats; 57 struct compute_stats cstats;
58 58
59 unsigned long paddr;
60 unsigned long paddr_cnt;
61 bool paddr_zero;
62 char *nodestr;
63
59 /* 64 /*
60 * must be at the end, 65 * must be at the end,
61 * because of its callchain dynamic entry 66 * because of its callchain dynamic entry
62 */ 67 */
63 struct hist_entry he; 68 struct hist_entry he;
64
65 unsigned long paddr;
66 unsigned long paddr_cnt;
67 bool paddr_zero;
68 char *nodestr;
69}; 69};
70 70
71static char const *coalesce_default = "pid,iaddr"; 71static char const *coalesce_default = "pid,iaddr";
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index cdb5b6949832..c04dc7b53797 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -217,7 +217,8 @@ static int process_feature_event(struct perf_tool *tool,
217 } 217 }
218 218
219 /* 219 /*
220 * All features are received, we can force the 220 * (feat_id = HEADER_LAST_FEATURE) is the end marker which
221 * means all features are received, now we can force the
221 * group if needed. 222 * group if needed.
222 */ 223 */
223 setup_forced_leader(rep, session->evlist); 224 setup_forced_leader(rep, session->evlist);
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index b3bf35512d21..568ddfac3213 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -180,6 +180,18 @@ static struct {
180 PERF_OUTPUT_EVNAME | PERF_OUTPUT_TRACE 180 PERF_OUTPUT_EVNAME | PERF_OUTPUT_TRACE
181 }, 181 },
182 182
183 [PERF_TYPE_HW_CACHE] = {
184 .user_set = false,
185
186 .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
187 PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
188 PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
189 PERF_OUTPUT_SYM | PERF_OUTPUT_SYMOFFSET |
190 PERF_OUTPUT_DSO | PERF_OUTPUT_PERIOD,
191
192 .invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
193 },
194
183 [PERF_TYPE_RAW] = { 195 [PERF_TYPE_RAW] = {
184 .user_set = false, 196 .user_set = false,
185 197
@@ -1822,6 +1834,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
1822 struct perf_evlist *evlist; 1834 struct perf_evlist *evlist;
1823 struct perf_evsel *evsel, *pos; 1835 struct perf_evsel *evsel, *pos;
1824 int err; 1836 int err;
1837 static struct perf_evsel_script *es;
1825 1838
1826 err = perf_event__process_attr(tool, event, pevlist); 1839 err = perf_event__process_attr(tool, event, pevlist);
1827 if (err) 1840 if (err)
@@ -1830,6 +1843,19 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
1830 evlist = *pevlist; 1843 evlist = *pevlist;
1831 evsel = perf_evlist__last(*pevlist); 1844 evsel = perf_evlist__last(*pevlist);
1832 1845
1846 if (!evsel->priv) {
1847 if (scr->per_event_dump) {
1848 evsel->priv = perf_evsel_script__new(evsel,
1849 scr->session->data);
1850 } else {
1851 es = zalloc(sizeof(*es));
1852 if (!es)
1853 return -ENOMEM;
1854 es->fp = stdout;
1855 evsel->priv = es;
1856 }
1857 }
1858
1833 if (evsel->attr.type >= PERF_TYPE_MAX && 1859 if (evsel->attr.type >= PERF_TYPE_MAX &&
1834 evsel->attr.type != PERF_TYPE_SYNTH) 1860 evsel->attr.type != PERF_TYPE_SYNTH)
1835 return 0; 1861 return 0;
@@ -3018,6 +3044,15 @@ int process_cpu_map_event(struct perf_tool *tool __maybe_unused,
3018 return set_maps(script); 3044 return set_maps(script);
3019} 3045}
3020 3046
3047static int process_feature_event(struct perf_tool *tool,
3048 union perf_event *event,
3049 struct perf_session *session)
3050{
3051 if (event->feat.feat_id < HEADER_LAST_FEATURE)
3052 return perf_event__process_feature(tool, event, session);
3053 return 0;
3054}
3055
3021#ifdef HAVE_AUXTRACE_SUPPORT 3056#ifdef HAVE_AUXTRACE_SUPPORT
3022static int perf_script__process_auxtrace_info(struct perf_tool *tool, 3057static int perf_script__process_auxtrace_info(struct perf_tool *tool,
3023 union perf_event *event, 3058 union perf_event *event,
@@ -3062,7 +3097,7 @@ int cmd_script(int argc, const char **argv)
3062 .attr = process_attr, 3097 .attr = process_attr,
3063 .event_update = perf_event__process_event_update, 3098 .event_update = perf_event__process_event_update,
3064 .tracing_data = perf_event__process_tracing_data, 3099 .tracing_data = perf_event__process_tracing_data,
3065 .feature = perf_event__process_feature, 3100 .feature = process_feature_event,
3066 .build_id = perf_event__process_build_id, 3101 .build_id = perf_event__process_build_id,
3067 .id_index = perf_event__process_id_index, 3102 .id_index = perf_event__process_id_index,
3068 .auxtrace_info = perf_script__process_auxtrace_info, 3103 .auxtrace_info = perf_script__process_auxtrace_info,
@@ -3113,8 +3148,9 @@ int cmd_script(int argc, const char **argv)
3113 "+field to add and -field to remove." 3148 "+field to add and -field to remove."
3114 "Valid types: hw,sw,trace,raw,synth. " 3149 "Valid types: hw,sw,trace,raw,synth. "
3115 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," 3150 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
3116 "addr,symoff,period,iregs,uregs,brstack,brstacksym,flags," 3151 "addr,symoff,srcline,period,iregs,uregs,brstack,"
3117 "bpf-output,callindent,insn,insnlen,brstackinsn,synth,phys_addr", 3152 "brstacksym,flags,bpf-output,brstackinsn,brstackoff,"
3153 "callindent,insn,insnlen,synth,phys_addr,metric,misc",
3118 parse_output_fields), 3154 parse_output_fields),
3119 OPT_BOOLEAN('a', "all-cpus", &system_wide, 3155 OPT_BOOLEAN('a', "all-cpus", &system_wide,
3120 "system-wide collection from all CPUs"), 3156 "system-wide collection from all CPUs"),
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 096ccb25c11f..22547a490e1f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -65,6 +65,7 @@
65#include "util/tool.h" 65#include "util/tool.h"
66#include "util/string2.h" 66#include "util/string2.h"
67#include "util/metricgroup.h" 67#include "util/metricgroup.h"
68#include "util/top.h"
68#include "asm/bug.h" 69#include "asm/bug.h"
69 70
70#include <linux/time64.h> 71#include <linux/time64.h>
@@ -144,6 +145,8 @@ static struct target target = {
144 145
145typedef int (*aggr_get_id_t)(struct cpu_map *m, int cpu); 146typedef int (*aggr_get_id_t)(struct cpu_map *m, int cpu);
146 147
148#define METRIC_ONLY_LEN 20
149
147static int run_count = 1; 150static int run_count = 1;
148static bool no_inherit = false; 151static bool no_inherit = false;
149static volatile pid_t child_pid = -1; 152static volatile pid_t child_pid = -1;
@@ -173,6 +176,7 @@ static struct cpu_map *aggr_map;
173static aggr_get_id_t aggr_get_id; 176static aggr_get_id_t aggr_get_id;
174static bool append_file; 177static bool append_file;
175static bool interval_count; 178static bool interval_count;
179static bool interval_clear;
176static const char *output_name; 180static const char *output_name;
177static int output_fd; 181static int output_fd;
178static int print_free_counters_hint; 182static int print_free_counters_hint;
@@ -180,6 +184,7 @@ static int print_mixed_hw_group_error;
180static u64 *walltime_run; 184static u64 *walltime_run;
181static bool ru_display = false; 185static bool ru_display = false;
182static struct rusage ru_data; 186static struct rusage ru_data;
187static unsigned int metric_only_len = METRIC_ONLY_LEN;
183 188
184struct perf_stat { 189struct perf_stat {
185 bool record; 190 bool record;
@@ -967,8 +972,6 @@ static void print_metric_csv(void *ctx,
967 fprintf(out, "%s%s%s%s", csv_sep, vals, csv_sep, unit); 972 fprintf(out, "%s%s%s%s", csv_sep, vals, csv_sep, unit);
968} 973}
969 974
970#define METRIC_ONLY_LEN 20
971
972/* Filter out some columns that don't work well in metrics only mode */ 975/* Filter out some columns that don't work well in metrics only mode */
973 976
974static bool valid_only_metric(const char *unit) 977static bool valid_only_metric(const char *unit)
@@ -999,22 +1002,20 @@ static void print_metric_only(void *ctx, const char *color, const char *fmt,
999{ 1002{
1000 struct outstate *os = ctx; 1003 struct outstate *os = ctx;
1001 FILE *out = os->fh; 1004 FILE *out = os->fh;
1002 int n; 1005 char buf[1024], str[1024];
1003 char buf[1024]; 1006 unsigned mlen = metric_only_len;
1004 unsigned mlen = METRIC_ONLY_LEN;
1005 1007
1006 if (!valid_only_metric(unit)) 1008 if (!valid_only_metric(unit))
1007 return; 1009 return;
1008 unit = fixunit(buf, os->evsel, unit); 1010 unit = fixunit(buf, os->evsel, unit);
1009 if (color)
1010 n = color_fprintf(out, color, fmt, val);
1011 else
1012 n = fprintf(out, fmt, val);
1013 if (n > METRIC_ONLY_LEN)
1014 n = METRIC_ONLY_LEN;
1015 if (mlen < strlen(unit)) 1011 if (mlen < strlen(unit))
1016 mlen = strlen(unit) + 1; 1012 mlen = strlen(unit) + 1;
1017 fprintf(out, "%*s", mlen - n, ""); 1013
1014 if (color)
1015 mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1;
1016
1017 color_snprintf(str, sizeof(str), color ?: "", fmt, val);
1018 fprintf(out, "%*s ", mlen, str);
1018} 1019}
1019 1020
1020static void print_metric_only_csv(void *ctx, const char *color __maybe_unused, 1021static void print_metric_only_csv(void *ctx, const char *color __maybe_unused,
@@ -1054,7 +1055,7 @@ static void print_metric_header(void *ctx, const char *color __maybe_unused,
1054 if (csv_output) 1055 if (csv_output)
1055 fprintf(os->fh, "%s%s", unit, csv_sep); 1056 fprintf(os->fh, "%s%s", unit, csv_sep);
1056 else 1057 else
1057 fprintf(os->fh, "%-*s ", METRIC_ONLY_LEN, unit); 1058 fprintf(os->fh, "%*s ", metric_only_len, unit);
1058} 1059}
1059 1060
1060static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg) 1061static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)
@@ -1704,9 +1705,12 @@ static void print_interval(char *prefix, struct timespec *ts)
1704 FILE *output = stat_config.output; 1705 FILE *output = stat_config.output;
1705 static int num_print_interval; 1706 static int num_print_interval;
1706 1707
1708 if (interval_clear)
1709 puts(CONSOLE_CLEAR);
1710
1707 sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); 1711 sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
1708 1712
1709 if (num_print_interval == 0 && !csv_output) { 1713 if ((num_print_interval == 0 && !csv_output) || interval_clear) {
1710 switch (stat_config.aggr_mode) { 1714 switch (stat_config.aggr_mode) {
1711 case AGGR_SOCKET: 1715 case AGGR_SOCKET:
1712 fprintf(output, "# time socket cpus"); 1716 fprintf(output, "# time socket cpus");
@@ -1719,7 +1723,7 @@ static void print_interval(char *prefix, struct timespec *ts)
1719 fprintf(output, " counts %*s events\n", unit_width, "unit"); 1723 fprintf(output, " counts %*s events\n", unit_width, "unit");
1720 break; 1724 break;
1721 case AGGR_NONE: 1725 case AGGR_NONE:
1722 fprintf(output, "# time CPU"); 1726 fprintf(output, "# time CPU ");
1723 if (!metric_only) 1727 if (!metric_only)
1724 fprintf(output, " counts %*s events\n", unit_width, "unit"); 1728 fprintf(output, " counts %*s events\n", unit_width, "unit");
1725 break; 1729 break;
@@ -1738,7 +1742,7 @@ static void print_interval(char *prefix, struct timespec *ts)
1738 } 1742 }
1739 } 1743 }
1740 1744
1741 if (num_print_interval == 0 && metric_only) 1745 if ((num_print_interval == 0 && metric_only) || interval_clear)
1742 print_metric_headers(" ", true); 1746 print_metric_headers(" ", true);
1743 if (++num_print_interval == 25) 1747 if (++num_print_interval == 25)
1744 num_print_interval = 0; 1748 num_print_interval = 0;
@@ -2057,6 +2061,8 @@ static const struct option stat_options[] = {
2057 "(overhead is possible for values <= 100ms)"), 2061 "(overhead is possible for values <= 100ms)"),
2058 OPT_INTEGER(0, "interval-count", &stat_config.times, 2062 OPT_INTEGER(0, "interval-count", &stat_config.times,
2059 "print counts for fixed number of times"), 2063 "print counts for fixed number of times"),
2064 OPT_BOOLEAN(0, "interval-clear", &interval_clear,
2065 "clear screen in between new interval"),
2060 OPT_UINTEGER(0, "timeout", &stat_config.timeout, 2066 OPT_UINTEGER(0, "timeout", &stat_config.timeout,
2061 "stop workload and print counts after a timeout period in ms (>= 10ms)"), 2067 "stop workload and print counts after a timeout period in ms (>= 10ms)"),
2062 OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode, 2068 OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode,
@@ -2436,14 +2442,13 @@ static int add_default_attributes(void)
2436 (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) | 2442 (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) |
2437 (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) }, 2443 (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
2438}; 2444};
2445 struct parse_events_error errinfo;
2439 2446
2440 /* Set attrs if no event is selected and !null_run: */ 2447 /* Set attrs if no event is selected and !null_run: */
2441 if (null_run) 2448 if (null_run)
2442 return 0; 2449 return 0;
2443 2450
2444 if (transaction_run) { 2451 if (transaction_run) {
2445 struct parse_events_error errinfo;
2446
2447 if (pmu_have_event("cpu", "cycles-ct") && 2452 if (pmu_have_event("cpu", "cycles-ct") &&
2448 pmu_have_event("cpu", "el-start")) 2453 pmu_have_event("cpu", "el-start"))
2449 err = parse_events(evsel_list, transaction_attrs, 2454 err = parse_events(evsel_list, transaction_attrs,
@@ -2454,6 +2459,7 @@ static int add_default_attributes(void)
2454 &errinfo); 2459 &errinfo);
2455 if (err) { 2460 if (err) {
2456 fprintf(stderr, "Cannot set up transaction events\n"); 2461 fprintf(stderr, "Cannot set up transaction events\n");
2462 parse_events_print_error(&errinfo, transaction_attrs);
2457 return -1; 2463 return -1;
2458 } 2464 }
2459 return 0; 2465 return 0;
@@ -2479,10 +2485,11 @@ static int add_default_attributes(void)
2479 pmu_have_event("msr", "smi")) { 2485 pmu_have_event("msr", "smi")) {
2480 if (!force_metric_only) 2486 if (!force_metric_only)
2481 metric_only = true; 2487 metric_only = true;
2482 err = parse_events(evsel_list, smi_cost_attrs, NULL); 2488 err = parse_events(evsel_list, smi_cost_attrs, &errinfo);
2483 } else { 2489 } else {
2484 fprintf(stderr, "To measure SMI cost, it needs " 2490 fprintf(stderr, "To measure SMI cost, it needs "
2485 "msr/aperf/, msr/smi/ and cpu/cycles/ support\n"); 2491 "msr/aperf/, msr/smi/ and cpu/cycles/ support\n");
2492 parse_events_print_error(&errinfo, smi_cost_attrs);
2486 return -1; 2493 return -1;
2487 } 2494 }
2488 if (err) { 2495 if (err) {
@@ -2517,12 +2524,13 @@ static int add_default_attributes(void)
2517 if (topdown_attrs[0] && str) { 2524 if (topdown_attrs[0] && str) {
2518 if (warn) 2525 if (warn)
2519 arch_topdown_group_warn(); 2526 arch_topdown_group_warn();
2520 err = parse_events(evsel_list, str, NULL); 2527 err = parse_events(evsel_list, str, &errinfo);
2521 if (err) { 2528 if (err) {
2522 fprintf(stderr, 2529 fprintf(stderr,
2523 "Cannot set up top down events %s: %d\n", 2530 "Cannot set up top down events %s: %d\n",
2524 str, err); 2531 str, err);
2525 free(str); 2532 free(str);
2533 parse_events_print_error(&errinfo, str);
2526 return -1; 2534 return -1;
2527 } 2535 }
2528 } else { 2536 } else {
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 7d4077068454..61211918bfba 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -1309,6 +1309,11 @@ static int test__checkevent_config_cache(struct perf_evlist *evlist)
1309 return 0; 1309 return 0;
1310} 1310}
1311 1311
1312static bool test__intel_pt_valid(void)
1313{
1314 return !!perf_pmu__find("intel_pt");
1315}
1316
1312static int test__intel_pt(struct perf_evlist *evlist) 1317static int test__intel_pt(struct perf_evlist *evlist)
1313{ 1318{
1314 struct perf_evsel *evsel = perf_evlist__first(evlist); 1319 struct perf_evsel *evsel = perf_evlist__first(evlist);
@@ -1375,6 +1380,7 @@ struct evlist_test {
1375 const char *name; 1380 const char *name;
1376 __u32 type; 1381 __u32 type;
1377 const int id; 1382 const int id;
1383 bool (*valid)(void);
1378 int (*check)(struct perf_evlist *evlist); 1384 int (*check)(struct perf_evlist *evlist);
1379}; 1385};
1380 1386
@@ -1648,6 +1654,7 @@ static struct evlist_test test__events[] = {
1648 }, 1654 },
1649 { 1655 {
1650 .name = "intel_pt//u", 1656 .name = "intel_pt//u",
1657 .valid = test__intel_pt_valid,
1651 .check = test__intel_pt, 1658 .check = test__intel_pt,
1652 .id = 52, 1659 .id = 52,
1653 }, 1660 },
@@ -1686,17 +1693,24 @@ static struct terms_test test__terms[] = {
1686 1693
1687static int test_event(struct evlist_test *e) 1694static int test_event(struct evlist_test *e)
1688{ 1695{
1696 struct parse_events_error err = { .idx = 0, };
1689 struct perf_evlist *evlist; 1697 struct perf_evlist *evlist;
1690 int ret; 1698 int ret;
1691 1699
1700 if (e->valid && !e->valid()) {
1701 pr_debug("... SKIP");
1702 return 0;
1703 }
1704
1692 evlist = perf_evlist__new(); 1705 evlist = perf_evlist__new();
1693 if (evlist == NULL) 1706 if (evlist == NULL)
1694 return -ENOMEM; 1707 return -ENOMEM;
1695 1708
1696 ret = parse_events(evlist, e->name, NULL); 1709 ret = parse_events(evlist, e->name, &err);
1697 if (ret) { 1710 if (ret) {
1698 pr_debug("failed to parse event '%s', err %d\n", 1711 pr_debug("failed to parse event '%s', err %d, str '%s'\n",
1699 e->name, ret); 1712 e->name, ret, err.str);
1713 parse_events_print_error(&err, e->name);
1700 } else { 1714 } else {
1701 ret = e->check(evlist); 1715 ret = e->check(evlist);
1702 } 1716 }
@@ -1714,10 +1728,11 @@ static int test_events(struct evlist_test *events, unsigned cnt)
1714 for (i = 0; i < cnt; i++) { 1728 for (i = 0; i < cnt; i++) {
1715 struct evlist_test *e = &events[i]; 1729 struct evlist_test *e = &events[i];
1716 1730
1717 pr_debug("running test %d '%s'\n", e->id, e->name); 1731 pr_debug("running test %d '%s'", e->id, e->name);
1718 ret1 = test_event(e); 1732 ret1 = test_event(e);
1719 if (ret1) 1733 if (ret1)
1720 ret2 = ret1; 1734 ret2 = ret1;
1735 pr_debug("\n");
1721 } 1736 }
1722 1737
1723 return ret2; 1738 return ret2;
@@ -1799,7 +1814,7 @@ static int test_pmu_events(void)
1799 } 1814 }
1800 1815
1801 while (!ret && (ent = readdir(dir))) { 1816 while (!ret && (ent = readdir(dir))) {
1802 struct evlist_test e; 1817 struct evlist_test e = { .id = 0, };
1803 char name[2 * NAME_MAX + 1 + 12 + 3]; 1818 char name[2 * NAME_MAX + 1 + 12 + 3];
1804 1819
1805 /* Names containing . are special and cannot be used directly */ 1820 /* Names containing . are special and cannot be used directly */
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index 40e30a26b23c..9497d02f69e6 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -45,6 +45,7 @@ static int session_write_header(char *path)
45 45
46 perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY); 46 perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
47 perf_header__set_feat(&session->header, HEADER_NRCPUS); 47 perf_header__set_feat(&session->header, HEADER_NRCPUS);
48 perf_header__set_feat(&session->header, HEADER_ARCH);
48 49
49 session->header.data_size += DATA_SIZE; 50 session->header.data_size += DATA_SIZE;
50 51
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index b085f1b3e34d..4ab663ec3e5e 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -382,7 +382,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
382 gtk_tree_store_set(store, &iter, col_idx++, s, -1); 382 gtk_tree_store_set(store, &iter, col_idx++, s, -1);
383 } 383 }
384 384
385 if (hists__has_callchains(hists) && 385 if (hist_entry__has_callchains(h) &&
386 symbol_conf.use_callchain && hists__has(hists, sym)) { 386 symbol_conf.use_callchain && hists__has(hists, sym)) {
387 if (callchain_param.mode == CHAIN_GRAPH_REL) 387 if (callchain_param.mode == CHAIN_GRAPH_REL)
388 total = symbol_conf.cumulate_callchain ? 388 total = symbol_conf.cumulate_callchain ?
diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp
index bf31ceab33bd..89512504551b 100644
--- a/tools/perf/util/c++/clang.cpp
+++ b/tools/perf/util/c++/clang.cpp
@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
146 raw_svector_ostream ostream(*Buffer); 146 raw_svector_ostream ostream(*Buffer);
147 147
148 legacy::PassManager PM; 148 legacy::PassManager PM;
149 if (TargetMachine->addPassesToEmitFile(PM, ostream, 149 bool NotAdded;
150 TargetMachine::CGFT_ObjectFile)) { 150#if CLANG_VERSION_MAJOR < 7
151 NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
152 TargetMachine::CGFT_ObjectFile);
153#else
154 NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
155 TargetMachine::CGFT_ObjectFile);
156#endif
157 if (NotAdded) {
151 llvm::errs() << "TargetMachine can't emit a file of this type\n"; 158 llvm::errs() << "TargetMachine can't emit a file of this type\n";
152 return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);; 159 return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);;
153 } 160 }
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 540cd2dcd3e7..653ff65aa2c3 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2129,6 +2129,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
2129 int cpu_nr = ff->ph->env.nr_cpus_avail; 2129 int cpu_nr = ff->ph->env.nr_cpus_avail;
2130 u64 size = 0; 2130 u64 size = 0;
2131 struct perf_header *ph = ff->ph; 2131 struct perf_header *ph = ff->ph;
2132 bool do_core_id_test = true;
2132 2133
2133 ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu)); 2134 ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
2134 if (!ph->env.cpu) 2135 if (!ph->env.cpu)
@@ -2183,6 +2184,13 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
2183 return 0; 2184 return 0;
2184 } 2185 }
2185 2186
2187 /* On s390 the socket_id number is not related to the numbers of cpus.
2188 * The socket_id number might be higher than the numbers of cpus.
2189 * This depends on the configuration.
2190 */
2191 if (ph->env.arch && !strncmp(ph->env.arch, "s390", 4))
2192 do_core_id_test = false;
2193
2186 for (i = 0; i < (u32)cpu_nr; i++) { 2194 for (i = 0; i < (u32)cpu_nr; i++) {
2187 if (do_read_u32(ff, &nr)) 2195 if (do_read_u32(ff, &nr))
2188 goto free_cpu; 2196 goto free_cpu;
@@ -2192,7 +2200,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
2192 if (do_read_u32(ff, &nr)) 2200 if (do_read_u32(ff, &nr))
2193 goto free_cpu; 2201 goto free_cpu;
2194 2202
2195 if (nr != (u32)-1 && nr > (u32)cpu_nr) { 2203 if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
2196 pr_debug("socket_id number is too big." 2204 pr_debug("socket_id number is too big."
2197 "You may need to upgrade the perf tool.\n"); 2205 "You may need to upgrade the perf tool.\n");
2198 goto free_cpu; 2206 goto free_cpu;
@@ -3456,7 +3464,7 @@ int perf_event__process_feature(struct perf_tool *tool,
3456 pr_warning("invalid record type %d in pipe-mode\n", type); 3464 pr_warning("invalid record type %d in pipe-mode\n", type);
3457 return 0; 3465 return 0;
3458 } 3466 }
3459 if (feat == HEADER_RESERVED || feat > HEADER_LAST_FEATURE) { 3467 if (feat == HEADER_RESERVED || feat >= HEADER_LAST_FEATURE) {
3460 pr_warning("invalid record type %d in pipe-mode\n", type); 3468 pr_warning("invalid record type %d in pipe-mode\n", type);
3461 return -1; 3469 return -1;
3462 } 3470 }
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 52e8fda93a47..828cb9794c76 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -370,9 +370,11 @@ void hists__delete_entries(struct hists *hists)
370 370
371static int hist_entry__init(struct hist_entry *he, 371static int hist_entry__init(struct hist_entry *he,
372 struct hist_entry *template, 372 struct hist_entry *template,
373 bool sample_self) 373 bool sample_self,
374 size_t callchain_size)
374{ 375{
375 *he = *template; 376 *he = *template;
377 he->callchain_size = callchain_size;
376 378
377 if (symbol_conf.cumulate_callchain) { 379 if (symbol_conf.cumulate_callchain) {
378 he->stat_acc = malloc(sizeof(he->stat)); 380 he->stat_acc = malloc(sizeof(he->stat));
@@ -473,7 +475,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,
473 475
474 he = ops->new(callchain_size); 476 he = ops->new(callchain_size);
475 if (he) { 477 if (he) {
476 err = hist_entry__init(he, template, sample_self); 478 err = hist_entry__init(he, template, sample_self, callchain_size);
477 if (err) { 479 if (err) {
478 ops->free(he); 480 ops->free(he);
479 he = NULL; 481 he = NULL;
@@ -619,9 +621,11 @@ __hists__add_entry(struct hists *hists,
619 .raw_data = sample->raw_data, 621 .raw_data = sample->raw_data,
620 .raw_size = sample->raw_size, 622 .raw_size = sample->raw_size,
621 .ops = ops, 623 .ops = ops,
622 }; 624 }, *he = hists__findnew_entry(hists, &entry, al, sample_self);
623 625
624 return hists__findnew_entry(hists, &entry, al, sample_self); 626 if (!hists->has_callchains && he && he->callchain_size != 0)
627 hists->has_callchains = true;
628 return he;
625} 629}
626 630
627struct hist_entry *hists__add_entry(struct hists *hists, 631struct hist_entry *hists__add_entry(struct hists *hists,
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 06607c434949..73049f7f0f60 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -85,6 +85,7 @@ struct hists {
85 struct events_stats stats; 85 struct events_stats stats;
86 u64 event_stream; 86 u64 event_stream;
87 u16 col_len[HISTC_NR_COLS]; 87 u16 col_len[HISTC_NR_COLS];
88 bool has_callchains;
88 int socket_filter; 89 int socket_filter;
89 struct perf_hpp_list *hpp_list; 90 struct perf_hpp_list *hpp_list;
90 struct list_head hpp_formats; 91 struct list_head hpp_formats;
@@ -222,8 +223,7 @@ static inline struct hists *evsel__hists(struct perf_evsel *evsel)
222 223
223static __pure inline bool hists__has_callchains(struct hists *hists) 224static __pure inline bool hists__has_callchains(struct hists *hists)
224{ 225{
225 const struct perf_evsel *evsel = hists_to_evsel(hists); 226 return hists->has_callchains;
226 return evsel__has_callchain(evsel);
227} 227}
228 228
229int hists__init(void); 229int hists__init(void);
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
index ba4c9dd18643..d426761a549d 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
@@ -366,7 +366,7 @@ static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
366 if (len < offs) 366 if (len < offs)
367 return INTEL_PT_NEED_MORE_BYTES; 367 return INTEL_PT_NEED_MORE_BYTES;
368 byte = buf[offs++]; 368 byte = buf[offs++];
369 payload |= (byte >> 1) << shift; 369 payload |= ((uint64_t)byte >> 1) << shift;
370 } 370 }
371 371
372 packet->type = INTEL_PT_CYC; 372 packet->type = INTEL_PT_CYC;
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 155d2570274f..da8fe57691b8 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -227,11 +227,16 @@ event_def: event_pmu |
227event_pmu: 227event_pmu:
228PE_NAME opt_pmu_config 228PE_NAME opt_pmu_config
229{ 229{
230 struct parse_events_state *parse_state = _parse_state;
231 struct parse_events_error *error = parse_state->error;
230 struct list_head *list, *orig_terms, *terms; 232 struct list_head *list, *orig_terms, *terms;
231 233
232 if (parse_events_copy_term_list($2, &orig_terms)) 234 if (parse_events_copy_term_list($2, &orig_terms))
233 YYABORT; 235 YYABORT;
234 236
237 if (error)
238 error->idx = @1.first_column;
239
235 ALLOC_LIST(list); 240 ALLOC_LIST(list);
236 if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) { 241 if (parse_events_add_pmu(_parse_state, list, $1, $2, false, false)) {
237 struct perf_pmu *pmu = NULL; 242 struct perf_pmu *pmu = NULL;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d2fb597c9a8c..3ba6a1742f91 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -234,6 +234,74 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
234 return 0; 234 return 0;
235} 235}
236 236
237static void perf_pmu_assign_str(char *name, const char *field, char **old_str,
238 char **new_str)
239{
240 if (!*old_str)
241 goto set_new;
242
243 if (*new_str) { /* Have new string, check with old */
244 if (strcasecmp(*old_str, *new_str))
245 pr_debug("alias %s differs in field '%s'\n",
246 name, field);
247 zfree(old_str);
248 } else /* Nothing new --> keep old string */
249 return;
250set_new:
251 *old_str = *new_str;
252 *new_str = NULL;
253}
254
255static void perf_pmu_update_alias(struct perf_pmu_alias *old,
256 struct perf_pmu_alias *newalias)
257{
258 perf_pmu_assign_str(old->name, "desc", &old->desc, &newalias->desc);
259 perf_pmu_assign_str(old->name, "long_desc", &old->long_desc,
260 &newalias->long_desc);
261 perf_pmu_assign_str(old->name, "topic", &old->topic, &newalias->topic);
262 perf_pmu_assign_str(old->name, "metric_expr", &old->metric_expr,
263 &newalias->metric_expr);
264 perf_pmu_assign_str(old->name, "metric_name", &old->metric_name,
265 &newalias->metric_name);
266 perf_pmu_assign_str(old->name, "value", &old->str, &newalias->str);
267 old->scale = newalias->scale;
268 old->per_pkg = newalias->per_pkg;
269 old->snapshot = newalias->snapshot;
270 memcpy(old->unit, newalias->unit, sizeof(old->unit));
271}
272
273/* Delete an alias entry. */
274static void perf_pmu_free_alias(struct perf_pmu_alias *newalias)
275{
276 zfree(&newalias->name);
277 zfree(&newalias->desc);
278 zfree(&newalias->long_desc);
279 zfree(&newalias->topic);
280 zfree(&newalias->str);
281 zfree(&newalias->metric_expr);
282 zfree(&newalias->metric_name);
283 parse_events_terms__purge(&newalias->terms);
284 free(newalias);
285}
286
287/* Merge an alias, search in alias list. If this name is already
288 * present merge both of them to combine all information.
289 */
290static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias,
291 struct list_head *alist)
292{
293 struct perf_pmu_alias *a;
294
295 list_for_each_entry(a, alist, list) {
296 if (!strcasecmp(newalias->name, a->name)) {
297 perf_pmu_update_alias(a, newalias);
298 perf_pmu_free_alias(newalias);
299 return true;
300 }
301 }
302 return false;
303}
304
237static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, 305static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
238 char *desc, char *val, 306 char *desc, char *val,
239 char *long_desc, char *topic, 307 char *long_desc, char *topic,
@@ -241,9 +309,11 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
241 char *metric_expr, 309 char *metric_expr,
242 char *metric_name) 310 char *metric_name)
243{ 311{
312 struct parse_events_term *term;
244 struct perf_pmu_alias *alias; 313 struct perf_pmu_alias *alias;
245 int ret; 314 int ret;
246 int num; 315 int num;
316 char newval[256];
247 317
248 alias = malloc(sizeof(*alias)); 318 alias = malloc(sizeof(*alias));
249 if (!alias) 319 if (!alias)
@@ -262,6 +332,27 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
262 return ret; 332 return ret;
263 } 333 }
264 334
335 /* Scan event and remove leading zeroes, spaces, newlines, some
336 * platforms have terms specified as
337 * event=0x0091 (read from files ../<PMU>/events/<FILE>
338 * and terms specified as event=0x91 (read from JSON files).
339 *
340 * Rebuild string to make alias->str member comparable.
341 */
342 memset(newval, 0, sizeof(newval));
343 ret = 0;
344 list_for_each_entry(term, &alias->terms, list) {
345 if (ret)
346 ret += scnprintf(newval + ret, sizeof(newval) - ret,
347 ",");
348 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
349 ret += scnprintf(newval + ret, sizeof(newval) - ret,
350 "%s=%#x", term->config, term->val.num);
351 else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
352 ret += scnprintf(newval + ret, sizeof(newval) - ret,
353 "%s=%s", term->config, term->val.str);
354 }
355
265 alias->name = strdup(name); 356 alias->name = strdup(name);
266 if (dir) { 357 if (dir) {
267 /* 358 /*
@@ -285,9 +376,10 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
285 snprintf(alias->unit, sizeof(alias->unit), "%s", unit); 376 snprintf(alias->unit, sizeof(alias->unit), "%s", unit);
286 } 377 }
287 alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1; 378 alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1;
288 alias->str = strdup(val); 379 alias->str = strdup(newval);
289 380
290 list_add_tail(&alias->list, list); 381 if (!perf_pmu_merge_alias(alias, list))
382 list_add_tail(&alias->list, list);
291 383
292 return 0; 384 return 0;
293} 385}
@@ -303,6 +395,9 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
303 395
304 buf[ret] = 0; 396 buf[ret] = 0;
305 397
398 /* Remove trailing newline from sysfs file */
399 rtrim(buf);
400
306 return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL, 401 return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
307 NULL, NULL, NULL); 402 NULL, NULL, NULL);
308} 403}
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 7cf2d5cc038e..8bf302cafcec 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -112,6 +112,8 @@ struct hist_entry {
112 112
113 char level; 113 char level;
114 u8 filtered; 114 u8 filtered;
115
116 u16 callchain_size;
115 union { 117 union {
116 /* 118 /*
117 * Since perf diff only supports the stdio output, TUI 119 * Since perf diff only supports the stdio output, TUI
@@ -153,7 +155,7 @@ struct hist_entry {
153 155
154static __pure inline bool hist_entry__has_callchains(struct hist_entry *he) 156static __pure inline bool hist_entry__has_callchains(struct hist_entry *he)
155{ 157{
156 return hists__has_callchains(he->hists); 158 return he->callchain_size != 0;
157} 159}
158 160
159static inline bool hist_entry__has_pairs(struct hist_entry *he) 161static inline bool hist_entry__has_pairs(struct hist_entry *he)
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index ca9ef7017624..d39e4ff7d0bf 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -56,7 +56,7 @@ name as necessary to disambiguate it from others is necessary. Note that option
56.PP 56.PP
57\fB--hide column\fP do not show the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--hide sysfs" to hide the sysfs statistics columns as a group. 57\fB--hide column\fP do not show the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--hide sysfs" to hide the sysfs statistics columns as a group.
58.PP 58.PP
59\fB--enable column\fP show the specified built-in columns, which are otherwise disabled, by default. Currently the only built-in counters disabled by default are "usec" and "Time_Of_Day_Seconds". 59\fB--enable column\fP show the specified built-in columns, which are otherwise disabled, by default. Currently the only built-in counters disabled by default are "usec", "Time_Of_Day_Seconds", "APIC" and "X2APIC".
60The column name "all" can be used to enable all disabled-by-default built-in counters. 60The column name "all" can be used to enable all disabled-by-default built-in counters.
61.PP 61.PP
62\fB--show column\fP show only the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--show sysfs" to show the sysfs statistics columns as a group. 62\fB--show column\fP show only the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names. Use "--show sysfs" to show the sysfs statistics columns as a group.
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index d6cff3070ebd..4d14bbbf9b63 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -109,6 +109,7 @@ unsigned int has_hwp_activity_window; /* IA32_HWP_REQUEST[bits 41:32] */
109unsigned int has_hwp_epp; /* IA32_HWP_REQUEST[bits 31:24] */ 109unsigned int has_hwp_epp; /* IA32_HWP_REQUEST[bits 31:24] */
110unsigned int has_hwp_pkg; /* IA32_HWP_REQUEST_PKG */ 110unsigned int has_hwp_pkg; /* IA32_HWP_REQUEST_PKG */
111unsigned int has_misc_feature_control; 111unsigned int has_misc_feature_control;
112unsigned int first_counter_read = 1;
112 113
113#define RAPL_PKG (1 << 0) 114#define RAPL_PKG (1 << 0)
114 /* 0x610 MSR_PKG_POWER_LIMIT */ 115 /* 0x610 MSR_PKG_POWER_LIMIT */
@@ -170,6 +171,8 @@ struct thread_data {
170 unsigned long long irq_count; 171 unsigned long long irq_count;
171 unsigned int smi_count; 172 unsigned int smi_count;
172 unsigned int cpu_id; 173 unsigned int cpu_id;
174 unsigned int apic_id;
175 unsigned int x2apic_id;
173 unsigned int flags; 176 unsigned int flags;
174#define CPU_IS_FIRST_THREAD_IN_CORE 0x2 177#define CPU_IS_FIRST_THREAD_IN_CORE 0x2
175#define CPU_IS_FIRST_CORE_IN_PACKAGE 0x4 178#define CPU_IS_FIRST_CORE_IN_PACKAGE 0x4
@@ -381,19 +384,23 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
381} 384}
382 385
383/* 386/*
384 * Each string in this array is compared in --show and --hide cmdline. 387 * This list matches the column headers, except
385 * Thus, strings that are proper sub-sets must follow their more specific peers. 388 * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
389 * 2. Core and CPU are moved to the end, we can't have strings that contain them
390 * matching on them for --show and --hide.
386 */ 391 */
387struct msr_counter bic[] = { 392struct msr_counter bic[] = {
388 { 0x0, "usec" }, 393 { 0x0, "usec" },
389 { 0x0, "Time_Of_Day_Seconds" }, 394 { 0x0, "Time_Of_Day_Seconds" },
390 { 0x0, "Package" }, 395 { 0x0, "Package" },
396 { 0x0, "Node" },
391 { 0x0, "Avg_MHz" }, 397 { 0x0, "Avg_MHz" },
398 { 0x0, "Busy%" },
392 { 0x0, "Bzy_MHz" }, 399 { 0x0, "Bzy_MHz" },
393 { 0x0, "TSC_MHz" }, 400 { 0x0, "TSC_MHz" },
394 { 0x0, "IRQ" }, 401 { 0x0, "IRQ" },
395 { 0x0, "SMI", "", 32, 0, FORMAT_DELTA, NULL}, 402 { 0x0, "SMI", "", 32, 0, FORMAT_DELTA, NULL},
396 { 0x0, "Busy%" }, 403 { 0x0, "sysfs" },
397 { 0x0, "CPU%c1" }, 404 { 0x0, "CPU%c1" },
398 { 0x0, "CPU%c3" }, 405 { 0x0, "CPU%c3" },
399 { 0x0, "CPU%c6" }, 406 { 0x0, "CPU%c6" },
@@ -424,73 +431,73 @@ struct msr_counter bic[] = {
424 { 0x0, "Cor_J" }, 431 { 0x0, "Cor_J" },
425 { 0x0, "GFX_J" }, 432 { 0x0, "GFX_J" },
426 { 0x0, "RAM_J" }, 433 { 0x0, "RAM_J" },
427 { 0x0, "Core" },
428 { 0x0, "CPU" },
429 { 0x0, "Mod%c6" }, 434 { 0x0, "Mod%c6" },
430 { 0x0, "sysfs" },
431 { 0x0, "Totl%C0" }, 435 { 0x0, "Totl%C0" },
432 { 0x0, "Any%C0" }, 436 { 0x0, "Any%C0" },
433 { 0x0, "GFX%C0" }, 437 { 0x0, "GFX%C0" },
434 { 0x0, "CPUGFX%" }, 438 { 0x0, "CPUGFX%" },
435 { 0x0, "Node%" }, 439 { 0x0, "Core" },
440 { 0x0, "CPU" },
441 { 0x0, "APIC" },
442 { 0x0, "X2APIC" },
436}; 443};
437 444
438
439
440#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter)) 445#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter))
441#define BIC_USEC (1ULL << 0) 446#define BIC_USEC (1ULL << 0)
442#define BIC_TOD (1ULL << 1) 447#define BIC_TOD (1ULL << 1)
443#define BIC_Package (1ULL << 2) 448#define BIC_Package (1ULL << 2)
444#define BIC_Avg_MHz (1ULL << 3) 449#define BIC_Node (1ULL << 3)
445#define BIC_Bzy_MHz (1ULL << 4) 450#define BIC_Avg_MHz (1ULL << 4)
446#define BIC_TSC_MHz (1ULL << 5) 451#define BIC_Busy (1ULL << 5)
447#define BIC_IRQ (1ULL << 6) 452#define BIC_Bzy_MHz (1ULL << 6)
448#define BIC_SMI (1ULL << 7) 453#define BIC_TSC_MHz (1ULL << 7)
449#define BIC_Busy (1ULL << 8) 454#define BIC_IRQ (1ULL << 8)
450#define BIC_CPU_c1 (1ULL << 9) 455#define BIC_SMI (1ULL << 9)
451#define BIC_CPU_c3 (1ULL << 10) 456#define BIC_sysfs (1ULL << 10)
452#define BIC_CPU_c6 (1ULL << 11) 457#define BIC_CPU_c1 (1ULL << 11)
453#define BIC_CPU_c7 (1ULL << 12) 458#define BIC_CPU_c3 (1ULL << 12)
454#define BIC_ThreadC (1ULL << 13) 459#define BIC_CPU_c6 (1ULL << 13)
455#define BIC_CoreTmp (1ULL << 14) 460#define BIC_CPU_c7 (1ULL << 14)
456#define BIC_CoreCnt (1ULL << 15) 461#define BIC_ThreadC (1ULL << 15)
457#define BIC_PkgTmp (1ULL << 16) 462#define BIC_CoreTmp (1ULL << 16)
458#define BIC_GFX_rc6 (1ULL << 17) 463#define BIC_CoreCnt (1ULL << 17)
459#define BIC_GFXMHz (1ULL << 18) 464#define BIC_PkgTmp (1ULL << 18)
460#define BIC_Pkgpc2 (1ULL << 19) 465#define BIC_GFX_rc6 (1ULL << 19)
461#define BIC_Pkgpc3 (1ULL << 20) 466#define BIC_GFXMHz (1ULL << 20)
462#define BIC_Pkgpc6 (1ULL << 21) 467#define BIC_Pkgpc2 (1ULL << 21)
463#define BIC_Pkgpc7 (1ULL << 22) 468#define BIC_Pkgpc3 (1ULL << 22)
464#define BIC_Pkgpc8 (1ULL << 23) 469#define BIC_Pkgpc6 (1ULL << 23)
465#define BIC_Pkgpc9 (1ULL << 24) 470#define BIC_Pkgpc7 (1ULL << 24)
466#define BIC_Pkgpc10 (1ULL << 25) 471#define BIC_Pkgpc8 (1ULL << 25)
467#define BIC_CPU_LPI (1ULL << 26) 472#define BIC_Pkgpc9 (1ULL << 26)
468#define BIC_SYS_LPI (1ULL << 27) 473#define BIC_Pkgpc10 (1ULL << 27)
469#define BIC_PkgWatt (1ULL << 26) 474#define BIC_CPU_LPI (1ULL << 28)
470#define BIC_CorWatt (1ULL << 27) 475#define BIC_SYS_LPI (1ULL << 29)
471#define BIC_GFXWatt (1ULL << 28) 476#define BIC_PkgWatt (1ULL << 30)
472#define BIC_PkgCnt (1ULL << 29) 477#define BIC_CorWatt (1ULL << 31)
473#define BIC_RAMWatt (1ULL << 30) 478#define BIC_GFXWatt (1ULL << 32)
474#define BIC_PKG__ (1ULL << 31) 479#define BIC_PkgCnt (1ULL << 33)
475#define BIC_RAM__ (1ULL << 32) 480#define BIC_RAMWatt (1ULL << 34)
476#define BIC_Pkg_J (1ULL << 33) 481#define BIC_PKG__ (1ULL << 35)
477#define BIC_Cor_J (1ULL << 34) 482#define BIC_RAM__ (1ULL << 36)
478#define BIC_GFX_J (1ULL << 35) 483#define BIC_Pkg_J (1ULL << 37)
479#define BIC_RAM_J (1ULL << 36) 484#define BIC_Cor_J (1ULL << 38)
480#define BIC_Core (1ULL << 37) 485#define BIC_GFX_J (1ULL << 39)
481#define BIC_CPU (1ULL << 38) 486#define BIC_RAM_J (1ULL << 40)
482#define BIC_Mod_c6 (1ULL << 39) 487#define BIC_Mod_c6 (1ULL << 41)
483#define BIC_sysfs (1ULL << 40) 488#define BIC_Totl_c0 (1ULL << 42)
484#define BIC_Totl_c0 (1ULL << 41) 489#define BIC_Any_c0 (1ULL << 43)
485#define BIC_Any_c0 (1ULL << 42) 490#define BIC_GFX_c0 (1ULL << 44)
486#define BIC_GFX_c0 (1ULL << 43) 491#define BIC_CPUGFX (1ULL << 45)
487#define BIC_CPUGFX (1ULL << 44) 492#define BIC_Core (1ULL << 46)
488#define BIC_Node (1ULL << 45) 493#define BIC_CPU (1ULL << 47)
489 494#define BIC_APIC (1ULL << 48)
490#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD) 495#define BIC_X2APIC (1ULL << 49)
496
497#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC)
491 498
492unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT); 499unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT);
493unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs; 500unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs | BIC_APIC | BIC_X2APIC;
494 501
495#define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME) 502#define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME)
496#define ENABLE_BIC(COUNTER_NAME) (bic_enabled |= COUNTER_NAME) 503#define ENABLE_BIC(COUNTER_NAME) (bic_enabled |= COUNTER_NAME)
@@ -517,17 +524,34 @@ void help(void)
517 "when COMMAND completes.\n" 524 "when COMMAND completes.\n"
518 "If no COMMAND is specified, turbostat wakes every 5-seconds\n" 525 "If no COMMAND is specified, turbostat wakes every 5-seconds\n"
519 "to print statistics, until interrupted.\n" 526 "to print statistics, until interrupted.\n"
520 "--add add a counter\n" 527 " -a, --add add a counter\n"
521 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n" 528 " eg. --add msr0x10,u64,cpu,delta,MY_TSC\n"
522 "--cpu cpu-set limit output to summary plus cpu-set:\n" 529 " -c, --cpu cpu-set limit output to summary plus cpu-set:\n"
523 " {core | package | j,k,l..m,n-p }\n" 530 " {core | package | j,k,l..m,n-p }\n"
524 "--quiet skip decoding system configuration header\n" 531 " -d, --debug displays usec, Time_Of_Day_Seconds and more debugging\n"
525 "--interval sec.subsec Override default 5-second measurement interval\n" 532 " -D, --Dump displays the raw counter values\n"
526 "--help print this help message\n" 533 " -e, --enable [all | column]\n"
527 "--list list column headers only\n" 534 " shows all or the specified disabled column\n"
528 "--num_iterations num number of the measurement iterations\n" 535 " -H, --hide [column|column,column,...]\n"
529 "--out file create or truncate \"file\" for all output\n" 536 " hide the specified column(s)\n"
530 "--version print version information\n" 537 " -i, --interval sec.subsec\n"
538 " Override default 5-second measurement interval\n"
539 " -J, --Joules displays energy in Joules instead of Watts\n"
540 " -l, --list list column headers only\n"
541 " -n, --num_iterations num\n"
542 " number of the measurement iterations\n"
543 " -o, --out file\n"
544 " create or truncate \"file\" for all output\n"
545 " -q, --quiet skip decoding system configuration header\n"
546 " -s, --show [column|column,column,...]\n"
547 " show only the specified column(s)\n"
548 " -S, --Summary\n"
549 " limits output to 1-line system summary per interval\n"
550 " -T, --TCC temperature\n"
551 " sets the Thermal Control Circuit temperature in\n"
552 " degrees Celsius\n"
553 " -h, --help print this help message\n"
554 " -v, --version print version information\n"
531 "\n" 555 "\n"
532 "For more help, run \"man turbostat\"\n"); 556 "For more help, run \"man turbostat\"\n");
533} 557}
@@ -601,6 +625,10 @@ void print_header(char *delim)
601 outp += sprintf(outp, "%sCore", (printed++ ? delim : "")); 625 outp += sprintf(outp, "%sCore", (printed++ ? delim : ""));
602 if (DO_BIC(BIC_CPU)) 626 if (DO_BIC(BIC_CPU))
603 outp += sprintf(outp, "%sCPU", (printed++ ? delim : "")); 627 outp += sprintf(outp, "%sCPU", (printed++ ? delim : ""));
628 if (DO_BIC(BIC_APIC))
629 outp += sprintf(outp, "%sAPIC", (printed++ ? delim : ""));
630 if (DO_BIC(BIC_X2APIC))
631 outp += sprintf(outp, "%sX2APIC", (printed++ ? delim : ""));
604 if (DO_BIC(BIC_Avg_MHz)) 632 if (DO_BIC(BIC_Avg_MHz))
605 outp += sprintf(outp, "%sAvg_MHz", (printed++ ? delim : "")); 633 outp += sprintf(outp, "%sAvg_MHz", (printed++ ? delim : ""));
606 if (DO_BIC(BIC_Busy)) 634 if (DO_BIC(BIC_Busy))
@@ -880,6 +908,10 @@ int format_counters(struct thread_data *t, struct core_data *c,
880 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); 908 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
881 if (DO_BIC(BIC_CPU)) 909 if (DO_BIC(BIC_CPU))
882 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); 910 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
911 if (DO_BIC(BIC_APIC))
912 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
913 if (DO_BIC(BIC_X2APIC))
914 outp += sprintf(outp, "%s-", (printed++ ? delim : ""));
883 } else { 915 } else {
884 if (DO_BIC(BIC_Package)) { 916 if (DO_BIC(BIC_Package)) {
885 if (p) 917 if (p)
@@ -904,6 +936,10 @@ int format_counters(struct thread_data *t, struct core_data *c,
904 } 936 }
905 if (DO_BIC(BIC_CPU)) 937 if (DO_BIC(BIC_CPU))
906 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id); 938 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->cpu_id);
939 if (DO_BIC(BIC_APIC))
940 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->apic_id);
941 if (DO_BIC(BIC_X2APIC))
942 outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), t->x2apic_id);
907 } 943 }
908 944
909 if (DO_BIC(BIC_Avg_MHz)) 945 if (DO_BIC(BIC_Avg_MHz))
@@ -1231,6 +1267,12 @@ delta_thread(struct thread_data *new, struct thread_data *old,
1231 int i; 1267 int i;
1232 struct msr_counter *mp; 1268 struct msr_counter *mp;
1233 1269
1270 /* we run cpuid just the 1st time, copy the results */
1271 if (DO_BIC(BIC_APIC))
1272 new->apic_id = old->apic_id;
1273 if (DO_BIC(BIC_X2APIC))
1274 new->x2apic_id = old->x2apic_id;
1275
1234 /* 1276 /*
1235 * the timestamps from start of measurement interval are in "old" 1277 * the timestamps from start of measurement interval are in "old"
1236 * the timestamp from end of measurement interval are in "new" 1278 * the timestamp from end of measurement interval are in "new"
@@ -1393,6 +1435,12 @@ int sum_counters(struct thread_data *t, struct core_data *c,
1393 int i; 1435 int i;
1394 struct msr_counter *mp; 1436 struct msr_counter *mp;
1395 1437
1438 /* copy un-changing apic_id's */
1439 if (DO_BIC(BIC_APIC))
1440 average.threads.apic_id = t->apic_id;
1441 if (DO_BIC(BIC_X2APIC))
1442 average.threads.x2apic_id = t->x2apic_id;
1443
1396 /* remember first tv_begin */ 1444 /* remember first tv_begin */
1397 if (average.threads.tv_begin.tv_sec == 0) 1445 if (average.threads.tv_begin.tv_sec == 0)
1398 average.threads.tv_begin = t->tv_begin; 1446 average.threads.tv_begin = t->tv_begin;
@@ -1619,6 +1667,34 @@ int get_mp(int cpu, struct msr_counter *mp, unsigned long long *counterp)
1619 return 0; 1667 return 0;
1620} 1668}
1621 1669
1670void get_apic_id(struct thread_data *t)
1671{
1672 unsigned int eax, ebx, ecx, edx, max_level;
1673
1674 eax = ebx = ecx = edx = 0;
1675
1676 if (!genuine_intel)
1677 return;
1678
1679 __cpuid(0, max_level, ebx, ecx, edx);
1680
1681 __cpuid(1, eax, ebx, ecx, edx);
1682 t->apic_id = (ebx >> 24) & 0xf;
1683
1684 if (max_level < 0xb)
1685 return;
1686
1687 if (!DO_BIC(BIC_X2APIC))
1688 return;
1689
1690 ecx = 0;
1691 __cpuid(0xb, eax, ebx, ecx, edx);
1692 t->x2apic_id = edx;
1693
1694 if (debug && (t->apic_id != t->x2apic_id))
1695 fprintf(stderr, "cpu%d: apic 0x%x x2apic 0x%x\n", t->cpu_id, t->apic_id, t->x2apic_id);
1696}
1697
1622/* 1698/*
1623 * get_counters(...) 1699 * get_counters(...)
1624 * migrate to cpu 1700 * migrate to cpu
@@ -1632,7 +1708,6 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
1632 struct msr_counter *mp; 1708 struct msr_counter *mp;
1633 int i; 1709 int i;
1634 1710
1635
1636 gettimeofday(&t->tv_begin, (struct timezone *)NULL); 1711 gettimeofday(&t->tv_begin, (struct timezone *)NULL);
1637 1712
1638 if (cpu_migrate(cpu)) { 1713 if (cpu_migrate(cpu)) {
@@ -1640,6 +1715,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
1640 return -1; 1715 return -1;
1641 } 1716 }
1642 1717
1718 if (first_counter_read)
1719 get_apic_id(t);
1643retry: 1720retry:
1644 t->tsc = rdtsc(); /* we are running on local CPU of interest */ 1721 t->tsc = rdtsc(); /* we are running on local CPU of interest */
1645 1722
@@ -2432,6 +2509,12 @@ void set_node_data(void)
2432 if (pni[pkg].count > topo.nodes_per_pkg) 2509 if (pni[pkg].count > topo.nodes_per_pkg)
2433 topo.nodes_per_pkg = pni[0].count; 2510 topo.nodes_per_pkg = pni[0].count;
2434 2511
2512 /* Fake 1 node per pkg for machines that don't
2513 * expose nodes and thus avoid -nan results
2514 */
2515 if (topo.nodes_per_pkg == 0)
2516 topo.nodes_per_pkg = 1;
2517
2435 for (cpu = 0; cpu < topo.num_cpus; cpu++) { 2518 for (cpu = 0; cpu < topo.num_cpus; cpu++) {
2436 pkg = cpus[cpu].physical_package_id; 2519 pkg = cpus[cpu].physical_package_id;
2437 node = cpus[cpu].physical_node_id; 2520 node = cpus[cpu].physical_node_id;
@@ -2879,6 +2962,7 @@ void do_sleep(void)
2879 } 2962 }
2880} 2963}
2881 2964
2965
2882void turbostat_loop() 2966void turbostat_loop()
2883{ 2967{
2884 int retval; 2968 int retval;
@@ -2892,6 +2976,7 @@ restart:
2892 2976
2893 snapshot_proc_sysfs_files(); 2977 snapshot_proc_sysfs_files();
2894 retval = for_all_cpus(get_counters, EVEN_COUNTERS); 2978 retval = for_all_cpus(get_counters, EVEN_COUNTERS);
2979 first_counter_read = 0;
2895 if (retval < -1) { 2980 if (retval < -1) {
2896 exit(retval); 2981 exit(retval);
2897 } else if (retval == -1) { 2982 } else if (retval == -1) {
@@ -4392,7 +4477,7 @@ void process_cpuid()
4392 if (!quiet) { 4477 if (!quiet) {
4393 fprintf(outf, "%d CPUID levels; family:model:stepping 0x%x:%x:%x (%d:%d:%d)\n", 4478 fprintf(outf, "%d CPUID levels; family:model:stepping 0x%x:%x:%x (%d:%d:%d)\n",
4394 max_level, family, model, stepping, family, model, stepping); 4479 max_level, family, model, stepping, family, model, stepping);
4395 fprintf(outf, "CPUID(1): %s %s %s %s %s %s %s %s %s\n", 4480 fprintf(outf, "CPUID(1): %s %s %s %s %s %s %s %s %s %s\n",
4396 ecx & (1 << 0) ? "SSE3" : "-", 4481 ecx & (1 << 0) ? "SSE3" : "-",
4397 ecx & (1 << 3) ? "MONITOR" : "-", 4482 ecx & (1 << 3) ? "MONITOR" : "-",
4398 ecx & (1 << 6) ? "SMX" : "-", 4483 ecx & (1 << 6) ? "SMX" : "-",
@@ -4401,6 +4486,7 @@ void process_cpuid()
4401 edx & (1 << 4) ? "TSC" : "-", 4486 edx & (1 << 4) ? "TSC" : "-",
4402 edx & (1 << 5) ? "MSR" : "-", 4487 edx & (1 << 5) ? "MSR" : "-",
4403 edx & (1 << 22) ? "ACPI-TM" : "-", 4488 edx & (1 << 22) ? "ACPI-TM" : "-",
4489 edx & (1 << 28) ? "HT" : "-",
4404 edx & (1 << 29) ? "TM" : "-"); 4490 edx & (1 << 29) ? "TM" : "-");
4405 } 4491 }
4406 4492
@@ -4652,7 +4738,6 @@ void process_cpuid()
4652 return; 4738 return;
4653} 4739}
4654 4740
4655
4656/* 4741/*
4657 * in /dev/cpu/ return success for names that are numbers 4742 * in /dev/cpu/ return success for names that are numbers
4658 * ie. filter out ".", "..", "microcode". 4743 * ie. filter out ".", "..", "microcode".
@@ -4842,6 +4927,13 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base,
4842 struct core_data *c; 4927 struct core_data *c;
4843 struct pkg_data *p; 4928 struct pkg_data *p;
4844 4929
4930
4931 /* Workaround for systems where physical_node_id==-1
4932 * and logical_node_id==(-1 - topo.num_cpus)
4933 */
4934 if (node_id < 0)
4935 node_id = 0;
4936
4845 t = GET_THREAD(thread_base, thread_id, core_id, node_id, pkg_id); 4937 t = GET_THREAD(thread_base, thread_id, core_id, node_id, pkg_id);
4846 c = GET_CORE(core_base, core_id, node_id, pkg_id); 4938 c = GET_CORE(core_base, core_id, node_id, pkg_id);
4847 p = GET_PKG(pkg_base, pkg_id); 4939 p = GET_PKG(pkg_base, pkg_id);
@@ -4946,6 +5038,7 @@ int fork_it(char **argv)
4946 5038
4947 snapshot_proc_sysfs_files(); 5039 snapshot_proc_sysfs_files();
4948 status = for_all_cpus(get_counters, EVEN_COUNTERS); 5040 status = for_all_cpus(get_counters, EVEN_COUNTERS);
5041 first_counter_read = 0;
4949 if (status) 5042 if (status)
4950 exit(status); 5043 exit(status);
4951 /* clear affinity side-effect of get_counters() */ 5044 /* clear affinity side-effect of get_counters() */
@@ -5009,7 +5102,7 @@ int get_and_dump_counters(void)
5009} 5102}
5010 5103
5011void print_version() { 5104void print_version() {
5012 fprintf(outf, "turbostat version 18.06.01" 5105 fprintf(outf, "turbostat version 18.06.20"
5013 " - Len Brown <lenb@kernel.org>\n"); 5106 " - Len Brown <lenb@kernel.org>\n");
5014} 5107}
5015 5108
@@ -5381,7 +5474,7 @@ void cmdline(int argc, char **argv)
5381 break; 5474 break;
5382 case 'e': 5475 case 'e':
5383 /* --enable specified counter */ 5476 /* --enable specified counter */
5384 bic_enabled |= bic_lookup(optarg, SHOW_LIST); 5477 bic_enabled = bic_enabled | bic_lookup(optarg, SHOW_LIST);
5385 break; 5478 break;
5386 case 'd': 5479 case 'd':
5387 debug++; 5480 debug++;
@@ -5465,7 +5558,6 @@ void cmdline(int argc, char **argv)
5465int main(int argc, char **argv) 5558int main(int argc, char **argv)
5466{ 5559{
5467 outf = stderr; 5560 outf = stderr;
5468
5469 cmdline(argc, argv); 5561 cmdline(argc, argv);
5470 5562
5471 if (!quiet) 5563 if (!quiet)
diff --git a/tools/testing/selftests/bpf/config b/tools/testing/selftests/bpf/config
index 1eefe211a4a8..7eb613ffef55 100644
--- a/tools/testing/selftests/bpf/config
+++ b/tools/testing/selftests/bpf/config
@@ -7,3 +7,13 @@ CONFIG_CGROUP_BPF=y
7CONFIG_NETDEVSIM=m 7CONFIG_NETDEVSIM=m
8CONFIG_NET_CLS_ACT=y 8CONFIG_NET_CLS_ACT=y
9CONFIG_NET_SCH_INGRESS=y 9CONFIG_NET_SCH_INGRESS=y
10CONFIG_NET_IPIP=y
11CONFIG_IPV6=y
12CONFIG_NET_IPGRE_DEMUX=y
13CONFIG_NET_IPGRE=y
14CONFIG_IPV6_GRE=y
15CONFIG_CRYPTO_USER_API_HASH=m
16CONFIG_CRYPTO_HMAC=m
17CONFIG_CRYPTO_SHA256=m
18CONFIG_VXLAN=y
19CONFIG_GENEVE=y
diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py
index e78aad0a68bb..be800d0e7a84 100755
--- a/tools/testing/selftests/bpf/test_offload.py
+++ b/tools/testing/selftests/bpf/test_offload.py
@@ -163,6 +163,10 @@ def bpftool(args, JSON=True, ns="", fail=True):
163 163
164def bpftool_prog_list(expected=None, ns=""): 164def bpftool_prog_list(expected=None, ns=""):
165 _, progs = bpftool("prog show", JSON=True, ns=ns, fail=True) 165 _, progs = bpftool("prog show", JSON=True, ns=ns, fail=True)
166 # Remove the base progs
167 for p in base_progs:
168 if p in progs:
169 progs.remove(p)
166 if expected is not None: 170 if expected is not None:
167 if len(progs) != expected: 171 if len(progs) != expected:
168 fail(True, "%d BPF programs loaded, expected %d" % 172 fail(True, "%d BPF programs loaded, expected %d" %
@@ -171,6 +175,10 @@ def bpftool_prog_list(expected=None, ns=""):
171 175
172def bpftool_map_list(expected=None, ns=""): 176def bpftool_map_list(expected=None, ns=""):
173 _, maps = bpftool("map show", JSON=True, ns=ns, fail=True) 177 _, maps = bpftool("map show", JSON=True, ns=ns, fail=True)
178 # Remove the base maps
179 for m in base_maps:
180 if m in maps:
181 maps.remove(m)
174 if expected is not None: 182 if expected is not None:
175 if len(maps) != expected: 183 if len(maps) != expected:
176 fail(True, "%d BPF maps loaded, expected %d" % 184 fail(True, "%d BPF maps loaded, expected %d" %
@@ -585,8 +593,8 @@ skip(os.getuid() != 0, "test must be run as root")
585# Check tools 593# Check tools
586ret, progs = bpftool("prog", fail=False) 594ret, progs = bpftool("prog", fail=False)
587skip(ret != 0, "bpftool not installed") 595skip(ret != 0, "bpftool not installed")
588# Check no BPF programs are loaded 596base_progs = progs
589skip(len(progs) != 0, "BPF programs already loaded on the system") 597_, base_maps = bpftool("map")
590 598
591# Check netdevsim 599# Check netdevsim
592ret, out = cmd("modprobe netdevsim", fail=False) 600ret, out = cmd("modprobe netdevsim", fail=False)
diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
index aeb2901f21f4..546aee3e9fb4 100755
--- a/tools/testing/selftests/bpf/test_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tunnel.sh
@@ -608,28 +608,26 @@ setup_xfrm_tunnel()
608test_xfrm_tunnel() 608test_xfrm_tunnel()
609{ 609{
610 config_device 610 config_device
611 #tcpdump -nei veth1 ip & 611 > /sys/kernel/debug/tracing/trace
612 output=$(mktemp) 612 setup_xfrm_tunnel
613 cat /sys/kernel/debug/tracing/trace_pipe | tee $output &
614 setup_xfrm_tunnel
615 tc qdisc add dev veth1 clsact 613 tc qdisc add dev veth1 clsact
616 tc filter add dev veth1 proto ip ingress bpf da obj test_tunnel_kern.o \ 614 tc filter add dev veth1 proto ip ingress bpf da obj test_tunnel_kern.o \
617 sec xfrm_get_state 615 sec xfrm_get_state
618 ip netns exec at_ns0 ping $PING_ARG 10.1.1.200 616 ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
619 sleep 1 617 sleep 1
620 grep "reqid 1" $output 618 grep "reqid 1" /sys/kernel/debug/tracing/trace
621 check_err $? 619 check_err $?
622 grep "spi 0x1" $output 620 grep "spi 0x1" /sys/kernel/debug/tracing/trace
623 check_err $? 621 check_err $?
624 grep "remote ip 0xac100164" $output 622 grep "remote ip 0xac100164" /sys/kernel/debug/tracing/trace
625 check_err $? 623 check_err $?
626 cleanup 624 cleanup
627 625
628 if [ $ret -ne 0 ]; then 626 if [ $ret -ne 0 ]; then
629 echo -e ${RED}"FAIL: xfrm tunnel"${NC} 627 echo -e ${RED}"FAIL: xfrm tunnel"${NC}
630 return 1 628 return 1
631 fi 629 fi
632 echo -e ${GREEN}"PASS: xfrm tunnel"${NC} 630 echo -e ${GREEN}"PASS: xfrm tunnel"${NC}
633} 631}
634 632
635attach_bpf() 633attach_bpf()
@@ -657,6 +655,10 @@ cleanup()
657 ip link del ip6geneve11 2> /dev/null 655 ip link del ip6geneve11 2> /dev/null
658 ip link del erspan11 2> /dev/null 656 ip link del erspan11 2> /dev/null
659 ip link del ip6erspan11 2> /dev/null 657 ip link del ip6erspan11 2> /dev/null
658 ip xfrm policy delete dir out src 10.1.1.200/32 dst 10.1.1.100/32 2> /dev/null
659 ip xfrm policy delete dir in src 10.1.1.100/32 dst 10.1.1.200/32 2> /dev/null
660 ip xfrm state delete src 172.16.1.100 dst 172.16.1.200 proto esp spi 0x1 2> /dev/null
661 ip xfrm state delete src 172.16.1.200 dst 172.16.1.100 proto esp spi 0x2 2> /dev/null
660} 662}
661 663
662cleanup_exit() 664cleanup_exit()
@@ -668,7 +670,7 @@ cleanup_exit()
668 670
669check() 671check()
670{ 672{
671 ip link help $1 2>&1 | grep -q "^Usage:" 673 ip link help 2>&1 | grep -q "\s$1\s"
672 if [ $? -ne 0 ];then 674 if [ $? -ne 0 ];then
673 echo "SKIP $1: iproute2 not support" 675 echo "SKIP $1: iproute2 not support"
674 cleanup 676 cleanup
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index 128e548aa377..1a0ac3a29ec5 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -12,3 +12,4 @@ tcp_mmap
12udpgso 12udpgso
13udpgso_bench_rx 13udpgso_bench_rx
14udpgso_bench_tx 14udpgso_bench_tx
15tcp_inq
diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
index 7ba089b33e8b..cd3a2f1545b5 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -12,3 +12,5 @@ CONFIG_NET_IPVTI=y
12CONFIG_INET6_XFRM_MODE_TUNNEL=y 12CONFIG_INET6_XFRM_MODE_TUNNEL=y
13CONFIG_IPV6_VTI=y 13CONFIG_IPV6_VTI=y
14CONFIG_DUMMY=y 14CONFIG_DUMMY=y
15CONFIG_BRIDGE=y
16CONFIG_VLAN_8021Q=y
diff --git a/tools/testing/selftests/pstore/pstore_post_reboot_tests b/tools/testing/selftests/pstore/pstore_post_reboot_tests
index 6ccb154cb4aa..22f8df1ad7d4 100755
--- a/tools/testing/selftests/pstore/pstore_post_reboot_tests
+++ b/tools/testing/selftests/pstore/pstore_post_reboot_tests
@@ -7,13 +7,16 @@
7# 7#
8# Released under the terms of the GPL v2. 8# Released under the terms of the GPL v2.
9 9
10# Kselftest framework requirement - SKIP code is 4.
11ksft_skip=4
12
10. ./common_tests 13. ./common_tests
11 14
12if [ -e $REBOOT_FLAG ]; then 15if [ -e $REBOOT_FLAG ]; then
13 rm $REBOOT_FLAG 16 rm $REBOOT_FLAG
14else 17else
15 prlog "pstore_crash_test has not been executed yet. we skip further tests." 18 prlog "pstore_crash_test has not been executed yet. we skip further tests."
16 exit 0 19 exit $ksft_skip
17fi 20fi
18 21
19prlog -n "Mounting pstore filesystem ... " 22prlog -n "Mounting pstore filesystem ... "
diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c
index 6a9f602a8718..615252331813 100644
--- a/tools/testing/selftests/rseq/param_test.c
+++ b/tools/testing/selftests/rseq/param_test.c
@@ -137,6 +137,30 @@ unsigned int yield_mod_cnt, nr_abort;
137 "subic. %%" INJECT_ASM_REG ", %%" INJECT_ASM_REG ", 1\n\t" \ 137 "subic. %%" INJECT_ASM_REG ", %%" INJECT_ASM_REG ", 1\n\t" \
138 "bne 222b\n\t" \ 138 "bne 222b\n\t" \
139 "333:\n\t" 139 "333:\n\t"
140
141#elif defined(__mips__)
142
143#define RSEQ_INJECT_INPUT \
144 , [loop_cnt_1]"m"(loop_cnt[1]) \
145 , [loop_cnt_2]"m"(loop_cnt[2]) \
146 , [loop_cnt_3]"m"(loop_cnt[3]) \
147 , [loop_cnt_4]"m"(loop_cnt[4]) \
148 , [loop_cnt_5]"m"(loop_cnt[5]) \
149 , [loop_cnt_6]"m"(loop_cnt[6])
150
151#define INJECT_ASM_REG "$5"
152
153#define RSEQ_INJECT_CLOBBER \
154 , INJECT_ASM_REG
155
156#define RSEQ_INJECT_ASM(n) \
157 "lw " INJECT_ASM_REG ", %[loop_cnt_" #n "]\n\t" \
158 "beqz " INJECT_ASM_REG ", 333f\n\t" \
159 "222:\n\t" \
160 "addiu " INJECT_ASM_REG ", -1\n\t" \
161 "bnez " INJECT_ASM_REG ", 222b\n\t" \
162 "333:\n\t"
163
140#else 164#else
141#error unsupported target 165#error unsupported target
142#endif 166#endif
diff --git a/tools/testing/selftests/rseq/rseq-arm.h b/tools/testing/selftests/rseq/rseq-arm.h
index 3b055f9aeaab..3cea19877227 100644
--- a/tools/testing/selftests/rseq/rseq-arm.h
+++ b/tools/testing/selftests/rseq/rseq-arm.h
@@ -57,6 +57,7 @@ do { \
57#define __RSEQ_ASM_DEFINE_ABORT(table_label, label, teardown, \ 57#define __RSEQ_ASM_DEFINE_ABORT(table_label, label, teardown, \
58 abort_label, version, flags, \ 58 abort_label, version, flags, \
59 start_ip, post_commit_offset, abort_ip) \ 59 start_ip, post_commit_offset, abort_ip) \
60 ".balign 32\n\t" \
60 __rseq_str(table_label) ":\n\t" \ 61 __rseq_str(table_label) ":\n\t" \
61 ".word " __rseq_str(version) ", " __rseq_str(flags) "\n\t" \ 62 ".word " __rseq_str(version) ", " __rseq_str(flags) "\n\t" \
62 ".word " __rseq_str(start_ip) ", 0x0, " __rseq_str(post_commit_offset) ", 0x0, " __rseq_str(abort_ip) ", 0x0\n\t" \ 63 ".word " __rseq_str(start_ip) ", 0x0, " __rseq_str(post_commit_offset) ", 0x0, " __rseq_str(abort_ip) ", 0x0\n\t" \
diff --git a/tools/testing/selftests/rseq/rseq-mips.h b/tools/testing/selftests/rseq/rseq-mips.h
new file mode 100644
index 000000000000..7f48ecf46994
--- /dev/null
+++ b/tools/testing/selftests/rseq/rseq-mips.h
@@ -0,0 +1,725 @@
1/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2/*
3 * Author: Paul Burton <paul.burton@mips.com>
4 * (C) Copyright 2018 MIPS Tech LLC
5 *
6 * Based on rseq-arm.h:
7 * (C) Copyright 2016-2018 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10#define RSEQ_SIG 0x53053053
11
12#define rseq_smp_mb() __asm__ __volatile__ ("sync" ::: "memory")
13#define rseq_smp_rmb() rseq_smp_mb()
14#define rseq_smp_wmb() rseq_smp_mb()
15
16#define rseq_smp_load_acquire(p) \
17__extension__ ({ \
18 __typeof(*p) ____p1 = RSEQ_READ_ONCE(*p); \
19 rseq_smp_mb(); \
20 ____p1; \
21})
22
23#define rseq_smp_acquire__after_ctrl_dep() rseq_smp_rmb()
24
25#define rseq_smp_store_release(p, v) \
26do { \
27 rseq_smp_mb(); \
28 RSEQ_WRITE_ONCE(*p, v); \
29} while (0)
30
31#ifdef RSEQ_SKIP_FASTPATH
32#include "rseq-skip.h"
33#else /* !RSEQ_SKIP_FASTPATH */
34
35#if _MIPS_SZLONG == 64
36# define LONG ".dword"
37# define LONG_LA "dla"
38# define LONG_L "ld"
39# define LONG_S "sd"
40# define LONG_ADDI "daddiu"
41# define U32_U64_PAD(x) x
42#elif _MIPS_SZLONG == 32
43# define LONG ".word"
44# define LONG_LA "la"
45# define LONG_L "lw"
46# define LONG_S "sw"
47# define LONG_ADDI "addiu"
48# ifdef __BIG_ENDIAN
49# define U32_U64_PAD(x) "0x0, " x
50# else
51# define U32_U64_PAD(x) x ", 0x0"
52# endif
53#else
54# error unsupported _MIPS_SZLONG
55#endif
56
57#define __RSEQ_ASM_DEFINE_TABLE(version, flags, start_ip, \
58 post_commit_offset, abort_ip) \
59 ".pushsection __rseq_table, \"aw\"\n\t" \
60 ".balign 32\n\t" \
61 ".word " __rseq_str(version) ", " __rseq_str(flags) "\n\t" \
62 LONG " " U32_U64_PAD(__rseq_str(start_ip)) "\n\t" \
63 LONG " " U32_U64_PAD(__rseq_str(post_commit_offset)) "\n\t" \
64 LONG " " U32_U64_PAD(__rseq_str(abort_ip)) "\n\t" \
65 ".popsection\n\t"
66
67#define RSEQ_ASM_DEFINE_TABLE(start_ip, post_commit_ip, abort_ip) \
68 __RSEQ_ASM_DEFINE_TABLE(0x0, 0x0, start_ip, \
69 (post_commit_ip - start_ip), abort_ip)
70
71#define RSEQ_ASM_STORE_RSEQ_CS(label, cs_label, rseq_cs) \
72 RSEQ_INJECT_ASM(1) \
73 LONG_LA " $4, " __rseq_str(cs_label) "\n\t" \
74 LONG_S " $4, %[" __rseq_str(rseq_cs) "]\n\t" \
75 __rseq_str(label) ":\n\t"
76
77#define RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, label) \
78 RSEQ_INJECT_ASM(2) \
79 "lw $4, %[" __rseq_str(current_cpu_id) "]\n\t" \
80 "bne $4, %[" __rseq_str(cpu_id) "], " __rseq_str(label) "\n\t"
81
82#define __RSEQ_ASM_DEFINE_ABORT(table_label, label, teardown, \
83 abort_label, version, flags, \
84 start_ip, post_commit_offset, abort_ip) \
85 ".balign 32\n\t" \
86 __rseq_str(table_label) ":\n\t" \
87 ".word " __rseq_str(version) ", " __rseq_str(flags) "\n\t" \
88 LONG " " U32_U64_PAD(__rseq_str(start_ip)) "\n\t" \
89 LONG " " U32_U64_PAD(__rseq_str(post_commit_offset)) "\n\t" \
90 LONG " " U32_U64_PAD(__rseq_str(abort_ip)) "\n\t" \
91 ".word " __rseq_str(RSEQ_SIG) "\n\t" \
92 __rseq_str(label) ":\n\t" \
93 teardown \
94 "b %l[" __rseq_str(abort_label) "]\n\t"
95
96#define RSEQ_ASM_DEFINE_ABORT(table_label, label, teardown, abort_label, \
97 start_ip, post_commit_ip, abort_ip) \
98 __RSEQ_ASM_DEFINE_ABORT(table_label, label, teardown, \
99 abort_label, 0x0, 0x0, start_ip, \
100 (post_commit_ip - start_ip), abort_ip)
101
102#define RSEQ_ASM_DEFINE_CMPFAIL(label, teardown, cmpfail_label) \
103 __rseq_str(label) ":\n\t" \
104 teardown \
105 "b %l[" __rseq_str(cmpfail_label) "]\n\t"
106
107#define rseq_workaround_gcc_asm_size_guess() __asm__ __volatile__("")
108
109static inline __attribute__((always_inline))
110int rseq_cmpeqv_storev(intptr_t *v, intptr_t expect, intptr_t newv, int cpu)
111{
112 RSEQ_INJECT_C(9)
113
114 rseq_workaround_gcc_asm_size_guess();
115 __asm__ __volatile__ goto (
116 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
117 /* Start rseq by storing table entry pointer into rseq_cs. */
118 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
119 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
120 RSEQ_INJECT_ASM(3)
121 LONG_L " $4, %[v]\n\t"
122 "bne $4, %[expect], %l[cmpfail]\n\t"
123 RSEQ_INJECT_ASM(4)
124#ifdef RSEQ_COMPARE_TWICE
125 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, %l[error1])
126 LONG_L " $4, %[v]\n\t"
127 "bne $4, %[expect], %l[error2]\n\t"
128#endif
129 /* final store */
130 LONG_S " %[newv], %[v]\n\t"
131 "2:\n\t"
132 RSEQ_INJECT_ASM(5)
133 "b 5f\n\t"
134 RSEQ_ASM_DEFINE_ABORT(3, 4, "", abort, 1b, 2b, 4f)
135 "5:\n\t"
136 : /* gcc asm goto does not allow outputs */
137 : [cpu_id] "r" (cpu),
138 [current_cpu_id] "m" (__rseq_abi.cpu_id),
139 [rseq_cs] "m" (__rseq_abi.rseq_cs),
140 [v] "m" (*v),
141 [expect] "r" (expect),
142 [newv] "r" (newv)
143 RSEQ_INJECT_INPUT
144 : "$4", "memory"
145 RSEQ_INJECT_CLOBBER
146 : abort, cmpfail
147#ifdef RSEQ_COMPARE_TWICE
148 , error1, error2
149#endif
150 );
151 rseq_workaround_gcc_asm_size_guess();
152 return 0;
153abort:
154 rseq_workaround_gcc_asm_size_guess();
155 RSEQ_INJECT_FAILED
156 return -1;
157cmpfail:
158 rseq_workaround_gcc_asm_size_guess();
159 return 1;
160#ifdef RSEQ_COMPARE_TWICE
161error1:
162 rseq_bug("cpu_id comparison failed");
163error2:
164 rseq_bug("expected value comparison failed");
165#endif
166}
167
168static inline __attribute__((always_inline))
169int rseq_cmpnev_storeoffp_load(intptr_t *v, intptr_t expectnot,
170 off_t voffp, intptr_t *load, int cpu)
171{
172 RSEQ_INJECT_C(9)
173
174 rseq_workaround_gcc_asm_size_guess();
175 __asm__ __volatile__ goto (
176 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
177 /* Start rseq by storing table entry pointer into rseq_cs. */
178 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
179 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
180 RSEQ_INJECT_ASM(3)
181 LONG_L " $4, %[v]\n\t"
182 "beq $4, %[expectnot], %l[cmpfail]\n\t"
183 RSEQ_INJECT_ASM(4)
184#ifdef RSEQ_COMPARE_TWICE
185 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, %l[error1])
186 LONG_L " $4, %[v]\n\t"
187 "beq $4, %[expectnot], %l[error2]\n\t"
188#endif
189 LONG_S " $4, %[load]\n\t"
190 LONG_ADDI " $4, %[voffp]\n\t"
191 LONG_L " $4, 0($4)\n\t"
192 /* final store */
193 LONG_S " $4, %[v]\n\t"
194 "2:\n\t"
195 RSEQ_INJECT_ASM(5)
196 "b 5f\n\t"
197 RSEQ_ASM_DEFINE_ABORT(3, 4, "", abort, 1b, 2b, 4f)
198 "5:\n\t"
199 : /* gcc asm goto does not allow outputs */
200 : [cpu_id] "r" (cpu),
201 [current_cpu_id] "m" (__rseq_abi.cpu_id),
202 [rseq_cs] "m" (__rseq_abi.rseq_cs),
203 /* final store input */
204 [v] "m" (*v),
205 [expectnot] "r" (expectnot),
206 [voffp] "Ir" (voffp),
207 [load] "m" (*load)
208 RSEQ_INJECT_INPUT
209 : "$4", "memory"
210 RSEQ_INJECT_CLOBBER
211 : abort, cmpfail
212#ifdef RSEQ_COMPARE_TWICE
213 , error1, error2
214#endif
215 );
216 rseq_workaround_gcc_asm_size_guess();
217 return 0;
218abort:
219 rseq_workaround_gcc_asm_size_guess();
220 RSEQ_INJECT_FAILED
221 return -1;
222cmpfail:
223 rseq_workaround_gcc_asm_size_guess();
224 return 1;
225#ifdef RSEQ_COMPARE_TWICE
226error1:
227 rseq_bug("cpu_id comparison failed");
228error2:
229 rseq_bug("expected value comparison failed");
230#endif
231}
232
233static inline __attribute__((always_inline))
234int rseq_addv(intptr_t *v, intptr_t count, int cpu)
235{
236 RSEQ_INJECT_C(9)
237
238 rseq_workaround_gcc_asm_size_guess();
239 __asm__ __volatile__ goto (
240 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
241 /* Start rseq by storing table entry pointer into rseq_cs. */
242 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
243 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
244 RSEQ_INJECT_ASM(3)
245#ifdef RSEQ_COMPARE_TWICE
246 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, %l[error1])
247#endif
248 LONG_L " $4, %[v]\n\t"
249 LONG_ADDI " $4, %[count]\n\t"
250 /* final store */
251 LONG_S " $4, %[v]\n\t"
252 "2:\n\t"
253 RSEQ_INJECT_ASM(4)
254 "b 5f\n\t"
255 RSEQ_ASM_DEFINE_ABORT(3, 4, "", abort, 1b, 2b, 4f)
256 "5:\n\t"
257 : /* gcc asm goto does not allow outputs */
258 : [cpu_id] "r" (cpu),
259 [current_cpu_id] "m" (__rseq_abi.cpu_id),
260 [rseq_cs] "m" (__rseq_abi.rseq_cs),
261 [v] "m" (*v),
262 [count] "Ir" (count)
263 RSEQ_INJECT_INPUT
264 : "$4", "memory"
265 RSEQ_INJECT_CLOBBER
266 : abort
267#ifdef RSEQ_COMPARE_TWICE
268 , error1
269#endif
270 );
271 rseq_workaround_gcc_asm_size_guess();
272 return 0;
273abort:
274 rseq_workaround_gcc_asm_size_guess();
275 RSEQ_INJECT_FAILED
276 return -1;
277#ifdef RSEQ_COMPARE_TWICE
278error1:
279 rseq_bug("cpu_id comparison failed");
280#endif
281}
282
283static inline __attribute__((always_inline))
284int rseq_cmpeqv_trystorev_storev(intptr_t *v, intptr_t expect,
285 intptr_t *v2, intptr_t newv2,
286 intptr_t newv, int cpu)
287{
288 RSEQ_INJECT_C(9)
289
290 rseq_workaround_gcc_asm_size_guess();
291 __asm__ __volatile__ goto (
292 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
293 /* Start rseq by storing table entry pointer into rseq_cs. */
294 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
295 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
296 RSEQ_INJECT_ASM(3)
297 LONG_L " $4, %[v]\n\t"
298 "bne $4, %[expect], %l[cmpfail]\n\t"
299 RSEQ_INJECT_ASM(4)
300#ifdef RSEQ_COMPARE_TWICE
301 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, %l[error1])
302 LONG_L " $4, %[v]\n\t"
303 "bne $4, %[expect], %l[error2]\n\t"
304#endif
305 /* try store */
306 LONG_S " %[newv2], %[v2]\n\t"
307 RSEQ_INJECT_ASM(5)
308 /* final store */
309 LONG_S " %[newv], %[v]\n\t"
310 "2:\n\t"
311 RSEQ_INJECT_ASM(6)
312 "b 5f\n\t"
313 RSEQ_ASM_DEFINE_ABORT(3, 4, "", abort, 1b, 2b, 4f)
314 "5:\n\t"
315 : /* gcc asm goto does not allow outputs */
316 : [cpu_id] "r" (cpu),
317 [current_cpu_id] "m" (__rseq_abi.cpu_id),
318 [rseq_cs] "m" (__rseq_abi.rseq_cs),
319 /* try store input */
320 [v2] "m" (*v2),
321 [newv2] "r" (newv2),
322 /* final store input */
323 [v] "m" (*v),
324 [expect] "r" (expect),
325 [newv] "r" (newv)
326 RSEQ_INJECT_INPUT
327 : "$4", "memory"
328 RSEQ_INJECT_CLOBBER
329 : abort, cmpfail
330#ifdef RSEQ_COMPARE_TWICE
331 , error1, error2
332#endif
333 );
334 rseq_workaround_gcc_asm_size_guess();
335 return 0;
336abort:
337 rseq_workaround_gcc_asm_size_guess();
338 RSEQ_INJECT_FAILED
339 return -1;
340cmpfail:
341 rseq_workaround_gcc_asm_size_guess();
342 return 1;
343#ifdef RSEQ_COMPARE_TWICE
344error1:
345 rseq_bug("cpu_id comparison failed");
346error2:
347 rseq_bug("expected value comparison failed");
348#endif
349}
350
351static inline __attribute__((always_inline))
352int rseq_cmpeqv_trystorev_storev_release(intptr_t *v, intptr_t expect,
353 intptr_t *v2, intptr_t newv2,
354 intptr_t newv, int cpu)
355{
356 RSEQ_INJECT_C(9)
357
358 rseq_workaround_gcc_asm_size_guess();
359 __asm__ __volatile__ goto (
360 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
361 /* Start rseq by storing table entry pointer into rseq_cs. */
362 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
363 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
364 RSEQ_INJECT_ASM(3)
365 LONG_L " $4, %[v]\n\t"
366 "bne $4, %[expect], %l[cmpfail]\n\t"
367 RSEQ_INJECT_ASM(4)
368#ifdef RSEQ_COMPARE_TWICE
369 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, %l[error1])
370 LONG_L " $4, %[v]\n\t"
371 "bne $4, %[expect], %l[error2]\n\t"
372#endif
373 /* try store */
374 LONG_S " %[newv2], %[v2]\n\t"
375 RSEQ_INJECT_ASM(5)
376 "sync\n\t" /* full sync provides store-release */
377 /* final store */
378 LONG_S " %[newv], %[v]\n\t"
379 "2:\n\t"
380 RSEQ_INJECT_ASM(6)
381 "b 5f\n\t"
382 RSEQ_ASM_DEFINE_ABORT(3, 4, "", abort, 1b, 2b, 4f)
383 "5:\n\t"
384 : /* gcc asm goto does not allow outputs */
385 : [cpu_id] "r" (cpu),
386 [current_cpu_id] "m" (__rseq_abi.cpu_id),
387 [rseq_cs] "m" (__rseq_abi.rseq_cs),
388 /* try store input */
389 [v2] "m" (*v2),
390 [newv2] "r" (newv2),
391 /* final store input */
392 [v] "m" (*v),
393 [expect] "r" (expect),
394 [newv] "r" (newv)
395 RSEQ_INJECT_INPUT
396 : "$4", "memory"
397 RSEQ_INJECT_CLOBBER
398 : abort, cmpfail
399#ifdef RSEQ_COMPARE_TWICE
400 , error1, error2
401#endif
402 );
403 rseq_workaround_gcc_asm_size_guess();
404 return 0;
405abort:
406 rseq_workaround_gcc_asm_size_guess();
407 RSEQ_INJECT_FAILED
408 return -1;
409cmpfail:
410 rseq_workaround_gcc_asm_size_guess();
411 return 1;
412#ifdef RSEQ_COMPARE_TWICE
413error1:
414 rseq_bug("cpu_id comparison failed");
415error2:
416 rseq_bug("expected value comparison failed");
417#endif
418}
419
420static inline __attribute__((always_inline))
421int rseq_cmpeqv_cmpeqv_storev(intptr_t *v, intptr_t expect,
422 intptr_t *v2, intptr_t expect2,
423 intptr_t newv, int cpu)
424{
425 RSEQ_INJECT_C(9)
426
427 rseq_workaround_gcc_asm_size_guess();
428 __asm__ __volatile__ goto (
429 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
430 /* Start rseq by storing table entry pointer into rseq_cs. */
431 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
432 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
433 RSEQ_INJECT_ASM(3)
434 LONG_L " $4, %[v]\n\t"
435 "bne $4, %[expect], %l[cmpfail]\n\t"
436 RSEQ_INJECT_ASM(4)
437 LONG_L " $4, %[v2]\n\t"
438 "bne $4, %[expect2], %l[cmpfail]\n\t"
439 RSEQ_INJECT_ASM(5)
440#ifdef RSEQ_COMPARE_TWICE
441 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, %l[error1])
442 LONG_L " $4, %[v]\n\t"
443 "bne $4, %[expect], %l[error2]\n\t"
444 LONG_L " $4, %[v2]\n\t"
445 "bne $4, %[expect2], %l[error3]\n\t"
446#endif
447 /* final store */
448 LONG_S " %[newv], %[v]\n\t"
449 "2:\n\t"
450 RSEQ_INJECT_ASM(6)
451 "b 5f\n\t"
452 RSEQ_ASM_DEFINE_ABORT(3, 4, "", abort, 1b, 2b, 4f)
453 "5:\n\t"
454 : /* gcc asm goto does not allow outputs */
455 : [cpu_id] "r" (cpu),
456 [current_cpu_id] "m" (__rseq_abi.cpu_id),
457 [rseq_cs] "m" (__rseq_abi.rseq_cs),
458 /* cmp2 input */
459 [v2] "m" (*v2),
460 [expect2] "r" (expect2),
461 /* final store input */
462 [v] "m" (*v),
463 [expect] "r" (expect),
464 [newv] "r" (newv)
465 RSEQ_INJECT_INPUT
466 : "$4", "memory"
467 RSEQ_INJECT_CLOBBER
468 : abort, cmpfail
469#ifdef RSEQ_COMPARE_TWICE
470 , error1, error2, error3
471#endif
472 );
473 rseq_workaround_gcc_asm_size_guess();
474 return 0;
475abort:
476 rseq_workaround_gcc_asm_size_guess();
477 RSEQ_INJECT_FAILED
478 return -1;
479cmpfail:
480 rseq_workaround_gcc_asm_size_guess();
481 return 1;
482#ifdef RSEQ_COMPARE_TWICE
483error1:
484 rseq_bug("cpu_id comparison failed");
485error2:
486 rseq_bug("1st expected value comparison failed");
487error3:
488 rseq_bug("2nd expected value comparison failed");
489#endif
490}
491
492static inline __attribute__((always_inline))
493int rseq_cmpeqv_trymemcpy_storev(intptr_t *v, intptr_t expect,
494 void *dst, void *src, size_t len,
495 intptr_t newv, int cpu)
496{
497 uintptr_t rseq_scratch[3];
498
499 RSEQ_INJECT_C(9)
500
501 rseq_workaround_gcc_asm_size_guess();
502 __asm__ __volatile__ goto (
503 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
504 LONG_S " %[src], %[rseq_scratch0]\n\t"
505 LONG_S " %[dst], %[rseq_scratch1]\n\t"
506 LONG_S " %[len], %[rseq_scratch2]\n\t"
507 /* Start rseq by storing table entry pointer into rseq_cs. */
508 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
509 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
510 RSEQ_INJECT_ASM(3)
511 LONG_L " $4, %[v]\n\t"
512 "bne $4, %[expect], 5f\n\t"
513 RSEQ_INJECT_ASM(4)
514#ifdef RSEQ_COMPARE_TWICE
515 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 6f)
516 LONG_L " $4, %[v]\n\t"
517 "bne $4, %[expect], 7f\n\t"
518#endif
519 /* try memcpy */
520 "beqz %[len], 333f\n\t" \
521 "222:\n\t" \
522 "lb $4, 0(%[src])\n\t" \
523 "sb $4, 0(%[dst])\n\t" \
524 LONG_ADDI " %[src], 1\n\t" \
525 LONG_ADDI " %[dst], 1\n\t" \
526 LONG_ADDI " %[len], -1\n\t" \
527 "bnez %[len], 222b\n\t" \
528 "333:\n\t" \
529 RSEQ_INJECT_ASM(5)
530 /* final store */
531 LONG_S " %[newv], %[v]\n\t"
532 "2:\n\t"
533 RSEQ_INJECT_ASM(6)
534 /* teardown */
535 LONG_L " %[len], %[rseq_scratch2]\n\t"
536 LONG_L " %[dst], %[rseq_scratch1]\n\t"
537 LONG_L " %[src], %[rseq_scratch0]\n\t"
538 "b 8f\n\t"
539 RSEQ_ASM_DEFINE_ABORT(3, 4,
540 /* teardown */
541 LONG_L " %[len], %[rseq_scratch2]\n\t"
542 LONG_L " %[dst], %[rseq_scratch1]\n\t"
543 LONG_L " %[src], %[rseq_scratch0]\n\t",
544 abort, 1b, 2b, 4f)
545 RSEQ_ASM_DEFINE_CMPFAIL(5,
546 /* teardown */
547 LONG_L " %[len], %[rseq_scratch2]\n\t"
548 LONG_L " %[dst], %[rseq_scratch1]\n\t"
549 LONG_L " %[src], %[rseq_scratch0]\n\t",
550 cmpfail)
551#ifdef RSEQ_COMPARE_TWICE
552 RSEQ_ASM_DEFINE_CMPFAIL(6,
553 /* teardown */
554 LONG_L " %[len], %[rseq_scratch2]\n\t"
555 LONG_L " %[dst], %[rseq_scratch1]\n\t"
556 LONG_L " %[src], %[rseq_scratch0]\n\t",
557 error1)
558 RSEQ_ASM_DEFINE_CMPFAIL(7,
559 /* teardown */
560 LONG_L " %[len], %[rseq_scratch2]\n\t"
561 LONG_L " %[dst], %[rseq_scratch1]\n\t"
562 LONG_L " %[src], %[rseq_scratch0]\n\t",
563 error2)
564#endif
565 "8:\n\t"
566 : /* gcc asm goto does not allow outputs */
567 : [cpu_id] "r" (cpu),
568 [current_cpu_id] "m" (__rseq_abi.cpu_id),
569 [rseq_cs] "m" (__rseq_abi.rseq_cs),
570 /* final store input */
571 [v] "m" (*v),
572 [expect] "r" (expect),
573 [newv] "r" (newv),
574 /* try memcpy input */
575 [dst] "r" (dst),
576 [src] "r" (src),
577 [len] "r" (len),
578 [rseq_scratch0] "m" (rseq_scratch[0]),
579 [rseq_scratch1] "m" (rseq_scratch[1]),
580 [rseq_scratch2] "m" (rseq_scratch[2])
581 RSEQ_INJECT_INPUT
582 : "$4", "memory"
583 RSEQ_INJECT_CLOBBER
584 : abort, cmpfail
585#ifdef RSEQ_COMPARE_TWICE
586 , error1, error2
587#endif
588 );
589 rseq_workaround_gcc_asm_size_guess();
590 return 0;
591abort:
592 rseq_workaround_gcc_asm_size_guess();
593 RSEQ_INJECT_FAILED
594 return -1;
595cmpfail:
596 rseq_workaround_gcc_asm_size_guess();
597 return 1;
598#ifdef RSEQ_COMPARE_TWICE
599error1:
600 rseq_workaround_gcc_asm_size_guess();
601 rseq_bug("cpu_id comparison failed");
602error2:
603 rseq_workaround_gcc_asm_size_guess();
604 rseq_bug("expected value comparison failed");
605#endif
606}
607
608static inline __attribute__((always_inline))
609int rseq_cmpeqv_trymemcpy_storev_release(intptr_t *v, intptr_t expect,
610 void *dst, void *src, size_t len,
611 intptr_t newv, int cpu)
612{
613 uintptr_t rseq_scratch[3];
614
615 RSEQ_INJECT_C(9)
616
617 rseq_workaround_gcc_asm_size_guess();
618 __asm__ __volatile__ goto (
619 RSEQ_ASM_DEFINE_TABLE(1f, 2f, 4f) /* start, commit, abort */
620 LONG_S " %[src], %[rseq_scratch0]\n\t"
621 LONG_S " %[dst], %[rseq_scratch1]\n\t"
622 LONG_S " %[len], %[rseq_scratch2]\n\t"
623 /* Start rseq by storing table entry pointer into rseq_cs. */
624 RSEQ_ASM_STORE_RSEQ_CS(1, 3f, rseq_cs)
625 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 4f)
626 RSEQ_INJECT_ASM(3)
627 LONG_L " $4, %[v]\n\t"
628 "bne $4, %[expect], 5f\n\t"
629 RSEQ_INJECT_ASM(4)
630#ifdef RSEQ_COMPARE_TWICE
631 RSEQ_ASM_CMP_CPU_ID(cpu_id, current_cpu_id, 6f)
632 LONG_L " $4, %[v]\n\t"
633 "bne $4, %[expect], 7f\n\t"
634#endif
635 /* try memcpy */
636 "beqz %[len], 333f\n\t" \
637 "222:\n\t" \
638 "lb $4, 0(%[src])\n\t" \
639 "sb $4, 0(%[dst])\n\t" \
640 LONG_ADDI " %[src], 1\n\t" \
641 LONG_ADDI " %[dst], 1\n\t" \
642 LONG_ADDI " %[len], -1\n\t" \
643 "bnez %[len], 222b\n\t" \
644 "333:\n\t" \
645 RSEQ_INJECT_ASM(5)
646 "sync\n\t" /* full sync provides store-release */
647 /* final store */
648 LONG_S " %[newv], %[v]\n\t"
649 "2:\n\t"
650 RSEQ_INJECT_ASM(6)
651 /* teardown */
652 LONG_L " %[len], %[rseq_scratch2]\n\t"
653 LONG_L " %[dst], %[rseq_scratch1]\n\t"
654 LONG_L " %[src], %[rseq_scratch0]\n\t"
655 "b 8f\n\t"
656 RSEQ_ASM_DEFINE_ABORT(3, 4,
657 /* teardown */
658 LONG_L " %[len], %[rseq_scratch2]\n\t"
659 LONG_L " %[dst], %[rseq_scratch1]\n\t"
660 LONG_L " %[src], %[rseq_scratch0]\n\t",
661 abort, 1b, 2b, 4f)
662 RSEQ_ASM_DEFINE_CMPFAIL(5,
663 /* teardown */
664 LONG_L " %[len], %[rseq_scratch2]\n\t"
665 LONG_L " %[dst], %[rseq_scratch1]\n\t"
666 LONG_L " %[src], %[rseq_scratch0]\n\t",
667 cmpfail)
668#ifdef RSEQ_COMPARE_TWICE
669 RSEQ_ASM_DEFINE_CMPFAIL(6,
670 /* teardown */
671 LONG_L " %[len], %[rseq_scratch2]\n\t"
672 LONG_L " %[dst], %[rseq_scratch1]\n\t"
673 LONG_L " %[src], %[rseq_scratch0]\n\t",
674 error1)
675 RSEQ_ASM_DEFINE_CMPFAIL(7,
676 /* teardown */
677 LONG_L " %[len], %[rseq_scratch2]\n\t"
678 LONG_L " %[dst], %[rseq_scratch1]\n\t"
679 LONG_L " %[src], %[rseq_scratch0]\n\t",
680 error2)
681#endif
682 "8:\n\t"
683 : /* gcc asm goto does not allow outputs */
684 : [cpu_id] "r" (cpu),
685 [current_cpu_id] "m" (__rseq_abi.cpu_id),
686 [rseq_cs] "m" (__rseq_abi.rseq_cs),
687 /* final store input */
688 [v] "m" (*v),
689 [expect] "r" (expect),
690 [newv] "r" (newv),
691 /* try memcpy input */
692 [dst] "r" (dst),
693 [src] "r" (src),
694 [len] "r" (len),
695 [rseq_scratch0] "m" (rseq_scratch[0]),
696 [rseq_scratch1] "m" (rseq_scratch[1]),
697 [rseq_scratch2] "m" (rseq_scratch[2])
698 RSEQ_INJECT_INPUT
699 : "$4", "memory"
700 RSEQ_INJECT_CLOBBER
701 : abort, cmpfail
702#ifdef RSEQ_COMPARE_TWICE
703 , error1, error2
704#endif
705 );
706 rseq_workaround_gcc_asm_size_guess();
707 return 0;
708abort:
709 rseq_workaround_gcc_asm_size_guess();
710 RSEQ_INJECT_FAILED
711 return -1;
712cmpfail:
713 rseq_workaround_gcc_asm_size_guess();
714 return 1;
715#ifdef RSEQ_COMPARE_TWICE
716error1:
717 rseq_workaround_gcc_asm_size_guess();
718 rseq_bug("cpu_id comparison failed");
719error2:
720 rseq_workaround_gcc_asm_size_guess();
721 rseq_bug("expected value comparison failed");
722#endif
723}
724
725#endif /* !RSEQ_SKIP_FASTPATH */
diff --git a/tools/testing/selftests/rseq/rseq.h b/tools/testing/selftests/rseq/rseq.h
index 0a808575cbc4..a4684112676c 100644
--- a/tools/testing/selftests/rseq/rseq.h
+++ b/tools/testing/selftests/rseq/rseq.h
@@ -73,6 +73,8 @@ extern __thread volatile struct rseq __rseq_abi;
73#include <rseq-arm.h> 73#include <rseq-arm.h>
74#elif defined(__PPC__) 74#elif defined(__PPC__)
75#include <rseq-ppc.h> 75#include <rseq-ppc.h>
76#elif defined(__mips__)
77#include <rseq-mips.h>
76#else 78#else
77#error unsupported target 79#error unsupported target
78#endif 80#endif
diff --git a/tools/testing/selftests/rseq/run_param_test.sh b/tools/testing/selftests/rseq/run_param_test.sh
index 3acd6d75ff9f..3acd6d75ff9f 100644..100755
--- a/tools/testing/selftests/rseq/run_param_test.sh
+++ b/tools/testing/selftests/rseq/run_param_test.sh
diff --git a/tools/testing/selftests/sparc64/Makefile b/tools/testing/selftests/sparc64/Makefile
index 2082eeffd779..a19531dba4dc 100644
--- a/tools/testing/selftests/sparc64/Makefile
+++ b/tools/testing/selftests/sparc64/Makefile
@@ -1,7 +1,18 @@
1# SPDX-License-Identifier: GPL-2.0
2uname_M := $(shell uname -m 2>/dev/null || echo not)
3ARCH ?= $(shell echo $(uname_M) | sed -e s/x86_64/x86/)
4
5ifneq ($(ARCH),sparc64)
6nothing:
7.PHONY: all clean run_tests install
8.SILENT:
9else
10
1SUBDIRS := drivers 11SUBDIRS := drivers
2 12
3TEST_PROGS := run.sh 13TEST_PROGS := run.sh
4 14
15
5.PHONY: all clean 16.PHONY: all clean
6 17
7include ../lib.mk 18include ../lib.mk
@@ -18,10 +29,6 @@ all:
18 fi \ 29 fi \
19 done 30 done
20 31
21override define RUN_TESTS
22 @cd $(OUTPUT); ./run.sh
23endef
24
25override define INSTALL_RULE 32override define INSTALL_RULE
26 mkdir -p $(INSTALL_PATH) 33 mkdir -p $(INSTALL_PATH)
27 install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) 34 install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
@@ -33,10 +40,6 @@ override define INSTALL_RULE
33 done; 40 done;
34endef 41endef
35 42
36override define EMIT_TESTS
37 echo "./run.sh"
38endef
39
40override define CLEAN 43override define CLEAN
41 @for DIR in $(SUBDIRS); do \ 44 @for DIR in $(SUBDIRS); do \
42 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 45 BUILD_TARGET=$(OUTPUT)/$$DIR; \
@@ -44,3 +47,4 @@ override define CLEAN
44 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 47 make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\
45 done 48 done
46endef 49endef
50endif
diff --git a/tools/testing/selftests/sparc64/drivers/Makefile b/tools/testing/selftests/sparc64/drivers/Makefile
index 6264f40bbdbc..deb0df415565 100644
--- a/tools/testing/selftests/sparc64/drivers/Makefile
+++ b/tools/testing/selftests/sparc64/drivers/Makefile
@@ -1,4 +1,4 @@
1 1# SPDX-License-Identifier: GPL-2.0
2INCLUDEDIR := -I. 2INCLUDEDIR := -I.
3CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g 3CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g
4 4
diff --git a/tools/testing/selftests/static_keys/test_static_keys.sh b/tools/testing/selftests/static_keys/test_static_keys.sh
index 24cff498b31a..fc9f8cde7d42 100755
--- a/tools/testing/selftests/static_keys/test_static_keys.sh
+++ b/tools/testing/selftests/static_keys/test_static_keys.sh
@@ -2,6 +2,19 @@
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3# Runs static keys kernel module tests 3# Runs static keys kernel module tests
4 4
5# Kselftest framework requirement - SKIP code is 4.
6ksft_skip=4
7
8if ! /sbin/modprobe -q -n test_static_key_base; then
9 echo "static_key: module test_static_key_base is not found [SKIP]"
10 exit $ksft_skip
11fi
12
13if ! /sbin/modprobe -q -n test_static_keys; then
14 echo "static_key: module test_static_keys is not found [SKIP]"
15 exit $ksft_skip
16fi
17
5if /sbin/modprobe -q test_static_key_base; then 18if /sbin/modprobe -q test_static_key_base; then
6 if /sbin/modprobe -q test_static_keys; then 19 if /sbin/modprobe -q test_static_keys; then
7 echo "static_key: ok" 20 echo "static_key: ok"
diff --git a/tools/testing/selftests/sync/config b/tools/testing/selftests/sync/config
new file mode 100644
index 000000000000..1ab7e8130db2
--- /dev/null
+++ b/tools/testing/selftests/sync/config
@@ -0,0 +1,4 @@
1CONFIG_STAGING=y
2CONFIG_ANDROID=y
3CONFIG_SYNC=y
4CONFIG_SW_SYNC=y
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index ec232c3cfcaa..584eb8ea780a 100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
@@ -14,6 +14,9 @@
14 14
15# This performs a series tests against the proc sysctl interface. 15# This performs a series tests against the proc sysctl interface.
16 16
17# Kselftest framework requirement - SKIP code is 4.
18ksft_skip=4
19
17TEST_NAME="sysctl" 20TEST_NAME="sysctl"
18TEST_DRIVER="test_${TEST_NAME}" 21TEST_DRIVER="test_${TEST_NAME}"
19TEST_DIR=$(dirname $0) 22TEST_DIR=$(dirname $0)
@@ -41,7 +44,7 @@ test_modprobe()
41 echo "$0: $DIR not present" >&2 44 echo "$0: $DIR not present" >&2
42 echo "You must have the following enabled in your kernel:" >&2 45 echo "You must have the following enabled in your kernel:" >&2
43 cat $TEST_DIR/config >&2 46 cat $TEST_DIR/config >&2
44 exit 1 47 exit $ksft_skip
45 fi 48 fi
46} 49}
47 50
@@ -98,28 +101,30 @@ test_reqs()
98 uid=$(id -u) 101 uid=$(id -u)
99 if [ $uid -ne 0 ]; then 102 if [ $uid -ne 0 ]; then
100 echo $msg must be run as root >&2 103 echo $msg must be run as root >&2
101 exit 0 104 exit $ksft_skip
102 fi 105 fi
103 106
104 if ! which perl 2> /dev/null > /dev/null; then 107 if ! which perl 2> /dev/null > /dev/null; then
105 echo "$0: You need perl installed" 108 echo "$0: You need perl installed"
106 exit 1 109 exit $ksft_skip
107 fi 110 fi
108 if ! which getconf 2> /dev/null > /dev/null; then 111 if ! which getconf 2> /dev/null > /dev/null; then
109 echo "$0: You need getconf installed" 112 echo "$0: You need getconf installed"
110 exit 1 113 exit $ksft_skip
111 fi 114 fi
112 if ! which diff 2> /dev/null > /dev/null; then 115 if ! which diff 2> /dev/null > /dev/null; then
113 echo "$0: You need diff installed" 116 echo "$0: You need diff installed"
114 exit 1 117 exit $ksft_skip
115 fi 118 fi
116} 119}
117 120
118function load_req_mod() 121function load_req_mod()
119{ 122{
120 trap "test_modprobe" EXIT
121
122 if [ ! -d $DIR ]; then 123 if [ ! -d $DIR ]; then
124 if ! modprobe -q -n $TEST_DRIVER; then
125 echo "$0: module $TEST_DRIVER not found [SKIP]"
126 exit $ksft_skip
127 fi
123 modprobe $TEST_DRIVER 128 modprobe $TEST_DRIVER
124 if [ $? -ne 0 ]; then 129 if [ $? -ne 0 ]; then
125 exit 130 exit
@@ -765,6 +770,7 @@ function parse_args()
765test_reqs 770test_reqs
766allow_user_defaults 771allow_user_defaults
767check_production_sysctl_writes_strict 772check_production_sysctl_writes_strict
773test_modprobe
768load_req_mod 774load_req_mod
769 775
770trap "test_finish" EXIT 776trap "test_finish" EXIT
diff --git a/tools/testing/selftests/user/test_user_copy.sh b/tools/testing/selftests/user/test_user_copy.sh
index d60506fc77f8..f9b31a57439b 100755
--- a/tools/testing/selftests/user/test_user_copy.sh
+++ b/tools/testing/selftests/user/test_user_copy.sh
@@ -2,6 +2,13 @@
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3# Runs copy_to/from_user infrastructure using test_user_copy kernel module 3# Runs copy_to/from_user infrastructure using test_user_copy kernel module
4 4
5# Kselftest framework requirement - SKIP code is 4.
6ksft_skip=4
7
8if ! /sbin/modprobe -q -n test_user_copy; then
9 echo "user: module test_user_copy is not found [SKIP]"
10 exit $ksft_skip
11fi
5if /sbin/modprobe -q test_user_copy; then 12if /sbin/modprobe -q test_user_copy; then
6 /sbin/modprobe -q -r test_user_copy 13 /sbin/modprobe -q -r test_user_copy
7 echo "user_copy: ok" 14 echo "user_copy: ok"
diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
index 1097f04e4d80..bcec71250873 100644
--- a/tools/testing/selftests/vm/compaction_test.c
+++ b/tools/testing/selftests/vm/compaction_test.c
@@ -16,6 +16,8 @@
16#include <unistd.h> 16#include <unistd.h>
17#include <string.h> 17#include <string.h>
18 18
19#include "../kselftest.h"
20
19#define MAP_SIZE 1048576 21#define MAP_SIZE 1048576
20 22
21struct map_list { 23struct map_list {
@@ -169,7 +171,7 @@ int main(int argc, char **argv)
169 printf("Either the sysctl compact_unevictable_allowed is not\n" 171 printf("Either the sysctl compact_unevictable_allowed is not\n"
170 "set to 1 or couldn't read the proc file.\n" 172 "set to 1 or couldn't read the proc file.\n"
171 "Skipping the test\n"); 173 "Skipping the test\n");
172 return 0; 174 return KSFT_SKIP;
173 } 175 }
174 176
175 lim.rlim_cur = RLIM_INFINITY; 177 lim.rlim_cur = RLIM_INFINITY;
diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c
index 4997b9222cfa..637b6d0ac0d0 100644
--- a/tools/testing/selftests/vm/mlock2-tests.c
+++ b/tools/testing/selftests/vm/mlock2-tests.c
@@ -9,6 +9,8 @@
9#include <stdbool.h> 9#include <stdbool.h>
10#include "mlock2.h" 10#include "mlock2.h"
11 11
12#include "../kselftest.h"
13
12struct vm_boundaries { 14struct vm_boundaries {
13 unsigned long start; 15 unsigned long start;
14 unsigned long end; 16 unsigned long end;
@@ -303,7 +305,7 @@ static int test_mlock_lock()
303 if (mlock2_(map, 2 * page_size, 0)) { 305 if (mlock2_(map, 2 * page_size, 0)) {
304 if (errno == ENOSYS) { 306 if (errno == ENOSYS) {
305 printf("Cannot call new mlock family, skipping test\n"); 307 printf("Cannot call new mlock family, skipping test\n");
306 _exit(0); 308 _exit(KSFT_SKIP);
307 } 309 }
308 perror("mlock2(0)"); 310 perror("mlock2(0)");
309 goto unmap; 311 goto unmap;
@@ -412,7 +414,7 @@ static int test_mlock_onfault()
412 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 414 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
413 if (errno == ENOSYS) { 415 if (errno == ENOSYS) {
414 printf("Cannot call new mlock family, skipping test\n"); 416 printf("Cannot call new mlock family, skipping test\n");
415 _exit(0); 417 _exit(KSFT_SKIP);
416 } 418 }
417 perror("mlock2(MLOCK_ONFAULT)"); 419 perror("mlock2(MLOCK_ONFAULT)");
418 goto unmap; 420 goto unmap;
@@ -425,7 +427,7 @@ static int test_mlock_onfault()
425 if (munlock(map, 2 * page_size)) { 427 if (munlock(map, 2 * page_size)) {
426 if (errno == ENOSYS) { 428 if (errno == ENOSYS) {
427 printf("Cannot call new mlock family, skipping test\n"); 429 printf("Cannot call new mlock family, skipping test\n");
428 _exit(0); 430 _exit(KSFT_SKIP);
429 } 431 }
430 perror("munlock()"); 432 perror("munlock()");
431 goto unmap; 433 goto unmap;
@@ -457,7 +459,7 @@ static int test_lock_onfault_of_present()
457 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { 459 if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) {
458 if (errno == ENOSYS) { 460 if (errno == ENOSYS) {
459 printf("Cannot call new mlock family, skipping test\n"); 461 printf("Cannot call new mlock family, skipping test\n");
460 _exit(0); 462 _exit(KSFT_SKIP);
461 } 463 }
462 perror("mlock2(MLOCK_ONFAULT)"); 464 perror("mlock2(MLOCK_ONFAULT)");
463 goto unmap; 465 goto unmap;
@@ -583,7 +585,7 @@ static int test_vma_management(bool call_mlock)
583 if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) { 585 if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) {
584 if (errno == ENOSYS) { 586 if (errno == ENOSYS) {
585 printf("Cannot call new mlock family, skipping test\n"); 587 printf("Cannot call new mlock family, skipping test\n");
586 _exit(0); 588 _exit(KSFT_SKIP);
587 } 589 }
588 perror("mlock(ONFAULT)\n"); 590 perror("mlock(ONFAULT)\n");
589 goto out; 591 goto out;
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
index 22d564673830..88cbe5575f0c 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -2,6 +2,9 @@
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3#please run as root 3#please run as root
4 4
5# Kselftest framework requirement - SKIP code is 4.
6ksft_skip=4
7
5mnt=./huge 8mnt=./huge
6exitcode=0 9exitcode=0
7 10
@@ -36,7 +39,7 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
36 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages 39 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
37 if [ $? -ne 0 ]; then 40 if [ $? -ne 0 ]; then
38 echo "Please run this test as root" 41 echo "Please run this test as root"
39 exit 1 42 exit $ksft_skip
40 fi 43 fi
41 while read name size unit; do 44 while read name size unit; do
42 if [ "$name" = "HugePages_Free:" ]; then 45 if [ "$name" = "HugePages_Free:" ]; then
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index de2f9ec8a87f..7b8171e3128a 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -69,6 +69,8 @@
69#include <setjmp.h> 69#include <setjmp.h>
70#include <stdbool.h> 70#include <stdbool.h>
71 71
72#include "../kselftest.h"
73
72#ifdef __NR_userfaultfd 74#ifdef __NR_userfaultfd
73 75
74static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; 76static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
@@ -1322,7 +1324,7 @@ int main(int argc, char **argv)
1322int main(void) 1324int main(void)
1323{ 1325{
1324 printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); 1326 printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
1325 return 0; 1327 return KSFT_SKIP;
1326} 1328}
1327 1329
1328#endif /* __NR_userfaultfd */ 1330#endif /* __NR_userfaultfd */
diff --git a/tools/testing/selftests/x86/sigreturn.c b/tools/testing/selftests/x86/sigreturn.c
index 246145b84a12..4d9dc3f2fd70 100644
--- a/tools/testing/selftests/x86/sigreturn.c
+++ b/tools/testing/selftests/x86/sigreturn.c
@@ -610,21 +610,41 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
610 */ 610 */
611 for (int i = 0; i < NGREG; i++) { 611 for (int i = 0; i < NGREG; i++) {
612 greg_t req = requested_regs[i], res = resulting_regs[i]; 612 greg_t req = requested_regs[i], res = resulting_regs[i];
613
613 if (i == REG_TRAPNO || i == REG_IP) 614 if (i == REG_TRAPNO || i == REG_IP)
614 continue; /* don't care */ 615 continue; /* don't care */
615 if (i == REG_SP) {
616 printf("\tSP: %llx -> %llx\n", (unsigned long long)req,
617 (unsigned long long)res);
618 616
617 if (i == REG_SP) {
619 /* 618 /*
620 * In many circumstances, the high 32 bits of rsp 619 * If we were using a 16-bit stack segment, then
621 * are zeroed. For example, we could be a real 620 * the kernel is a bit stuck: IRET only restores
622 * 32-bit program, or we could hit any of a number 621 * the low 16 bits of ESP/RSP if SS is 16-bit.
623 * of poorly-documented IRET or segmented ESP 622 * The kernel uses a hack to restore bits 31:16,
624 * oddities. If this happens, it's okay. 623 * but that hack doesn't help with bits 63:32.
624 * On Intel CPUs, bits 63:32 end up zeroed, and, on
625 * AMD CPUs, they leak the high bits of the kernel
626 * espfix64 stack pointer. There's very little that
627 * the kernel can do about it.
628 *
629 * Similarly, if we are returning to a 32-bit context,
630 * the CPU will often lose the high 32 bits of RSP.
625 */ 631 */
626 if (res == (req & 0xFFFFFFFF)) 632
627 continue; /* OK; not expected to work */ 633 if (res == req)
634 continue;
635
636 if (cs_bits != 64 && ((res ^ req) & 0xFFFFFFFF) == 0) {
637 printf("[NOTE]\tSP: %llx -> %llx\n",
638 (unsigned long long)req,
639 (unsigned long long)res);
640 continue;
641 }
642
643 printf("[FAIL]\tSP mismatch: requested 0x%llx; got 0x%llx\n",
644 (unsigned long long)requested_regs[i],
645 (unsigned long long)resulting_regs[i]);
646 nerrs++;
647 continue;
628 } 648 }
629 649
630 bool ignore_reg = false; 650 bool ignore_reg = false;
@@ -654,25 +674,18 @@ static int test_valid_sigreturn(int cs_bits, bool use_16bit_ss, int force_ss)
654#endif 674#endif
655 675
656 /* Sanity check on the kernel */ 676 /* Sanity check on the kernel */
657 if (i == REG_CX && requested_regs[i] != resulting_regs[i]) { 677 if (i == REG_CX && req != res) {
658 printf("[FAIL]\tCX (saved SP) mismatch: requested 0x%llx; got 0x%llx\n", 678 printf("[FAIL]\tCX (saved SP) mismatch: requested 0x%llx; got 0x%llx\n",
659 (unsigned long long)requested_regs[i], 679 (unsigned long long)req,
660 (unsigned long long)resulting_regs[i]); 680 (unsigned long long)res);
661 nerrs++; 681 nerrs++;
662 continue; 682 continue;
663 } 683 }
664 684
665 if (requested_regs[i] != resulting_regs[i] && !ignore_reg) { 685 if (req != res && !ignore_reg) {
666 /*
667 * SP is particularly interesting here. The
668 * usual cause of failures is that we hit the
669 * nasty IRET case of returning to a 16-bit SS,
670 * in which case bits 16:31 of the *kernel*
671 * stack pointer persist in ESP.
672 */
673 printf("[FAIL]\tReg %d mismatch: requested 0x%llx; got 0x%llx\n", 686 printf("[FAIL]\tReg %d mismatch: requested 0x%llx; got 0x%llx\n",
674 i, (unsigned long long)requested_regs[i], 687 i, (unsigned long long)req,
675 (unsigned long long)resulting_regs[i]); 688 (unsigned long long)res);
676 nerrs++; 689 nerrs++;
677 } 690 }
678 } 691 }
diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh
index 754de7da426a..232e958ec454 100755
--- a/tools/testing/selftests/zram/zram.sh
+++ b/tools/testing/selftests/zram/zram.sh
@@ -2,6 +2,9 @@
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3TCID="zram.sh" 3TCID="zram.sh"
4 4
5# Kselftest framework requirement - SKIP code is 4.
6ksft_skip=4
7
5. ./zram_lib.sh 8. ./zram_lib.sh
6 9
7run_zram () { 10run_zram () {
@@ -24,5 +27,5 @@ elif [ -b /dev/zram0 ]; then
24else 27else
25 echo "$TCID : No zram.ko module or /dev/zram0 device file not found" 28 echo "$TCID : No zram.ko module or /dev/zram0 device file not found"
26 echo "$TCID : CONFIG_ZRAM is not set" 29 echo "$TCID : CONFIG_ZRAM is not set"
27 exit 1 30 exit $ksft_skip
28fi 31fi
diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh
index f6a9c73e7a44..9e73a4fb9b0a 100755
--- a/tools/testing/selftests/zram/zram_lib.sh
+++ b/tools/testing/selftests/zram/zram_lib.sh
@@ -18,6 +18,9 @@ MODULE=0
18dev_makeswap=-1 18dev_makeswap=-1
19dev_mounted=-1 19dev_mounted=-1
20 20
21# Kselftest framework requirement - SKIP code is 4.
22ksft_skip=4
23
21trap INT 24trap INT
22 25
23check_prereqs() 26check_prereqs()
@@ -27,7 +30,7 @@ check_prereqs()
27 30
28 if [ $uid -ne 0 ]; then 31 if [ $uid -ne 0 ]; then
29 echo $msg must be run as root >&2 32 echo $msg must be run as root >&2
30 exit 0 33 exit $ksft_skip
31 fi 34 fi
32} 35}
33 36
diff --git a/tools/virtio/linux/scatterlist.h b/tools/virtio/linux/scatterlist.h
index 9a45f90e2d08..369ee308b668 100644
--- a/tools/virtio/linux/scatterlist.h
+++ b/tools/virtio/linux/scatterlist.h
@@ -36,7 +36,6 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
36 */ 36 */
37 BUG_ON((unsigned long) page & 0x03); 37 BUG_ON((unsigned long) page & 0x03);
38#ifdef CONFIG_DEBUG_SG 38#ifdef CONFIG_DEBUG_SG
39 BUG_ON(sg->sg_magic != SG_MAGIC);
40 BUG_ON(sg_is_chain(sg)); 39 BUG_ON(sg_is_chain(sg));
41#endif 40#endif
42 sg->page_link = page_link | (unsigned long) page; 41 sg->page_link = page_link | (unsigned long) page;
@@ -67,7 +66,6 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
67static inline struct page *sg_page(struct scatterlist *sg) 66static inline struct page *sg_page(struct scatterlist *sg)
68{ 67{
69#ifdef CONFIG_DEBUG_SG 68#ifdef CONFIG_DEBUG_SG
70 BUG_ON(sg->sg_magic != SG_MAGIC);
71 BUG_ON(sg_is_chain(sg)); 69 BUG_ON(sg_is_chain(sg));
72#endif 70#endif
73 return (struct page *)((sg)->page_link & ~0x3); 71 return (struct page *)((sg)->page_link & ~0x3);
@@ -116,9 +114,6 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
116 **/ 114 **/
117static inline void sg_mark_end(struct scatterlist *sg) 115static inline void sg_mark_end(struct scatterlist *sg)
118{ 116{
119#ifdef CONFIG_DEBUG_SG
120 BUG_ON(sg->sg_magic != SG_MAGIC);
121#endif
122 /* 117 /*
123 * Set termination bit, clear potential chain bit 118 * Set termination bit, clear potential chain bit
124 */ 119 */
@@ -136,17 +131,11 @@ static inline void sg_mark_end(struct scatterlist *sg)
136 **/ 131 **/
137static inline void sg_unmark_end(struct scatterlist *sg) 132static inline void sg_unmark_end(struct scatterlist *sg)
138{ 133{
139#ifdef CONFIG_DEBUG_SG
140 BUG_ON(sg->sg_magic != SG_MAGIC);
141#endif
142 sg->page_link &= ~0x02; 134 sg->page_link &= ~0x02;
143} 135}
144 136
145static inline struct scatterlist *sg_next(struct scatterlist *sg) 137static inline struct scatterlist *sg_next(struct scatterlist *sg)
146{ 138{
147#ifdef CONFIG_DEBUG_SG
148 BUG_ON(sg->sg_magic != SG_MAGIC);
149#endif
150 if (sg_is_last(sg)) 139 if (sg_is_last(sg))
151 return NULL; 140 return NULL;
152 141
@@ -160,13 +149,6 @@ static inline struct scatterlist *sg_next(struct scatterlist *sg)
160static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) 149static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
161{ 150{
162 memset(sgl, 0, sizeof(*sgl) * nents); 151 memset(sgl, 0, sizeof(*sgl) * nents);
163#ifdef CONFIG_DEBUG_SG
164 {
165 unsigned int i;
166 for (i = 0; i < nents; i++)
167 sgl[i].sg_magic = SG_MAGIC;
168 }
169#endif
170 sg_mark_end(&sgl[nents - 1]); 152 sg_mark_end(&sgl[nents - 1]);
171} 153}
172 154
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index 72143cfaf6ec..ea434ddc8499 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -47,7 +47,7 @@ config KVM_GENERIC_DIRTYLOG_READ_PROTECT
47 47
48config KVM_COMPAT 48config KVM_COMPAT
49 def_bool y 49 def_bool y
50 depends on KVM && COMPAT && !S390 50 depends on KVM && COMPAT && !(S390 || ARM64)
51 51
52config HAVE_KVM_IRQ_BYPASS 52config HAVE_KVM_IRQ_BYPASS
53 bool 53 bool
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index 8d90de213ce9..1d90d79706bd 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -297,6 +297,8 @@ static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size)
297 phys_addr_t next; 297 phys_addr_t next;
298 298
299 assert_spin_locked(&kvm->mmu_lock); 299 assert_spin_locked(&kvm->mmu_lock);
300 WARN_ON(size & ~PAGE_MASK);
301
300 pgd = kvm->arch.pgd + stage2_pgd_index(addr); 302 pgd = kvm->arch.pgd + stage2_pgd_index(addr);
301 do { 303 do {
302 /* 304 /*
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index ff7dc890941a..cdce653e3c47 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -617,11 +617,6 @@ int vgic_v3_probe(const struct gic_kvm_info *info)
617 pr_warn("GICV physical address 0x%llx not page aligned\n", 617 pr_warn("GICV physical address 0x%llx not page aligned\n",
618 (unsigned long long)info->vcpu.start); 618 (unsigned long long)info->vcpu.start);
619 kvm_vgic_global_state.vcpu_base = 0; 619 kvm_vgic_global_state.vcpu_base = 0;
620 } else if (!PAGE_ALIGNED(resource_size(&info->vcpu))) {
621 pr_warn("GICV size 0x%llx not a multiple of page size 0x%lx\n",
622 (unsigned long long)resource_size(&info->vcpu),
623 PAGE_SIZE);
624 kvm_vgic_global_state.vcpu_base = 0;
625 } else { 620 } else {
626 kvm_vgic_global_state.vcpu_base = info->vcpu.start; 621 kvm_vgic_global_state.vcpu_base = info->vcpu.start;
627 kvm_vgic_global_state.can_emulate_gicv2 = true; 622 kvm_vgic_global_state.can_emulate_gicv2 = true;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ada21f47f22b..8b47507faab5 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -116,6 +116,11 @@ static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
116#ifdef CONFIG_KVM_COMPAT 116#ifdef CONFIG_KVM_COMPAT
117static long kvm_vcpu_compat_ioctl(struct file *file, unsigned int ioctl, 117static long kvm_vcpu_compat_ioctl(struct file *file, unsigned int ioctl,
118 unsigned long arg); 118 unsigned long arg);
119#define KVM_COMPAT(c) .compat_ioctl = (c)
120#else
121static long kvm_no_compat_ioctl(struct file *file, unsigned int ioctl,
122 unsigned long arg) { return -EINVAL; }
123#define KVM_COMPAT(c) .compat_ioctl = kvm_no_compat_ioctl
119#endif 124#endif
120static int hardware_enable_all(void); 125static int hardware_enable_all(void);
121static void hardware_disable_all(void); 126static void hardware_disable_all(void);
@@ -2396,11 +2401,9 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
2396static struct file_operations kvm_vcpu_fops = { 2401static struct file_operations kvm_vcpu_fops = {
2397 .release = kvm_vcpu_release, 2402 .release = kvm_vcpu_release,
2398 .unlocked_ioctl = kvm_vcpu_ioctl, 2403 .unlocked_ioctl = kvm_vcpu_ioctl,
2399#ifdef CONFIG_KVM_COMPAT
2400 .compat_ioctl = kvm_vcpu_compat_ioctl,
2401#endif
2402 .mmap = kvm_vcpu_mmap, 2404 .mmap = kvm_vcpu_mmap,
2403 .llseek = noop_llseek, 2405 .llseek = noop_llseek,
2406 KVM_COMPAT(kvm_vcpu_compat_ioctl),
2404}; 2407};
2405 2408
2406/* 2409/*
@@ -2824,10 +2827,8 @@ static int kvm_device_release(struct inode *inode, struct file *filp)
2824 2827
2825static const struct file_operations kvm_device_fops = { 2828static const struct file_operations kvm_device_fops = {
2826 .unlocked_ioctl = kvm_device_ioctl, 2829 .unlocked_ioctl = kvm_device_ioctl,
2827#ifdef CONFIG_KVM_COMPAT
2828 .compat_ioctl = kvm_device_ioctl,
2829#endif
2830 .release = kvm_device_release, 2830 .release = kvm_device_release,
2831 KVM_COMPAT(kvm_device_ioctl),
2831}; 2832};
2832 2833
2833struct kvm_device *kvm_device_from_filp(struct file *filp) 2834struct kvm_device *kvm_device_from_filp(struct file *filp)
@@ -3165,10 +3166,8 @@ static long kvm_vm_compat_ioctl(struct file *filp,
3165static struct file_operations kvm_vm_fops = { 3166static struct file_operations kvm_vm_fops = {
3166 .release = kvm_vm_release, 3167 .release = kvm_vm_release,
3167 .unlocked_ioctl = kvm_vm_ioctl, 3168 .unlocked_ioctl = kvm_vm_ioctl,
3168#ifdef CONFIG_KVM_COMPAT
3169 .compat_ioctl = kvm_vm_compat_ioctl,
3170#endif
3171 .llseek = noop_llseek, 3169 .llseek = noop_llseek,
3170 KVM_COMPAT(kvm_vm_compat_ioctl),
3172}; 3171};
3173 3172
3174static int kvm_dev_ioctl_create_vm(unsigned long type) 3173static int kvm_dev_ioctl_create_vm(unsigned long type)
@@ -3259,8 +3258,8 @@ out:
3259 3258
3260static struct file_operations kvm_chardev_ops = { 3259static struct file_operations kvm_chardev_ops = {
3261 .unlocked_ioctl = kvm_dev_ioctl, 3260 .unlocked_ioctl = kvm_dev_ioctl,
3262 .compat_ioctl = kvm_dev_ioctl,
3263 .llseek = noop_llseek, 3261 .llseek = noop_llseek,
3262 KVM_COMPAT(kvm_dev_ioctl),
3264}; 3263};
3265 3264
3266static struct miscdevice kvm_dev = { 3265static struct miscdevice kvm_dev = {